Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Michael Vogel 2013-05-17 00:01:02 +02:00
commit f75ef0c59e
155 changed files with 1648 additions and 307 deletions

Binary file not shown.

View file

@ -1,3 +0,0 @@
{{ inc field_radio.tpl with $field=$global }}{{ endinc }}
{{ inc field_radio.tpl with $field=$individual }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

View file

@ -1,3 +0,0 @@
{{ inc field_radio.tpl with $field=$global }}{{ endinc }}
{{ inc field_radio.tpl with $field=$individual }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

Binary file not shown.

View file

@ -1,11 +0,0 @@
{{ inc field_input.tpl with $field=$startdate }}{{ endinc }}
{{ inc field_input.tpl with $field=$enddate }}{{ endinc }}
{{ inc field_input.tpl with $field=$rurl }}{{ endinc }}
<div style="border: 2px solid #f00; padding: 10px; margin:
10px;font-size: 1.2em;"><strong>Note</strong>: The redirect will be active from the moment you
press the submit button. Users currently logged in will <strong>not</strong> be
thrown out but can't login again after logging out should the blackout is
still in place.</div>
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

Binary file not shown.

View file

@ -16,6 +16,7 @@ function blockem_install() {
register_hook('plugin_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post');
register_hook('conversation_start', 'addon/blockem/blockem.php', 'blockem_conversation_start');
register_hook('item_photo_menu', 'addon/blockem/blockem.php', 'blockem_item_photo_menu');
register_hook('enotify_store', 'addon/blockem/blockem.php', 'blockem_enotify_store' );
}
@ -26,6 +27,7 @@ function blockem_uninstall() {
unregister_hook('plugin_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post');
unregister_hook('conversation_start', 'addon/blockem/blockem.php', 'blockem_conversation_start');
unregister_hook('item_photo_menu', 'addon/blockem/blockem.php', 'blockem_item_photo_menu');
unregister_hook('enotify_store', 'addon/blockem/blockem.php', 'blockem_enotify_store' );
}
@ -71,6 +73,35 @@ function blockem_addon_settings_post(&$a,&$b) {
}
}
function blockem_enotify_store(&$a,&$b) {
$words = get_pconfig($b['uid'],'blockem','words');
if($words) {
$arr = explode(',',$words);
}
else {
return;
}
$found = false;
if(count($arr)) {
foreach($arr as $word) {
if(! strlen(trim($word))) {
continue;
}
if(link_compare($b['url'],$word)) {
$found = true;
break;
}
}
}
if($found) {
$b['abort'] = true;
}
}
function blockem_prepare_body(&$a,&$b) {
if(! local_user())

Binary file not shown.

Binary file not shown.

BIN
calc.tgz

Binary file not shown.

Binary file not shown.

View file

@ -1,70 +0,0 @@
<script>
$(function(){
$("#tab_1 a").click(function(e){
$("#login_standard").show();
$("#login_openid").hide();
$("#tab_1").addClass("active");
$("#tab_2").removeClass("active");
e.preventDefault();
return false;
});
$("#tab_2 a").click(function(e){
$("#login_openid").show();
$("#login_standard").hide();
$("#tab_2").addClass("active");
$("#tab_1").removeClass("active");
e.preventDefault();
return false;
});
});
</script>
{{ if $noOid }}
<h3>$login_title</h3>
{{ else }}
<ul class="tabs">
<li id="tab_1" class="tab button active"><a href="#">$tab_1</a></li>
<li id="tab_2" class="tab button"><a href="#">$tab_2</a></li>
</ul>
{{ endif }}
$login_form
{{ if $lastusers_title }}
<h3>$lastusers_title</h3>
<div class='items-wrapper'>
{{ for $lastusers_items as $i }}
$i
{{ endfor }}
</div>
{{ endif }}
{{ if $activeusers_title }}
<h3>$activeusers_title</h3>
<div class='items-wrapper'>
{{ for $activeusers_items as $i }}
$i
{{ endfor }}
</div>
{{ endif }}
{{ if $photos_title }}
<h3>$photos_title</h3>
<div class='items-wrapper'>
{{ for $photos_items as $i }}
$i
{{ endfor }}
</div>
{{ endif }}
{{ if $like_title }}
<h3>$like_title</h3>
<ul id='likes'>
{{ for $like_items as $i }}
<li>$i</li>
{{ endfor }}
</ul>
{{ endif }}

View file

@ -1,10 +0,0 @@
<div class="directory-item" id="directory-item-$id" >
<div class="directory-photo-wrapper" id="directory-photo-wrapper-$id" >
<div class="directory-photo" id="directory-photo-$id" >
<a href="$profile_link" class="directory-profile-link" id="directory-profile-link-$id" >
<img class="directory-photo-img" src="$photo" alt="$alt_text" title="$alt_text" />
</a>
</div>
</div>
</div>

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
dav.tgz

Binary file not shown.

Binary file not shown.

View file

@ -1,9 +0,0 @@
<input type='hidden' name='form_security_token' value='$form_security_token'>
{{ for $features as $f }}
<h3 class="settings-heading">$f.0</h3>
{{ for $f.1 as $fcat }}
{{ inc field_yesno.tpl with $field=$fcat }}{{endinc}}
{{ endfor }}
{{ endfor }}
<div class="submit"><input type="submit" name="defaultfeatures-submit" value="$submit" /></div>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,42 +0,0 @@
<div class="forumdirectory-item" id="forumdirectory-item-$id" >
<div class="forumdirectory-photo-wrapper" id="forumdirectory-photo-wrapper-$id" >
<div class="forumdirectory-photo" id="forumdirectory-photo-$id" >
<a href="$profile_link" class="forumdirectory-profile-link" id="forumdirectory-profile-link-$id" >
<img class="forumdirectory-photo-img photo" src="$photo" alt="$alt_text" title="$alt_text" />
</a>
</div>
</div>
<div class="forumdirectory-profile-wrapper" id="forumdirectory-profile-wrapper-$id" >
<div class="contact-name" id="forumdirectory-name-$id">$name</div>
<div class="page-type">$page_type</div>
{{ if $pdesc }}<div class="forumdirectory-profile-title">$profile.pdesc</div>{{ endif }}
<div class="forumdirectory-detailcolumns-wrapper" id="forumdirectory-detailcolumns-wrapper-$id">
<div class="forumdirectory-detailscolumn-wrapper" id="forumdirectory-detailscolumn1-wrapper-$id">
{{ if $location }}
<dl class="location"><dt class="location-label">$location</dt>
<dd class="adr">
{{ if $profile.address }}<div class="street-address">$profile.address</div>{{ endif }}
<span class="city-state-zip">
<span class="locality">$profile.locality</span>{{ if $profile.locality }}, {{ endif }}
<span class="region">$profile.region</span>
<span class="postal-code">$profile.postal-code</span>
</span>
{{ if $profile.country-name }}<span class="country-name">$profile.country-name</span>{{ endif }}
</dd>
</dl>
{{ endif }}
{{ if $gender }}<dl class="mf"><dt class="gender-label">$gender</dt> <dd class="x-gender">$profile.gender</dd></dl>{{ endif }}
</div>
<div class="forumdirectory-detailscolumn-wrapper" id="forumdirectory-detailscolumn2-wrapper-$id">
{{ if $marital }}<dl class="marital"><dt class="marital-label"><span class="heart">&hearts;</span>$marital</dt><dd class="marital-text">$profile.marital</dd></dl>{{ endif }}
{{ if $homepage }}<dl class="homepage"><dt class="homepage-label">$homepage</dt><dd class="homepage-url"><a href="$profile.homepage" target="external-link">$profile.homepage</a></dd></dl>{{ endif }}
</div>
</div>
<div class="forumdirectory-copy-wrapper" id="forumdirectory-copy-wrapper-$id" >
{{ if $about }}<dl class="forumdirectory-copy"><dt class="forumdirectory-copy-label">$about</dt><dd class="forumdirectory-copy-data">$profile.about</dd></dl>{{ endif }}
</div>
</div>
</div>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
gnot.tgz

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,3 +0,0 @@
{{ inc field_select.tpl with $field=$default_avatar}}{{ endinc }}
{{ inc field_select.tpl with $field=$rating }}{{ endinc }}
<div class="submit"><input type="submit" value="$submit" /></div>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,7 +0,0 @@
{{ inc field_input.tpl with $field=$owner }}{{ endinc }}
{{ inc field_input.tpl with $field=$ownerprofile }}{{ endinc }}
{{ inc field_textarea.tpl with $field=$postal }}{{ endinc }}
{{ inc field_textarea.tpl with $field=$notes }}{{ endinc }}
{{ inc field_input.tpl with $field=$email }}{{ endinc }}
{{ inc field_textarea.tpl with $field=$footer_text }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

Binary file not shown.

BIN
irc.tgz

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,2 +0,0 @@
{{ inc field_select.tpl with $field=$default_avatar}}{{ endinc }}
<div class="submit"><input type="submit" value="$submit" /></div>

Binary file not shown.

Binary file not shown.

View file

@ -4,10 +4,10 @@ CREATE TABLE IF NOT EXISTS `mailstream_item` (
`contact-id` int(11) NOT NULL,
`uri` char(255) NOT NULL,
`message-id` char(255) NOT NULL,
`created` timestamp NOT NULL DEFAULT now()',
`created` timestamp NOT NULL DEFAULT now(),
`completed` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `message-id` (`message-id`),
KEY `created` (`created`),
KEY `completed` (`completed`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATION=utf8_bin;
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

View file

@ -2,7 +2,7 @@
/**
* Name: Mail Stream
* Description: Mail all items coming into your network feed to an email address
* Version: 0.1
* Version: 0.2
* Author: Matthew Exon <http://mat.exon.name>
*/
@ -74,29 +74,46 @@ function mailstream_generate_id($a, $uri) {
}
function mailstream_post_remote_hook(&$a, &$item) {
if (get_pconfig($item['uid'], 'mailstream', 'enabled') === 'on') {
if ($item['uid'] && $item['contact-id'] && $item['uri']) {
q("INSERT INTO `mailstream_item` (`uid`, `contact-id`, `uri`, `message-id`) " .
"VALUES (%d, '%s', '%s', '%s')", intval($item['uid']),
intval($item['contact-id']), dbesc($item['uri']), dbesc(mailstream_generate_id($a, $item['uri'])));
$r = q('SELECT * FROM `mailstream_item` WHERE `uid` = %d AND `contact-id` = %d AND `uri` = "%s"', intval($item['uid']), intval($item['contact-id']), dbesc($item['uri']));
if (count($r) != 1) {
logger('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', LOGGER_NORMAL);
return;
}
$ms_item = $r[0];
logger('mailstream_post_remote_hook: created mailstream_item '
. $ms_item['id'] . ' for item ' . $item['uri'] . ' '
. $item['uid'] . ' ' . $item['contact-id'], LOGGER_DATA);
$r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($item['uid']));
if (count($r) != 1) {
logger('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_NORMAL);
return;
}
$user = $r[0];
mailstream_send($a, $ms_item, $item, $user);
}
if (!get_pconfig($item['uid'], 'mailstream', 'enabled')) {
return;
}
if (!$item['uid']) {
return;
}
if (!$item['contact-id']) {
return;
}
if (!$item['uri']) {
return;
}
q("INSERT INTO `mailstream_item` (`uid`, `contact-id`, `uri`, `message-id`) " .
"VALUES (%d, '%s', '%s', '%s')", intval($item['uid']),
intval($item['contact-id']), dbesc($item['uri']), dbesc(mailstream_generate_id($a, $item['uri'])));
$r = q('SELECT * FROM `mailstream_item` WHERE `uid` = %d AND `contact-id` = %d AND `uri` = "%s"', intval($item['uid']), intval($item['contact-id']), dbesc($item['uri']));
if (count($r) != 1) {
logger('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', LOGGER_NORMAL);
return;
}
$ms_item = $r[0];
logger('mailstream_post_remote_hook: created mailstream_item '
. $ms_item['id'] . ' for item ' . $item['uri'] . ' '
. $item['uid'] . ' ' . $item['contact-id'], LOGGER_DATA);
$user = mailstream_get_user($item['uid']);
if (!$user) {
logger('mailstream_post_remote_hook: no user ' . $item['uid'], LOGGER_NORMAL);
return;
}
mailstream_send($a, $ms_item, $item, $user);
}
function mailstream_get_user($uid) {
$r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($uid));
if (count($r) != 1) {
logger('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_NORMAL);
return;
}
return $r[0];
}
function mailstream_do_images($a, &$item, &$attachments) {
@ -183,12 +200,15 @@ function mailstream_send($a, $ms_item, $item, $user) {
if ($frommail == "") {
$frommail = 'friendica@localhost.local';
}
$email = get_pconfig($item['uid'], 'mailstream', 'address');
$address = get_pconfig($item['uid'], 'mailstream', 'address');
if (!$address) {
$address = $user['email'];
}
$mail = new PHPmailer;
try {
$mail->XMailer = 'Friendica Mailstream Plugin';
$mail->SetFrom($frommail, $item['author-name']);
$mail->AddAddress($email, $user['username']);
$mail->AddAddress($address, $user['username']);
$mail->MessageID = $ms_item['message-id'];
$mail->Subject = mailstream_subject($item);
if ($item['thr-parent'] != $item['uri']) {
@ -246,24 +266,31 @@ function mailstream_cron($a, $b) {
function mailstream_plugin_settings(&$a,&$s) {
$enabled = get_pconfig(local_user(), 'mailstream', 'enabled');
$enabled_mu = ($enabled === 'on') ? ' checked="true"' : '';
$address = get_pconfig(local_user(), 'mailstream', 'address');
$address_mu = $address ? (' value="' . $address . '"') : '';
$template = get_markup_template('settings.tpl', 'addon/mailstream/');
$s .= replace_macros($template, array(
'$submit' => t('Submit'),
'$address' => $address_mu,
'$address_caption' => t('Address:'),
'$enabled' => $enabled_mu,
'$enabled_caption' => t('Enabled:')));
'$address' => array(
'mailstream_address',
t('Email Address'),
$address,
t("Leave blank to use your account email address")),
'$enabled' => array(
'mailstream_enabled',
t('Enabled'),
$enabled),
'$title' => t('Mail Stream Settings'),
'$submit' => t('Submit')));
}
function mailstream_plugin_settings_post($a,$post) {
if ($_POST['address'] != "") {
set_pconfig(local_user(), 'mailstream', 'address', $_POST['address']);
if ($_POST['mailstream_address'] != "") {
set_pconfig(local_user(), 'mailstream', 'address', $_POST['mailstream_address']);
}
if ($_POST['enabled']) {
set_pconfig(local_user(), 'mailstream', 'enabled', $_POST['enabled']);
else {
del_pconfig(local_user(), 'mailstream', 'address');
}
if ($_POST['mailstream_enabled']) {
set_pconfig(local_user(), 'mailstream', 'enabled', $_POST['mailstream_enabled']);
}
else {
del_pconfig(local_user(), 'mailstream', 'enabled');

View file

@ -0,0 +1,11 @@
{{*
* AUTOMATICALLY GENERATED TEMPLATE
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
*
*}}
<div class="settings-block">
<h3>{{$title}}</h3>
{{include file="field_input.tpl" field=$address}}
{{include file="field_checkbox.tpl" field=$enabled}}
<input type="submit" value="{{$submit}}">
</div>

View file

@ -1,3 +0,0 @@
{{ inc field_input.tpl with $field=$frommail }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit"></div>

View file

@ -1,5 +0,0 @@
<div class="mailstream-item-body">$item.body</div>
{{ if $item.plink }}
<div>$upstream: <a class="mailstream-item-plink" href="$item.plink">$item.plink</a><div>
<div>$local: <a class="mailstream-item-url" href="$item.url">$item.url</a></div>
{{ endif }}

View file

@ -1,18 +0,0 @@
<div class="settings-block">
<h3>Mail Stream Settings</h3>
<table>
<tbody>
<tr>
<td>$enabled_caption</td>
<td><input class="checkbox" type="checkbox" name="enabled" $enabled></td>
</tr>
<tr>
<td>$address_caption</td>
<td><input class="input" size="70" name="address"$address></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="$submit"></td>
</tr>
</tbody>
</table>
</div>

Binary file not shown.

View file

@ -1,2 +0,0 @@
{{ inc field_input.tpl with $field=$baseurl }}{{endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
nsfw.tgz

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,3 +0,0 @@
{{ inc field_input.tpl with $field=$tmsserver }}{{ endinc }}
{{ inc field_input.tpl with $field=$zoom }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

BIN
page.tgz

Binary file not shown.

BIN
piwik.tgz

Binary file not shown.

View file

@ -1,5 +0,0 @@
{{ inc field_input.tpl with $field=$baseurl }}{{ endinc }}
{{ inc field_input.tpl with $field=$siteid }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$optout }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$async }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,3 +0,0 @@
{{ inc field_radio.tpl with $field=$global }}{{ endinc }}
{{ inc field_radio.tpl with $field=$individual }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

View file

@ -1,8 +0,0 @@
<div class="settings-block">
<h3>$remote_perms_title</h3>
<div id="remote-perms-wrapper">
<label id="remote-perms-label" for="remote-perms">$remote_perms_label</label>
<input id="remote-perms-input" type="checkbox" name="remote-perms" value="1" $checked />
</div><div class="clear"></div>
<div class="settings-submit-wrapper" ><input type="submit" name="remote-perms-submit" class="settings-submit" value="$submit" /></div></div>

Binary file not shown.

BIN
retriever.tgz Normal file

Binary file not shown.

35
retriever/database.sql Normal file
View file

@ -0,0 +1,35 @@
CREATE TABLE IF NOT EXISTS `retriever_rule` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(11) NOT NULL,
`contact-id` int(11) NOT NULL,
`data` mediumtext NOT NULL,
PRIMARY KEY (`id`),
KEY `uid` (`uid`),
KEY `contact-id` (`contact-id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `retriever_item` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`item-uri` varchar(800) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`item-uid` int(10) unsigned NOT NULL DEFAULT '0',
`contact-id` int(10) unsigned NOT NULL DEFAULT '0',
`resource` int(11) NOT NULL,
`parent` int(11) NOT NULL,
`finished` tinyint(1) unsigned NOT NULL DEFAULT '0',
KEY `resource` (`resource`),
KEY `all` (`item-uri`, `item-uid`, `contact-id`),
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `retriever_resource` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`type` char(255) NOT NULL,
`binary` int(1) NOT NULL DEFAULT 0,
`url` varchar(800) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`created` timestamp NOT NULL DEFAULT now(),
`completed` timestamp NULL DEFAULT NULL,
`last-try` timestamp NULL DEFAULT NULL,
`num-tries` int(11) NOT NULL DEFAULT 0,
`data` mediumtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin

736
retriever/retriever.php Normal file
View file

@ -0,0 +1,736 @@
<?php
/**
* Name: Retrieve Feed Content
* Description: Follow the permalink of RSS/Atom feed items and replace the summary with the full content.
* Version: 0.2
* Author: Matthew Exon <http://mat.exon.name>
*/
function retriever_install() {
register_hook('plugin_settings', 'addon/retriever/retriever.php', 'retriever_plugin_settings');
register_hook('plugin_settings_post', 'addon/retriever/retriever.php', 'retriever_plugin_settings_post');
register_hook('post_remote', 'addon/retriever/retriever.php', 'retriever_post_remote_hook');
register_hook('contact_photo_menu', 'addon/retriever/retriever.php', 'retriever_contact_photo_menu');
register_hook('cron', 'addon/retriever/retriever.php', 'retriever_cron');
$schema = file_get_contents(dirname(__file__).'/database.sql');
$arr = explode(';', $schema);
foreach ($arr as $a) {
$r = q($a);
}
$r = q("SELECT `id` FROM `pconfig` WHERE `cat` LIKE 'retriever_%%'");
if (count($r) || (get_config('retriever', 'dbversion') == '0.1')) {
$retrievers = array();
$r = q("SELECT SUBSTRING(`cat`, 10) AS `contact`, `k`, `v` FROM `pconfig` WHERE `cat` LIKE 'retriever%%'");
foreach ($r as $rr) {
$retrievers[$rr['contact']][$rr['k']] = $rr['v'];
}
foreach ($retrievers as $k => $v) {
$rr = q("SELECT `uid` FROM `contact` WHERE `id` = %d", intval($k));
$uid = $rr[0]['uid'];
$v['images'] = 'on';
q("INSERT INTO `retriever_rule` (`uid`, `contact-id`, `data`) VALUES (%d, %d, '%s')",
intval($uid), intval($k), dbesc(json_encode($v)));
}
q("DELETE FROM `pconfig` WHERE `cat` LIKE 'retriever%%'");
}
if (get_config('retriever', 'dbversion') == '0.2') {
q("ALTER TABLE `retriever_resource` DROP COLUMN `retriever`");
}
if (get_config('retriever', 'dbversion') == '0.3') {
q("ALTER TABLE `retriever_item` MODIFY COLUMN `item-uri` varchar(800) CHARACTER SET ascii NOT NULL");
q("ALTER TABLE `retriever_resource` MODIFY COLUMN `url` varchar(800) CHARACTER SET ascii NOT NULL");
}
if (get_config('retriever', 'dbversion') == '0.4') {
q("ALTER TABLE `retriever_item` ADD COLUMN `finished` tinyint(1) unsigned NOT NULL DEFAULT '0'");
}
if (get_config('retriever', 'dbversion') == '0.5') {
q('ALTER TABLE `retriever_resource` CHANGE `created` `created` timestamp NOT NULL DEFAULT now()');
q('ALTER TABLE `retriever_resource` CHANGE `completed` `completed` timestamp NULL DEFAULT NULL');
q('ALTER TABLE `retriever_resource` CHANGE `last-try` `last-try` timestamp NULL DEFAULT NULL');
q('ALTER TABLE `retriever_item` DROP KEY `all`');
q('ALTER TABLE `retriever_item` ADD KEY `all` (`item-uri`, `item-uid`, `contact-id`)');
}
if (get_config('retriever', 'dbversion') == '0.6') {
q('ALTER TABLE `retriever_item` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin');
q('ALTER TABLE `retriever_item` CHANGE `item-uri` `item-uri` varchar(800) CHARACTER SET ascii COLLATE ascii_bin NOT NULL');
q('ALTER TABLE `retriever_resource` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin');
q('ALTER TABLE `retriever_resource` CHANGE `url` `url` varchar(800) CHARACTER SET ascii COLLATE ascii_bin NOT NULL');
q('ALTER TABLE `retriever_rule` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin');
}
if (get_config('retriever', 'dbversion') == '0.7') {
$r = q("SELECT `id`, `data` FROM `retriever_rule`");
foreach ($r as $rr) {
logger('retriever_install: retriever ' . $rr['id'] . ' old config ' . $rr['data'], LOGGER_DATA);
$data = json_decode($rr['data'], true);
if ($data['pattern']) {
$matches = array();
if (preg_match("/\/(.*)\//", $data['pattern'], $matches)) {
$data['pattern'] = $matches[1];
}
}
if ($data['match']) {
$include = array();
foreach (explode('|', $data['match']) as $component) {
$matches = array();
if (preg_match("/([A-Za-z][A-Za-z0-9]*)\[@([A-Za-z][a-z0-9]*)='([^']*)'\]/", $component, $matches)) {
$include[] = array(
'element' => $matches[1],
'attribute' => $matches[2],
'value' => $matches[3]);
}
if (preg_match("/([A-Za-z][A-Za-z0-9]*)\[contains(concat(' ',normalize-space(@class),' '),' ([^ ']+) ')]/", $component, $matches)) {
$include[] = array(
'element' => $matches[1],
'attribute' => $matches[2],
'value' => $matches[3]);
}
}
$data['include'] = $include;
unset($data['match']);
}
if ($data['remove']) {
$exclude = array();
foreach (explode('|', $data['remove']) as $component) {
$matches = array();
if (preg_match("/([A-Za-z][A-Za-z0-9]*)\[@([A-Za-z][a-z0-9]*)='([^']*)'\]/", $component, $matches)) {
$exclude[] = array(
'element' => $matches[1],
'attribute' => $matches[2],
'value' => $matches[3]);
}
if (preg_match("/([A-Za-z][A-Za-z0-9]*)\[contains(concat(' ',normalize-space(@class),' '),' ([^ ']+) ')]/", $component, $matches)) {
$exclude[] = array(
'element' => $matches[1],
'attribute' => $matches[2],
'value' => $matches[3]);
}
}
$data['exclude'] = $exclude;
unset($data['remove']);
}
$r = q('UPDATE `retriever_rule` SET `data` = "%s" WHERE `id` = %d', dbesc(json_encode($data)), $rr['id']);
logger('retriever_install: retriever ' . $rr['id'] . ' new config ' . json_encode($data), LOGGER_DATA);
}
}
set_config('retriever', 'dbversion', '0.8');
}
function retriever_uninstall() {
unregister_hook('plugin_settings', 'addon/retriever/retriever.php', 'retriever_plugin_settings');
unregister_hook('plugin_settings_post', 'addon/retriever/retriever.php', 'retriever_plugin_settings_post');
unregister_hook('post_remote', 'addon/retriever/retriever.php', 'retriever_post_remote_hook');
unregister_hook('plugin_settings', 'addon/retriever/retriever.php', 'retriever_plugin_settings');
unregister_hook('plugin_settings_post', 'addon/retriever/retriever.php', 'retriever_plugin_settings_post');
unregister_hook('contact_photo_menu', 'addon/retriever/retriever.php', 'retriever_contact_photo_menu');
unregister_hook('cron', 'addon/retriever/retriever.php', 'retriever_cron');
}
function retriever_module() {}
function retriever_cron($a, $b) {
// 100 is a nice sane number. Maybe this should be configurable.
retriever_retrieve_items(100);
retriever_tidy();
}
$retriever_item_count = 0;
function retriever_retrieve_items($max_items) {
global $retriever_item_count;
$retriever_schedule = array(array(1,'minute'),
array(10,'minute'),
array(1,'hour'),
array(1,'day'),
array(2,'day'),
array(1,'week'),
array(1,'month'));
$schedule_clauses = array();
for ($i = 0; $i < count($retriever_schedule); $i++) {
$num = $retriever_schedule[$i][0];
$unit = $retriever_schedule[$i][1];
array_push($schedule_clauses,
'(`num-tries` = ' . $i . ' AND TIMESTAMPADD(' . dbesc($unit) .
', ' . intval($num) . ', `last-try`) < now())');
}
$retrieve_items = $max_items - $retriever_item_count;
do {
$r = q("SELECT * FROM `retriever_resource` WHERE `completed` IS NULL AND (`last-try` IS NULL OR %s) ORDER BY `last-try` ASC LIMIT %d",
dbesc(implode($schedule_clauses, ' OR ')),
intval($retrieve_items));
if (count($r) == 0) {
break;
}
foreach ($r as $rr) {
retrieve_resource($rr);
$retriever_item_count++;
}
$retrieve_items = $max_items - $retriever_item_count;
}
while ($retrieve_items > 0);
/* Look for items that are waiting even though the resource has
* completed. This usually happens because we've been asked to
* retrospectively apply a config change. It could also happen
* due to a cron job dying or something. */
$r = q("SELECT retriever_resource.`id` as resource, retriever_item.`id` as item FROM retriever_resource, retriever_item, retriever_rule WHERE retriever_item.`finished` = 0 AND retriever_item.`resource` = retriever_resource.`id` AND retriever_resource.`completed` IS NOT NULL AND retriever_item.`contact-id` = retriever_rule.`contact-id` AND retriever_item.`item-uid` = retriever_rule.`uid` LIMIT %d",
intval($retrieve_items));
if (!$r) {
$r = array();
}
foreach ($r as $rr) {
$resource = q("SELECT * FROM retriever_resource WHERE `id` = %d", $rr['resource']);
$retriever_item = retriever_get_retriever_item($rr['item']);
if (!$retriever_item) {
logger('retriever_retrieve_items: no retriever item with id ' . $rr['item']);
continue;
}
$item = retriever_get_item($retriever_item);
if (!$item) {
logger('retriever_retrieve_items: no item ' . $retriever_item['item-uri']);
continue;
}
$retriever = get_retriever($item['contact-id'], $item['uid']);
if (!$retriever) {
logger('retriever_retrieve_items: no retriever for item ' .
$retriever_item['item-uri'] . ' ' . $retriever_item['uid'] . ' ' . $item['contact-id']);
continue;
}
retriever_apply_completed_resource_to_item($retriever, $item, $resource[0]);
q("UPDATE `retriever_item` SET `finished` = 1 WHERE id = %d",
intval($retriever_item['id']));
retriever_check_item_completed($item);
}
}
function retriever_tidy() {
q("DELETE FROM retriever_resource WHERE completed IS NOT NULL AND completed < DATE_SUB(now(), INTERVAL 1 WEEK)");
q("DELETE FROM retriever_resource WHERE completed IS NULL AND created < DATE_SUB(now(), INTERVAL 3 MONTH)");
$r = q("SELECT retriever_item.id FROM retriever_item LEFT OUTER JOIN retriever_resource ON (retriever_item.resource = retriever_resource.id) WHERE retriever_resource.id is null");
foreach ($r as $rr) {
q('DELETE FROM retriever_item WHERE id = %d', intval($rr['id']));
}
}
function retrieve_resource($resource) {
logger('retrieve_resource: ' . ($resource['num-tries'] + 1) .
' attempt at resource ' . $resource['id'] . ' ' . $resource['url'], LOGGER_DEBUG);
q("UPDATE `retriever_resource` SET `last-try` = now(), `num-tries` = `num-tries` + 1 WHERE id = %d",
intval($resource['id']));
$data = fetch_url($resource['url'], $resource['binary'], $resource['type']);
$resource['type'] = get_app()->get_curl_content_type();
if ($data) {
$resource['data'] = $data;
q("UPDATE `retriever_resource` SET `completed` = now(), `data` = '%s', `type` = '%s' WHERE id = %d",
dbesc($data), dbesc($resource['type']), intval($resource['id']));
retriever_resource_completed($resource);
}
}
function get_retriever($contact_id, $uid, $create = false) {
$r = q("SELECT * FROM `retriever_rule` WHERE `contact-id` = %d AND `uid` = %d",
intval($contact_id), intval($uid));
if (count($r)) {
$r[0]['data'] = json_decode($r[0]['data'], true);
return $r[0];
}
if ($create) {
q("INSERT INTO `retriever_rule` (`uid`, `contact-id`) VALUES (%d, %d)",
intval($uid), intval($contact_id));
$r = q("SELECT * FROM `retriever_rule` WHERE `contact-id` = %d AND `uid` = %d",
intval($contact_id), intval($uid));
return $r[0];
}
}
function retriever_get_retriever_item($id) {
$retriever_items = q("SELECT * FROM `retriever_item` WHERE id = %d", intval($id));
if (count($retriever_items) != 1) {
logger('retriever_get_retriever_item: unable to find retriever_item ' . $id, LOGGER_NORMAL);
return;
}
return $retriever_items[0];
}
function retriever_get_item($retriever_item) {
$items = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `contact-id` = %d",
dbesc($retriever_item['item-uri']),
intval($retriever_item['item-uid']),
intval($retriever_item['contact-id']));
if (count($items) != 1) {
logger('retriever_get_item: unexpected number of results ' .
count($items) . " when searching for item $uri $uid $cid", LOGGER_NORMAL);
return;
}
return $items[0];
}
function retriever_item_completed($retriever_item_id, $resource) {
logger('retriever_item_completed: id ' . $retriever_item_id . ' url ' . $resource['url'], LOGGER_DEBUG);
$retriever_item = retriever_get_retriever_item($retriever_item_id);
if (!$retriever_item) {
return;
}
// Note: the retriever might be null. Doesn't matter.
$retriever = get_retriever($retriever_item['contact-id'], $retriever_item['item-uid']);
$item = retriever_get_item($retriever_item);
if (!$item) {
return;
}
retriever_apply_completed_resource_to_item($retriever, $item, $resource);
q("UPDATE `retriever_item` SET `finished` = 1 WHERE id = %d",
intval($retriever_item['id']));
retriever_check_item_completed($item);
}
function retriever_resource_completed($resource) {
logger('retriever_resource_completed: id ' . $resource['id'] . ' url ' . $resource['url'], LOGGER_DEBUG);
$r = q("SELECT `id` FROM `retriever_item` WHERE `resource` = %d", $resource['id']);
foreach ($r as $rr) {
retriever_item_completed($rr['id'], $resource);
}
}
function apply_retrospective($retriever, $num) {
$r = q("SELECT * FROM `item` WHERE `contact-id` = %d ORDER BY `received` DESC LIMIT %d",
intval($retriever['contact-id']), intval($num));
foreach ($r as $item) {
q('UPDATE `item` SET `visible` = 0 WHERE `id` = %d', $item['id']);
retriever_on_item_insert($retriever, $item);
}
}
function retriever_on_item_insert($retriever, &$item) {
if (!$retriever || !$retriever['id']) {
logger('retriever_on_item_insert: No retriever supplied', LOGGER_NORMAL);
return;
}
if (!$retriever["data"]['enable'] == "on") {
return;
}
if ($retriever["data"]['pattern']) {
$url = preg_replace('/' . $retriever["data"]['pattern'] . '/', $retriever["data"]['replace'], $item['plink']);
logger('retriever_on_item_insert: Changed ' . $item['plink'] . ' to ' . $url, LOGGER_DATA);
}
else {
$url = $item['plink'];
}
$resource = add_retriever_resource($url);
$retriever_item_id = add_retriever_item($item, $resource);
}
function add_retriever_resource($url, $binary = false) {
logger('add_retriever_resource: ' . $url, LOGGER_DEBUG);
$r = q("SELECT * FROM `retriever_resource` WHERE `url` = '%s'", dbesc($url));
$resource = $r[0];
if (count($r)) {
logger('add_retriever_resource: Resource ' . $url . ' already requested', LOGGER_DEBUG);
return $r[0];
}
else {
q("INSERT INTO `retriever_resource` (`binary`, `url`) " .
"VALUES (%d, '%s')", intval($binary ? 1 : 0), dbesc($url));
$r = q("SELECT * FROM `retriever_resource` WHERE `url` = '%s'", dbesc($url));
return $r[0];
}
}
function add_retriever_item(&$item, $resource) {
logger('add_retriever_item: ' . $resource['url'] . ' for ' . $item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'], LOGGER_DEBUG);
q("INSERT INTO `retriever_item` (`item-uri`, `item-uid`, `contact-id`, `resource`) " .
"VALUES ('%s', %d, %d, %d)",
dbesc($item['uri']), intval($item['uid']), intval($item['contact-id']), intval($resource["id"]));
$r = q("SELECT id FROM `retriever_item` WHERE " .
"`item-uri` = '%s' AND `item-uid` = %d AND `contact-id` = %d AND `resource` = %d ORDER BY id DESC",
dbesc($item['uri']), intval($item['uid']), intval($item['contact-id']), intval($resource['id']));
if (!count($r)) {
logger("add_retriever_item: couldn't create retriever item for " .
$item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'],
LOGGER_NORMAL);
return;
}
logger('add_retriever_item: created retriever_item ' . $r[0]['id'] . ' for item ' . $item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'], LOGGER_DEBUG);
return $r[0]['id'];
}
function retriever_get_encoding($resource) {
$matches = array();
if (preg_match('/charset=(.*)/', $resource['type'], $matches)) {
return trim(array_pop($matches));
}
return 'utf-8';
}
function retriever_construct_xpath($spec) {
if (gettype($spec) != "array") {
return;
}
$components = array();
foreach ($spec as $clause) {
if (!$clause['attribute']) {
$components[] = $clause['element'];
continue;
}
if ($clause['attribute'] === 'class') {
$components[] =
$clause['element'] .
"[contains(concat(' ', normalize-space(@class), ' '), ' " .
$clause['value'] . " ')]";
}
else {
$components[] =
$clause['element'] . '[@' .
$clause['attribute'] . "='" .
$clause['value'] . "']";
}
}
// It would be better to do this in smarty3 in extract.tpl
return implode('|', $components);
}
function retriever_apply_dom_filter($retriever, &$item, $resource) {
logger('retriever_apply_dom_filter: applying XSLT to ' . $item['id'] . ' ' . $item['plink'], LOGGER_DEBUG);
require_once('include/html2bbcode.php');
if (!$retriever['data']['include']) {
return;
}
if (!$resource['data']) {
logger('retriever_apply_dom_filter: no text to work with', LOGGER_NORMAL);
return;
}
$encoding = retriever_get_encoding($resource);
logger('@@@ item type ' . $resource['type'] . ' encoding ' . $encoding);
$extracter_template = get_markup_template('extract.tpl', 'addon/retriever/');
$doc = new DOMDocument('1.0', 'utf-8');
if (strpos($resource['type'], 'html') !== false) {
@$doc->loadHTML($resource['data']);
}
else {
$doc->loadXML($resource['data']);
}
logger('@@@ actual encoding of document is ' . $doc->encoding);
$components = parse_url($item['plink']);
$rooturl = $components['scheme'] . "://" . $components['host'];
$dirurl = $rooturl . dirname($components['path']) . "/";
$params = array('$include' => retriever_construct_xpath($retriever['data']['include']),
'$exclude' => retriever_construct_xpath($retriever['data']['exclude']),
'$pageurl' => $item['plink'],
'$dirurl' => $dirurl,
'$rooturl' => $rooturl);
$xslt = replace_macros($extracter_template, $params);
$xmldoc = new DOMDocument();
$xmldoc->loadXML($xslt);
$xp = new XsltProcessor();
$xp->importStylesheet($xmldoc);
$transformed = $xp->transformToXML($doc);
$item['body'] = html2bbcode($transformed);
if (!strlen($item['body'])) {
logger('retriever_apply_dom_filter retriever ' . $retriever['id'] . ' item ' . $item['id'] . ': output was empty', LOGGER_NORMAL);
return;
}
$item['body'] .= "\n\n" . t('Retrieved') . ' ' . date("Y-m-d") . ': [url=';
$item['body'] .= $item['plink'];
$item['body'] .= ']' . $item['plink'] . '[/url]';
q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `id` = %d",
dbesc($item['body']), dbesc(datetime_convert('UTC', 'UTC')), intval($item['id']));
}
function retrieve_images(&$item) {
$matches1 = array();
preg_match_all("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", $item["body"], $matches1);
$matches2 = array();
preg_match_all("/\[img\](.*?)\[\/img\]/ism", $item["body"], $matches2);
$matches = array_merge($matches1[3], $matches2[1]);
logger('retrieve_images: found ' . count($matches) . ' images for item ' . $item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'], LOGGER_DEBUG);
foreach ($matches as $url) {
if (strpos($url, get_app()->get_baseurl()) === FALSE) {
$resource = add_retriever_resource($url, true);
if (!$resource['completed']) {
add_retriever_item($item, $resource);
}
else {
retriever_transform_images($item, $resource);
}
}
}
}
function retriever_check_item_completed(&$item)
{
$r = q('SELECT count(*) FROM retriever_item WHERE `item-uri` = "%s" ' .
'AND `item-uid` = %d AND `contact-id` = %d AND `finished` = 0',
dbesc($item['uri']), intval($item['uid']),
intval($item['contact-id']));
$waiting = $r[0]['count(*)'];
logger('retriever_check_item_completed: item ' . $item['uri'] . ' ' . $item['uid']
. ' '. $item['contact-id'] . ' waiting for ' . $waiting . ' resources', LOGGER_DEBUG);
$old_visible = $item['visible'];
$item['visible'] = $waiting ? 0 : 1;
if (($item['id'] > 0) && ($old_visible != $item['visible'])) {
logger('retriever_check_item_completed: changing visible flag to ' . $item['visible'] . ' and invoking notifier ("edit_post", ' . $item['id'] . ')', LOGGER_DEBUG);
q("UPDATE `item` SET `visible` = %d, `edited` = '%s' WHERE `id` = %d",
intval($item['visible']),
dbesc(datetime_convert('UTC', 'UTC')),
intval($item['id']));
proc_run('php', "include/notifier.php", 'edit_post', $item['id']);
}
}
function retriever_apply_completed_resource_to_item($retriever, &$item, $resource) {
logger('retriever_apply_completed_resource_to_item: retriever ' .
($retriever ? $retriever['id'] : 'none') .
' resource ' . $resource['url'] . ' plink ' . $item['plink'], LOGGER_DEBUG);
if (strpos($resource['type'], 'image') !== false) {
retriever_transform_images($item, $resource);
}
if (!$retriever) {
return;
}
if ((strpos($resource['type'], 'html') !== false) ||
(strpos($resource['type'], 'xml') !== false)) {
retriever_apply_dom_filter($retriever, $item, $resource);
if ($retriever["data"]['images'] ) {
retrieve_images($item);
}
}
}
function retriever_store_photo($item, &$resource) {
$hash = photo_new_resource();
if (class_exists('Imagick')) {
try {
$image = new Imagick();
$image->readImageBlob($resource['data']);
$resource['width'] = $image->getImageWidth();
$resource['height'] = $image->getImageHeight();
}
catch (Exception $e) {
logger("ImageMagick couldn't process image " . $resource['id'] . " " . $resource['url'] . ' length ' . strlen($resource['data']) . ': ' . $e->getMessage(), LOGGER_DEBUG);
return false;
}
}
if (!array_key_exists('width', $resource)) {
$image = @imagecreatefromstring($resource['data']);
if ($image === false) {
logger("Couldn't process image " . $resource['id'] . " " . $resource['url'], LOGGER_DEBUG);
return false;
}
$resource['width'] = imagesx($image);
$resource['height'] = imagesy($image);
imagedestroy($image);
}
$url_components = parse_url($resource['url']);
$filename = basename($url_components['path']);
if (!strlen($filename)) {
$filename = 'image';
}
$r = q("INSERT INTO `photo`
( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `type`, `album`, `height`, `width`, `datasize`, `data` )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s' )",
intval($item['item-uid']),
intval($item['contact-id']),
dbesc(get_guid()),
dbesc($hash),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($filename),
dbesc($resource['type']),
dbesc('Retrieved Images'),
intval($resource['height']),
intval($resource['width']),
intval(strlen($resource['data'])),
dbesc($resource['data'])
);
return $hash;
}
function retriever_transform_images(&$item, $resource) {
require_once('include/Photo.php');
if (!$resource["data"]) {
logger('retriever_transform_images: no data available for '
. $resource['id'] . ' ' . $resource['url'], LOGGER_NORMAL);
return;
}
$hash = retriever_store_photo($item, $resource);
if ($hash === false) {
logger('retriever_transform_images: unable to store photo '
. $resource['id'] . ' ' . $resource['url'], LOGGER_NORMAL);
return;
}
$new_url = get_app()->get_baseurl() . '/photo/' . $hash;
logger('retriever_transform_images: replacing ' . $resource['url'] . ' with ' .
$new_url . ' in item ' . $item['plink'], LOGGER_DEBUG);
$transformed = str_replace($resource["url"], $new_url, $item['body']);
if ($transformed === $item['body']) {
return;
}
$item['body'] = $transformed;
q("UPDATE `item` SET `edited` = '%s', `body` = '%s' WHERE `plink` = '%s' AND `uid` = %d AND `contact-id` = %d",
dbesc(datetime_convert('UTC', 'UTC')),
dbesc($item['body']),
dbesc($item['plink']),
intval($item['uid']),
intval($item['contact-id']));
}
function retriever_content($a) {
if (!local_user()) {
$a->page['content'] .= "<p>Please log in</p>";
return;
}
if ($a->argv[1] === 'help') {
$feeds = q("SELECT `id`, `name`, `thumb` FROM contact WHERE `uid` = %d AND `network` = 'feed'",
local_user());
foreach ($feeds as $k=>$v) {
$feeds[$k]['url'] = $a->get_baseurl() . '/retriever/' . $v['id'];
}
$template = get_markup_template('/help.tpl', 'addon/retriever/');
$a->page['content'] .= replace_macros($template, array(
'$config' => $a->get_baseurl() . '/settings/addon',
'$feeds' => $feeds));
return;
}
if ($a->argv[1]) {
$retriever = get_retriever($a->argv[1], local_user(), false);
if (x($_POST["id"])) {
$retriever = get_retriever($a->argv[1], local_user(), true);
$retriever["data"] = array();
foreach (array('pattern', 'replace', 'enable', 'images') as $setting) {
if (x($_POST['retriever_' . $setting])) {
$retriever["data"][$setting] = $_POST['retriever_' . $setting];
}
}
foreach ($_POST as $k=>$v) {
if (preg_match("/retriever-(include|exclude)-(\d+)-(element|attribute|value)/", $k, $matches)) {
$retriever['data'][$matches[1]][intval($matches[2])][$matches[3]] = $v;
}
}
// You've gotta have an element, even if it's just "*"
foreach ($retriever['data']['include'] as $k=>$clause) {
if (!$clause['element']) {
unset($retriever['data']['include'][$k]);
}
}
foreach ($retriever['data']['exclude'] as $k=>$clause) {
if (!$clause['element']) {
unset($retriever['data']['exclude'][$k]);
}
}
q("UPDATE `retriever_rule` SET `data`='%s' WHERE `id` = %d",
dbesc(json_encode($retriever["data"])), intval($retriever["id"]));
$a->page['content'] .= "<p><b>Settings Updated";
if (x($_POST["retriever_retrospective"])) {
apply_retrospective($retriever, $_POST["retriever_retrospective"]);
$a->page['content'] .= " and retrospectively applied to " . $_POST["apply"] . " posts";
}
$a->page['content'] .= ".</p></b>";
}
$template = get_markup_template('/rule-config.tpl', 'addon/retriever/');
$a->page['content'] .= replace_macros($template, array(
'$enable' => array(
'retriever_enable',
t('Enabled'),
$retriever['data']['enable']),
'$pattern' => array(
'retriever_pattern',
t('URL Pattern'),
$retriever["data"]['pattern'],
t('Regular expression matching part of the URL to replace')),
'$replace' => array(
'retriever_replace',
t('URL Replace'),
$retriever["data"]['replace'],
t('Text to replace matching part of above regular expression')),
'$images' => array(
'retriever_images',
t('Download Images'),
$retriever['data']['images']),
'$retrospective' => array(
'retriever_retrospective',
t('Retrospectively Apply'),
'0',
t('Reapply the rules to this number of posts')),
'$title' => t('Retrieve Feed Content'),
'$help' => $a->get_baseurl() . '/retriever/help',
'$submit' => t('Submit'),
'$id' => ($retriever["id"] ? $retriever["id"] : "create"),
'$tag_t' => t('Tag'),
'$attribute_t' => t('Attribute'),
'$value_t' => t('Value'),
'$add_t' => t('Add'),
'$remove_t' => t('Remove'),
'$include_t' => t('Include'),
'$include' => $retriever['data']['include'],
'$exclude_t' => t('Exclude'),
'$exclude' => $retriever["data"]['exclude']));
return;
}
}
function retriever_contact_photo_menu($a, &$args) {
if (!$args) {
return;
}
if ($args["contact"]["network"] == "feed") {
$args["menu"][ 'retriever' ] = array(t('Retriever'), $a->get_baseurl() . '/retriever/' . $args["contact"]['id']);
}
}
function retriever_post_remote_hook(&$a, &$item) {
logger('retriever_post_remote_hook: ' . $item['uri'] . ' ' . $item['uid'] . ' ' . $item['contact-id'], LOGGER_DEBUG);
$retriever = get_retriever($item['contact-id'], $item["uid"], false);
if ($retriever) {
retriever_on_item_insert($retriever, $item);
}
else {
if (get_pconfig($item["uid"], 'retriever', 'all_photos')) {
retrieve_images($item, null);
}
}
retriever_check_item_completed($item);
}
function retriever_plugin_settings(&$a,&$s) {
$all_photos = get_pconfig(local_user(), 'retriever', 'all_photos');
$all_photos_mu = ($all_photos == 'on') ? ' checked="true"' : '';
$template = get_markup_template('/settings.tpl', 'addon/retriever/');
$s .= replace_macros($template, array(
'$submit' => t('Submit'),
'$title' => t('Retriever Settings'),
'$help' => $a->get_baseurl() . '/retriever/help',
'$all_photos' => $all_photos_mu,
'$all_photos_t' => t('All Photos')));
}
function retriever_plugin_settings_post($a,$post) {
if ($_POST['all_photos']) {
set_pconfig(local_user(), 'retriever', 'all_photos', $_POST['all_photos']);
}
else {
del_pconfig(local_user(), 'retriever', 'all_photos');
}
}

View file

@ -0,0 +1,41 @@
{{*
* AUTOMATICALLY GENERATED TEMPLATE
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
*
*}}
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="text()"/>
<xsl:template match="{{$include}}">
<xsl:copy>
<xsl:apply-templates select="node()|@*" mode="remove"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node()|@*" mode="remove">
<xsl:copy>
<xsl:apply-templates select="node()|@*" mode="remove"/>
</xsl:copy>
</xsl:template>
{{if $exclude}}
<xsl:template match="{{$exclude}}" mode="remove"/>
{{/if}}
<!-- attempt to replace relative URLs with absolute URLs -->
<!-- http://stackoverflow.com/questions/3824631/replace-href-value-in-anchor-tags-of-html-using-xslt -->
<xsl:template match="*/@src[starts-with(.,'.')]" mode="remove">
<xsl:attribute name="src">
<xsl:value-of select="concat('{{$dirurl}}',.)"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="*/@src[starts-with(.,'/')]" mode="remove">
<xsl:attribute name="src">
<xsl:value-of select="concat('{{$rooturl}}',.)"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,153 @@
{{*
* AUTOMATICALLY GENERATED TEMPLATE
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
*
*}}
<h2>Retriever Plugin Help</h2>
<p>
This plugin replaces the short excerpts you normally get in RSS feeds
with the full content of the article from the source website. You
specify which part of the page you're interested in with a set of
rules. When each item arrives, the plugin downloads the full page
from the website, extracts content using the rules, and replaces the
original article.
</p>
<p>
There's a few reasons you may want to do this. The source website
might be slow or overloaded. The source website might be
untrustworthy, in which case using Friendica to scrub the HTML is a
good idea. You might be on a LAN that blacklists certain websites.
It also works neatly with the mailstream plugin, allowing you to read
a news stream comfortably without needing continuous Internet
connectivity.
</p>
<p>
However, setting up retriever can be quite tricky since it depends on
the internal design of the website. That was designed to make life
easy for the website's developers, not for you. You'll need to have
some familiarity with HTML, and be willing to adapt when the website
suddenly changes everything without notice.
</p>
<h3>Configuring Retriever for a feed</h3>
<p>
To set up retriever for an RSS feed, go to the "Contacts" page and
find your feed. Then click on the drop-down menu on the contact.
Select "Retriever" to get to the retriever configuration.
</p>
<p>
The "Include" configuration section specifies parts of the page to
include in the article. Each row has three components:
</p>
<ul>
<li>An HTML tag (e.g. "div", "span", "p")</li>
<li>An attribute (usually "class" or "id")</li>
<li>A value for the attribute</li>
</ul>
<p>
A simple case is when the article is wrapped in a "div" element:
</p>
<pre>
...
&lt;div class="ArticleWrapper"&gt;
&lt;h2&gt;Man Bites Dog&lt;/h2&gt;
&lt;img src="mbd.jpg"&gt;
&lt;p&gt;
Residents of the sleepy community of Nowheresville were
shocked yesterday by the sight of creepy local weirdo Jim
McOddman assaulting innocent local dog Snufflekins with his
false teeth.
&lt;/p&gt;
...
&lt;/div&gt;
...
</pre>
<p>
You then specify the tag "div", attribute "class", and value
"ArticleWrapper". Everything else in the page, such as navigation
panels and menus and footers and so on, will be discarded. If there
is more than one section of the page you want to include, specify each
one on a separate row. If the matching section contains some sections
you want to remove, specify those in the "Exclude" section in the same
way.
</p>
<p>
Once you've got a configuration that you think will work, you can try
it out on some existing articles. Type a number into the
"Retrospectively Apply" box and click "Submit". After a while
(exactly how long depends on your system's cron configuration) the new
articles should be available.
</p>
<h3>Techniques</h3>
<p>
You can leave the attribute and value blank to include all the
corresponding elements with the specified tag name. You can also use
a tag name of just an asterisk ("*"), which will match any element type with the
specified attribute regardless of the tag.
</p>
<p>
Note that the "class" attribute is a special case. Many web page
templates will put multiple different classes in the same element,
separated by spaces. If you specify an attribute of "class" it will
match an element if any of its classes matches the specified value.
For example:
</p>
<pre>
&lt;div class="article breaking-news"&gt;
</pre>
<p>
In this case you can specify a value of "article", or "breaking-news".
You can also specify "article breaking-news", but that won't match if
the website suddenly changes to "breaking-news article", so that's not
recommended.
</p>
<p>
One useful trick you can try is using the website's "print" pages.
Many news sites have print versions of all their articles. These are
usually drastically simplified compared to the live website page.
Sometimes this is a good way to get the whole article when it's
normally split across multiple pages.
</p>
<p>
Hopefully the URL for the print page is a predictable variant of the
normal article URL. For example, an article URL like:
</p>
<pre>
http://www.newssite.com/article-8636.html
</pre>
<p>
...might have a print version at:
</p>
<pre>
http://www.newssite.com/print/article-8636.html
</pre>
<p>
To change the URL used to retrieve the page, use the "URL Pattern" and
"URL Replace" fields. The pattern is a regular expression matching
part of the URL to replace. In this case, you might use a pattern of
"/article" and a replace string of "/print/article". A common pattern
is simply a dollar sign ("$"), used to add the replace string to the end of the URL.
</p>
<h3>Background Processing</h3>
<p>
Note that retrieving and processing the articles can take some time,
so it's done in the background. Incoming articles will be marked as
invisible while they're in the process of being downloaded. If a URL
fails, the plugin will keep trying at progressively longer intervals
for up to a month, in case the website is temporarily overloaded or
the network is down.
</p>
<h3>Retrieving Images</h3>
<p>
Retriever can also optionally download images and store them in the
local Friendica instance. Just check the "Download Images" box. You
can also download images in every item from your network, whether it's
an RSS feed or not. Go to the "Settings" page and
click <a href="$config">"Plugin settings"</a>. Then check the "All
Photos" box in the "Retriever Settings" section and click "Submit".
</p>
<h2>Configure Feeds:</h2>
<div>
{{ for $feeds as $feed }}
{{ inc contact_template.tpl with $contact=$feed }}{{ endinc }}
{{ endfor }}
</div>

View file

@ -0,0 +1,116 @@
{{*
* AUTOMATICALLY GENERATED TEMPLATE
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
*
*}}
<div class="settings-block">
<script language="javascript">
function retriever_add_row(id)
{
var tbody = document.getElementById(id);
var last = tbody.rows[tbody.childElementCount - 1];
var count = +last.id.replace(id + '-', '');
count++;
var row = document.createElement('tr');
row.id = id + '-' + count;
var cell1 = document.createElement('td');
var inptag = document.createElement('input');
inptag.name = row.id + '-element';
cell1.appendChild(inptag);
row.appendChild(cell1);
var cell2 = document.createElement('td');
var inpatt = document.createElement('input');
inpatt.name = row.id + '-attribute';
cell2.appendChild(inpatt);
row.appendChild(cell2);
var cell3 = document.createElement('td');
var inpval = document.createElement('input');
inpval.name = row.id + '-value';
cell3.appendChild(inpval);
row.appendChild(cell3);
var cell4 = document.createElement('td');
var butrem = document.createElement('input');
butrem.id = row.id + '-rem';
butrem.type = 'button';
butrem.onclick = function(){retriever_remove_row(id, count)};
butrem.value = '{{$remove_t}}';
cell4.appendChild(butrem);
row.appendChild(cell4);
tbody.appendChild(row);
}
function retriever_remove_row(id, number)
{
var tbody = document.getElementById(id);
var row = document.getElementById(id + '-' + number);
tbody.removeChild(row);
}
</script>
<h2>{{$title}}</h2>
<p><a href="{{$help}}">Get Help</a></p>
<form method="post">
<input type="hidden" name="id" value="{{$id}}">
{{include file="field_checkbox.tpl" field=$enable}}
{{include file="field_input.tpl" field=$pattern}}
{{include file="field_input.tpl" field=$replace}}
{{include file="field_checkbox.tpl" field=$images}}
{{include file="field_input.tpl" field=$retrospective}}
<h3>{{$include_t}}:</h3>
<div>
<table>
<thead>
<tr><th>{{$tag_t}}</th><th>{{$attribute_t}}</th><th>{{$value_t}}</th></tr>
</thead>
<tbody id="retriever-include">
{{if $include}}
{{foreach $include as $k=>$m}}
<tr id="retriever-include-{{$k}}">
<td><input name="retriever-include-{{$k}}-element" value="{{$m.element}}"></td>
<td><input name="retriever-include-{{$k}}-attribute" value="{{$m.attribute}}"></td>
<td><input name="retriever-include-{{$k}}-value" value="{{$m.value}}"></td>
<td><input id="retrieve-include-{{$k}}-rem" type="button" onclick="retriever_remove_row('retriever-include', {{$k}})" value="{{$remove_t}}"></td>
</tr>
{{/foreach}}
{{else}}
<tr id="retriever-include-0">
<td><input name="retriever-include-0-element"></td>
<td><input name="retriever-include-0-attribute"></td>
<td><input name="retriever-include-0-value"></td>
<td><input id="retrieve-include-0-rem" type="button" onclick="retriever_remove_row('retriever-include', 0)" value="{{$remove_t}}"></td>
</tr>
{{/if}}
</tbody>
</table>
<input type="button" onclick="retriever_add_row('retriever-include')" value="{{$add_t}}">
</div>
<h3>{{$exclude_t}}:</h3>
<div>
<table>
<thead>
<tr><th>Tag</th><th>Attribute</th><th>Value</th></tr>
</thead>
<tbody id="retriever-exclude">
{{if $exclude}}
{{foreach $exclude as $k=>$r}}
<tr id="retriever-exclude-{{$k}}">
<td><input name="retriever-exclude-{{$k}}-element" value="{{$r.element}}"></td>
<td><input name="retriever-exclude-{{$k}}-attribute" value="{{$r.attribute}}"></td>
<td><input name="retriever-exclude-{{$k}}-value" value="{{$r.value}}"></td>
<td><input id="retrieve-exclude-{{$k}}-rem" type="button" onclick="retriever_remove_row('retriever-exclude', {{$k}})" value="{{$remove_t}}"></td>
</tr>
{{/foreach}}
{{else}}
<tr id="retriever-exclude-0">
<td><input name="retriever-exclude-0-element"></td>
<td><input name="retriever-exclude-0-attribute"></td>
<td><input name="retriever-exclude-0-value"></td>
<td><input id="retrieve-exclude-0-rem" type="button" onclick="retriever_remove_row('retriever-exclude', 0)" value="{{$remove_t}}"></td>
</tr>
{{/if}}
</tbody>
</table>
<input type="button" onclick="retriever_add_row('retriever-exclude')" value="{{$add_t}}">
</div>
<input type="submit" size="70" value="{{$submit}}">
</form>
</div>

View file

@ -4,16 +4,15 @@
*
*}}
<div class="settings-block">
<h3>Mail Stream Settings</h3>
<h3>{{$title}}</h3>
<p>
<a href="{{$help}}">Get Help</a>
</p>
<table>
<tbody>
<tr>
<td>{{$enabled_caption}}</td>
<td><input class="checkbox" type="checkbox" name="enabled" {{$enabled}}></td>
</tr>
<tr>
<td>{{$address_caption}}</td>
<td><input class="input" size="70" name="address"{{$address}}></td>
<td>{{$all_photos_t}}:</td>
<td><input class="checkbox" type="checkbox" name="all_photos" {{$all_photos}}></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="{{$submit}}"></td>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -4,6 +4,7 @@
* Description: Relay public postings to a connected StatusNet account
* Version: 1.0.5
* Author: Tobias Diekershoff <http://diekershoff.homeunix.net/friendika/profile/tobias>
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
/* StatusNet Plugin for Friendica
@ -658,7 +659,7 @@ function statusnet_post_hook(&$a,&$b) {
// ok, all the links we want to send out are save, now strip
// away the remaining bbcode
//$msg = strip_tags(bbcode($tmp, false, false));
$msg = bbcode($tmp, false, false);
$msg = bbcode($tmp, false, false, true);
$msg = str_replace(array('<br>','<br />'),"\n",$msg);
$msg = strip_tags($msg);

View file

@ -1,17 +0,0 @@
{{ for $sites as $s }}
{{ inc field_input.tpl with $field=$s.sitename }}{{ endinc }}
{{ inc field_input.tpl with $field=$s.apiurl }}{{ endinc }}
{{ inc field_input.tpl with $field=$s.secret }}{{ endinc }}
{{ inc field_input.tpl with $field=$s.key }}{{ endinc }}
{{ inc field_input.tpl with $field=$s.applicationname }}{{ endinc }}
{{ if $s.delete }}
{{ inc field_checkbox.tpl with $field=$s.delete }}{{ endinc }}
<hr>
{{ else }}
<p>Fill this form to add a new site</p>
{{ endif }}
{{ endfor }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

BIN
superblock.tgz Normal file

Binary file not shown.

View file

@ -0,0 +1,51 @@
# ADDON blockem
# Copyright (C)
# This file is distributed under the same license as the Friendica blockem addon package.
#
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-02-27 05:01-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: blockem.php:51
msgid "\"Blockem\" Settings"
msgstr ""
#: blockem.php:53
msgid "Comma separated profile URLS to block"
msgstr ""
#: blockem.php:57
msgid "Submit"
msgstr ""
#: blockem.php:70
msgid "BLOCKEM Settings saved."
msgstr ""
#: blockem.php:105
#, php-format
msgid "Blocked %s - Click to open/close"
msgstr ""
#: blockem.php:160
msgid "Unblock Author"
msgstr ""
#: blockem.php:162
msgid "Block Author"
msgstr ""
#: blockem.php:194
msgid "blockem settings updated"
msgstr ""

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "Configuració de \"Bloqueig\"";
$a->strings["Comma separated profile URLS to block"] = "URLS dels perfils a bloquejar, separats per comes";
$a->strings["Submit"] = "Enviar";
$a->strings["BLOCKEM Settings saved."] = "Guardada la configuració de BLOQUEIG.";
$a->strings["Blocked %s - Click to open/close"] = "Bloquejar %s - Clica per obrir/tancar";
$a->strings["Unblock Author"] = "Desbloquejar Autor";
$a->strings["Block Author"] = "Bloquejar Autor";
$a->strings["blockem settings updated"] = "Actualitzar la Configuració de bloqueig";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "\"Blockem\" Nastavení";
$a->strings["Comma separated profile URLS to block"] = "Čárkou oddělené URL adresy profilů určených k ignorování";
$a->strings["Submit"] = "Odeslat";
$a->strings["BLOCKEM Settings saved."] = "BLOCKEM nastavení uloženo.";
$a->strings["Blocked %s - Click to open/close"] = "Blokován %s - Klikněte pro otevření/zavření";
$a->strings["Unblock Author"] = "Odblokovat autora";
$a->strings["Block Author"] = "Zablokovat autora";
$a->strings["blockem settings updated"] = "blockem nastavení aktualizováno";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "\"Blockem\"-Einstellungen";
$a->strings["Comma separated profile URLS to block"] = "Profil-URLs, die blockiert werden sollen (durch Kommas getrennt)";
$a->strings["Submit"] = "Senden";
$a->strings["BLOCKEM Settings saved."] = "BLOCKEM-Einstellungen gesichert.";
$a->strings["Blocked %s - Click to open/close"] = "%s blockiert - Zum Öffnen/Schließen klicken";
$a->strings["Unblock Author"] = "Autor freischalten";
$a->strings["Block Author"] = "Autor blockieren";
$a->strings["blockem settings updated"] = "blockem Einstellungen aktualisiert";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "\"Blockem\" Agordoj";
$a->strings["Comma separated profile URLS to block"] = "Blokotaj URL adresoj, disigita per komo";
$a->strings["Submit"] = "Sendi";
$a->strings["BLOCKEM Settings saved."] = "Konservis Agordojn de BLOCKEM.";
$a->strings["Blocked %s - Click to open/close"] = "%s blokita - Klaku por malfermi/fermi";
$a->strings["Unblock Author"] = "Malbloki Aŭtoron";
$a->strings["Block Author"] = "Bloki Aŭtoron";
$a->strings["blockem settings updated"] = "Ĝisdatigis la blockem agordojn";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "Configuración de \"Blockem\"";
$a->strings["Comma separated profile URLS to block"] = "Direcciones separadas por coma de los perfiles a bloquear";
$a->strings["Submit"] = "Envíar";
$a->strings["BLOCKEM Settings saved."] = "Configuracion Blockem guardada.";
$a->strings["Blocked %s - Click to open/close"] = "%s bloqueado. Pulsa aquí para mostrar/ocultar";
$a->strings["Unblock Author"] = "Desbloquear Autor";
$a->strings["Block Author"] = "Bloquear Autor";
$a->strings["blockem settings updated"] = "Configuración de Blockem actualizada";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "Réglages de Blockem";
$a->strings["Comma separated profile URLS to block"] = "Liste d'URLS de profils à bloquer, séparés par des virgules";
$a->strings["Submit"] = "Envoyer";
$a->strings["BLOCKEM Settings saved."] = "Réglages Blockem sauvés.";
$a->strings["Blocked %s - Click to open/close"] = "Bloqué %s - Cliquez pour ouvrir/fermer";
$a->strings["Unblock Author"] = "Débloquer l'auteur";
$a->strings["Block Author"] = "Bloquer l'auteur";
$a->strings["blockem settings updated"] = "Réglages blockem sauvés";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "\"Blockem\" stillingar";
$a->strings["Comma separated profile URLS to block"] = "Banna lista af forsíðum (komma á milli)";
$a->strings["Submit"] = "Senda inn";
$a->strings["BLOCKEM Settings saved."] = "BLOCKEM stillingar vistaðar.";
$a->strings["Blocked %s - Click to open/close"] = "%s sett í straff - Smella til að taka úr/setja á";
$a->strings["Unblock Author"] = "Leyfa notanda";
$a->strings["Block Author"] = "Banna notanda";
$a->strings["blockem settings updated"] = "";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "Impostazioni \"Blockem\"";
$a->strings["Comma separated profile URLS to block"] = "Lista, separata da virgola, di indirizzi da bloccare";
$a->strings["Submit"] = "Invia";
$a->strings["BLOCKEM Settings saved."] = "Impostazioni salvate.";
$a->strings["Blocked %s - Click to open/close"] = "%s bloccato - Clicca per aprire/chiudere";
$a->strings["Unblock Author"] = "Sblocca autore";
$a->strings["Block Author"] = "Blocca autore";
$a->strings["blockem settings updated"] = "Impostazioni 'blockem' aggiornate.";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "";
$a->strings["Comma separated profile URLS to block"] = "";
$a->strings["Submit"] = "Lagre";
$a->strings["BLOCKEM Settings saved."] = "";
$a->strings["Blocked %s - Click to open/close"] = "";
$a->strings["Unblock Author"] = "";
$a->strings["Block Author"] = "";
$a->strings["blockem settings updated"] = "";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "";
$a->strings["Comma separated profile URLS to block"] = "";
$a->strings["Submit"] = "Potwierdź";
$a->strings["BLOCKEM Settings saved."] = "";
$a->strings["Blocked %s - Click to open/close"] = "";
$a->strings["Unblock Author"] = "Odblokuj autora";
$a->strings["Block Author"] = "Zablokuj autora";
$a->strings["blockem settings updated"] = "";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "Configurações \"Blockem\"";
$a->strings["Comma separated profile URLS to block"] = "URLS de perfis separados por vírgulas a serem bloqueados";
$a->strings["Submit"] = "Enviar";
$a->strings["BLOCKEM Settings saved."] = "Configurações BLOCKEM armazenadas.";
$a->strings["Blocked %s - Click to open/close"] = "Bloqueado %s - Clique para abrir/fechar";
$a->strings["Unblock Author"] = "Desbloqueie Autor";
$a->strings["Block Author"] = "Bloqueie Autor";
$a->strings["blockem settings updated"] = "configurações blockem atualizadas";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "\"Blockem\" настройки";
$a->strings["Comma separated profile URLS to block"] = "URLS, которые заблокировать (список через запятую)";
$a->strings["Submit"] = "Подтвердить";
$a->strings["BLOCKEM Settings saved."] = "BLOCKEM-Настройки сохранены.";
$a->strings["Blocked %s - Click to open/close"] = "Заблокированные %s - Нажмите, чтобы открыть/закрыть";
$a->strings["Unblock Author"] = "";
$a->strings["Block Author"] = "Блокировать Автора";
$a->strings["blockem settings updated"] = "\"Blockem\" настройки обновлены";

View file

@ -0,0 +1,3 @@
<?php
$a->strings["Submit"] = "Spara";

View file

@ -0,0 +1,10 @@
<?php
$a->strings["\"Blockem\" Settings"] = "「Blockem」配置";
$a->strings["Comma separated profile URLS to block"] = "逗号分简介URL为栏";
$a->strings["Submit"] = "提交";
$a->strings["BLOCKEM Settings saved."] = "「Blockem」配置保存了。";
$a->strings["Blocked %s - Click to open/close"] = "%s拦了点击为开关";
$a->strings["Unblock Author"] = "不拦作家";
$a->strings["Block Author"] = "拦作家";
$a->strings["blockem settings updated"] = "blockem设置更新了";

18
superblock/superblock.css Executable file
View file

@ -0,0 +1,18 @@
#superblock-label {
float: left;
width: 300px;
margin-top: 10px;
}
#superblock-words {
float: left;
margin-top: 10px;
width: 400px;
height: 150px;
}
#superblock-submit {
margin-top: 15px;
}

165
superblock/superblock.php Executable file
View file

@ -0,0 +1,165 @@
<?php
/**
* Name: superblock
* Description: block people
* Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*
*/
function superblock_install() {
register_hook('plugin_settings', 'addon/superblock/superblock.php', 'superblock_addon_settings');
register_hook('plugin_settings_post', 'addon/superblock/superblock.php', 'superblock_addon_settings_post');
register_hook('conversation_start', 'addon/superblock/superblock.php', 'superblock_conversation_start');
register_hook('item_photo_menu', 'addon/superblock/superblock.php', 'superblock_item_photo_menu');
register_hook('enotify_store', 'addon/superblock/superblock.php', 'superblock_enotify_store');
}
function superblock_uninstall() {
unregister_hook('plugin_settings', 'addon/superblock/superblock.php', 'superblock_addon_settings');
unregister_hook('plugin_settings_post', 'addon/superblock/superblock.php', 'superblock_addon_settings_post');
unregister_hook('conversation_start', 'addon/superblock/superblock.php', 'superblock_conversation_start');
unregister_hook('item_photo_menu', 'addon/superblock/superblock.php', 'superblock_item_photo_menu');
unregister_hook('enotify_store', 'addon/superblock/superblock.php', 'superblock_enotify_store');
}
function superblock_addon_settings(&$a,&$s) {
if(! local_user())
return;
/* Add our stylesheet to the page so we can make our settings look nice */
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/superblock/superblock.css' . '" media="all" />' . "\r\n";
$words = get_pconfig(local_user(),'system','blocked');
if(! $words)
$words = '';
$s .= '<div class="settings-block">';
$s .= '<h3>' . t('"Superblock" Settings') . '</h3>';
$s .= '<div id="superblock-wrapper">';
$s .= '<label id="superblock-label" for="superblock-words">' . t('Comma separated profile URLS to block') . ' </label>';
$s .= '<textarea id="superblock-words" type="text" name="superblock-words" >' . htmlspecialchars($words) . '</textarea>';
$s .= '</div><div class="clear"></div>';
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="superblock-submit" name="superblock-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
return;
}
function superblock_addon_settings_post(&$a,&$b) {
if(! local_user())
return;
if($_POST['superblock-submit']) {
set_pconfig(local_user(),'system','blocked',trim($_POST['superblock-words']));
info( t('SUPERBLOCK Settings saved.') . EOL);
}
}
function superblock_enotify_store(&$a,&$b) {
$words = get_pconfig($b['uid'],'system','blocked');
if($words) {
$arr = explode(',',$words);
}
else {
return;
}
$found = false;
if(count($arr)) {
foreach($arr as $word) {
if(! strlen(trim($word))) {
continue;
}
if(link_compare($b['url'],$word)) {
$found = true;
break;
}
}
}
if($found) {
$b['abort'] = true;
}
}
function superblock_conversation_start(&$a,&$b) {
if(! local_user())
return;
$words = get_pconfig(local_user(),'system','blocked');
if($words) {
$a->data['superblock'] = explode(',',$words);
}
$a->page['htmlhead'] .= <<< EOT
<script>
function superblockBlock(author) {
$.get('superblock?block=' +author, function(data) {
location.reload(true);
});
}
</script>
EOT;
}
function superblock_item_photo_menu(&$a,&$b) {
if((! local_user()) || ($b['item']['self']))
return;
$blocked = false;
$author = $b['item']['author-link'];
if(is_array($a->data['superblock'])) {
foreach($a->data['superblock'] as $bloke) {
if(link_compare($bloke,$author)) {
$blocked = true;
break;
}
}
}
$b['menu'][ t('Block Completely')] = 'javascript:superblockBlock(\'' . $author . '\'); return false;';
}
function superblock_module() {}
function superblock_init(&$a) {
if(! local_user())
return;
$words = get_pconfig(local_user(),'system','blocked');
if(array_key_exists('block',$_GET) && $_GET['block']) {
if(strlen($words))
$words .= ',';
$words .= trim($_GET['block']);
}
set_pconfig(local_user(),'system','blocked',$words);
info( t('superblock settings updated') . EOL );
killme();
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -4,6 +4,7 @@
* Description: Relay public postings to a connected Twitter account
* Version: 1.0.4
* Author: Tobias Diekershoff <http://diekershoff.homeunix.net/friendika/profile/tobias>
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
@ -285,7 +286,7 @@ function twitter_shortenmsg($b) {
require_once("include/bbcode.php");
require_once("include/html2plain.php");
$max_char = 140;
$max_char = 130;
// Looking for the first image
$image = '';
@ -511,7 +512,7 @@ function twitter_post_hook(&$a,&$b) {
// ok, all the links we want to send out are save, now strip
// away the remaining bbcode
//$msg = strip_tags(bbcode($tmp, false, false));
$msg = bbcode($tmp, false, false);
$msg = bbcode($tmp, false, false, true);
$msg = str_replace(array('<br>','<br />'),"\n",$msg);
$msg = strip_tags($msg);

View file

@ -1,4 +0,0 @@
{{ inc field_input.tpl with $field=$consumerkey }}{{ endinc }}
{{ inc field_input.tpl with $field=$consumersecret }}{{ endinc }}
{{ inc field_input.tpl with $field=$applicationname }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>

Binary file not shown.

View file

@ -1,9 +0,0 @@
<div class="settings-block">
<h3>$title</h3>
<p>$desc</p>
{{ inc field_input.tpl with $field=$url }}{{ endinc }}
{{ inc field_input.tpl with $field=$auth }}{{ endinc }}
{{ inc field_select.tpl with $field=$api }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>
</div>

Binary file not shown.

BIN
webrtc.tgz Normal file

Binary file not shown.

22
webrtc/README Normal file
View file

@ -0,0 +1,22 @@
Webrtc Plugin
====================
This is a quick and dirty addon to add a webrtc website as an app. As webrtc
advances so rapidly there is s a chance this plugin will be obsolete. Webrtc is
a new video and audio conferencing tool that is browser to browser
communication, no need to download specific software for just conferencing.
There are many different webrtc instances and because of the technology it is
really a person 2 person communication, using the server to only signal who
wants to talk to who, the actual transfer of the audio and video is directly
between the participants.
If you would like to try this plugin please download one of the following
either Chrome/Chromium 25 or higher or Firefox 21 or higher. Then test it by
visiting a known webrtc instance (i.e. https://live.mayfirst.org) create a
room, you should be asked to share your camera and microphone (firefox will let
you choose one or the other, whereas chrome/chromium asks for both in one
question).
If the test is successful then proceed with copying the webrtc instance you
would like to use and place it in the config window and save. Now when you
opent he app it will load the webrtc instance for you to use.

View file

@ -0,0 +1,2 @@
{{include file="field_input.tpl" field=$webrtcurl}}
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>

58
webrtc/webrtc.php Normal file
View file

@ -0,0 +1,58 @@
<?php
/*
* Name: WebRTC Application
* Description: add a webrtc instance for video/audio
* Version: 1.0
* Author: stephen mahood <https://friends.mayfirst.org/profile/marxistvegan>
* Author: Tobias Diekershoff <http://diekershoff.homeunix.net/friendica/profile/tobias>
*/
function webrtc_install() {
register_hook('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
}
function webrtc_uninstall() {
unregister_hook('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
}
function webrtc_app_menu($a,&$b) {
$b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . t('WebRTC Videochat') . '</a></div>';
}
function webrtc_plugin_admin (&$a, &$o) {
$t = get_markup_template( "admin.tpl", "addon/webrtc/" );
$o = replace_macros( $t, array(
'$submit' => t('Submit'),
'$webrtcurl' => array('webrtcurl', t('WebRTC Base URL'), get_config('webrtc','webrtcurl' ), t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')),
));
}
function webrtc_plugin_admin_post (&$a) {
$url = ((x($_POST, 'webrtcurl')) ? notags(trim($_POST['webrtcurl'])) : '');
set_config('webrtc', 'webrtcurl', $url);
info( t('Settings updated.'). EOL);
}
function webrtc_module() {
return;
}
function webrtc_content(&$a) {
$o = '';
/* landingpage to create chatrooms */
$webrtcurl = get_config('webrtc','webrtcurl');
/* embedd the landing page in an iframe */
$o .= '<h2>'.t('Video Chat').'</h2>';
$o .= '<p>'.t('WebRTC is a video and audio conferencing tool that works with Firefox (version 21 and above) and Chrome/Chromium (version 25 and above). Just create a new chat room and send the link to someone you want to chat with.').'</p>';
if ($webrtcurl == '') {
$o .= '<p>'.t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
} else {
$o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';
}
return $o;
}
?>

Binary file not shown.

View file

@ -1,19 +0,0 @@
<div class="settings-block">
<h3 class="settings-heading">$title</h3>
<div class='field noedit'>
<label>$label</label>
<tt>$key</tt>
</div>
<div class="settings-submit-wrapper">
<input type="submit" value="$submit" class="settings-submit" name="widgets-submit" />
</div>
<h4>$widgets_h</h4>
<ul>
{{ for $widgets as $w }}
<li><a href="$baseurl/widgets/$w.0/?k=$key&p=1">$w.1</a></li>
{{ endfor }}
</ul>
</div>

View file

@ -1,3 +0,0 @@
<style>body {font-size: 0.8em; margin: 0px; padding: 0px;}</style>
<span class='f9k_like' title="$strlike">$like <img src="$baseurl/images/like.gif" alt="like"/></span>
<span class='f9k_dislike' title="$strdislike">$dislike <img src="$baseurl/images/dislike.gif" alt="dislike"/></span>

Binary file not shown.

Binary file not shown.