diff --git a/blockem/blockem.php b/blockem/blockem.php index 3de7be40..412e53e5 100644 --- a/blockem/blockem.php +++ b/blockem/blockem.php @@ -6,6 +6,8 @@ * Author: Mike Macgirvin * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; @@ -68,7 +70,7 @@ function blockem_addon_settings(&$a, &$s) } -function blockem_addon_settings_post(&$a,&$b) { +function blockem_addon_settings_post(App $a, array &$b) { if(! local_user()) return; @@ -79,7 +81,7 @@ function blockem_addon_settings_post(&$a,&$b) { } } -function blockem_enotify_store(&$a,&$b) { +function blockem_enotify_store(App $a, array &$b) { $words = PConfig::get($b['uid'],'blockem','words'); if($words) { @@ -107,7 +109,7 @@ function blockem_enotify_store(&$a,&$b) { } } -function blockem_prepare_body_content_filter(\Friendica\App $a, &$hook_data) +function blockem_prepare_body_content_filter(App $a, array &$hook_data) { if (!local_user()) { return; @@ -137,24 +139,25 @@ function blockem_prepare_body_content_filter(\Friendica\App $a, &$hook_data) } } -function blockem_display_item(&$a,&$b) { - if (empty($b['output']['body'])) { - return; - } - - if(strstr($b['output']['body'],'id="blockem-wrap-')) +function blockem_display_item(App $a, array &$b) +{ + if (isset($b['output']) && strstr($b['output']['body'], 'id="blockem-wrap-')) { $b['output']['thumb'] = $a->get_baseurl() . "/images/person-80.jpg"; + } } -function blockem_conversation_start(&$a,&$b) { +function blockem_conversation_start(App $a, array &$b) { - if(! local_user()) + if (! local_user()) { return; - - $words = PConfig::get(local_user(),'blockem','words'); - if($words) { - $a->data['blockem'] = explode(',',$words); } + + $words = PConfig::get(local_user(), 'blockem', 'words'); + + if ($words) { + $a->data['blockem'] = explode(',', $words); + } + $a->page['htmlhead'] .= <<< EOT "; } -function jappixmini_settings_post(App $a, &$b) +function jappixmini_settings_post(App $a, array &$b) { // save addon settings for a user if (!local_user()) { diff --git a/js_upload/js_upload.php b/js_upload/js_upload.php index b1373ffc..cb46c191 100644 --- a/js_upload/js_upload.php +++ b/js_upload/js_upload.php @@ -14,6 +14,8 @@ * Module Author: Chris Case * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -34,7 +36,7 @@ function js_upload_uninstall() { } -function js_upload_form(&$a,&$b) { +function js_upload_form(App $a, array &$b) { $b['default_upload'] = false; @@ -134,7 +136,7 @@ EOT; } -function js_upload_post_init(&$a,&$b) { +function js_upload_post_init(App $a, array &$b) { // list of valid extensions, ex. array("jpeg", "xml", "bmp") @@ -162,7 +164,7 @@ function js_upload_post_init(&$a,&$b) { } -function js_upload_post_file(&$a,&$b) { +function js_upload_post_file(App $a, array &$b) { $result = $a->data['upload_result']; @@ -173,7 +175,7 @@ function js_upload_post_file(&$a,&$b) { } -function js_upload_post_end(&$a,&$b) { +function js_upload_post_end(App $a, array &$b) { logger('upload_post_end'); if(x($a->data,'upload_jsonresponse')) { diff --git a/krynn/krynn.php b/krynn/krynn.php index 47372926..87c406d4 100644 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -9,6 +9,8 @@ * *"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin Majere */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; @@ -134,7 +136,7 @@ function krynn_settings_post($a,$post) { -function krynn_settings(&$a,&$s) { +function krynn_settings(App $a, &$s) { if(! local_user()) return; diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php index f22034e2..cb8ccfe7 100644 --- a/langfilter/langfilter.php +++ b/langfilter/langfilter.php @@ -70,7 +70,7 @@ function langfilter_addon_settings(App $a, &$s) * 3rd save the settings to the DB for later usage */ -function langfilter_addon_settings_post(App $a, &$b) +function langfilter_addon_settings_post(App $a, array &$b) { if (!local_user()) { return; diff --git a/ldapauth/ldapauth.php b/ldapauth/ldapauth.php index 514fb1d1..c92995c7 100644 --- a/ldapauth/ldapauth.php +++ b/ldapauth/ldapauth.php @@ -53,6 +53,8 @@ * * ...etc. */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Model\User; @@ -69,12 +71,12 @@ function ldapauth_uninstall() Addon::unregisterHook('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate'); } -function ldapauth_load_config(\Friendica\App $a) +function ldapauth_load_config(App $a) { $a->loadConfigFile(__DIR__. '/config/ldapauth.ini.php'); } -function ldapauth_hook_authenticate($a, &$b) +function ldapauth_hook_authenticate(App $a, array &$b) { if (ldapauth_authenticate($b['username'], $b['password'])) { $results = get_existing_account($b['username']); diff --git a/libertree/libertree.php b/libertree/libertree.php index 7fce4b4e..f143c78a 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -6,6 +6,7 @@ * Author: Tony Baldwin */ +use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; @@ -30,7 +31,7 @@ function libertree_uninstall() { } -function libertree_jot_nets(&$a,&$b) { +function libertree_jot_nets(App $a, &$b) { if(! local_user()) return; @@ -44,7 +45,7 @@ function libertree_jot_nets(&$a,&$b) { } -function libertree_settings(&$a,&$s) { +function libertree_settings(App $a, &$s) { if(! local_user()) return; @@ -104,7 +105,7 @@ function libertree_settings(&$a,&$s) { } -function libertree_settings_post(&$a,&$b) { +function libertree_settings_post(App $a, array &$b) { if(x($_POST,'libertree-submit')) { @@ -117,7 +118,7 @@ function libertree_settings_post(&$a,&$b) { } -function libertree_post_local(&$a,&$b) { +function libertree_post_local(App $a, array &$b) { // This can probably be changed to allow editing by pointing to a different API endpoint @@ -155,7 +156,7 @@ function libertree_post_local(&$a,&$b) { -function libertree_send(&$a,&$b) { +function libertree_send(App $a, array &$b) { logger('libertree_send: invoked'); diff --git a/libravatar/libravatar.php b/libravatar/libravatar.php index 14bc0358..2fe26119 100644 --- a/libravatar/libravatar.php +++ b/libravatar/libravatar.php @@ -5,6 +5,8 @@ * Version: 1.1 * Author: Klaus Weidenbach */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -40,7 +42,7 @@ function libravatar_load_config(\Friendica\App $a) * @param $a array * @param &$b array */ -function libravatar_lookup($a, &$b) +function libravatar_lookup(App $a, array &$b) { $default_avatar = Config::get('libravatar', 'default_avatar'); diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index ec99f9ba..998ec592 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -8,10 +8,12 @@ * Author: Cat Gray */ +use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; +use Friendica\Database\DBM; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; @@ -33,7 +35,7 @@ function ljpost_uninstall() { } -function ljpost_jot_nets(&$a,&$b) { +function ljpost_jot_nets(App $a, &$b) { if(! local_user()) return; @@ -101,7 +103,7 @@ function ljpost_settings(&$a,&$s) { } -function ljpost_settings_post(&$a,&$b) { +function ljpost_settings_post(App $a, array &$b) { if(x($_POST,'ljpost-submit')) { @@ -114,7 +116,7 @@ function ljpost_settings_post(&$a,&$b) { } -function ljpost_post_local(&$a,&$b) { +function ljpost_post_local(App $a, array &$b) { // This can probably be changed to allow editing by pointing to a different API endpoint @@ -145,7 +147,7 @@ function ljpost_post_local(&$a,&$b) { -function ljpost_send(&$a,&$b) { +function ljpost_send(App $a, array &$b) { if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) return; @@ -162,11 +164,13 @@ function ljpost_send(&$a,&$b) { $tz = 'UTC'; - $x = q("select timezone from user where uid = %d limit 1", + $x = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($b['uid']) ); - if($x && strlen($x[0]['timezone'])) + + if (!empty($x[0]['timezone'])) { $tz = $x[0]['timezone']; + } $lj_username = xmlify(PConfig::get($b['uid'],'ljpost','lj_username')); $lj_password = xmlify(PConfig::get($b['uid'],'ljpost','lj_password')); @@ -175,10 +179,11 @@ function ljpost_send(&$a,&$b) { // $lj_journal = $lj_username; $lj_blog = xmlify(PConfig::get($b['uid'],'ljpost','lj_blog')); - if(! strlen($lj_blog)) + if (! strlen($lj_blog)) { $lj_blog = xmlify('http://www.livejournal.com/interface/xmlrpc'); + } - if($lj_username && $lj_password && $lj_blog) { + if ($lj_username && $lj_password && $lj_blog) { $title = xmlify($b['title']); $post = BBCode::convert($b['body']); $post = xmlify($post); diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 66b43303..d6ccdc1c 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -6,6 +6,7 @@ * Author: Matthew Exon */ +use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; @@ -71,7 +72,7 @@ function mailstream_uninstall() { function mailstream_module() {} -function mailstream_addon_admin(&$a,&$o) { +function mailstream_addon_admin(App $a, &$o) { $frommail = Config::get('mailstream', 'frommail'); $template = get_markup_template('admin.tpl', 'addon/mailstream/'); $config = ['frommail', @@ -83,13 +84,13 @@ function mailstream_addon_admin(&$a,&$o) { '$submit' => L10n::t('Save Settings')]); } -function mailstream_addon_admin_post ($a) { +function mailstream_addon_admin_post (App $a) { if (x($_POST, 'frommail')) { Config::set('mailstream', 'frommail', $_POST['frommail']); } } -function mailstream_generate_id($a, $uri) { +function mailstream_generate_id(App $a, $uri) { // http://www.jwz.org/doc/mid.html $host = $a->get_hostname(); $resource = hash('md5', $uri); @@ -98,56 +99,58 @@ function mailstream_generate_id($a, $uri) { return $message_id; } -function mailstream_post_hook(&$a, &$item) { +function mailstream_post_hook(App $a, array &$item) { if (!PConfig::get($item['uid'], 'mailstream', 'enabled')) { return; } - if (!$item['uid']) { + + if (!isset($item['uid']) || !isset($item['contact-id']) || !isset($item['uri'])) { return; } - if (!$item['contact-id']) { + + if (PConfig::get($item['uid'], 'mailstream', 'nolikes') && $item['verb'] == ACTIVITY_LIKE) { return; } - if (!$item['uri']) { - return; - } - if (PConfig::get($item['uid'], 'mailstream', 'nolikes')) { - if ($item['verb'] == ACTIVITY_LIKE) { - return; - } - } $message_id = mailstream_generate_id($a, $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($message_id)); $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) { + + if (!DBM::is_result($r)) { 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['message-id'], $item, $user); } function mailstream_get_user($uid) { $r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($uid)); - if (count($r) != 1) { + + if (!DBM::is_result($r)) { logger('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_NORMAL); return; } + return $r[0]; } -function mailstream_do_images($a, &$item, &$attachments) { +function mailstream_do_images(App $a, array &$item, &$attachments) { if (!PConfig::get($item['uid'], 'mailstream', 'attachimg')) { return; } @@ -162,7 +165,9 @@ function mailstream_do_images($a, &$item, &$attachments) { 'data' => Network::fetchUrl($url, true, $redirects, 0, null, $cookiejar), 'guid' => hash("crc32", $url), 'filename' => basename($url), - 'type' => $a->get_curl_content_type()]; + 'type' => $a->get_curl_content_type() + ]; + if (strlen($attachments[$url]['data'])) { $item['body'] = str_replace($url, 'cid:' . $attachments[$url]['guid'], $item['body']); continue; @@ -171,105 +176,141 @@ function mailstream_do_images($a, &$item, &$attachments) { return $attachments; } -function mailstream_sender($item) { +function mailstream_sender(array $item) { $r = q('SELECT * FROM `contact` WHERE `id` = %d', $item['contact-id']); + if (DBM::is_result($r)) { - $contact = $r[0]; - if ($contact['name'] != $item['author-name']) { - return $contact['name'] . ' - ' . $item['author-name']; + if ($r[0]['name'] != $item['author-name']) { + return $r[0]['name'] . ' - ' . $item['author-name']; } } + return $item['author-name']; } function mailstream_decode_subject($subject) { $html = BBCode::convert($subject); + if (!$html) { return $subject; } + $notags = strip_tags($html); + if (!$notags) { return $subject; } + $noentity = html_entity_decode($notags); + if (!$noentity) { return $notags; } + $nocodes = preg_replace_callback("/(&#[0-9]+;)/", function($m) { return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $noentity); + if (!$nocodes) { return $noentity; } + $trimmed = trim($nocodes); + if (!$trimmed) { return $nocodes; } + return $trimmed; } -function mailstream_subject($item) { - if ($item['title']) { +function mailstream_subject(array $item) { + if (!empty($item['title'])) { return mailstream_decode_subject($item['title']); } + $parent = $item['thr-parent']; // Don't look more than 100 levels deep for a subject, in case of loops for ($i = 0; ($i < 100) && $parent; $i++) { $parent_item = Item::selectFirst(['thr-parent', 'title'], ['uri' => $parent]); + if (!DBM::is_result($parent_item)) { break; } + if ($parent_item['thr-parent'] === $parent) { break; } + if ($parent_item['title']) { return L10n::t('Re:') . ' ' . mailstream_decode_subject($parent_item['title']); } + $parent = $parent_item['thr-parent']; } + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d", intval($item['contact-id']), intval($item['uid'])); + + /// @TODO If above statement fails, this will cause E_NOTICE-s + /// @TODO Also maybe directly use $r[0] instead of variable copy? $contact = $r[0]; + if ($contact['network'] === 'dfrn') { return L10n::t("Friendica post"); } + if ($contact['network'] === 'dspr') { return L10n::t("Diaspora post"); } + if ($contact['network'] === 'face') { $text = mailstream_decode_subject($item['body']); + // For some reason these do show up in Facebook $text = preg_replace('/\xA0$/', '', $text); $subject = (strlen($text) > 150) ? (substr($text, 0, 140) . '...') : $text; + return preg_replace('/\\s+/', ' ', $subject); } + if ($contact['network'] === 'feed') { return L10n::t("Feed item"); } + if ($contact['network'] === 'mail') { return L10n::t("Email"); } + return L10n::t("Friendica Item"); } -function mailstream_send($a, $message_id, $item, $user) { - if (!$item['visible']) { +function mailstream_send(App $a, $message_id, array $item, $user) { + if (empty($item['visible'])) { return; } + if (!$message_id) { return; } - require_once(dirname(__file__).'/phpmailer/class.phpmailer.php'); + + /// @TODO Maybe properly use Composer + require_once dirname(__FILE__) . '/phpmailer/class.phpmailer.php'; $attachments = []; mailstream_do_images($a, $item, $attachments); $frommail = Config::get('mailstream', 'frommail'); + if ($frommail == "") { $frommail = 'friendica@localhost.local'; } + $address = PConfig::get($item['uid'], 'mailstream', 'address'); + if (!$address) { $address = $user['email']; } + $mail = new PHPmailer; + try { $mail->XMailer = 'Friendica Mailstream Addon'; $mail->SetFrom($frommail, mailstream_sender($item)); @@ -350,7 +391,7 @@ function mailstream_cron($a, $b) { mailstream_tidy(); } -function mailstream_addon_settings(&$a,&$s) { +function mailstream_addon_settings(App $a, &$s) { $enabled = PConfig::get(local_user(), 'mailstream', 'enabled'); $address = PConfig::get(local_user(), 'mailstream', 'address'); $nolikes = PConfig::get(local_user(), 'mailstream', 'nolikes'); @@ -380,37 +421,43 @@ function mailstream_addon_settings(&$a,&$s) { '$submit' => L10n::t('Save Settings')]); } -function mailstream_addon_settings_post($a,$post) { +function mailstream_addon_settings_post(App $a, $post) { if ($_POST['mailstream_address'] != "") { PConfig::set(local_user(), 'mailstream', 'address', $_POST['mailstream_address']); - } - else { + } else { PConfig::delete(local_user(), 'mailstream', 'address'); } + if ($_POST['mailstream_nolikes']) { PConfig::set(local_user(), 'mailstream', 'nolikes', $_POST['mailstream_enabled']); - } - else { + } else { PConfig::delete(local_user(), 'mailstream', 'nolikes'); } + if ($_POST['mailstream_enabled']) { PConfig::set(local_user(), 'mailstream', 'enabled', $_POST['mailstream_enabled']); - } - else { + } else { PConfig::delete(local_user(), 'mailstream', 'enabled'); } + if ($_POST['mailstream_attachimg']) { PConfig::set(local_user(), 'mailstream', 'attachimg', $_POST['mailstream_attachimg']); - } - else { + } else { PConfig::delete(local_user(), 'mailstream', 'attachimg'); } } function mailstream_tidy() { $r = q("SELECT id FROM mailstream_item WHERE completed IS NOT NULL AND completed < DATE_SUB(NOW(), INTERVAL 1 YEAR)"); + + if (!DBM::is_result($r)) { + logger('Cannot load records from mailstream_item or none are returned.', LOGGER_DEBUG); + return; + } + foreach ($r as $rr) { q('DELETE FROM mailstream_item WHERE id = %d', intval($rr['id'])); } + logger('mailstream_tidy: deleted ' . count($r) . ' old items', LOGGER_DEBUG); } diff --git a/mathjax/mathjax.php b/mathjax/mathjax.php index c85068ea..3250f24c 100644 --- a/mathjax/mathjax.php +++ b/mathjax/mathjax.php @@ -6,6 +6,7 @@ * Author: Tobias Diekershoff * License: 3-clause BSD license */ + use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; @@ -73,7 +74,7 @@ function mathjax_settings (&$a, &$s) { /* we need to add one JavaScript include command to the html output * note that you have to check the jsmath/easy/load.js too. */ -function mathjax_page_header($a, &$b) { +function mathjax_page_header(App $a, &$b) { // if the visitor of the page is not a local_user, use MathJax // otherwise check the users settings. $url = Config::get ('mathjax','baseurl'); diff --git a/membersince/membersince.php b/membersince/membersince.php index c11f9b53..543bb231 100644 --- a/membersince/membersince.php +++ b/membersince/membersince.php @@ -7,6 +7,7 @@ * Status: Unsupported */ +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Util\DateTimeFormat; @@ -21,7 +22,7 @@ function membersince_uninstall() Addon::unregisterHook('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display'); } -function membersince_display(Friendica\App $a, &$b) +function membersince_display(App $a, array &$b) { if ($a->getCurrentTheme() == 'frio') { // Works in Frio. diff --git a/morepokes/morepokes.php b/morepokes/morepokes.php index e0caaa52..da14025e 100644 --- a/morepokes/morepokes.php +++ b/morepokes/morepokes.php @@ -6,6 +6,8 @@ * Author: Thomas Willingham * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; @@ -19,7 +21,7 @@ function morepokes_uninstall() Addon::unregisterHook('poke_verbs', 'addon/morepokes/morepokes.php', 'morepokes_poke_verbs'); } -function morepokes_poke_verbs($a, &$b) +function morepokes_poke_verbs(App $a, array &$b) { $b['bitchslap'] = ['bitchslapped', L10n::t('bitchslap'), L10n::t('bitchslapped')]; $b['shag'] = ['shag', L10n::t('shag'), L10n::t('shagged')]; diff --git a/nsfw/nsfw.php b/nsfw/nsfw.php index 2ea20b4a..1bda9065 100644 --- a/nsfw/nsfw.php +++ b/nsfw/nsfw.php @@ -7,6 +7,8 @@ * Author: Mike Macgirvin * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; @@ -95,7 +97,7 @@ function nsfw_addon_settings(&$a, &$s) return; } -function nsfw_addon_settings_post(&$a, &$b) +function nsfw_addon_settings_post(App $a, array &$b) { if (!local_user()) { return; @@ -110,9 +112,10 @@ function nsfw_addon_settings_post(&$a, &$b) } } -function nsfw_prepare_body_content_filter(\Friendica\App $a, &$hook_data) +function nsfw_prepare_body_content_filter(App $a, &$hook_data) { $words = null; + if (PConfig::get(local_user(), 'nsfw', 'disable')) { return; } @@ -128,16 +131,19 @@ function nsfw_prepare_body_content_filter(\Friendica\App $a, &$hook_data) } $found = false; + if (count($word_list)) { $body = $hook_data['item']['title'] . "\n" . nsfw_extract_photos($hook_data['item']['body']); foreach ($word_list as $word) { $word = trim($word); + if (!strlen($word)) { continue; } $tag_search = false; + switch ($word[0]) { case '/'; // Regular expression $found = preg_match($word, $body); diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index 26d51e1a..b97543f5 100644 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -8,6 +8,8 @@ * Author: Klaus Weidenbach * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\Config; @@ -88,15 +90,18 @@ function openstreetmap_location($a, &$item) $nomserver = OSM_NOM; } - if ($item['coord'] != "") { + if (!empty($item['coord'])) { $coords = explode(' ', $item['coord']); + if (count($coords) > 1) { $lat = urlencode(round($coords[0], 5)); $lon = urlencode(round($coords[1], 5)); $target = $tmsserver; + if ($marker > 0) { $target .= '?mlat=' . $lat . '&mlon=' . $lon; } + $target .= '#map='.intval($zoom).'/'.$lat.'/'.$lon; } } @@ -105,7 +110,7 @@ function openstreetmap_location($a, &$item) $target = $nomserver.'?q='.urlencode($item['location']); } - if ($item['location'] != "") { + if (!empty($item['location'])) { $title = $item['location']; } else { $title = $item['coord']; @@ -114,7 +119,7 @@ function openstreetmap_location($a, &$item) $item['html'] = ''.$title.''; } -function openstreetmap_get_coordinates($a, &$b) +function openstreetmap_get_coordinates(App $a, array &$b) { $nomserver = Config::get('openstreetmap', 'nomserver', OSM_NOM); @@ -142,7 +147,7 @@ function openstreetmap_get_coordinates($a, &$b) } } -function openstreetmap_generate_named_map(&$a, &$b) +function openstreetmap_generate_named_map(App $a, array &$b) { openstreetmap_get_coordinates($a, $b); @@ -151,7 +156,7 @@ function openstreetmap_generate_named_map(&$a, &$b) } } -function openstreetmap_generate_map(&$a, &$b) +function openstreetmap_generate_map(App $a, array &$b) { $tmsserver = Config::get('openstreetmap', 'tmsserver', OSM_TMS); diff --git a/pageheader/pageheader.php b/pageheader/pageheader.php index eb121fb5..19bd7b32 100644 --- a/pageheader/pageheader.php +++ b/pageheader/pageheader.php @@ -7,6 +7,8 @@ * Hauke Altmann * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -33,7 +35,7 @@ function pageheader_uninstall() { -function pageheader_addon_settings(&$a,&$s) { +function pageheader_addon_settings(App $a, &$s) { if(! is_site_admin()) @@ -59,7 +61,7 @@ function pageheader_addon_settings(&$a,&$s) { } -function pageheader_addon_settings_post(&$a,&$b) { +function pageheader_addon_settings_post(App $a, array &$b) { if(! is_site_admin()) return; @@ -70,7 +72,7 @@ function pageheader_addon_settings_post(&$a,&$b) { } } -function pageheader_fetch($a,&$b) { +function pageheader_fetch(App $a, &$b) { if(file_exists('pageheader.html')){ $s = file_get_contents('pageheader.html'); diff --git a/piwik/piwik.php b/piwik/piwik.php index 5e34e098..1a35300d 100644 --- a/piwik/piwik.php +++ b/piwik/piwik.php @@ -30,6 +30,8 @@ * about http/https but beware to put the trailing / at the end of your * setting. */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -48,12 +50,12 @@ function piwik_uninstall() { logger("uninstalled piwik addon"); } -function piwik_load_config(\Friendica\App $a) +function piwik_load_config(App $a) { $a->loadConfigFile(__DIR__. '/config/piwik.ini.php'); } -function piwik_analytics($a,&$b) { +function piwik_analytics(App $a, &$b) { /* * styling of every HTML block added by this addon is done in the diff --git a/pledgie/pledgie.php b/pledgie/pledgie.php index 8b736d8b..81c86c2d 100644 --- a/pledgie/pledgie.php +++ b/pledgie/pledgie.php @@ -5,25 +5,29 @@ * Version: 1.1 * Author: tony baldwin * Hauke Altmann - * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; -function pledgie_install() { +function pledgie_install() +{ Addon::registerHook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active'); Addon::registerHook('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings'); Addon::registerHook('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post'); } -function pledgie_uninstall() { +function pledgie_uninstall() +{ Addon::unregisterHook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active'); Addon::unregisterHook('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings'); Addon::unregisterHook('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post'); } -function pledgie_addon_settings(&$a,&$s) { +function pledgie_addon_settings(App $a, &$s) +{ if(! is_site_admin()) return; @@ -58,8 +62,8 @@ function pledgie_addon_settings(&$a,&$s) { return; } -function pledgie_addon_settings_post(&$a,&$b) { - +function pledgie_addon_settings_post(App $a, array &$b) +{ if(! is_site_admin()) return; @@ -70,9 +74,11 @@ function pledgie_addon_settings_post(&$a,&$b) { } } -function pledgie_active(&$a,&$b) { +function pledgie_active(App $a, &$b) +{ $campaign = Config::get('pledgie-campaign','text'); $describe = Config::get('pledgie-describe','text'); + $b .= ''; } -function pumpio_settings_post(&$a, &$b) -{ - if (x($_POST, 'pumpio-submit')) { - if (x($_POST, 'pumpio_delete')) { +function pumpio_settings_post(App $a, array &$b) { + + if (x($_POST,'pumpio-submit')) { + if (x($_POST,'pumpio_delete')) { PConfig::set(local_user(), 'pumpio', 'consumer_key', ''); PConfig::set(local_user(), 'pumpio', 'consumer_secret', ''); PConfig::set(local_user(), 'pumpio', 'oauth_token', ''); @@ -375,12 +376,11 @@ function pumpio_settings_post(&$a, &$b) } } -function pumpio_load_config(\Friendica\App $a) { $a->loadConfigFile(__DIR__. '/config/pumpio.ini.php'); } -function pumpio_post_local(&$a, &$b) +function pumpio_post_local(App $a, array &$b) { if (!local_user() || (local_user() != $b['uid'])) { return; @@ -405,7 +405,7 @@ function pumpio_post_local(&$a, &$b) $b['postopts'] .= 'pumpio'; } -function pumpio_send(&$a, &$b) +function pumpio_send(App $a, array &$b) { if (!PConfig::get($b["uid"], 'pumpio', 'import')) { if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { @@ -1398,11 +1398,12 @@ function pumpio_getallusers(&$a, $uid) } } -function pumpio_queue_hook(&$a, &$b) +function pumpio_queue_hook(App $a, array &$b) { $qi = q("SELECT * FROM `queue` WHERE `network` = '%s'", dbesc(NETWORK_PUMPIO) ); + if (!DBM::is_result($qi)) { return; } diff --git a/qcomment/qcomment.php b/qcomment/qcomment.php index c499fb86..9053f3f7 100644 --- a/qcomment/qcomment.php +++ b/qcomment/qcomment.php @@ -15,8 +15,9 @@ * you wish to use them. On some themes they may be visible. * Wave the mouse around near the comment input box and the qcomments will show up. Click on any of * them to open the comment window fully and insert the qcomment. Then "Submit" will submit it. - * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; @@ -59,7 +60,7 @@ function qcomment_addon_settings(&$a, &$s) return; } -function qcomment_addon_settings_post(&$a,&$b) { +function qcomment_addon_settings_post(App $a, array &$b) { if(! local_user()) return; diff --git a/securemail/securemail.php b/securemail/securemail.php index 87941e79..d8f4a9a9 100644 --- a/securemail/securemail.php +++ b/securemail/securemail.php @@ -25,7 +25,8 @@ require_once 'openpgp.php'; require_once 'openpgp_crypt_symmetric.php'; -function securemail_install() { +function securemail_install() +{ Addon::registerHook('addon_settings', 'addon/securemail/securemail.php', 'securemail_settings'); Addon::registerHook('addon_settings_post', 'addon/securemail/securemail.php', 'securemail_settings_post'); @@ -53,7 +54,8 @@ function securemail_uninstall() { * * @see App */ -function securemail_settings(App &$a, &$s){ +function securemail_settings(App $a, &$s) +{ if (!local_user()) { return; } @@ -82,8 +84,8 @@ function securemail_settings(App &$a, &$s){ * * @see App */ -function securemail_settings_post(App &$a, array &$b){ - +function securemail_settings_post(App $a, array &$b) +{ if (!local_user()) { return; } @@ -146,8 +148,10 @@ function securemail_settings_post(App &$a, array &$b){ * @param array $b hook data * * @see App + * @todo x() is deprecated, next PR */ -function securemail_emailer_send_prepare(App &$a, array &$b) { +function securemail_emailer_send_prepare(App $a, array &$b) +{ if (!x($b, 'uid')) { return; } @@ -183,7 +187,7 @@ function securemail_emailer_send_prepare(App &$a, array &$b) { $b['htmlVersion'] = null; } - +/// @TODO Old lost code? Next PR! /** * add addon composer autoloader maps to system autoloader diff --git a/showmore/showmore.php b/showmore/showmore.php index 3673c956..4ae66e85 100644 --- a/showmore/showmore.php +++ b/showmore/showmore.php @@ -5,8 +5,9 @@ * Version: 1.0 * Author: Michael Vogel * based upon NSFW from Mike Macgirvin - * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; @@ -61,7 +62,7 @@ function showmore_addon_settings(&$a,&$s) { return; } -function showmore_addon_settings_post(&$a,&$b) { +function showmore_addon_settings_post(App $a, array &$b) { if(! local_user()) return; diff --git a/smiley_pack/lang/smiley_pack_es/smiley_pack_es.php b/smiley_pack/lang/smiley_pack_es/smiley_pack_es.php index 47566380..c19f840f 100644 --- a/smiley_pack/lang/smiley_pack_es/smiley_pack_es.php +++ b/smiley_pack/lang/smiley_pack_es/smiley_pack_es.php @@ -6,6 +6,8 @@ * Author: Thomas Willingham (based on Mike Macgirvin's Adult Smile template) * All smileys from sites offering them as Public Domain */ + +use Friendica\App; use Friendica\Core\Addon; function smiley_pack_es_install() { @@ -18,7 +20,7 @@ function smiley_pack_es_uninstall() { -function smiley_pack_smilies_es(&$a,&$b) { +function smiley_pack_smilies_es(App $a, array &$b) { #Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever. diff --git a/smiley_pack/lang/smiley_pack_fr/smiley_pack_fr.php b/smiley_pack/lang/smiley_pack_fr/smiley_pack_fr.php index 282c0dde..143d0dd2 100644 --- a/smiley_pack/lang/smiley_pack_fr/smiley_pack_fr.php +++ b/smiley_pack/lang/smiley_pack_fr/smiley_pack_fr.php @@ -5,9 +5,9 @@ * Version: 1.01 * Author: Thomas Willingham (based on Mike Macgirvin's Adult Smile template) * All smileys from sites offering them as Public Domain - * - * */ + +use Friendica\App; use Friendica\Core\Addon; function smiley_pack_fr_install() { @@ -20,7 +20,7 @@ function smiley_pack_fr_uninstall() { -function smiley_pack_fr_smilies(&$a,&$b) { +function smiley_pack_fr_smilies(App $a, array &$b) { #Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever. diff --git a/smiley_pack/smiley_pack.php b/smiley_pack/smiley_pack.php index ea3490eb..7695629d 100644 --- a/smiley_pack/smiley_pack.php +++ b/smiley_pack/smiley_pack.php @@ -7,6 +7,7 @@ * All smileys from sites offering them as Public Domain */ +use Friendica\App; use Friendica\Core\Addon; function smiley_pack_install() { @@ -19,7 +20,7 @@ function smiley_pack_uninstall() { -function smiley_pack_smilies(&$a,&$b) { +function smiley_pack_smilies(App $a, array &$b) { #Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever. diff --git a/smileybutton/smileybutton.php b/smileybutton/smileybutton.php index f613d290..71e1b93f 100644 --- a/smileybutton/smileybutton.php +++ b/smileybutton/smileybutton.php @@ -5,6 +5,8 @@ * Version: 0.2 * Author: Johannes Schwab */ + +use Friendica\App; use Friendica\Core\Addon; function smileybutton_install() { @@ -24,15 +26,17 @@ function smileybutton_uninstall() { -function show_button(Friendica\App $a, &$b) { +function show_button(App $a, &$b) { // Disable if theme is quattro // TODO add style for quattro - if ($a->getCurrentTheme() == 'quattro') + if ($a->getCurrentTheme() == 'quattro') { return; + } // Disable for mobile because most mobiles have a smiley key for ther own - if ($a->is_mobile || $a->is_tablet) + if ($a->is_mobile || $a->is_tablet) { return; + } /** * diff --git a/smilies_adult/smilies_adult.php b/smilies_adult/smilies_adult.php index bb673f23..6e81b424 100644 --- a/smilies_adult/smilies_adult.php +++ b/smilies_adult/smilies_adult.php @@ -8,6 +8,8 @@ * This is a template for how to extend the "smily" code. * */ + +use Friendica\App; use Friendica\Core\Addon; function smilies_adult_install() { @@ -20,7 +22,7 @@ function smilies_adult_uninstall() { -function smilies_adult_smilies(&$a,&$b) { +function smilies_adult_smilies(App $a, array &$b) { $b['texts'][] = '(o)(o)'; $b['icons'][] = '' . '(o)(o)' . ''; @@ -40,4 +42,4 @@ function smilies_adult_smilies(&$a,&$b) { $b['texts'][] = ':finger'; $b['icons'][] = '' . ':finger' . ''; -} \ No newline at end of file +} diff --git a/statusnet/library/codebirdsn.php b/statusnet/library/codebirdsn.php index cba5f936..c90eb9e8 100644 --- a/statusnet/library/codebirdsn.php +++ b/statusnet/library/codebirdsn.php @@ -317,7 +317,7 @@ class CodebirdSN * * @return string The OAuth authenticate URL */ - public function oauth_authenticate($force_login = NULL, $screen_name = NULL) + public function oauth_authenticate($force_login = null, $screen_name = null) { if ($this->_oauth_token == null) { throw new \Exception('To get the authenticate URL, the OAuth token must be set.'); @@ -337,7 +337,7 @@ class CodebirdSN * * @return string The OAuth authorize URL */ - public function oauth_authorize($force_login = NULL, $screen_name = NULL) + public function oauth_authorize($force_login = null, $screen_name = null) { if ($this->_oauth_token == null) { throw new \Exception('To get the authorize URL, the OAuth token must be set.'); diff --git a/statusnet/library/statusnetoauth.php b/statusnet/library/statusnetoauth.php index 27d91638..e9fd783c 100644 --- a/statusnet/library/statusnetoauth.php +++ b/statusnet/library/statusnetoauth.php @@ -1,104 +1,104 @@ -get($this->host . 'statusnet/config.json'); - return $config->site->textlimit; - } - - function accessTokenURL() - { - return $this->host . 'oauth/access_token'; - } - - function authenticateURL() - { - return $this->host . 'oauth/authenticate'; - } - - function authorizeURL() - { - return $this->host . 'oauth/authorize'; - } - - function requestTokenURL() - { - return $this->host . 'oauth/request_token'; - } - - function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) - { - parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret); - $this->host = $apipath; - } - - /** - * Make an HTTP request - * - * Copied here from the TwitterOAuth library and complemented by applying the proxy settings of Friendica - * - * @param string $method - * @param string $host - * @param string $path - * @param array $parameters - * - * @return array|object API results - */ - function http($url, $method, $postfields = NULL) - { - $this->http_info = []; - $ci = curl_init(); - /* Curl settings */ - $prx = Config::get('system', 'proxy'); - if (strlen($prx)) { - curl_setopt($ci, CURLOPT_HTTPPROXYTUNNEL, 1); - curl_setopt($ci, CURLOPT_PROXY, $prx); - $prxusr = Config::get('system', 'proxyuser'); - if (strlen($prxusr)) { - curl_setopt($ci, CURLOPT_PROXYUSERPWD, $prxusr); - } - } - curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent); - curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout); - curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout); - curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($ci, CURLOPT_HTTPHEADER, ['Expect:']); - curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer); - curl_setopt($ci, CURLOPT_HEADERFUNCTION, [$this, 'getHeader']); - curl_setopt($ci, CURLOPT_HEADER, FALSE); - - switch ($method) { - case 'POST': - curl_setopt($ci, CURLOPT_POST, TRUE); - if (!empty($postfields)) { - curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); - } - break; - case 'DELETE': - curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE'); - if (!empty($postfields)) { - $url = "{$url}?{$postfields}"; - } - } - - curl_setopt($ci, CURLOPT_URL, $url); - $response = curl_exec($ci); - $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE); - $this->http_info = array_merge($this->http_info, curl_getinfo($ci)); - $this->url = $url; - curl_close($ci); - return $response; - } -} +get($this->host . 'statusnet/config.json'); + return $config->site->textlimit; + } + + function accessTokenURL() + { + return $this->host . 'oauth/access_token'; + } + + function authenticateURL() + { + return $this->host . 'oauth/authenticate'; + } + + function authorizeURL() + { + return $this->host . 'oauth/authorize'; + } + + function requestTokenURL() + { + return $this->host . 'oauth/request_token'; + } + + function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null) + { + parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret); + $this->host = $apipath; + } + + /** + * Make an HTTP request + * + * Copied here from the TwitterOAuth library and complemented by applying the proxy settings of Friendica + * + * @param string $method + * @param string $host + * @param string $path + * @param array $parameters + * + * @return array|object API results + */ + function http($url, $method, $postfields = null) + { + $this->http_info = []; + $ci = curl_init(); + /* Curl settings */ + $prx = Config::get('system', 'proxy'); + if (strlen($prx)) { + curl_setopt($ci, CURLOPT_HTTPPROXYTUNNEL, 1); + curl_setopt($ci, CURLOPT_PROXY, $prx); + $prxusr = Config::get('system', 'proxyuser'); + if (strlen($prxusr)) { + curl_setopt($ci, CURLOPT_PROXYUSERPWD, $prxusr); + } + } + curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent); + curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout); + curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout); + curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($ci, CURLOPT_HTTPHEADER, ['Expect:']); + curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer); + curl_setopt($ci, CURLOPT_HEADERFUNCTION, [$this, 'getHeader']); + curl_setopt($ci, CURLOPT_HEADER, FALSE); + + switch ($method) { + case 'POST': + curl_setopt($ci, CURLOPT_POST, TRUE); + if (!empty($postfields)) { + curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); + } + break; + case 'DELETE': + curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE'); + if (!empty($postfields)) { + $url = "{$url}?{$postfields}"; + } + } + + curl_setopt($ci, CURLOPT_URL, $url); + $response = curl_exec($ci); + $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE); + $this->http_info = array_merge($this->http_info, curl_getinfo($ci)); + $this->url = $url; + curl_close($ci); + return $response; + } +} diff --git a/statusnet/library/twitteroauth.php b/statusnet/library/twitteroauth.php index bf56fc01..78d58089 100644 --- a/statusnet/library/twitteroauth.php +++ b/statusnet/library/twitteroauth.php @@ -76,14 +76,14 @@ class TwitterOAuth /** * construct TwitterOAuth object */ - function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) + function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null) { $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1(); $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret); if (!empty($oauth_token) && !empty($oauth_token_secret)) { $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret); } else { - $this->token = NULL; + $this->token = null; } } @@ -92,7 +92,7 @@ class TwitterOAuth * * @returns a key/value array containing oauth_token and oauth_token_secret */ - function getRequestToken($oauth_callback = NULL) + function getRequestToken($oauth_callback = null) { $parameters = array(); if (!empty($oauth_callback)) { @@ -224,7 +224,7 @@ class TwitterOAuth * * @return API results */ - function http($url, $method, $postfields = NULL) + function http($url, $method, $postfields = null) { $this->http_info = array(); $ci = curl_init(); diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 9af2c6d1..1859535b 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -385,7 +385,7 @@ function statusnet_settings(App $a, &$s) $s .= '
'; } -function statusnet_post_local(App $a, &$b) +function statusnet_post_local(App $a, array &$b) { if ($b['edit']) { return; @@ -440,7 +440,7 @@ function statusnet_action(App $a, $uid, $pid, $action) logger("statusnet_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG); } -function statusnet_post_hook(App $a, &$b) +function statusnet_post_hook(App $a, array &$b) { /** * Post to GNU Social @@ -669,7 +669,7 @@ function statusnet_addon_admin(App $a, &$o) ]); } -function statusnet_prepare_body(App $a, &$b) +function statusnet_prepare_body(App $a, array &$b) { if ($b["item"]["network"] != NETWORK_STATUSNET) { return; @@ -712,7 +712,7 @@ function statusnet_prepare_body(App $a, &$b) } } -function statusnet_cron(App $a, $b) +function statusnet_cron(App $a) { $last = Config::get('statusnet', 'last_poll'); @@ -731,6 +731,7 @@ function statusnet_cron(App $a, $b) logger('statusnet: cron_start'); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() "); + if (DBM::is_result($r)) { foreach ($r as $rr) { logger('statusnet: fetching for user ' . $rr['uid']); @@ -746,10 +747,12 @@ function statusnet_cron(App $a, $b) $abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()"); + if (DBM::is_result($r)) { foreach ($r as $rr) { if ($abandon_days != 0) { $user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit); + if (!DBM::is_result($user)) { logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported'); continue; diff --git a/superblock/superblock.php b/superblock/superblock.php index 24111486..aa4d99a0 100644 --- a/superblock/superblock.php +++ b/superblock/superblock.php @@ -1,6 +1,4 @@ * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; @@ -69,7 +69,7 @@ function superblock_addon_settings(&$a,&$s) { return; } -function superblock_addon_settings_post(&$a,&$b) { +function superblock_addon_settings_post(App $a, array &$b) { if(! local_user()) return; @@ -80,7 +80,7 @@ function superblock_addon_settings_post(&$a,&$b) { } } -function superblock_enotify_store(&$a,&$b) { +function superblock_enotify_store(App $a, array &$b) { $words = PConfig::get($b['uid'],'system','blocked'); if($words) { @@ -109,7 +109,7 @@ function superblock_enotify_store(&$a,&$b) { } -function superblock_conversation_start(&$a,&$b) { +function superblock_conversation_start(App $a, array &$b) { if(! local_user()) return; @@ -132,7 +132,7 @@ EOT; } -function superblock_item_photo_menu(&$a,&$b) { +function superblock_item_photo_menu(App $a, array &$b) { if((! local_user()) || ($b['item']['self'])) return; diff --git a/testdrive/testdrive.php b/testdrive/testdrive.php index 8e71103f..c2d107ab 100644 --- a/testdrive/testdrive.php +++ b/testdrive/testdrive.php @@ -6,9 +6,11 @@ * Author: Mike Macgirvin */ +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Database\DBM; use Friendica\Model\User; use Friendica\Util\DateTimeFormat; @@ -33,16 +35,17 @@ function testdrive_uninstall() { } -function testdrive_load_config(\Friendica\App $a) +function testdrive_load_config(App $a) { $a->loadConfigFile(__DIR__. '/config/testdrive.ini.php'); } -function testdrive_globaldir_update($a,&$b) { +function testdrive_globaldir_update(App $a, &$b) +{ $b['url'] = ''; } -function testdrive_register_account($a,$b) { +function testdrive_register_account(App $a, $b) { $uid = $b; @@ -58,13 +61,13 @@ function testdrive_register_account($a,$b) { }; -function testdrive_cron($a,$b) { +function testdrive_cron(App $a) { require_once('include/enotify.php'); - $r = q("select * from user where account_expires_on < UTC_TIMESTAMP() + INTERVAL 5 DAY and - expire_notification_sent = '0000-00-00 00:00:00' "); + $r = q("SELECT * FROM `user` WHERE `account_expires_on` < UTC_TIMESTAMP() + INTERVAL 5 DAY AND + `expire_notification_sent` = '0000-00-00 00:00:00'"); - if(count($r)) { + if (DBM::is_result($r)) { foreach($r as $rr) { notification([ 'uid' => $rr['uid'], @@ -78,23 +81,23 @@ function testdrive_cron($a,$b) { 'source_photo' => $a->get_baseurl() . '/images/person-80.jpg', ]); - q("update user set expire_notification_sent = '%s' where uid = %d", + q("UPDATE `user` SET `expire_notification_sent`='%s' WHERE `uid`=%d", dbesc(DateTimeFormat::utcNow()), intval($rr['uid']) ); - } } - $r = q("select * from user where account_expired = 1 and account_expires_on < UTC_TIMESTAMP() - INTERVAL 5 DAY "); - if(count($r)) { + $r = q("SELECT * FROM `user` WHERE `account_expired`=1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 5 DAY"); + + if (DBM::is_result($r)) { foreach($r as $rr) { User::remove($rr['uid']); } } } -function testdrive_enotify(&$a, &$b) { +function testdrive_enotify(App $a, array &$b) { if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM && x($b['params'], 'system_type') && $b['params']['system_type'] === 'testdrive_expire') { $b['itemlink'] = $a->get_baseurl(); diff --git a/tumblr/library/tumblroauth.php b/tumblr/library/tumblroauth.php index 914e6afa..948b19b6 100644 --- a/tumblr/library/tumblroauth.php +++ b/tumblr/library/tumblroauth.php @@ -53,13 +53,13 @@ class TumblrOAuth { /** * construct TumblrOAuth object */ - function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) { + function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null) { $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1(); $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret); if (!empty($oauth_token) && !empty($oauth_token_secret)) { $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret); } else { - $this->token = NULL; + $this->token = null; } } @@ -69,7 +69,7 @@ class TumblrOAuth { * * @returns a key/value array containing oauth_token and oauth_token_secret */ - function getRequestToken($oauth_callback = NULL) { + function getRequestToken($oauth_callback = null) { $parameters = array(); if (!empty($oauth_callback)) { $parameters['oauth_callback'] = $oauth_callback; @@ -191,7 +191,7 @@ class TumblrOAuth { * * @return API results */ - function http($url, $method, $postfields = NULL) { + function http($url, $method, $postfields = null) { $this->http_info = array(); $ci = curl_init(); /* Curl settings */ diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 7ed91175..aa625ba7 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -9,6 +9,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'tumblroauth.php'; +use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; @@ -126,7 +127,7 @@ function tumblr_connect($a) { // Give an error message $o = 'Could not connect to Tumblr. Refresh the page or try again later.'; } - return($o); + return $o; } function tumblr_callback($a) { @@ -168,15 +169,17 @@ function tumblr_callback($a) { $o = L10n::t("You are now authenticated to tumblr."); $o .= '
'.L10n::t("return to the connector page").''; - return($o); + return $o; } -function tumblr_jot_nets(&$a,&$b) { - if(! local_user()) +function tumblr_jot_nets(App $a, &$b) { + if (! local_user()) { return; + } - $tmbl_post = PConfig::get(local_user(),'tumblr','post'); - if(intval($tmbl_post) == 1) { + $tmbl_post = PConfig::get(local_user(), 'tumblr', 'post'); + + if (intval($tmbl_post) == 1) { $tmbl_defpost = PConfig::get(local_user(),'tumblr','post_by_default'); $selected = ((intval($tmbl_defpost) == 1) ? ' checked="checked" ' : ''); $b .= '
' @@ -185,10 +188,11 @@ function tumblr_jot_nets(&$a,&$b) { } -function tumblr_settings(&$a,&$s) { +function tumblr_settings(App $a, &$s) { - if(! local_user()) + if (! local_user()) { return; + } /* Add our stylesheet to the page so we can make our settings look nice */ @@ -266,7 +270,7 @@ function tumblr_settings(&$a,&$s) { } -function tumblr_settings_post(&$a,&$b) { +function tumblr_settings_post(App $a, array &$b) { if(x($_POST,'tumblr-submit')) { @@ -278,7 +282,7 @@ function tumblr_settings_post(&$a,&$b) { } -function tumblr_post_local(&$a, &$b) { +function tumblr_post_local(App $a, array &$b) { // This can probably be changed to allow editing by pointing to a different API endpoint @@ -316,7 +320,7 @@ function tumblr_post_local(&$a, &$b) { -function tumblr_send(&$a,&$b) { +function tumblr_send(App $a, array &$b) { if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { return; diff --git a/twitter/twitter.php b/twitter/twitter.php index aa0adfb8..7db67a1c 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -386,7 +386,7 @@ function twitter_settings(App $a, &$s) $s .= '
'; } -function twitter_post_local(App $a, &$b) +function twitter_post_local(App $a, array &$b) { if ($b['edit']) { return; @@ -446,7 +446,7 @@ function twitter_action(App $a, $uid, $pid, $action) logger("twitter_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG); } -function twitter_post_hook(App $a, &$b) +function twitter_post_hook(App $a, array &$b) { // Post to Twitter if (!PConfig::get($b["uid"], 'twitter', 'import') @@ -658,7 +658,7 @@ function twitter_addon_admin(App $a, &$o) ]); } -function twitter_cron(App $a, $b) +function twitter_cron(App $a) { $last = Config::get('twitter', 'last_poll'); @@ -726,7 +726,7 @@ function twitter_cron(App $a, $b) Config::set('twitter', 'last_poll', time()); } -function twitter_expire(App $a, $b) +function twitter_expire(App $a) { $days = Config::get('twitter', 'expire'); @@ -761,7 +761,7 @@ function twitter_expire(App $a, $b) logger('twitter_expire: expire_end'); } -function twitter_prepare_body(App $a, &$b) +function twitter_prepare_body(App $a, array &$b) { if ($b["item"]["network"] != NETWORK_TWITTER) { return; @@ -920,7 +920,7 @@ function twitter_fetchtimeline(App $a, $uid) PConfig::set($uid, 'twitter', 'lastid', $lastid); } -function twitter_queue_hook(App $a, &$b) +function twitter_queue_hook(App $a, array &$b) { $qi = q("SELECT * FROM `queue` WHERE `network` = '%s'", dbesc(NETWORK_TWITTER) diff --git a/unicode_smilies/unicode_smilies.php b/unicode_smilies/unicode_smilies.php index faa553cc..93eefc3e 100644 --- a/unicode_smilies/unicode_smilies.php +++ b/unicode_smilies/unicode_smilies.php @@ -5,6 +5,8 @@ * Version: 1.0 * Author: Michael Vogel */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Content\Smilies; @@ -16,7 +18,7 @@ function unicode_smilies_uninstall() { Addon::unregisterHook('smilie', 'addon/unicode_smilies/unicode_smilies.php', 'unicode_smilies_smilies'); } -function unicode_smilies_smilies(&$a,&$b) { +function unicode_smilies_smilies(App $a, array &$b) { Smilies::add($b, ':-)', '😀'); Smilies::add($b, ':)', '😀'); Smilies::add($b, ':-(', '🙁'); diff --git a/viewsrc/viewsrc.php b/viewsrc/viewsrc.php index 9ffa0b8c..875b60e1 100644 --- a/viewsrc/viewsrc.php +++ b/viewsrc/viewsrc.php @@ -6,6 +6,8 @@ * Author: Mike Macgirvin * */ + +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Model\Item; @@ -35,7 +37,7 @@ function viewsrc_page_end(&$a, &$o){ EOS; } -function viewsrc_item_photo_menu(&$a, &$b) +function viewsrc_item_photo_menu(App $a, array &$b) { if (!local_user()) { return; diff --git a/wppost/wppost.php b/wppost/wppost.php index 45b48993..d0059a58 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -6,6 +6,7 @@ * Author: Mike Macgirvin */ +use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Addon; @@ -14,7 +15,8 @@ use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Util\Network; -function wppost_install() { +function wppost_install() +{ Addon::registerHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local'); Addon::registerHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send'); Addon::registerHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets'); @@ -22,7 +24,9 @@ function wppost_install() { Addon::registerHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); } -function wppost_uninstall() { + +function wppost_uninstall() +{ Addon::unregisterHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local'); Addon::unregisterHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send'); Addon::unregisterHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets'); @@ -37,11 +41,13 @@ function wppost_uninstall() { } -function wppost_jot_nets(&$a,&$b) { +function wppost_jot_nets(App $a, &$b) +{ if(! local_user()) return; $wp_post = PConfig::get(local_user(),'wppost','post'); + if(intval($wp_post) == 1) { $wp_defpost = PConfig::get(local_user(),'wppost','post_by_default'); $selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : ''); @@ -51,7 +57,8 @@ function wppost_jot_nets(&$a,&$b) { } -function wppost_settings(&$a,&$s) { +function wppost_settings(App &$a, &$s) +{ if(! local_user()) return; @@ -136,8 +143,8 @@ function wppost_settings(&$a,&$s) { } -function wppost_settings_post(&$a,&$b) { - +function wppost_settings_post(App $a, array &$b) +{ if(x($_POST,'wppost-submit')) { PConfig::set(local_user(),'wppost','post',intval($_POST['wppost'])); @@ -156,8 +163,8 @@ function wppost_settings_post(&$a,&$b) { } -function wppost_post_local(&$a, &$b) { - +function wppost_post_local(App $a, array &$b) +{ // This can probably be changed to allow editing by pointing to a different API endpoint if ($b['edit']) { @@ -194,8 +201,8 @@ function wppost_post_local(&$a, &$b) { -function wppost_send(&$a,&$b) { - +function wppost_send(App $a, array &$b) +{ if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { return; } diff --git a/xmpp/xmpp.php b/xmpp/xmpp.php index bef31fed..eee4ea75 100644 --- a/xmpp/xmpp.php +++ b/xmpp/xmpp.php @@ -5,6 +5,7 @@ * Version: 0.1 * Author: Michael Vogel */ + use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config;