diff --git a/LICENSE b/LICENSE index c155965f81..2bbe2d1de7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ Friendica Communications Server -Copyright (c) 2010-2016 the Friendica Project +Copyright (c) 2010-2017 the Friendica Project This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by diff --git a/boot.php b/boot.php index 8ecd2f76e4..1ff44d2a84 100644 --- a/boot.php +++ b/boot.php @@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5.1-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1211 ); +define ( 'DB_UPDATE_VERSION', 1212 ); /** * @brief Constant with a HTML line break. @@ -1539,7 +1539,7 @@ function check_db() { * Sets the base url for use in cmdline programs which don't have * $_SERVER variables */ -function check_url(App &$a) { +function check_url(App $a) { $url = get_config('system','url'); @@ -1561,7 +1561,7 @@ function check_url(App &$a) { /** * @brief Automatic database updates */ -function update_db(App &$a) { +function update_db(App $a) { $build = get_config('system','build'); if(! x($build)) $build = set_config('system','build',DB_UPDATE_VERSION); @@ -1677,7 +1677,7 @@ function run_update_function($x) { * @param App $a * */ -function check_plugins(App &$a) { +function check_plugins(App $a) { $r = q("SELECT * FROM `addon` WHERE `installed` = 1"); if (dbm::is_result($r)) @@ -2413,7 +2413,7 @@ function get_temppath() { } /// @deprecated -function set_template_engine(App &$a, $engine = 'internal') { +function set_template_engine(App $a, $engine = 'internal') { /// @note This function is no longer necessary, but keep it as a wrapper to the class method /// to avoid breaking themes again unnecessarily diff --git a/database.sql b/database.sql index 2e83c33a64..becd14fc73 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 3.5.1-dev (Asparagus) --- DB_UPDATE_VERSION 1211 +-- DB_UPDATE_VERSION 1212 -- ------------------------------------------ @@ -174,9 +174,16 @@ CREATE TABLE IF NOT EXISTS `contact` ( `fetch_further_information` tinyint(1) NOT NULL DEFAULT 0, `ffi_keyword_blacklist` mediumtext, PRIMARY KEY(`id`), - INDEX `uid` (`uid`), - INDEX `addr_uid` (`addr`,`uid`), - INDEX `nurl` (`nurl`) + INDEX `uid_name` (`uid`,`name`), + INDEX `uid_self` (`uid`,`self`), + INDEX `alias_uid` (`alias`(32),`uid`), + INDEX `uid_pending` (`uid`,`pending`), + INDEX `uid_blocked` (`uid`,`blocked`), + INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`), + INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)), + INDEX `addr_uid` (`addr`(32),`uid`), + INDEX `nurl_uid` (`nurl`(32),`uid`), + INDEX `nick_uid` (`nick`(32),`uid`) ) DEFAULT CHARSET=utf8mb4; -- @@ -232,7 +239,7 @@ CREATE TABLE IF NOT EXISTS `event` ( `deny_cid` mediumtext, `deny_gid` mediumtext, PRIMARY KEY(`id`), - INDEX `uid` (`uid`) + INDEX `uid_start` (`uid`,`start`) ) DEFAULT CHARSET=utf8mb4; -- @@ -257,7 +264,7 @@ CREATE TABLE IF NOT EXISTS `fcontact` ( `pubkey` text, `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY(`id`), - INDEX `addr` (`addr`) + INDEX `addr` (`addr`(32)) ) DEFAULT CHARSET=utf8mb4; -- @@ -280,7 +287,7 @@ CREATE TABLE IF NOT EXISTS `fserver` ( `posturl` varchar(255) NOT NULL DEFAULT '', `key` text, PRIMARY KEY(`id`), - INDEX `server` (`server`) + INDEX `server` (`server`(32)) ) DEFAULT CHARSET=utf8mb4; -- @@ -342,10 +349,10 @@ CREATE TABLE IF NOT EXISTS `gcontact` ( `generation` tinyint(3) NOT NULL DEFAULT 0, `server_url` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY(`id`), - INDEX `nurl` (`nurl`), - INDEX `name` (`name`), - INDEX `nick` (`nick`), - INDEX `addr` (`addr`), + INDEX `nurl` (`nurl`(32)), + INDEX `name` (`name`(32)), + INDEX `nick` (`nick`(32)), + INDEX `addr` (`addr`(32)), INDEX `updated` (`updated`) ) DEFAULT CHARSET=utf8mb4; @@ -360,7 +367,7 @@ CREATE TABLE IF NOT EXISTS `glink` ( `zcid` int(11) NOT NULL DEFAULT 0, `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY(`id`), - INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`), + UNIQUE INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`), INDEX `gcid` (`gcid`), INDEX `zcid` (`zcid`) ) DEFAULT CHARSET=utf8mb4; @@ -387,7 +394,9 @@ CREATE TABLE IF NOT EXISTS `group_member` ( `gid` int(10) unsigned NOT NULL DEFAULT 0, `contact-id` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY(`id`), - INDEX `uid_gid_contactid` (`uid`,`gid`,`contact-id`) + INDEX `cid_contactid` (`cid`,`contact-id`), + INDEX `uid_contactid` (`uid`,`contact-id`), + UNIQUE INDEX `uid_gid_contactid` (`uid`,`gid`,`contact-id`) ) DEFAULT CHARSET=utf8mb4; -- @@ -410,7 +419,7 @@ CREATE TABLE IF NOT EXISTS `gserver` ( `last_contact` datetime DEFAULT '0000-00-00 00:00:00', `last_failure` datetime DEFAULT '0000-00-00 00:00:00', PRIMARY KEY(`id`), - INDEX `nurl` (`nurl`) + INDEX `nurl` (`nurl`(32)) ) DEFAULT CHARSET=utf8mb4; -- @@ -525,24 +534,17 @@ CREATE TABLE IF NOT EXISTS `item` ( INDEX `uid_network_received` (`uid`,`network`,`received`), INDEX `uid_received` (`uid`,`received`), INDEX `uid_network_commented` (`uid`,`network`,`commented`), - INDEX `uid_commented` (`uid`,`commented`), INDEX `uid_title` (`uid`,`title`), INDEX `uid_thrparent` (`uid`,`thr-parent`), INDEX `uid_parenturi` (`uid`,`parent-uri`), INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`), INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`), - INDEX `gcontactid_uid_created` (`gcontact-id`,`uid`,`created`), INDEX `authorid_created` (`author-id`,`created`), - INDEX `ownerid_created` (`owner-id`,`created`), - INDEX `wall_body` (`wall`,`body`(6)), - INDEX `uid_visible_moderated_created` (`uid`,`visible`,`moderated`,`created`), INDEX `uid_uri` (`uid`,`uri`), INDEX `uid_wall_created` (`uid`,`wall`,`created`), INDEX `resource-id` (`resource-id`), INDEX `uid_type` (`uid`,`type`), - INDEX `uid_starred_id` (`uid`,`starred`,`id`), INDEX `contactid_allowcid_allowpid_denycid_denygid` (`contact-id`,`allow_cid`(10),`allow_gid`(10),`deny_cid`(10),`deny_gid`(10)), - INDEX `uid_wall_parent_created` (`uid`,`wall`,`parent`,`created`), INDEX `uid_type_changed` (`uid`,`type`,`changed`), INDEX `contactid_verb` (`contact-id`,`verb`), INDEX `deleted_changed` (`deleted`,`changed`), @@ -564,7 +566,7 @@ CREATE TABLE IF NOT EXISTS `item_id` ( PRIMARY KEY(`id`), INDEX `uid` (`uid`), INDEX `sid` (`sid`), - INDEX `service` (`service`), + INDEX `service` (`service`(32)), INDEX `iid` (`iid`) ) DEFAULT CHARSET=utf8mb4; @@ -602,11 +604,10 @@ CREATE TABLE IF NOT EXISTS `mail` ( `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY(`id`), INDEX `uid` (`uid`), - INDEX `guid` (`guid`), + INDEX `uid_seen` (`uid`,`seen`), INDEX `convid` (`convid`), - INDEX `reply` (`reply`), - INDEX `uri` (`uri`), - INDEX `parent-uri` (`parent-uri`) + INDEX `uri` (`uri`(64)), + INDEX `parent-uri` (`parent-uri`(64)) ) DEFAULT CHARSET=utf8mb4; -- @@ -662,7 +663,11 @@ CREATE TABLE IF NOT EXISTS `notify` ( `name_cache` tinytext, `msg_cache` mediumtext, PRIMARY KEY(`id`), - INDEX `uid` (`uid`) + INDEX `uid_hash` (`uid`,`hash`), + INDEX `uid_seen_date` (`uid`,`seen`,`date`), + INDEX `uid_type_link` (`uid`,`type`,`link`), + INDEX `uid_link` (`uid`,`link`), + INDEX `uid_date` (`uid`,`date`) ) DEFAULT CHARSET=utf8mb4; -- @@ -675,8 +680,7 @@ CREATE TABLE IF NOT EXISTS `notify-threads` ( `parent-item` int(10) unsigned NOT NULL DEFAULT 0, `receiver-uid` int(11) NOT NULL DEFAULT 0, PRIMARY KEY(`id`), - INDEX `master-parent-item` (`master-parent-item`), - INDEX `receiver-uid` (`receiver-uid`) + INDEX `master-parent-item` (`master-parent-item`) ) DEFAULT CHARSET=utf8mb4; -- @@ -745,9 +749,9 @@ CREATE TABLE IF NOT EXISTS `photo` ( PRIMARY KEY(`id`), INDEX `uid_contactid` (`uid`,`contact-id`), INDEX `uid_profile` (`uid`,`profile`), - INDEX `uid_album_created` (`uid`,`album`,`created`), - INDEX `resource-id` (`resource-id`), - INDEX `guid` (`guid`) + INDEX `uid_album_created` (`uid`,`album`(32),`created`), + INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`(64),`created`), + INDEX `resource-id` (`resource-id`(64)) ) DEFAULT CHARSET=utf8mb4; -- @@ -839,8 +843,7 @@ CREATE TABLE IF NOT EXISTS `profile` ( `thumb` varchar(255) NOT NULL DEFAULT '', `publish` tinyint(1) NOT NULL DEFAULT 0, `net-publish` tinyint(1) NOT NULL DEFAULT 0, - PRIMARY KEY(`id`), - INDEX `hometown` (`hometown`) + PRIMARY KEY(`id`) ) DEFAULT CHARSET=utf8mb4; -- @@ -912,8 +915,7 @@ CREATE TABLE IF NOT EXISTS `search` ( `uid` int(11) NOT NULL DEFAULT 0, `term` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY(`id`), - INDEX `uid` (`uid`), - INDEX `term` (`term`) + INDEX `uid` (`uid`) ) DEFAULT CHARSET=utf8mb4; -- @@ -925,7 +927,7 @@ CREATE TABLE IF NOT EXISTS `session` ( `data` text, `expire` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY(`id`), - INDEX `sid` (`sid`), + INDEX `sid` (`sid`(64)), INDEX `expire` (`expire`) ) DEFAULT CHARSET=utf8mb4; @@ -977,12 +979,11 @@ CREATE TABLE IF NOT EXISTS `term` ( `uid` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY(`tid`), INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`), - INDEX `uid_term_tid` (`uid`,`term`,`tid`), - INDEX `type_term` (`type`,`term`), - INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`,`global`,`created`), - INDEX `otype_type_term_tid` (`otype`,`type`,`term`,`tid`), - INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`), - INDEX `guid` (`guid`) + INDEX `uid_term_tid` (`uid`,`term`(32),`tid`), + INDEX `type_term` (`type`,`term`(32)), + INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`), + INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)), + INDEX `guid` (`guid`(64)) ) DEFAULT CHARSET=utf8mb4; -- @@ -1022,9 +1023,6 @@ CREATE TABLE IF NOT EXISTS `thread` ( INDEX `uid_network_created` (`uid`,`network`,`created`), INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`), INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`), - INDEX `uid_gcontactid_commented` (`uid`,`gcontact-id`,`commented`), - INDEX `uid_gcontactid_created` (`uid`,`gcontact-id`,`created`), - INDEX `wall_private_received` (`wall`,`private`,`received`), INDEX `uid_created` (`uid`,`created`), INDEX `uid_commented` (`uid`,`commented`) ) DEFAULT CHARSET=utf8mb4; @@ -1090,7 +1088,7 @@ CREATE TABLE IF NOT EXISTS `user` ( `deny_gid` mediumtext, `openidserver` text, PRIMARY KEY(`uid`), - INDEX `nickname` (`nickname`) + INDEX `nickname` (`nickname`(32)) ) DEFAULT CHARSET=utf8mb4; -- @@ -1100,7 +1098,7 @@ CREATE TABLE IF NOT EXISTS `userd` ( `id` int(11) NOT NULL auto_increment, `username` varchar(255) NOT NULL, PRIMARY KEY(`id`), - INDEX `username` (`username`) + INDEX `username` (`username`(32)) ) DEFAULT CHARSET=utf8mb4; -- diff --git a/doc/Plugins.md b/doc/Plugins.md index 6460fd5a09..3a25dc7217 100644 --- a/doc/Plugins.md +++ b/doc/Plugins.md @@ -40,7 +40,7 @@ Arguments --- Your hook callback functions will be called with at least one and possibly two arguments - function myhook_function(&$a, &$b) { + function myhook_function(App $a, &$b) { } @@ -77,9 +77,9 @@ This will include: $a->argc = 3 $a->argv = array(0 => 'plugin', 1 => 'arg1', 2 => 'arg2'); -Your module functions will often contain the function plugin_name_content(App &$a), which defines and returns the page body content. -They may also contain plugin_name_post(App &$a) which is called before the _content function and typically handles the results of POST forms. -You may also have plugin_name_init(App &$a) which is called very early on and often does module initialisation. +Your module functions will often contain the function plugin_name_content(App $a), which defines and returns the page body content. +They may also contain plugin_name_post(App $a) which is called before the _content function and typically handles the results of POST forms. +You may also have plugin_name_init(App $a) which is called very early on and often does module initialisation. Templates --- @@ -285,7 +285,7 @@ $b is an array with: is called after the other queries have passed. The registered function can add, change or remove the acl_lookup() variables. - 'results' => array of the acl_lookup() vars + 'results' => array of the acl_lookup() vars Complete list of hook callbacks diff --git a/doc/autoloader.md b/doc/autoloader.md index 25ffd7fe45..69c62451cd 100644 --- a/doc/autoloader.md +++ b/doc/autoloader.md @@ -32,7 +32,7 @@ Let's say you have a php file in "include/" that define a very useful class: file: include/ItemsManager.php getAll(); - + // pass $items to template // return result } @@ -86,7 +86,7 @@ Going further: now we have a bunch of "*Manager" classes that cause some code du file: include/BaseManager.php argc = 3 $a->argv = array(0 => 'plugin', 1 => 'arg1', 2 => 'arg2'); -Deine Modulfunktionen umfassen oft die Funktion plugin_name_content(App &$a), welche den Seiteninhalt definiert und zurückgibt. -Sie können auch plugin_name_post(App &$a) umfassen, welches vor der content-Funktion aufgerufen wird und normalerweise die Resultate der POST-Formulare handhabt. -Du kannst ebenso plugin_name_init(App &$a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert. +Deine Modulfunktionen umfassen oft die Funktion plugin_name_content(App $a), welche den Seiteninhalt definiert und zurückgibt. +Sie können auch plugin_name_post(App $a) umfassen, welches vor der content-Funktion aufgerufen wird und normalerweise die Resultate der POST-Formulare handhabt. +Du kannst ebenso plugin_name_init(App $a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert. Derzeitige Hooks @@ -311,7 +311,7 @@ mod/photos.php: call_hooks('photo_post_end',intval($item_id)); mod/photos.php: call_hooks('photo_upload_form',$ret); -mod/friendica.php: call_hooks('about_hook', $o); +mod/friendica.php: call_hooks('about_hook', $o); mod/editpost.php: call_hooks('jot_tool', $jotplugins); diff --git a/doc/htconfig.md b/doc/htconfig.md index fb257c3dac..05a2a7a963 100644 --- a/doc/htconfig.md +++ b/doc/htconfig.md @@ -25,6 +25,7 @@ Example: To set the directory value please add this line to your .htconfig.php: * **allowed_link_protocols** (Array) - Allowed protocols in links URLs, add at your own risk. http is always allowed. * **birthday_input_format** - Default value is "ymd". * **block_local_dir** (Boolean) - Blocks the access to the directory of the local users. +* **dbclean** (Boolean) - Enable the automatic database cleanup process * **default_service_class** - * **delivery_batch_count** - Number of deliveries per process. Default value is 1. (Disabled when using the worker) * **diaspora_test** (Boolean) - For development only. Disables the message transfer. @@ -45,7 +46,8 @@ Example: To set the directory value please add this line to your .htconfig.php: * **max_processes_frontend** - Maximum number of concurrent database processes for foreground tasks. Default value is 20. * **memcache** (Boolean) - Use memcache. To use memcache the PECL extension "memcache" has to be installed and activated. * **memcache_host** - Hostname of the memcache daemon. Default is '127.0.0.1'. -* **memcache_port** - Portnumberof the memcache daemon. Default is 11211. +* **memcache_port** - Portnumber of the memcache daemon. Default is 11211. +* **no_count** (Boolean) - Don't do count calculations (currently only when showing albums) * **no_oembed** (Boolean) - Don't use OEmbed to fetch more information about a link. * **no_oembed_rich_content** (Boolean) - Don't show the rich content (e.g. embedded PDF). * **no_smilies** (Boolean) - Don't show smilies. diff --git a/doc/themes.md b/doc/themes.md index 0b8f6cb83d..b553debfd7 100644 --- a/doc/themes.md +++ b/doc/themes.md @@ -122,7 +122,7 @@ the 1st part of the line is the name of the CSS file (without the .css) the 2nd Calling the t() function with the common name makes the string translateable. The selected 1st part will be saved in the database by the theme_post function. - function theme_post(App &$a){ + function theme_post(App $a){ // non local users shall not pass if (! local_user()) { return; @@ -168,7 +168,7 @@ The content of this file should be something like theme_info = array( 'extends' => 'duepuntozero'. ); @@ -251,7 +251,7 @@ Next crucial part of the theme.php file is a definition of an init function. The name of the function is _init. So in the case of quattro it is - function quattro_init(App &$a) { + function quattro_init(App $a) { $a->theme_info = array(); set_template_engine($a, 'smarty3'); } diff --git a/include/Contact.php b/include/Contact.php index 5d8ccc4529..15b6813714 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -612,7 +612,7 @@ function get_contact($url, $uid = 0, $no_update = false) { * * @return string posts in HTML */ -function posts_from_gcontact($a, $gcontact_id) { +function posts_from_gcontact(App $a, $gcontact_id) { require_once('include/conversation.php'); @@ -636,7 +636,7 @@ function posts_from_gcontact($a, $gcontact_id) { $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, `author-name` AS `name`, `owner-avatar` AS `photo`, `owner-link` AS `url`, `owner-avatar` AS `thumb` - FROM `item` FORCE INDEX (`gcontactid_uid_created`) + FROM `item` WHERE `gcontact-id` = %d AND $sql AND NOT `deleted` AND NOT `moderated` AND `visible` ORDER BY `item`.`created` DESC LIMIT %d, %d", @@ -664,7 +664,7 @@ function posts_from_gcontact($a, $gcontact_id) { * * @return string posts in HTML */ -function posts_from_contact_url($a, $contact_url) { +function posts_from_contact_url(App $a, $contact_url) { require_once('include/conversation.php'); diff --git a/include/Photo.php b/include/Photo.php index 1a97fe2fe4..828dce82d7 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -283,7 +283,7 @@ class Photo { do { // FIXME - implement horizantal bias for scaling as in followin GD functions - // to allow very tall images to be constrained only horizontally. + // to allow very tall images to be constrained only horizontally. $this->image->scaleImage($dest_width, $dest_height); } while ($this->image->nextImage()); @@ -943,7 +943,7 @@ function scale_image($width, $height, $max) { return array("width" => $dest_width, "height" => $dest_height); } -function store_photo($a, $uid, $imagedata = "", $url = "") { +function store_photo(App $a, $uid, $imagedata = "", $url = "") { $r = q("SELECT `user`.`nickname`, `user`.`page-flags`, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`uid` = %d AND `user`.`blocked` = 0 AND `contact`.`self` = 1 LIMIT 1", intval($uid)); diff --git a/include/acl_selectors.php b/include/acl_selectors.php index f6c4f947ed..fccdb80665 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -135,7 +135,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $o .= "\r\n"; $r = q("SELECT `id`, `name`, `url`, `network` FROM `contact` - WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != '' + WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' $sql_extra ORDER BY `name` ASC ", intval(local_user()) @@ -372,7 +372,7 @@ function populate_acl($user = null, $show_jotnets = false) { } -function construct_acl_data(&$a, $user) { +function construct_acl_data(App $a, $user) { // Get group and contact information for html ACL selector $acl_data = acl_lookup($a, 'html'); @@ -404,7 +404,7 @@ function construct_acl_data(&$a, $user) { } -function acl_lookup(&$a, $out_type = 'json') { +function acl_lookup(App $a, $out_type = 'json') { if (!local_user()) { return ''; @@ -449,8 +449,8 @@ function acl_lookup(&$a, $out_type = 'json') { // autocomplete for editor mentions if ($type=='' || $type=='c'){ $r = q("SELECT COUNT(*) AS c FROM `contact` - WHERE `uid` = %d AND `self` = 0 - AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 + WHERE `uid` = %d AND NOT `self` + AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' $sql_extra2" , intval(local_user()) ); @@ -461,8 +461,8 @@ function acl_lookup(&$a, $out_type = 'json') { // autocomplete for Private Messages $r = q("SELECT COUNT(*) AS c FROM `contact` - WHERE `uid` = %d AND `self` = 0 - AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 + WHERE `uid` = %d AND NOT `self` + AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `network` IN ('%s','%s','%s') $sql_extra2" , intval(local_user()), dbesc(NETWORK_DFRN), @@ -477,8 +477,8 @@ function acl_lookup(&$a, $out_type = 'json') { // autocomplete for Contacts $r = q("SELECT COUNT(*) AS c FROM `contact` - WHERE `uid` = %d AND `self` = 0 - AND `pending` = 0 $sql_extra2" , + WHERE `uid` = %d AND NOT `self` + AND NOT `pending` $sql_extra2" , intval(local_user()) ); $contact_count = (int)$r[0]['c']; @@ -525,7 +525,7 @@ function acl_lookup(&$a, $out_type = 'json') { if ($type==''){ $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` - WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != '' + WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' AND NOT (`network` IN ('%s', '%s')) $sql_extra2 ORDER BY `name` ASC ", @@ -536,7 +536,7 @@ function acl_lookup(&$a, $out_type = 'json') { elseif ($type=='c'){ $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` - WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != '' + WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' AND NOT (`network` IN ('%s')) $sql_extra2 ORDER BY `name` ASC ", @@ -546,7 +546,7 @@ function acl_lookup(&$a, $out_type = 'json') { } elseif($type == 'm') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact` - WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 + WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `network` IN ('%s','%s','%s') $sql_extra2 ORDER BY `name` ASC ", @@ -687,11 +687,11 @@ function acl_lookup(&$a, $out_type = 'json') { } /** * @brief Searching for global contacts for autocompletion - * + * * @param App $a * @return array with the search results */ -function navbar_complete(App &$a) { +function navbar_complete(App $a) { // logger('navbar_complete'); diff --git a/include/api.php b/include/api.php index 3543a38362..91a3a34d11 100644 --- a/include/api.php +++ b/include/api.php @@ -133,7 +133,7 @@ * @hook 'logged_in' * array $user logged user record */ - function api_login(App &$a){ + function api_login(App $a){ // login with oauth try{ $oauth = new FKOAuth1(); @@ -251,7 +251,7 @@ * @param App $a * @return string API call result */ - function api_call(App &$a){ + function api_call(App $a){ global $API, $called_api; $type="json"; @@ -404,7 +404,7 @@ * @param array $user_info * @return array */ - function api_rss_extra(&$a, $arr, $user_info){ + function api_rss_extra(App $a, $arr, $user_info){ if (is_null($user_info)) $user_info = api_get_user($a); $arr['$user'] = $user_info; $arr['$rss'] = array( @@ -444,7 +444,7 @@ * @param int|string $contact_id Contact ID or URL * @param string $type Return type (for errors) */ - function api_get_user(&$a, $contact_id = Null, $type = "json"){ + function api_get_user(App $a, $contact_id = Null, $type = "json"){ global $called_api; $user = null; $extra_query = ""; @@ -712,7 +712,7 @@ * @param array $item : item from db * @return array(array:author, array:owner) */ - function api_item_get_user(&$a, $item) { + function api_item_get_user(App $a, $item) { $status_user = api_get_user($a, $item["author-link"]); @@ -2451,7 +2451,7 @@ 'homepage' => $profile['homepage'], 'users' => null); return $profile; - } + } } /** @@ -2874,14 +2874,14 @@ // BadRequestException if no id specified (for clients using Twitter API) if ($id == 0) throw new BadRequestException('Message id not specified'); - // add parent-uri to sql command if specified by calling app + // add parent-uri to sql command if specified by calling app $sql_extra = ($parenturi != "" ? " AND `parent-uri` = '" . dbesc($parenturi) . "'" : ""); // get data of the specified message id $r = q("SELECT `id` FROM `mail` WHERE `uid` = %d AND `id` = %d" . $sql_extra, - intval($uid), + intval($uid), intval($id)); - + // error message if specified id is not in database if (!dbm::is_result($r)) { if ($verbose == "true") { @@ -2893,8 +2893,8 @@ } // delete message - $result = q("DELETE FROM `mail` WHERE `uid` = %d AND `id` = %d" . $sql_extra, - intval($uid), + $result = q("DELETE FROM `mail` WHERE `uid` = %d AND `id` = %d" . $sql_extra, + intval($uid), intval($id)); if ($verbose == "true") { @@ -3860,7 +3860,7 @@ // get data of the specified message id $r = q("SELECT `id` FROM `mail` WHERE `id` = %d AND `uid` = %d", - intval($id), + intval($id), intval($uid)); // error message if specified id is not in database if (!dbm::is_result($r)) { @@ -3869,8 +3869,8 @@ } // update seen indicator - $result = q("UPDATE `mail` SET `seen` = 1 WHERE `id` = %d AND `uid` = %d", - intval($id), + $result = q("UPDATE `mail` SET `seen` = 1 WHERE `id` = %d AND `uid` = %d", + intval($id), intval($uid)); if ($result) { @@ -3921,7 +3921,7 @@ // message if nothing was found if (!dbm::is_result($r)) $success = array('success' => false, 'search_results' => 'problem with query'); - else if (count($r) == 0) + else if (count($r) == 0) $success = array('success' => false, 'search_results' => 'nothing found'); else { $ret = Array(); diff --git a/include/conversation.php b/include/conversation.php index 36eded8e8a..571e2faced 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -466,7 +466,7 @@ function item_condition() { */ if(!function_exists('conversation')) { -function conversation(&$a, $items, $mode, $update, $preview = false) { +function conversation(App $a, $items, $mode, $update, $preview = false) { require_once('include/bbcode.php'); require_once('include/Contact.php'); diff --git a/include/cron.php b/include/cron.php index e98239b829..5a9054b11b 100644 --- a/include/cron.php +++ b/include/cron.php @@ -128,7 +128,7 @@ function cron_run(&$argv, &$argc){ proc_run(PRIORITY_LOW, 'include/expire.php'); - proc_run(PRIORITY_LOW, 'include/dbclean.php'); + proc_run(PRIORITY_MEDIUM, 'include/dbclean.php'); cron_update_photo_albums(); } @@ -343,7 +343,7 @@ function cron_poll_contacts($argc, $argv) { * * @param App $a */ -function cron_clear_cache(App &$a) { +function cron_clear_cache(App $a) { $last = get_config('system','cache_last_cleared'); @@ -430,7 +430,7 @@ function cron_clear_cache(App &$a) { * * @param App $a */ -function cron_repair_diaspora(App &$a) { +function cron_repair_diaspora(App $a) { $r = q("SELECT `id`, `url` FROM `contact` WHERE `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '') ORDER BY RAND() LIMIT 50", dbesc(NETWORK_DIASPORA)); diff --git a/include/dbclean.php b/include/dbclean.php index 0baece8168..c80e5a3be3 100644 --- a/include/dbclean.php +++ b/include/dbclean.php @@ -3,13 +3,18 @@ * @file include/dbclean.php * @brief The script is called from time to time to clean the database entries and remove orphaned data. */ + +use \Friendica\Core\Config; +use \Friendica\Core\PConfig; + require_once("boot.php"); function dbclean_run(&$argv, &$argc) { global $a, $db; - if (is_null($a)) + if (is_null($a)) { $a = new App; + } if (is_null($db)) { @include(".htconfig.php"); @@ -18,8 +23,12 @@ function dbclean_run(&$argv, &$argc) { unset($db_host, $db_user, $db_pass, $db_data); } - load_config('config'); - load_config('system'); + Config::load('config'); + Config::load('system'); + + if (!Config::get('system', 'dbclean', false)) { + return; + } if ($argc == 2) { $stage = intval($argv[1]); @@ -27,7 +36,7 @@ function dbclean_run(&$argv, &$argc) { $stage = 0; } - if (get_config("system", "worker") AND ($stage == 0)) { + if (Config::get("system", "worker") AND ($stage == 0)) { proc_run(PRIORITY_LOW, 'include/dbclean.php', 1); proc_run(PRIORITY_LOW, 'include/dbclean.php', 2); proc_run(PRIORITY_LOW, 'include/dbclean.php', 3); @@ -48,11 +57,18 @@ function remove_orphans($stage = 0) { $count = 0; + // With activated worker we split the deletion in many small tasks + if (Config::get("system", "worker")) { + $limit = 1000; + } else { + $limit = 10000; + } + if (($stage == 1) OR ($stage == 0)) { logger("Deleting old global item entries from item table without user copy"); if ($db->q("SELECT `id` FROM `item` WHERE `uid` = 0 AND NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0) - AND `received` < UTC_TIMESTAMP() - INTERVAL 90 DAY LIMIT 10000", true)) { + AND `received` < UTC_TIMESTAMP() - INTERVAL 90 DAY LIMIT ".intval($limit), true)) { $count = $db->num_rows(); logger("found global item orphans: ".$count); while ($orphan = $db->qfetch()) { @@ -65,7 +81,7 @@ function remove_orphans($stage = 0) { if (($stage == 2) OR ($stage == 0)) { logger("Deleting items without parents"); - if ($db->q("SELECT `id` FROM `item` WHERE NOT EXISTS (SELECT `id` FROM `item` AS `i` WHERE `item`.`parent` = `i`.`id`) LIMIT 10000", true)) { + if ($db->q("SELECT `id` FROM `item` WHERE NOT EXISTS (SELECT `id` FROM `item` AS `i` WHERE `item`.`parent` = `i`.`id`) LIMIT ".intval($limit), true)) { $count = $db->num_rows(); logger("found item orphans without parents: ".$count); while ($orphan = $db->qfetch()) { @@ -78,7 +94,7 @@ function remove_orphans($stage = 0) { if (($stage == 3) OR ($stage == 0)) { logger("Deleting orphaned data from thread table"); - if ($db->q("SELECT `iid` FROM `thread` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `thread`.`iid`)", true)) { + if ($db->q("SELECT `iid` FROM `thread` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `thread`.`iid`) LIMIT ".intval($limit), true)) { $count = $db->num_rows(); logger("found thread orphans: ".$count); while ($orphan = $db->qfetch()) { @@ -91,7 +107,7 @@ function remove_orphans($stage = 0) { if (($stage == 4) OR ($stage == 0)) { logger("Deleting orphaned data from notify table"); - if ($db->q("SELECT `iid` FROM `notify` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `notify`.`iid`)", true)) { + if ($db->q("SELECT `iid` FROM `notify` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `notify`.`iid`) LIMIT ".intval($limit), true)) { $count = $db->num_rows(); logger("found notify orphans: ".$count); while ($orphan = $db->qfetch()) { @@ -104,7 +120,7 @@ function remove_orphans($stage = 0) { if (($stage == 5) OR ($stage == 0)) { logger("Deleting orphaned data from notify-threads table"); - if ($db->q("SELECT `id` FROM `notify-threads` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `notify-threads`.`master-parent-item`)", true)) { + if ($db->q("SELECT `id` FROM `notify-threads` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `notify-threads`.`master-parent-item`) LIMIT ".intval($limit), true)) { $count = $db->num_rows(); logger("found notify-threads orphans: ".$count); while ($orphan = $db->qfetch()) { @@ -118,7 +134,7 @@ function remove_orphans($stage = 0) { if (($stage == 6) OR ($stage == 0)) { logger("Deleting orphaned data from sign table"); - if ($db->q("SELECT `iid` FROM `sign` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `sign`.`iid`)", true)) { + if ($db->q("SELECT `iid` FROM `sign` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `sign`.`iid`) LIMIT ".intval($limit), true)) { $count = $db->num_rows(); logger("found sign orphans: ".$count); while ($orphan = $db->qfetch()) { @@ -132,7 +148,7 @@ function remove_orphans($stage = 0) { if (($stage == 7) OR ($stage == 0)) { logger("Deleting orphaned data from term table"); - if ($db->q("SELECT `oid` FROM `term` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `term`.`oid`)", true)) { + if ($db->q("SELECT `oid` FROM `term` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `term`.`oid`) LIMIT ".intval($limit), true)) { $count = $db->num_rows(); logger("found term orphans: ".$count); while ($orphan = $db->qfetch()) { @@ -144,8 +160,8 @@ function remove_orphans($stage = 0) { } // Call it again if not all entries were purged - if (($stage != 0) AND ($count > 0) AND get_config("system", "worker")) { - proc_run(PRIORITY_LOW, 'include/dbclean.php'); + if (($stage != 0) AND ($count > 0) AND Config::get("system", "worker")) { + proc_run(PRIORITY_MEDIUM, 'include/dbclean.php'); } } diff --git a/include/dbstructure.php b/include/dbstructure.php index 4a8bac1982..5c89f49fb9 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -586,9 +586,16 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "uid" => array("uid"), - "addr_uid" => array("addr", "uid"), - "nurl" => array("nurl"), + "uid_name" => array("uid", "name"), + "uid_self" => array("uid", "self"), + "alias_uid" => array("alias(32)", "uid"), + "uid_pending" => array("uid", "pending"), + "uid_blocked" => array("uid", "blocked"), + "uid_rel_network_poll" => array("uid", "rel", "network", "poll(64)", "archive"), + "uid_network_batch" => array("uid", "network", "batch(64)"), + "addr_uid" => array("addr(32)", "uid"), + "nurl_uid" => array("nurl(32)", "uid"), + "nick_uid" => array("nick(32)", "uid"), ) ); $database["conv"] = array( @@ -644,7 +651,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "uid" => array("uid"), + "uid_start" => array("uid", "start"), ) ); $database["fcontact"] = array( @@ -669,7 +676,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "addr" => array("addr"), + "addr" => array("addr(32)"), ) ); $database["ffinder"] = array( @@ -692,7 +699,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "server" => array("server"), + "server" => array("server(32)"), ) ); $database["fsuggest"] = array( @@ -754,10 +761,10 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "nurl" => array("nurl"), - "name" => array("name"), - "nick" => array("nick"), - "addr" => array("addr"), + "nurl" => array("nurl(32)"), + "name" => array("name(32)"), + "nick" => array("nick(32)"), + "addr" => array("addr(32)"), "updated" => array("updated"), ) ); @@ -772,7 +779,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"), + "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"), "gcid" => array("gcid"), "zcid" => array("zcid"), ) @@ -799,7 +806,9 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "uid_gid_contactid" => array("uid","gid","contact-id"), + "gid_contactid" => array("gid", "contact-id"), + "uid_contactid" => array("uid", "contact-id"), + "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"), ) ); $database["gserver"] = array( @@ -822,7 +831,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "nurl" => array("nurl"), + "nurl" => array("nurl(32)"), ) ); $database["hook"] = array( @@ -937,24 +946,17 @@ function db_definition($charset) { "uid_network_received" => array("uid","network","received"), "uid_received" => array("uid","received"), "uid_network_commented" => array("uid","network","commented"), - "uid_commented" => array("uid","commented"), "uid_title" => array("uid","title"), "uid_thrparent" => array("uid","thr-parent"), "uid_parenturi" => array("uid","parent-uri"), "uid_contactid_id" => array("uid","contact-id","id"), "uid_contactid_created" => array("uid","contact-id","created"), - "gcontactid_uid_created" => array("gcontact-id","uid","created"), "authorid_created" => array("author-id","created"), - "ownerid_created" => array("owner-id","created"), - "wall_body" => array("wall","body(6)"), - "uid_visible_moderated_created" => array("uid","visible","moderated","created"), "uid_uri" => array("uid", "uri"), "uid_wall_created" => array("uid","wall","created"), "resource-id" => array("resource-id"), "uid_type" => array("uid","type"), - "uid_starred_id" => array("uid","starred", "id"), "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), - "uid_wall_parent_created" => array("uid","wall","parent","created"), "uid_type_changed" => array("uid","type","changed"), "contactid_verb" => array("contact-id","verb"), "deleted_changed" => array("deleted","changed"), @@ -976,7 +978,7 @@ function db_definition($charset) { "PRIMARY" => array("id"), "uid" => array("uid"), "sid" => array("sid"), - "service" => array("service"), + "service" => array("service(32)"), "iid" => array("iid"), ) ); @@ -1014,11 +1016,10 @@ function db_definition($charset) { "indexes" => array( "PRIMARY" => array("id"), "uid" => array("uid"), - "guid" => array("guid"), + "uid_seen" => array("uid", "seen"), "convid" => array("convid"), - "reply" => array("reply"), - "uri" => array("uri"), - "parent-uri" => array("parent-uri"), + "uri" => array("uri(64)"), + "parent-uri" => array("parent-uri(64)"), ) ); $database["mailacct"] = array( @@ -1074,7 +1075,11 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "uid" => array("uid"), + "uid_hash" => array("uid", "hash"), + "uid_seen_date" => array("uid", "seen", "date"), + "uid_type_link" => array("uid", "type", "link"), + "uid_link" => array("uid", "link"), + "uid_date" => array("uid", "date"), ) ); $database["notify-threads"] = array( @@ -1088,7 +1093,6 @@ function db_definition($charset) { "indexes" => array( "PRIMARY" => array("id"), "master-parent-item" => array("master-parent-item"), - "receiver-uid" => array("receiver-uid"), ) ); $database["oembed"] = array( @@ -1157,9 +1161,9 @@ function db_definition($charset) { "PRIMARY" => array("id"), "uid_contactid" => array("uid", "contact-id"), "uid_profile" => array("uid", "profile"), - "uid_album_created" => array("uid", "album", "created"), - "resource-id" => array("resource-id"), - "guid" => array("guid"), + "uid_album_created" => array("uid", "album(32)", "created"), + "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"), + "resource-id" => array("resource-id(64)"), ) ); $database["poll"] = array( @@ -1252,7 +1256,6 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "hometown" => array("hometown"), ) ); $database["profile_check"] = array( @@ -1325,7 +1328,6 @@ function db_definition($charset) { "indexes" => array( "PRIMARY" => array("id"), "uid" => array("uid"), - "term" => array("term"), ) ); $database["session"] = array( @@ -1337,7 +1339,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "sid" => array("sid"), + "sid" => array("sid(64)"), "expire" => array("expire"), ) ); @@ -1389,12 +1391,11 @@ function db_definition($charset) { "indexes" => array( "PRIMARY" => array("tid"), "oid_otype_type_term" => array("oid","otype","type","term"), - "uid_term_tid" => array("uid","term","tid"), - "type_term" => array("type","term"), - "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"), - "otype_type_term_tid" => array("otype","type","term","tid"), - "uid_otype_type_url" => array("uid","otype","type","url"), - "guid" => array("guid"), + "uid_term_tid" => array("uid","term(32)","tid"), + "type_term" => array("type","term(32)"), + "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"), + "uid_otype_type_url" => array("uid","otype","type","url(64)"), + "guid" => array("guid(64)"), ) ); $database["thread"] = array( @@ -1434,9 +1435,6 @@ function db_definition($charset) { "uid_network_created" => array("uid","network","created"), "uid_contactid_commented" => array("uid","contact-id","commented"), "uid_contactid_created" => array("uid","contact-id","created"), - "uid_gcontactid_commented" => array("uid","gcontact-id","commented"), - "uid_gcontactid_created" => array("uid","gcontact-id","created"), - "wall_private_received" => array("wall","private","received"), "uid_created" => array("uid","created"), "uid_commented" => array("uid","commented"), ) @@ -1502,7 +1500,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("uid"), - "nickname" => array("nickname"), + "nickname" => array("nickname(32)"), ) ); $database["userd"] = array( @@ -1512,7 +1510,7 @@ function db_definition($charset) { ), "indexes" => array( "PRIMARY" => array("id"), - "username" => array("username"), + "username" => array("username(32)"), ) ); $database["workerqueue"] = array( diff --git a/include/diaspora.php b/include/diaspora.php index db2cca471b..fc88c79bf2 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -325,8 +325,9 @@ class Diaspora { logger("delivering to: ".$rr["username"]); self::dispatch($rr,$msg); } - } else - logger("No subscribers for ".$msg["author"]." ".print_r($msg, true)); + } else { + logger("No subscribers for ".$msg["author"]." ".print_r($msg, true), LOGGER_DEBUG); + } return $message_id; } @@ -736,13 +737,28 @@ class Diaspora { * @return The contact id */ private static function contact_by_handle($uid, $handle) { + + // First do a direct search on the contact table $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `addr` = '%s' LIMIT 1", intval($uid), dbesc($handle) ); - if ($r) + if (dbm::is_result($r)) { return $r[0]; + } else { + // We haven't found it? + // We use another function for it that will possibly create a contact entry + $cid = get_contact($handle, $uid); + + if ($cid > 0) { + $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid)); + + if (dbm::is_result($r)) { + return $r[0]; + } + } + } $handle_parts = explode("@", $handle); $nurl_sql = "%%://".$handle_parts[1]."%%/profile/".$handle_parts[0]; @@ -751,9 +767,11 @@ class Diaspora { intval($uid), dbesc($nurl_sql) ); - if($r) + if (dbm::is_result($r)) { return $r[0]; + } + logger("Haven't found contact for user ".$uid." and handle ".$handle, LOGGER_DEBUG); return false; } @@ -833,7 +851,7 @@ class Diaspora { dbesc($guid) ); - if ($r) { + if (dbm::is_result($r)) { logger("message ".$guid." already exists for user ".$uid); return $r[0]["id"]; } diff --git a/include/enotify.php b/include/enotify.php index aa29e117a6..ebc27309db 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -105,7 +105,7 @@ function notification($params) { // If so don't create a second notification $p = null; - $p = q("SELECT `id` FROM `notify` WHERE (`type` = %d OR `type` = %d OR `type` = %d) AND `link` = '%s' AND `uid` = %d LIMIT 1", + $p = q("SELECT `id` FROM `notify` WHERE `type` IN (%d, %d, %d) AND `link` = '%s' AND `uid` = %d LIMIT 1", intval(NOTIFY_TAGSELF), intval(NOTIFY_COMMENT), intval(NOTIFY_SHARE), @@ -472,7 +472,7 @@ function notification($params) { // After we've stored everything, look again to see if there are any duplicates and if so remove them $p = null; - $p = q("SELECT `id` FROM `notify` WHERE (`type` = %d OR `type` = %d) AND `link` = '%s' AND `uid` = %d ORDER BY `id`", + $p = q("SELECT `id` FROM `notify` WHERE `type` IN (%d, %d) AND `link` = '%s' AND `uid` = %d ORDER BY `id`", intval(NOTIFY_TAGSELF), intval(NOTIFY_COMMENT), dbesc($params['link']), diff --git a/include/event.php b/include/event.php index a1ff9bb336..616018bb77 100644 --- a/include/event.php +++ b/include/event.php @@ -206,7 +206,7 @@ function bbtoevent($s) { } -function sort_by_date(App &$a) { +function sort_by_date(App $a) { usort($a,'ev_compare'); return $a; @@ -495,7 +495,7 @@ function get_event_strings() { /** * @brief Get an event by its event ID - * + * * @param type $owner_uid The User ID of the owner of the event * @param type $event_params An assoziative array with * int 'event_id' => The ID of the event in the event table @@ -523,15 +523,15 @@ function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') { /** * @brief Get all events in a specific timeframe - * + * * @param int $owner_uid The User ID of the owner of the events * @param array $event_params An assoziative array with - * int 'ignored' => + * int 'ignored' => * string 'start' => Start time of the timeframe * string 'finish' => Finish time of the timeframe - * string 'adjust_start' => * string 'adjust_start' => - * + * string 'adjust_start' => + * * @param string $sql_extra Additional sql conditions (e.g. permission request) * @return array Query results */ @@ -564,7 +564,7 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') { /** * @brief Convert an array query results in an arry which could be used by the events template - * + * * @param array $arr Event query array * @return array Event array for the template */ @@ -623,11 +623,11 @@ function process_events ($arr) { /** * @brief Format event to export format (ical/csv) - * + * * @param array $events Query result for events * @param string $format The output format (ical/csv) * @param string $timezone The timezone of the user (not implemented yet) - * + * * @return string Content according to selected export format */ function event_format_export ($events, $format = 'ical', $timezone) { @@ -641,7 +641,7 @@ function event_format_export ($events, $format = 'ical', $timezone) { $o = '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL; foreach ($events as $event) { - /// @todo the time / date entries don't include any information about the + /// @todo the time / date entries don't include any information about the // timezone the event is scheduled in :-/ $tmp1 = strtotime($event['start']); $tmp2 = strtotime($event['finish']); @@ -650,7 +650,7 @@ function event_format_export ($events, $format = 'ical', $timezone) { $o .= '"'.$event['summary'].'", "'.strftime($date_format, $tmp1) . '", "'.strftime($time_format, $tmp1).'", "'.$event['desc'] . '", "'.strftime($date_format, $tmp2) . - '", "'.strftime($time_format, $tmp2) . + '", "'.strftime($time_format, $tmp2) . '", "'.$event['location'].'"' . PHP_EOL; } break; @@ -672,7 +672,7 @@ function event_format_export ($events, $format = 'ical', $timezone) { foreach ($events as $event) { if ($event['adjust'] == 1) { $UTC = 'Z'; - } else { + } else { $UTC = ''; } $o .= 'BEGIN:VEVENT' . PHP_EOL; @@ -716,16 +716,16 @@ function event_format_export ($events, $format = 'ical', $timezone) { /** * @brief Get all events for a user ID - * + * * The query for events is done permission sensitive * If the user is the owner of the calendar he/she * will get all of his/her available events. * If the user is only a visitor only the public events will * be available - * + * * @param int $uid The user ID * @param int $sql_extra Additional sql conditions for permission - * + * * @return array Query results */ function events_by_uid($uid = 0, $sql_extra = '') { @@ -736,8 +736,8 @@ function events_by_uid($uid = 0, $sql_extra = '') { if($sql_extra == '') $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' "; - // does the user who requests happen to be the owner of the events - // requested? then show all of your events, otherwise only those that + // does the user who requests happen to be the owner of the events + // requested? then show all of your events, otherwise only those that // don't have limitations set in allow_cid and allow_gid if (local_user() == $uid) { $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location`, `nofinish` @@ -756,7 +756,7 @@ function events_by_uid($uid = 0, $sql_extra = '') { } /** - * + * * @param int $uid The user ID * @param string $format Output format (ical/csv) * @return array With the results @@ -764,7 +764,7 @@ function events_by_uid($uid = 0, $sql_extra = '') { * string 'format' => The output format * string 'extension' => The file extension of the output format * string 'content' => The formatted output content - * + * * @todo Respect authenticated users with events_by_uid() */ function event_export($uid, $format = 'ical') { @@ -815,7 +815,7 @@ function event_export($uid, $format = 'ical') { /** * @brief Get the events widget - * + * * @return string Formated html of the evens widget */ function widget_events() { @@ -835,11 +835,11 @@ function widget_events() { // Cal logged in user (test permission at foreign profile page) // If the $owner uid is available we know it is part of one of the profile pages (like /cal) - // So we have to test if if it's the own profile page of the logged in user + // So we have to test if if it's the own profile page of the logged in user // or a foreign one. For foreign profile pages we need to check if the feature // for exporting the cal is enabled (otherwise the widget would appear for logged in users // on foreigen profile pages even if the widget is disabled) - if(intval($owner_uid) && local_user() !== $owner_uid && ! feature_enabled($owner_uid, "export_calendar")) + if(intval($owner_uid) && local_user() !== $owner_uid && ! feature_enabled($owner_uid, "export_calendar")) return; // If it's a kind of profile page (intval($owner_uid)) return if the user not logged in and diff --git a/include/identity.php b/include/identity.php index a302dc34cd..c18bc3a805 100644 --- a/include/identity.php +++ b/include/identity.php @@ -31,7 +31,7 @@ require_once("mod/proxy.php"); * @param int $profile * @param array $profiledata */ -function profile_load(&$a, $nickname, $profile = 0, $profiledata = array()) { +function profile_load(App $a, $nickname, $profile = 0, $profiledata = array()) { $user = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1", dbesc($nickname) @@ -118,12 +118,12 @@ function profile_load(&$a, $nickname, $profile = 0, $profiledata = array()) { /** * @brief Get all profil data of a local user - * + * * If the viewer is an authenticated remote viewer, the profile displayed is the * one that has been configured for his/her viewing in the Contact manager. * Passing a non-zero profile ID can also allow a preview of a selected profile * by the owner - * + * * @param string $nickname * @param int $uid * @param int $profile @@ -177,17 +177,17 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) { /** * @brief Formats a profile for display in the sidebar. - * + * * It is very difficult to templatise the HTML completely * because of all the conditional logic. - * + * * @param array $profile * @param int $block - * + * * @return HTML string stuitable for sidebar inclusion - * + * * @note Returns empty string if passed $profile is wrong type or not populated - * + * * @hooks 'profile_sidebar_enter' * array $profile - profile data * @hooks 'profile_sidebar' @@ -598,7 +598,7 @@ function get_events() { )); } -function advanced_profile(App &$a) { +function advanced_profile(App $a) { $o = ''; $uid = $a->profile['uid']; @@ -755,7 +755,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ array( 'label'=>t('Status'), 'url' => $url, - 'sel' => ((!isset($tab)&&$a->argv[0]=='profile')?'active':''), + 'sel' => ((!isset($tab) && $a->argv[0]=='profile')?'active':''), 'title' => t('Status Messages and Posts'), 'id' => 'status-tab', 'accesskey' => 'm', @@ -771,7 +771,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ array( 'label' => t('Photos'), 'url' => App::get_baseurl() . '/photos/' . $nickname, - 'sel' => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''), + 'sel' => ((!isset($tab) && $a->argv[0]=='photos')?'active':''), 'title' => t('Photo Albums'), 'id' => 'photo-tab', 'accesskey' => 'h', @@ -779,7 +779,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ array( 'label' => t('Videos'), 'url' => App::get_baseurl() . '/videos/' . $nickname, - 'sel' => ((!isset($tab)&&$a->argv[0]=='videos')?'active':''), + 'sel' => ((!isset($tab) && $a->argv[0]=='videos')?'active':''), 'title' => t('Videos'), 'id' => 'video-tab', 'accesskey' => 'v', @@ -791,7 +791,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ $tabs[] = array( 'label' => t('Events'), 'url' => App::get_baseurl() . '/events', - 'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''), + 'sel' =>((!isset($tab) && $a->argv[0]=='events')?'active':''), 'title' => t('Events and Calendar'), 'id' => 'events-tab', 'accesskey' => 'e', @@ -802,7 +802,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ $tabs[] = array( 'label' => t('Events'), 'url' => App::get_baseurl() . '/cal/' . $nickname, - 'sel' =>((!isset($tab)&&$a->argv[0]=='cal')?'active':''), + 'sel' =>((!isset($tab) && $a->argv[0]=='cal')?'active':''), 'title' => t('Events and Calendar'), 'id' => 'events-tab', 'accesskey' => 'e', @@ -813,7 +813,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ $tabs[] = array( 'label' => t('Personal Notes'), 'url' => App::get_baseurl() . '/notes', - 'sel' =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''), + 'sel' =>((!isset($tab) && $a->argv[0]=='notes')?'active':''), 'title' => t('Only You Can See This'), 'id' => 'notes-tab', 'accesskey' => 't', @@ -824,7 +824,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ $tabs[] = array( 'label' => t('Contacts'), 'url' => App::get_baseurl() . '/viewcontacts/' . $nickname, - 'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''), + 'sel' => ((!isset($tab) && $a->argv[0]=='viewcontacts')?'active':''), 'title' => t('Contacts'), 'id' => 'viewcontacts-tab', 'accesskey' => 'k', @@ -845,7 +845,7 @@ function get_my_url() { return false; } -function zrl_init(App &$a) { +function zrl_init(App $a) { $tmp_str = get_my_url(); if(validate_url($tmp_str)) { @@ -891,7 +891,7 @@ function zrl($s,$force = false) { * settings except their own while on this site. * * @return int user ID - * + * * @note Returns local_user instead of user ID if "always_my_theme" * is set to true */ diff --git a/include/nav.php b/include/nav.php index bd933929d3..fe4c50818e 100644 --- a/include/nav.php +++ b/include/nav.php @@ -1,6 +1,6 @@ 0 ? gps2Num($exifCoord[0]) : 0; $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0; @@ -42,16 +45,28 @@ function photo_albums($uid, $update = false) { $key = "photo_albums:".$uid.":".local_user().":".remote_user(); $albums = Cache::get($key); if (is_null($albums) OR $update) { - /// @todo This query needs to be renewed. It is really slow - // At this time we just store the data in the cache - $albums = qu("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album` - FROM `photo` USE INDEX (`uid_album_created`) - WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra - GROUP BY `album` ORDER BY `created` DESC", - intval($uid), - dbesc('Contact Photos'), - dbesc(t('Contact Photos')) - ); + if (!Config::get('system', 'no_count', false)) { + /// @todo This query needs to be renewed. It is really slow + // At this time we just store the data in the cache + $albums = qu("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album` + FROM `photo` USE INDEX (`uid_album_created`) + WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra + GROUP BY `album` ORDER BY `created` DESC", + intval($uid), + dbesc('Contact Photos'), + dbesc(t('Contact Photos')) + ); + } else { + // This query doesn't do the count and is much faster + $albums = qu("SELECT DISTINCT(`album`), '' AS `total` + FROM `photo` USE INDEX (`uid_album_created`) + WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra + GROUP BY `album` ORDER BY `created` DESC", + intval($uid), + dbesc('Contact Photos'), + dbesc(t('Contact Photos')) + ); + } Cache::set($key, $albums, CACHE_DAY); } return $albums; diff --git a/include/plaintext.php b/include/plaintext.php index 8302728679..632abf30cb 100644 --- a/include/plaintext.php +++ b/include/plaintext.php @@ -296,7 +296,7 @@ function shortenmsg($msg, $limit, $twitter = false) { * * @return string The converted message */ -function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2, $target_network = "") { +function plaintext(App $a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2, $target_network = "") { // Remove the hash tags $URLSearchString = "^\[\]"; diff --git a/include/redir.php b/include/redir.php index d8bb764396..76e30a6eac 100644 --- a/include/redir.php +++ b/include/redir.php @@ -1,6 +1,6 @@ user['nickname']), - dbesc($baseurl), - dbesc($nurl) + /// @todo Why is there a query for "url" *and* "nurl"? Especially this normalising is strange. + $r = q("SELECT `id` FROM `contact` WHERE `uid` = (SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1) + AND `nick` = '%s' AND NOT `self` AND (`url` LIKE '%%%s%%' OR `nurl` LIKE '%%%s%%') AND NOT `blocked` AND NOT `pending` LIMIT 1", + dbesc($contact_nick), + dbesc($a->user['nickname']), + dbesc($baseurl), + dbesc($nurl) ); if ((! dbm::is_result($r)) || $r[0]['id'] == remote_user()) { @@ -70,7 +70,7 @@ function auto_redir(&$a, $contact_nick) { if(strlen($dfrn_id) < 3) return; - + $sec = random_string(); q("INSERT INTO `profile_check` ( `uid`, `cid`, `dfrn_id`, `sec`, `expire`) @@ -84,9 +84,9 @@ function auto_redir(&$a, $contact_nick) { $url = curPageURL(); - logger('auto_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG); + logger('auto_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG); $dest = (($url) ? '&destination_url=' . $url : ''); - goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id + goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest ); } diff --git a/include/security.php b/include/security.php index cd00b5f7b0..c379518562 100644 --- a/include/security.php +++ b/include/security.php @@ -106,7 +106,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive -function can_write_wall(&$a,$owner) { +function can_write_wall(App $a, $owner) { static $verified = 0; @@ -148,8 +148,8 @@ function can_write_wall(&$a,$owner) { return false; } - $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid` - WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid` + WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1", intval($owner), intval($cid), @@ -183,10 +183,10 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) { * default permissions - anonymous user */ - $sql = " AND allow_cid = '' - AND allow_gid = '' - AND deny_cid = '' - AND deny_gid = '' + $sql = " AND allow_cid = '' + AND allow_gid = '' + AND deny_cid = '' + AND deny_gid = '' "; /** @@ -194,11 +194,11 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) { */ if(($local_user) && ($local_user == $owner_id)) { - $sql = ''; + $sql = ''; } /** - * Authenticated visitor. Unless pre-verified, + * Authenticated visitor. Unless pre-verified, * check that the contact belongs to this $owner_id * and load the groups the visitor belongs to. * If pre-verified, the caller is expected to have already @@ -224,11 +224,11 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) { if(is_array($groups) && count($groups)) { foreach($groups as $g) $gs .= '|<' . intval($g) . '>'; - } + } /*$sql = sprintf( - " AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' ) - AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) + " AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' ) + AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) AND ( allow_gid = '' OR allow_gid REGEXP '%s' ) AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s') ", @@ -280,7 +280,7 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) } /** - * Authenticated visitor. Unless pre-verified, + * Authenticated visitor. Unless pre-verified, * check that the contact belongs to this $owner_id * and load the groups the visitor belongs to. * If pre-verified, the caller is expected to have already @@ -306,13 +306,13 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) if(is_array($groups) && count($groups)) { foreach($groups as $g) $gs .= '|<' . intval($g) . '>'; - } + } $sql = sprintf( - /*" AND ( private = 0 OR ( private in (1,2) AND wall = 1 AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' ) - AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) + /*" AND ( private = 0 OR ( private in (1,2) AND wall = 1 AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' ) + AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) AND ( allow_gid = '' OR allow_gid REGEXP '%s' ) - AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s'))) + AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s'))) ", intval($remote_user), intval($remote_user), @@ -345,29 +345,29 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) * If the new page contains by any chance external elements, then the used security token is exposed by the referrer. * Actually, important actions should not be triggered by Links / GET-Requests at all, but somethimes they still are, * so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types). - */ + */ function get_form_security_token($typename = '') { $a = get_app(); - + $timestamp = time(); $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $timestamp . $typename); - + return $timestamp . '.' . $sec_hash; } function check_form_security_token($typename = '', $formname = 'form_security_token') { if (!x($_REQUEST, $formname)) return false; $hash = $_REQUEST[$formname]; - + $max_livetime = 10800; // 3 hours - + $a = get_app(); - + $x = explode('.', $hash); if (time() > (IntVal($x[0]) + $max_livetime)) return false; - + $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $x[0] . $typename); - + return ($sec_hash == $x[1]); } @@ -395,13 +395,13 @@ function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'f // Returns an array of group id's this contact is a member of. // This array will only contain group id's related to the uid of this -// DFRN contact. They are *not* neccessarily unique across the entire site. +// DFRN contact. They are *not* neccessarily unique across the entire site. if(! function_exists('init_groups_visitor')) { function init_groups_visitor($contact_id) { $groups = array(); - $r = q("SELECT `gid` FROM `group_member` + $r = q("SELECT `gid` FROM `group_member` WHERE `contact-id` = %d ", intval($contact_id) ); diff --git a/include/text.php b/include/text.php index 6672b0d32f..77a9f25af9 100644 --- a/include/text.php +++ b/include/text.php @@ -276,7 +276,7 @@ if(! function_exists('paginate_data')) { * @param int $count [optional] item count (used with alt pager) * @return Array data for pagination template */ -function paginate_data(&$a, $count=null) { +function paginate_data(App $a, $count=null) { $stripped = preg_replace('/([&?]page=[0-9]*)/','',$a->query_string); $stripped = str_replace('q=','',$stripped); @@ -369,7 +369,7 @@ if(! function_exists('paginate')) { * @param App $a App instance * @return string html for pagination #FIXME remove html */ -function paginate(App &$a) { +function paginate(App $a) { $data = paginate_data($a); $tpl = get_markup_template("paginate.tpl"); @@ -384,7 +384,7 @@ if(! function_exists('alt_pager')) { * @param int $i * @return string html for pagination #FIXME remove html */ -function alt_pager(&$a, $i) { +function alt_pager(App $a, $i) { $data = paginate_data($a, $i); $tpl = get_markup_template("paginate.tpl"); diff --git a/include/uimport.php b/include/uimport.php index 0d9ffc35fc..b774d78c6d 100644 --- a/include/uimport.php +++ b/include/uimport.php @@ -78,7 +78,7 @@ function import_cleanup($newuid) { q("DELETE FROM `pconfig` WHERE uid = %d", $newuid); } -function import_account(&$a, $file) { +function import_account(App $a, $file) { logger("Start user import from " . $file['tmp_name']); /* STEPS diff --git a/mod/_well_known.php b/mod/_well_known.php index eedddf1e5b..75948a0088 100644 --- a/mod/_well_known.php +++ b/mod/_well_known.php @@ -3,7 +3,7 @@ require_once("mod/hostxrd.php"); require_once("mod/nodeinfo.php"); -function _well_known_init(App &$a){ +function _well_known_init(App $a) { if ($a->argc > 1) { switch($a->argv[1]) { case "host-meta": @@ -21,7 +21,7 @@ function _well_known_init(App &$a){ killme(); } -function wk_social_relay(App &$a) { +function wk_social_relay(App $a) { define('SR_SCOPE_ALL', 'all'); define('SR_SCOPE_TAGS', 'tags'); diff --git a/mod/acctlink.php b/mod/acctlink.php index 29f17d6e41..892b59655f 100644 --- a/mod/acctlink.php +++ b/mod/acctlink.php @@ -2,7 +2,7 @@ require_once('include/Scrape.php'); -function acctlink_init(App &$a) { +function acctlink_init(App $a) { if(x($_GET,'addr')) { $addr = trim($_GET['addr']); diff --git a/mod/acl.php b/mod/acl.php index 802b0a399f..04aa9f50a6 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -3,7 +3,7 @@ require_once("include/acl_selectors.php"); -function acl_init(App &$a){ +function acl_init(App $a) { acl_lookup($a); } diff --git a/mod/admin.php b/mod/admin.php index fd57f92d5f..b1bc96fd4f 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -2,7 +2,7 @@ /** * @file mod/admin.php - * + * * @brief Friendica admin */ @@ -23,7 +23,7 @@ require_once("include/text.php"); * @param App $a * */ -function admin_post(App &$a){ +function admin_post(App $a) { if(!is_site_admin()) { @@ -66,7 +66,7 @@ function admin_post(App &$a){ $theme = $a->argv[2]; if(is_file("view/theme/$theme/config.php")){ - function __call_theme_admin_post(&$a, $theme) { + function __call_theme_admin_post(App $a, $theme) { $orig_theme = $a->theme; $orig_page = $a->page; $orig_session_theme = $_SESSION['theme']; @@ -127,7 +127,7 @@ function admin_post(App &$a){ * @param App $a * @return string */ -function admin_content(App &$a) { +function admin_content(App $a) { if(!is_site_admin()) { return login(false); @@ -260,7 +260,7 @@ function admin_content(App &$a) { * @param App $a * @return string */ -function admin_page_federation(App &$a) { +function admin_page_federation(App $a) { // get counts on active friendica, diaspora, redmatrix, hubzilla, gnu // social and statusnet nodes this node is knowing // @@ -316,12 +316,12 @@ function admin_page_federation(App &$a) { $newVC = $vv['total']; $newVV = $vv['version']; $posDash = strpos($newVV, '-'); - if($posDash) + if($posDash) $newVV = substr($newVV, 0, $posDash); if(isset($newV[$newVV])) - $newV[$newVV] += $newVC; + $newV[$newVV] += $newVC; else - $newV[$newVV] = $newVC; + $newV[$newVV] = $newVC; } foreach ($newV as $key => $value) { array_push($newVv, array('total'=>$value, 'version'=>$key)); @@ -393,7 +393,7 @@ function admin_page_federation(App &$a) { * @param App $a * @return string */ -function admin_page_queue(App &$a) { +function admin_page_queue(App $a) { // get content from the queue table $r = q("SELECT `c`.`name`, `c`.`nurl`, `q`.`id`, `q`.`network`, `q`.`created`, `q`.`last` FROM `queue` AS `q`, `contact` AS `c` @@ -427,7 +427,7 @@ function admin_page_queue(App &$a) { * @param App $a * @return string */ -function admin_page_summary(App &$a) { +function admin_page_summary(App $a) { global $db; // are there MyISAM tables in the DB? If so, trigger a warning message $r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1", @@ -501,10 +501,10 @@ function admin_page_summary(App &$a) { /** * @brief Process send data from Admin Site Page - * + * * @param App $a */ -function admin_page_site_post(App &$a) { +function admin_page_site_post(App $a) { if(!x($_POST,"page_site")) { return; } @@ -845,7 +845,7 @@ function admin_page_site_post(App &$a) { * @param App $a * @return string */ -function admin_page_site(App &$a) { +function admin_page_site(App $a) { /* Installed langs */ $lang_choices = get_available_languages(); @@ -1072,7 +1072,7 @@ function admin_page_site(App &$a) { * @param App $a * @return string **/ -function admin_page_dbsync(App &$a) { +function admin_page_dbsync(App $a) { $o = ''; @@ -1152,10 +1152,10 @@ function admin_page_dbsync(App &$a) { /** * @brief Process data send by Users admin page - * + * * @param App $a */ -function admin_page_users_post(App &$a){ +function admin_page_users_post(App $a) { $pending = (x($_POST, 'pending') ? $_POST['pending'] : array()); $users = (x($_POST, 'user') ? $_POST['user'] : array()); $nu_name = (x($_POST, 'new_user_name') ? $_POST['new_user_name'] : ''); @@ -1168,7 +1168,7 @@ function admin_page_users_post(App &$a){ if (!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) { require_once('include/user.php'); - $result = create_user(array('username'=>$nu_name, 'email'=>$nu_email, + $result = create_user(array('username'=>$nu_name, 'email'=>$nu_email, 'nickname'=>$nu_nickname, 'verified'=>1, 'language'=>$nu_language)); if (! $result['success']) { notice($result['message']); @@ -1260,7 +1260,7 @@ function admin_page_users_post(App &$a){ * @param App $a * @return string */ -function admin_page_users(App &$a){ +function admin_page_users(App $a) { if($a->argc>2) { $uid = $a->argv[3]; $user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid)); @@ -1396,7 +1396,7 @@ function admin_page_users(App &$a){ array(t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account')), $valid_orders ); - + $t = get_markup_template("admin_users.tpl"); $o = replace_macros($t, array( // strings // @@ -1460,7 +1460,7 @@ function admin_page_users(App &$a){ * @param App $a * @return string */ -function admin_page_plugins(App &$a){ +function admin_page_plugins(App $a) { /* * Single plugin @@ -1588,7 +1588,7 @@ function admin_page_plugins(App &$a){ '$baseurl' => App::get_baseurl(true), '$function' => 'plugins', '$plugins' => $plugins, - '$pcount' => count($plugins), + '$pcount' => count($plugins), '$noplugshint' => sprintf(t('There are currently no plugins available on your node. You can find the official plugin repository at %1$s and might find other interesting plugins in the open plugin registry at %2$s'), 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'), '$form_security_token' => get_form_security_token("admin_themes"), )); @@ -1669,7 +1669,7 @@ function rebuild_theme_table($themes) { * @param App $a * @return string */ -function admin_page_themes(App &$a){ +function admin_page_themes(App $a) { $allowed_themes_str = get_config('system','allowed_themes'); $allowed_themes_raw = explode(',',$allowed_themes_str); @@ -1749,7 +1749,7 @@ function admin_page_themes(App &$a){ $admin_form=""; if(is_file("view/theme/$theme/config.php")) { - function __get_theme_admin_form(&$a, $theme) { + function __get_theme_admin_form(App $a, $theme) { $orig_theme = $a->theme; $orig_page = $a->page; $orig_session_theme = $_SESSION['theme']; @@ -1847,10 +1847,10 @@ function admin_page_themes(App &$a){ /** * @brief Prosesses data send by Logs admin page - * + * * @param App $a */ -function admin_page_logs_post(App &$a) { +function admin_page_logs_post(App $a) { if (x($_POST,"page_logs")) { check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs'); @@ -1884,7 +1884,7 @@ function admin_page_logs_post(App &$a) { * @param App $a * @return string */ -function admin_page_logs(App &$a){ +function admin_page_logs(App $a) { $log_choices = array( LOGGER_NORMAL => 'Normal', @@ -1893,7 +1893,7 @@ function admin_page_logs(App &$a){ LOGGER_DATA => 'Data', LOGGER_ALL => 'All' ); - + if (ini_get('log_errors')) { $phplogenabled = t('PHP log currently enabled.'); } else { @@ -1941,7 +1941,7 @@ function admin_page_logs(App &$a){ * @param App $a * @return string */ -function admin_page_viewlogs(App &$a){ +function admin_page_viewlogs(App $a) { $t = get_markup_template("admin_viewlogs.tpl"); $f = get_config('system','logfile'); $data = ''; @@ -1980,10 +1980,10 @@ function admin_page_viewlogs(App &$a){ /** * @brief Prosesses data send by the features admin page - * + * * @param App $a */ -function admin_page_features_post(App &$a) { +function admin_page_features_post(App $a) { check_form_security_token_redirectOnErr('/admin/features', 'admin_manage_features'); @@ -2017,20 +2017,20 @@ function admin_page_features_post(App &$a) { /** * @brief Subpage for global additional feature management - * + * * This functin generates the subpage 'Manage Additional Features' * for the admin panel. At this page the admin can set preferences - * for the user settings of the 'additional features'. If needed this + * for the user settings of the 'additional features'. If needed this * preferences can be locked through the admin. - * + * * The returned string contains the HTML code of the subpage 'Manage * Additional Features' - * + * * @param App $a * @return string */ -function admin_page_features(App &$a) { - +function admin_page_features(App $a) { + if((argc() > 1) && (argv(1) === 'features')) { $arr = array(); $features = get_features(false); @@ -2049,7 +2049,7 @@ function admin_page_features(App &$a) { ); } } - + $tpl = get_markup_template("admin_settings_features.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("admin_manage_features"), diff --git a/mod/allfriends.php b/mod/allfriends.php index 7a134a7be1..f51070bbe8 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -5,7 +5,7 @@ require_once('include/Contact.php'); require_once('include/contact_selectors.php'); require_once('mod/contacts.php'); -function allfriends_content(App &$a) { +function allfriends_content(App $a) { $o = ''; if (! local_user()) { diff --git a/mod/amcd.php b/mod/amcd.php index 3fcdb42c8d..5f9f97e3f1 100644 --- a/mod/amcd.php +++ b/mod/amcd.php @@ -1,6 +1,6 @@ cmd=='api/oauth/authorize'){ /* * api/oauth/authorize interact with the user. return a standard page diff --git a/mod/apps.php b/mod/apps.php index 4d6395e4ea..199ce0f918 100644 --- a/mod/apps.php +++ b/mod/apps.php @@ -1,6 +1,6 @@ $a->apps, )); - + } diff --git a/mod/attach.php b/mod/attach.php index 3b1fc0ec82..dd7154dfe1 100644 --- a/mod/attach.php +++ b/mod/attach.php @@ -2,7 +2,7 @@ require_once('include/security.php'); -function attach_init(App &$a) { +function attach_init(App $a) { if($a->argc != 2) { notice( t('Item not available.') . EOL); diff --git a/mod/babel.php b/mod/babel.php index 5129f5bf59..e8ea11c94e 100644 --- a/mod/babel.php +++ b/mod/babel.php @@ -9,55 +9,55 @@ function visible_lf($s) { return str_replace("\n",'
', $s); } -function babel_content(App &$a) { +function babel_content(App $a) { $o .= '

Babel Diagnostic

'; $o .= '
'; $o .= t('Source (bbcode) text:') . EOL . '' . EOL; - $o .= '
'; + $o .= ''; $o .= '

'; $o .= '
'; $o .= t('Source (Diaspora) text to convert to BBcode:') . EOL . '' . EOL; - $o .= '
'; + $o .= ''; $o .= '

'; if(x($_REQUEST,'text')) { $text = trim($_REQUEST['text']); - $o .= "

" . t("Source input: ") . "

" . EOL. EOL; - $o .= visible_lf($text) . EOL. EOL; + $o .= "

" . t("Source input: ") . "

" . EOL. EOL; + $o .= visible_lf($text) . EOL. EOL; $html = bbcode($text); - $o .= "

" . t("bb2html (raw HTML): ") . "

" . EOL. EOL; - $o .= htmlspecialchars($html). EOL. EOL; + $o .= "

" . t("bb2html (raw HTML): ") . "

" . EOL. EOL; + $o .= htmlspecialchars($html). EOL. EOL; //$html = bbcode($text); - $o .= "

" . t("bb2html: ") . "

" . EOL. EOL; - $o .= $html. EOL. EOL; + $o .= "

" . t("bb2html: ") . "

" . EOL. EOL; + $o .= $html. EOL. EOL; $bbcode = html2bbcode($html); - $o .= "

" . t("bb2html2bb: ") . "

" . EOL. EOL; - $o .= visible_lf($bbcode) . EOL. EOL; + $o .= "

" . t("bb2html2bb: ") . "

" . EOL. EOL; + $o .= visible_lf($bbcode) . EOL. EOL; $diaspora = bb2diaspora($text); - $o .= "

" . t("bb2md: ") . "

" . EOL. EOL; - $o .= visible_lf($diaspora) . EOL. EOL; + $o .= "

" . t("bb2md: ") . "

" . EOL. EOL; + $o .= visible_lf($diaspora) . EOL. EOL; $html = Markdown($diaspora); - $o .= "

" . t("bb2md2html: ") . "

" . EOL. EOL; - $o .= $html. EOL. EOL; + $o .= "

" . t("bb2md2html: ") . "

" . EOL. EOL; + $o .= $html. EOL. EOL; $bbcode = diaspora2bb($diaspora); - $o .= "

" . t("bb2dia2bb: ") . "

" . EOL. EOL; - $o .= visible_lf($bbcode) . EOL. EOL; + $o .= "

" . t("bb2dia2bb: ") . "

" . EOL. EOL; + $o .= visible_lf($bbcode) . EOL. EOL; $bbcode = html2bbcode($html); - $o .= "

" . t("bb2md2html2bb: ") . "

" . EOL. EOL; - $o .= visible_lf($bbcode) . EOL. EOL; + $o .= "

" . t("bb2md2html2bb: ") . "

" . EOL. EOL; + $o .= visible_lf($bbcode) . EOL. EOL; @@ -66,13 +66,13 @@ function babel_content(App &$a) { if(x($_REQUEST,'d2bbtext')) { $d2bbtext = trim($_REQUEST['d2bbtext']); - $o .= "

" . t("Source input (Diaspora format): ") . "

" . EOL. EOL; - $o .= visible_lf($d2bbtext) . EOL. EOL; + $o .= "

" . t("Source input (Diaspora format): ") . "

" . EOL. EOL; + $o .= visible_lf($d2bbtext) . EOL. EOL; $bb = diaspora2bb($d2bbtext); - $o .= "

" . t("diaspora2bb: ") . "

" . EOL. EOL; - $o .= visible_lf($bb) . EOL. EOL; + $o .= "

" . t("diaspora2bb: ") . "

" . EOL. EOL; + $o .= visible_lf($bb) . EOL. EOL; } return $o; diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php index 9bc8c33535..c4ef845704 100644 --- a/mod/bookmarklet.php +++ b/mod/bookmarklet.php @@ -3,11 +3,11 @@ require_once('include/conversation.php'); require_once('include/items.php'); -function bookmarklet_init(App &$a) { +function bookmarklet_init(App $a) { $_GET["mode"] = "minimal"; } -function bookmarklet_content(App &$a) { +function bookmarklet_content(App $a) { if (!local_user()) { $o = '

'.t('Login').'

'; $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true); diff --git a/mod/cal.php b/mod/cal.php index 7cb36e7a54..b3cd1e3221 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -9,7 +9,7 @@ require_once('include/event.php'); require_once('include/redir.php'); -function cal_init(App &$a) { +function cal_init(App $a) { if($a->argc > 1) auto_redir($a, $a->argv[1]); @@ -64,7 +64,7 @@ function cal_init(App &$a) { return; } -function cal_content(App &$a) { +function cal_content(App $a) { nav_set_selected('events'); $editselect = 'none'; diff --git a/mod/cb.php b/mod/cb.php index 90e41fb6d5..3c5df6e38b 100644 --- a/mod/cb.php +++ b/mod/cb.php @@ -5,19 +5,19 @@ */ -function cb_init(App &$a) { +function cb_init(App $a) { call_hooks('cb_init'); } -function cb_post(App &$a) { +function cb_post(App $a) { call_hooks('cb_post', $_POST); } -function cb_afterpost(App &$a) { +function cb_afterpost(App $a) { call_hooks('cb_afterpost'); } -function cb_content(App &$a) { +function cb_content(App $a) { $o = ''; call_hooks('cb_content', $o); return $o; diff --git a/mod/common.php b/mod/common.php index 26ef7e48b7..5a40663f9e 100644 --- a/mod/common.php +++ b/mod/common.php @@ -5,7 +5,7 @@ require_once('include/Contact.php'); require_once('include/contact_selectors.php'); require_once('mod/contacts.php'); -function common_content(App &$a) { +function common_content(App $a) { $o = ''; diff --git a/mod/community.php b/mod/community.php index 2c2ea32b33..7c92ff462f 100644 --- a/mod/community.php +++ b/mod/community.php @@ -1,6 +1,6 @@ t('Delete'), - 'url' => 'contacts/' . $contact['id'] . '/drop', + 'url' => 'contacts/' . $contact['id'] . '/drop', 'title' => t('Delete contact'), 'sel' => '', 'id' => 'delete', diff --git a/mod/content.php b/mod/content.php index 2377032a79..43f3fc2ba6 100644 --- a/mod/content.php +++ b/mod/content.php @@ -16,7 +16,7 @@ // and 10-20 milliseconds to fetch all the child items. -function content_content(&$a, $update = 0) { +function content_content(App $a, $update = 0) { require_once('include/conversation.php'); @@ -61,7 +61,7 @@ function content_content(&$a, $update = 0) { $o = ''; - + $contact_id = $a->cid; @@ -100,7 +100,7 @@ function content_content(&$a, $update = 0) { $def_acl = array('allow_cid' => $str); } - + $sql_options = (($star) ? " and starred = 1 " : ''); $sql_options .= (($bmark) ? " and bookmark = 1 " : ''); @@ -137,7 +137,7 @@ function content_content(&$a, $update = 0) { } elseif($cid) { - $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d + $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($cid) ); @@ -307,7 +307,7 @@ function content_content(&$a, $update = 0) { -function render_content(&$a, $items, $mode, $update, $preview = false) { +function render_content(App $a, $items, $mode, $update, $preview = false) { require_once('include/bbcode.php'); require_once('mod/proxy.php'); @@ -382,7 +382,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { if($mode === 'network-new' || $mode === 'search' || $mode === 'community') { - // "New Item View" on network page or search page results + // "New Item View" on network page or search page results // - just loop through the items and format them minimally for display //$tpl = get_markup_template('search_item.tpl'); @@ -402,7 +402,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { || (activity_match($item['verb'],ACTIVITY_DISLIKE)) || activity_match($item['verb'],ACTIVITY_ATTEND) || activity_match($item['verb'],ACTIVITY_ATTENDNO) - || activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)) + || activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)) && ($item['id'] != $item['parent'])) continue; $nickname = $item['nickname']; @@ -450,7 +450,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { $drop = array( 'dropping' => $dropping, - 'select' => t('Select'), + 'select' => t('Select'), 'delete' => t('Delete'), ); @@ -540,11 +540,11 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { $comments[$item['parent']] = 1; else $comments[$item['parent']] += 1; - } elseif(! x($comments,$item['parent'])) + } elseif(! x($comments,$item['parent'])) $comments[$item['parent']] = 0; // avoid notices later on } - // map all the like/dislike/attendance activities for each parent item + // map all the like/dislike/attendance activities for each parent item // Store these in the $alike and $dlike arrays foreach($items as $item) { @@ -633,14 +633,14 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { $redirect_url = 'redir/' . $item['cid'] ; - $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) + $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) ? t('Private Message') : false); // Top-level wall post not written by the wall owner (wall-to-wall) - // First figure out who owns it. + // First figure out who owns it. $osparkle = ''; @@ -667,13 +667,13 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) { // The author url doesn't match the owner (typically the contact) - // and also doesn't match the contact alias. - // The name match is a hack to catch several weird cases where URLs are + // and also doesn't match the contact alias. + // The name match is a hack to catch several weird cases where URLs are // all over the park. It can be tricked, but this prevents you from // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn - // well that it's the same Bob Smith. + // well that it's the same Bob Smith. - // But it could be somebody else with the same name. It just isn't highly likely. + // But it could be somebody else with the same name. It just isn't highly likely. $owner_url = $item['owner-link']; @@ -682,7 +682,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { $template = $wallwall; $commentww = 'ww'; // If it is our contact, use a friendly redirect link - if((link_compare($item['owner-link'],$item['url'])) + if((link_compare($item['owner-link'],$item['url'])) && ($item['network'] === NETWORK_DFRN)) { $owner_url = $redirect_url; $osparkle = ' sparkle'; @@ -694,7 +694,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { } $likebuttons = ''; - $shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false); + $shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false); if($page_writeable) { /* if($toplevelpost) { */ @@ -714,7 +714,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) { $comment = replace_macros($cmnt_tpl,array( - '$return_path' => '', + '$return_path' => '', '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'), '$id' => $item['item_id'], @@ -756,7 +756,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { $drop = array( 'dropping' => $dropping, - 'select' => t('Select'), + 'select' => t('Select'), 'delete' => t('Delete'), ); diff --git a/mod/credits.php b/mod/credits.php index 84e32b83d5..f5c34b6105 100644 --- a/mod/credits.php +++ b/mod/credits.php @@ -5,7 +5,7 @@ * addons repository will be listed though ATM) */ -function credits_content (App &$a) { +function credits_content (App $a) { /* fill the page with credits */ $f = fopen('util/credits.txt','r'); $names = fread($f, filesize('util/credits.txt')); diff --git a/mod/crepair.php b/mod/crepair.php index c141958e8b..902a129303 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -2,7 +2,7 @@ require_once("include/contact_selectors.php"); require_once("mod/contacts.php"); -function crepair_init(App &$a) { +function crepair_init(App $a) { if (! local_user()) { return; } @@ -30,7 +30,7 @@ function crepair_init(App &$a) { } } -function crepair_post(App &$a) { +function crepair_post(App $a) { if (! local_user()) { return; } @@ -96,7 +96,7 @@ function crepair_post(App &$a) { -function crepair_content(App &$a) { +function crepair_content(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL); diff --git a/mod/delegate.php b/mod/delegate.php index 6930a5943a..4212ec9b13 100644 --- a/mod/delegate.php +++ b/mod/delegate.php @@ -1,12 +1,12 @@ argc > 1) $which = $a->argv[1]; @@ -42,7 +42,7 @@ function dfrn_request_init(App &$a) { * After logging in, we click 'submit' to approve the linkage. * */ -function dfrn_request_post(App &$a) { +function dfrn_request_post(App $a) { if(($a->argc != 2) || (! count($a->profile))) { logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile)); @@ -658,7 +658,7 @@ function dfrn_request_post(App &$a) { } -function dfrn_request_content(App &$a) { +function dfrn_request_content(App $a) { if (($a->argc != 2) || (! count($a->profile))) { return ""; diff --git a/mod/directory.php b/mod/directory.php index f3fbb9eb77..ba48bb3926 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -1,6 +1,6 @@ set_pager_itemspage(60); if(local_user()) { @@ -20,19 +20,19 @@ function directory_init(App &$a) { } -function directory_post(App &$a) { +function directory_post(App $a) { if(x($_POST,'search')) $a->data['search'] = $_POST['search']; } -function directory_content(App &$a) { +function directory_content(App $a) { global $db; require_once("mod/proxy.php"); - if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) || + if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) || (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) { notice( t('Public access denied.') . EOL); return; @@ -124,7 +124,7 @@ function directory_content(App &$a) { } // if(strlen($rr['dob'])) { // if(($years = age($rr['dob'],$rr['timezone'],'')) != 0) -// $details .= '
' . t('Age: ') . $years ; +// $details .= '
' . t('Age: ') . $years ; // } // if(strlen($rr['gender'])) // $details .= '
' . t('Gender: ') . $rr['gender']; diff --git a/mod/dirfind.php b/mod/dirfind.php index 7eb830bb68..1b19ad92c4 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -5,7 +5,7 @@ require_once('include/Contact.php'); require_once('include/contact_selectors.php'); require_once('mod/contacts.php'); -function dirfind_init(App &$a) { +function dirfind_init(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL ); @@ -23,7 +23,7 @@ function dirfind_init(App &$a) { -function dirfind_content(&$a, $prefix = "") { +function dirfind_content(App $a, $prefix = "") { $community = false; $discover_user = false; diff --git a/mod/display.php b/mod/display.php index c98d936a0f..115feb0ce5 100644 --- a/mod/display.php +++ b/mod/display.php @@ -1,6 +1,6 @@ argc != 3) OR (!in_array($a->argv[1], array("post", "status_message", "reshare")))) { header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found')); diff --git a/mod/filer.php b/mod/filer.php index 1b5589380b..47c4aa5e4c 100644 --- a/mod/filer.php +++ b/mod/filer.php @@ -5,7 +5,7 @@ require_once('include/bbcode.php'); require_once('include/items.php'); -function filer_content(App &$a) { +function filer_content(App $a) { if (! local_user()) { killme(); @@ -30,7 +30,7 @@ function filer_content(App &$a) { '$field' => array('term', t("Save to Folder:"), '', '', $filetags, t('- select -')), '$submit' => t('Save'), )); - + echo $o; } killme(); diff --git a/mod/filerm.php b/mod/filerm.php index 7dbfe29473..7dd7df2f5a 100644 --- a/mod/filerm.php +++ b/mod/filerm.php @@ -1,6 +1,6 @@ argv[1]=="json"){ $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'); @@ -59,7 +59,7 @@ function friendica_init(App &$a) { -function friendica_content(App &$a) { +function friendica_content(App $a) { $o = ''; $o .= '

Friendica

'; @@ -70,7 +70,7 @@ function friendica_content(App &$a) { $o .= t('This is Friendica, version') . ' ' . FRIENDICA_VERSION . ' '; $o .= t('running at web location') . ' ' . z_root() . '

'; - $o .= t('Please visit Friendica.com to learn more about the Friendica project.') . '

'; + $o .= t('Please visit Friendica.com to learn more about the Friendica project.') . '

'; $o .= t('Bug reports and issues: please visit') . ' ' . ''.t('the bugtracker at github').'

'; $o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendica - dot com') . '

'; @@ -102,7 +102,7 @@ function friendica_content(App &$a) { else $o .= '

' . t('No installed plugins/addons/apps') . '

'; - call_hooks('about_hook', $o); + call_hooks('about_hook', $o); return $o; diff --git a/mod/fsuggest.php b/mod/fsuggest.php index fcbadcc9b7..b3d5439712 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -1,7 +1,7 @@ '; - $o .= contact_selector('suggest','suggest-select', false, + $o .= contact_selector('suggest','suggest-select', false, array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true)); diff --git a/mod/group.php b/mod/group.php index 681bc88cc3..2b332e401f 100644 --- a/mod/group.php +++ b/mod/group.php @@ -4,7 +4,7 @@ function validate_members(&$item) { $item = intval($item); } -function group_init(App &$a) { +function group_init(App $a) { if(local_user()) { require_once('include/group.php'); $a->page['aside'] = group_side('contacts','group','extended',(($a->argc > 1) ? intval($a->argv[1]) : 0)); @@ -13,7 +13,7 @@ function group_init(App &$a) { -function group_post(App &$a) { +function group_post(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL); @@ -69,7 +69,7 @@ function group_post(App &$a) { return; } -function group_content(App &$a) { +function group_content(App $a) { $change = false; if (! local_user()) { diff --git a/mod/hcard.php b/mod/hcard.php index d53405009a..07eb291510 100644 --- a/mod/hcard.php +++ b/mod/hcard.php @@ -1,6 +1,6 @@ argc==2 && $a->argv[1]=="testrewrite") { @@ -24,7 +24,7 @@ function install_init(App &$a){ } -function install_post(App &$a) { +function install_post(App $a) { global $install_wizard_pass, $db; switch($install_wizard_pass) { @@ -132,7 +132,7 @@ function get_db_errno() { } } -function install_content(App &$a) { +function install_content(App $a) { global $install_wizard_pass, $db; $o = ''; @@ -565,7 +565,7 @@ function check_imagik(&$checks) { } } -function manual_config(App &$a) { +function manual_config(App $a) { $data = htmlentities($a->data['txt'],ENT_COMPAT,'UTF-8'); $o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); $o .= ""; diff --git a/mod/invite.php b/mod/invite.php index a7739fc774..f5c60e1ed3 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -9,7 +9,7 @@ require_once('include/email.php'); -function invite_post(App &$a) { +function invite_post(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL); @@ -73,8 +73,8 @@ function invite_post(App &$a) { $nmessage = $message; } - $res = mail($recip, email_header_encode( t('Please join us on Friendica'),'UTF-8'), - $nmessage, + $res = mail($recip, email_header_encode( t('Please join us on Friendica'),'UTF-8'), + $nmessage, "From: " . $a->user['email'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); @@ -97,7 +97,7 @@ function invite_post(App &$a) { } -function invite_content(App &$a) { +function invite_content(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL); @@ -136,7 +136,7 @@ function invite_content(App &$a) { '$msg_text' => t('Your message:'), '$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n" . $linktxt - . "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:') + . "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:') . "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname'] . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n" , '$submit' => t('Submit') diff --git a/mod/item.php b/mod/item.php index 1c7a970c2d..c9306c523a 100644 --- a/mod/item.php +++ b/mod/item.php @@ -27,7 +27,7 @@ require_once('include/Scrape.php'); require_once('include/diaspora.php'); require_once('include/Contact.php'); -function item_post(App &$a) { +function item_post(App $a) { if((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter'))) return; @@ -1066,7 +1066,7 @@ function item_post_return($baseurl, $api_source, $return_path) { -function item_content(App &$a) { +function item_content(App $a) { if ((! local_user()) && (! remote_user())) { return; diff --git a/mod/like.php b/mod/like.php index ff1e238ac1..1f6a233f3d 100755 --- a/mod/like.php +++ b/mod/like.php @@ -5,7 +5,7 @@ require_once('include/bbcode.php'); require_once('include/items.php'); require_once('include/like.php'); -function like_content(App &$a) { +function like_content(App $a) { if(! local_user() && ! remote_user()) { return false; } diff --git a/mod/localtime.php b/mod/localtime.php index 00a7c59094..5353089031 100644 --- a/mod/localtime.php +++ b/mod/localtime.php @@ -3,7 +3,7 @@ require_once('include/datetime.php'); -function localtime_post(App &$a) { +function localtime_post(App $a) { $t = $_REQUEST['time']; if(! $t) @@ -16,7 +16,7 @@ function localtime_post(App &$a) { } -function localtime_content(App &$a) { +function localtime_content(App $a) { $t = $_REQUEST['time']; if(! $t) $t = 'now'; @@ -38,7 +38,7 @@ function localtime_content(App &$a) { $o .= '
'; - $o .= '

' . t('Please select your timezone:') . '

'; + $o .= '

' . t('Please select your timezone:') . '

'; $o .= select_timezone(($_REQUEST['timezone']) ? $_REQUEST['timezone'] : 'America/Los_Angeles'); diff --git a/mod/lockview.php b/mod/lockview.php index 746df28cd9..38a308634e 100644 --- a/mod/lockview.php +++ b/mod/lockview.php @@ -1,8 +1,8 @@ argc > 1) ? $a->argv[1] : 0); if (is_numeric($type)) { $item_id = intval($type); @@ -10,13 +10,13 @@ function lockview_content(App &$a) { } else { $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0); } - + if(! $item_id) killme(); if (!in_array($type, array('item','photo','event'))) killme(); - + $r = q("SELECT * FROM `%s` WHERE `id` = %d LIMIT 1", dbesc($type), intval($item_id) @@ -34,7 +34,7 @@ function lockview_content(App &$a) { } - if(($item['private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid'])) + if(($item['private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid'])) && (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) { echo t('Remote privacy information not available.') . '
'; @@ -54,7 +54,7 @@ function lockview_content(App &$a) { dbesc(implode(', ', $allowed_groups)) ); if (dbm::is_result($r)) - foreach($r as $rr) + foreach($r as $rr) $l[] = '' . $rr['name'] . ''; } if(count($allowed_users)) { @@ -62,7 +62,7 @@ function lockview_content(App &$a) { dbesc(implode(', ',$allowed_users)) ); if (dbm::is_result($r)) - foreach($r as $rr) + foreach($r as $rr) $l[] = $rr['name']; } @@ -72,7 +72,7 @@ function lockview_content(App &$a) { dbesc(implode(', ', $deny_groups)) ); if (dbm::is_result($r)) - foreach($r as $rr) + foreach($r as $rr) $l[] = '' . $rr['name'] . ''; } if(count($deny_users)) { @@ -80,7 +80,7 @@ function lockview_content(App &$a) { dbesc(implode(', ',$deny_users)) ); if (dbm::is_result($r)) - foreach($r as $rr) + foreach($r as $rr) $l[] = '' . $rr['name'] . ''; } diff --git a/mod/login.php b/mod/login.php index db49ba20ac..8fd28c7230 100644 --- a/mod/login.php +++ b/mod/login.php @@ -1,6 +1,6 @@ argc != 2) killme(); diff --git a/mod/mood.php b/mod/mood.php index 0e603c869a..e80a7f0976 100644 --- a/mod/mood.php +++ b/mod/mood.php @@ -5,7 +5,7 @@ require_once('include/bbcode.php'); require_once('include/items.php'); -function mood_init(App &$a) { +function mood_init(App $a) { if (! local_user()) { return; @@ -60,7 +60,7 @@ function mood_init(App &$a) { $uri = item_new_uri($a->get_hostname(),$uid); - $action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]); + $action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]); $arr = array(); $arr['guid'] = get_guid(32); @@ -109,7 +109,7 @@ function mood_init(App &$a) { -function mood_content(App &$a) { +function mood_content(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL); diff --git a/mod/msearch.php b/mod/msearch.php index 4b5205ac08..277242afff 100644 --- a/mod/msearch.php +++ b/mod/msearch.php @@ -1,6 +1,6 @@ $rr['name'], - 'url' => App::get_baseurl() . '/profile/' . $rr['nickname'], + 'name' => $rr['name'], + 'url' => App::get_baseurl() . '/profile/' . $rr['nickname'], 'photo' => App::get_baseurl() . '/photo/avatar/' . $rr['uid'] . '.jpg', 'tags' => str_replace(array(',',' '),array(' ',' '),$rr['pub_keywords']) ); diff --git a/mod/navigation.php b/mod/navigation.php index d69c76a843..be1b522e9c 100644 --- a/mod/navigation.php +++ b/mod/navigation.php @@ -2,7 +2,7 @@ require_once("include/nav.php"); -function navigation_content(App &$a) { +function navigation_content(App $a) { $nav_info = nav_info($a); diff --git a/mod/network.php b/mod/network.php index 61df38fb12..2f33c62f72 100644 --- a/mod/network.php +++ b/mod/network.php @@ -1,5 +1,5 @@ argc >= 2 && is_numeric($a->argv[1])) { @@ -303,7 +303,7 @@ function network_query_get_sel_group(App &$a) { } -function network_content(&$a, $update = 0) { +function network_content(App $a, $update = 0) { require_once('include/conversation.php'); @@ -728,7 +728,7 @@ function network_content(&$a, $update = 0) { intval($parents), intval($max_comments + 1) ); - + if (dbm::is_result($thread_items)) $items = array_merge($items, $thread_items); } @@ -805,11 +805,11 @@ function network_content(&$a, $update = 0) { /** * @brief Get the network tabs menu - * + * * @param app $a The global App * @return string Html of the networktab */ -function network_tabs(App &$a) { +function network_tabs(App $a) { // item filter tabs /// @TODO fix this logic, reduce duplication /// $a->page['content'] .= '
'; @@ -892,7 +892,7 @@ function network_tabs(App &$a) { $arr = array('tabs' => $tabs); call_hooks('network_tabs', $arr); - + $tpl = get_markup_template('common_tabs.tpl'); return replace_macros($tpl, array('$tabs' => $arr['tabs'])); diff --git a/mod/newmember.php b/mod/newmember.php index 1ef0985066..a5e41f1e24 100644 --- a/mod/newmember.php +++ b/mod/newmember.php @@ -1,6 +1,6 @@ ' . t('Welcome to Friendica') . ''; @@ -15,7 +15,7 @@ function newmember_content(App &$a) { $o .= '
    '; - $o .= '
  • ' . '' . t('Friendica Walk-Through') . '
    ' . t('On your Quick Start page - find a brief introduction to your profile and network tabs, make some new connections, and find some groups to join.') . '
  • ' . EOL; + $o .= '
  • ' . '' . t('Friendica Walk-Through') . '
    ' . t('On your Quick Start page - find a brief introduction to your profile and network tabs, make some new connections, and find some groups to join.') . '
  • ' . EOL; $o .= '
'; @@ -23,7 +23,7 @@ function newmember_content(App &$a) { $o .= '
    '; - $o .= '
  • ' . '' . t('Go to Your Settings') . '
    ' . t('On your Settings page - change your initial password. Also make a note of your Identity Address. This looks just like an email address - and will be useful in making friends on the free social web.') . '
  • ' . EOL; + $o .= '
  • ' . '' . t('Go to Your Settings') . '
    ' . t('On your Settings page - change your initial password. Also make a note of your Identity Address. This looks just like an email address - and will be useful in making friends on the free social web.') . '
  • ' . EOL; $o .= '
  • ' . t('Review the other settings, particularly the privacy settings. An unpublished directory listing is like having an unlisted phone number. In general, you should probably publish your listing - unless all of your friends and potential friends know exactly how to find you.') . '
  • ' . EOL; @@ -33,7 +33,7 @@ function newmember_content(App &$a) { $o .= '
      '; - $o .= '
    • ' . '' . t('Upload Profile Photo') . '
      ' . t('Upload a profile photo if you have not done so already. Studies have shown that people with real photos of themselves are ten times more likely to make friends than people who do not.') . '
    • ' . EOL; + $o .= '
    • ' . '' . t('Upload Profile Photo') . '
      ' . t('Upload a profile photo if you have not done so already. Studies have shown that people with real photos of themselves are ten times more likely to make friends than people who do not.') . '
    • ' . EOL; $o .= '
    • ' . '' . t('Edit Your Profile') . '
      ' . t('Edit your default profile to your liking. Review the settings for hiding your list of friends and hiding the profile from unknown visitors.') . '
    • ' . EOL; @@ -46,7 +46,7 @@ function newmember_content(App &$a) { $o .= '
        '; $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); - + if(! $mail_disabled) $o .= '
      • ' . '' . t('Importing Emails') . '
        ' . t('Enter your email access information on your Connector Settings page if you wish to import and interact with friends or mailing lists from your email INBOX') . '
      • ' . EOL; diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index 104fecb755..e084b25da3 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -1,13 +1,13 @@ argc > 1) $which = $a->argv[1]; diff --git a/mod/notes.php b/mod/notes.php index b2aa5487af..c7cfe8d70f 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -1,6 +1,6 @@ friendica items permanent-url compatibility */ - - function notice_init(App &$a){ + + function notice_init(App $a) { $id = $a->argv[1]; $r = q("SELECT user.nickname FROM user LEFT JOIN item ON item.uid=user.uid WHERE item.id=%d", intval($id) diff --git a/mod/notifications.php b/mod/notifications.php index 47e4cd0340..8cd1b29ea4 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -9,7 +9,7 @@ require_once("include/NotificationsManager.php"); require_once("include/contact_selectors.php"); require_once("include/network.php"); -function notifications_post(App &$a) { +function notifications_post(App $a) { if (! local_user()) { goaway(z_root()); @@ -65,7 +65,7 @@ function notifications_post(App &$a) { } } -function notifications_content(App &$a) { +function notifications_content(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL); diff --git a/mod/notify.php b/mod/notify.php index bd7a7faf49..0026f5ca6e 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -1,7 +1,7 @@ getByID($a->argv[2]); if ($note) { $nm->setSeen($note); - + // The friendica client has problems with the GUID. this is some workaround if ($a->is_friendica_app()) { require_once("include/items.php"); @@ -39,13 +39,13 @@ function notify_init(App &$a) { } -function notify_content(App &$a) { +function notify_content(App $a) { if (! local_user()) { return login(); } $nm = new NotificationsManager(); - + $notif_tpl = get_markup_template('notifications.tpl'); $not_tpl = get_markup_template('notify.tpl'); diff --git a/mod/oembed.php b/mod/oembed.php index 1d6e6145cd..7770c62fb0 100644 --- a/mod/oembed.php +++ b/mod/oembed.php @@ -1,7 +1,7 @@ query_string, LOGGER_ALL); if ($a->argv[1]=='b2h'){ diff --git a/mod/oexchange.php b/mod/oexchange.php index 49c5d01f45..47547e691c 100644 --- a/mod/oexchange.php +++ b/mod/oexchange.php @@ -1,7 +1,7 @@ argc > 1) && ($a->argv[1] === 'xrd')) { $tpl = get_markup_template('oexchange_xrd.tpl'); @@ -14,7 +14,7 @@ function oexchange_init(App &$a) { } -function oexchange_content(App &$a) { +function oexchange_content(App $a) { if (! local_user()) { $o = login(false); @@ -26,13 +26,13 @@ function oexchange_content(App &$a) { return; } - $url = (((x($_REQUEST,'url')) && strlen($_REQUEST['url'])) + $url = (((x($_REQUEST,'url')) && strlen($_REQUEST['url'])) ? urlencode(notags(trim($_REQUEST['url']))) : ''); - $title = (((x($_REQUEST,'title')) && strlen($_REQUEST['title'])) + $title = (((x($_REQUEST,'title')) && strlen($_REQUEST['title'])) ? '&title=' . urlencode(notags(trim($_REQUEST['title']))) : ''); - $description = (((x($_REQUEST,'description')) && strlen($_REQUEST['description'])) + $description = (((x($_REQUEST,'description')) && strlen($_REQUEST['description'])) ? '&description=' . urlencode(notags(trim($_REQUEST['description']))) : ''); - $tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags'])) + $tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags'])) ? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : ''); $s = fetch_url(App::get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags); diff --git a/mod/openid.php b/mod/openid.php index ce707c4150..59a7530140 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -4,7 +4,7 @@ require_once('library/openid.php'); -function openid_content(App &$a) { +function openid_content(App $a) { $noid = get_config('system','no_openid'); if($noid) @@ -47,7 +47,7 @@ function openid_content(App &$a) { require_once('include/security.php'); authenticate_success($r[0],true,true); - // just in case there was no return url set + // just in case there was no return url set // and we fell through goaway(z_root()); diff --git a/mod/opensearch.php b/mod/opensearch.php index 1a7d4cd307..a599ddc1ed 100644 --- a/mod/opensearch.php +++ b/mod/opensearch.php @@ -1,18 +1,18 @@ App::get_baseurl(), '$nodename' => $a->get_hostname(), )); - + echo $o; - + killme(); - + } ?> \ No newline at end of file diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index b2f536e6df..a9f7c3a909 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -3,7 +3,7 @@ require_once('include/Scrape.php'); require_once('include/follow.php'); -function ostatus_subscribe_content(App &$a) { +function ostatus_subscribe_content(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL); diff --git a/mod/parse_url.php b/mod/parse_url.php index 44cf80935e..2c610f2751 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -1,9 +1,9 @@ argc > 1) auto_redir($a, $a->argv[1]); @@ -112,7 +112,7 @@ function photos_init(App &$a) { -function photos_post(App &$a) { +function photos_post(App $a) { logger('mod-photos: photos_post: begin' , LOGGER_DEBUG); @@ -182,11 +182,11 @@ function photos_post(App &$a) { return; // NOTREACHED } - $r = qu("SELECT count(*) FROM `photo` WHERE `album` = '%s' AND `uid` = %d", + $r = qu("SELECT `album` FROM `photo` WHERE `album` = '%s' AND `uid` = %d", dbesc($album), intval($page_owner_uid) ); - if (! dbm::is_result($r)) { + if (!dbm::is_result($r)) { notice( t('Album not found.') . EOL); goaway($_SESSION['photo_return']); return; // NOTREACHED @@ -818,21 +818,22 @@ function photos_post(App &$a) { $imagedata = @file_get_contents($src); - - $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ", - intval($a->data['user']['uid']) - ); - $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit'); - if (($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) { - notice( upgrade_message() . EOL ); - @unlink($src); - $foo = 0; - call_hooks('photo_post_end',$foo); - killme(); - } + if ($limit) { + $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ", + intval($a->data['user']['uid']) + ); + $size = $r[0]['total']; + if (($size + strlen($imagedata)) > $limit) { + notice( upgrade_message() . EOL ); + @unlink($src); + $foo = 0; + call_hooks('photo_post_end',$foo); + killme(); + } + } $ph = new Photo($imagedata, $type); @@ -945,7 +946,7 @@ function photos_post(App &$a) { -function photos_content(App &$a) { +function photos_content(App $a) { // URLs: // photos/name diff --git a/mod/poco.php b/mod/poco.php index 0415e1a2ce..4ce075301c 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -2,7 +2,7 @@ // See here for a documentation for portable contacts: // https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html -function poco_init(App &$a) { +function poco_init(App $a) { require_once("include/bbcode.php"); $system_mode = false; diff --git a/mod/poke.php b/mod/poke.php index 2e15ed853f..5161129b31 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -4,11 +4,11 @@ * * Poke, prod, finger, or otherwise do unspeakable things to somebody - who must be a connection in your address book * This function can be invoked with the required arguments (verb and cid and private and possibly parent) silently via ajax or - * other web request. You must be logged in and connected to a profile. + * other web request. You must be logged in and connected to a profile. * If the required arguments aren't present, we'll display a simple form to choose a recipient and a verb. * parent is a special argument which let's you attach this activity as a comment to an existing conversation, which * may have started with somebody else poking (etc.) somebody, but this isn't necessary. This can be used in the more pokes - * plugin version to have entire conversations where Alice poked Bob, Bob fingered Alice, Alice hugged Bob, etc. + * plugin version to have entire conversations where Alice poked Bob, Bob fingered Alice, Alice hugged Bob, etc. * * private creates a private conversation with the recipient. Otherwise your profile's default post privacy is used. * @@ -19,7 +19,7 @@ require_once('include/bbcode.php'); require_once('include/items.php'); -function poke_init(App &$a) { +function poke_init(App $a) { if (! local_user()) { return; @@ -148,7 +148,7 @@ function poke_init(App &$a) { -function poke_content(App &$a) { +function poke_content(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL); diff --git a/mod/post.php b/mod/post.php index 076587839d..c8a88e66cd 100644 --- a/mod/post.php +++ b/mod/post.php @@ -9,8 +9,8 @@ require_once('include/salmon.php'); require_once('include/crypto.php'); // not yet ready for prime time //require_once('include/zot.php'); - -function post_post(App &$a) { + +function post_post(App $a) { $bulk_delivery = false; @@ -19,7 +19,7 @@ function post_post(App &$a) { } else { $nickname = $a->argv[2]; - $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' + $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($nickname) ); diff --git a/mod/pretheme.php b/mod/pretheme.php index 694fd5ba27..6dd6b781ac 100644 --- a/mod/pretheme.php +++ b/mod/pretheme.php @@ -1,7 +1,7 @@ Probe Diagnostic'; $o .= ''; $o .= 'Lookup address: '; - $o .= ''; + $o .= ''; $o .= '

        '; diff --git a/mod/profile.php b/mod/profile.php index 32d3985b7f..5dd8293c7f 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -4,7 +4,7 @@ require_once('include/contact_widgets.php'); require_once('include/redir.php'); -function profile_init(App &$a) { +function profile_init(App $a) { if(! x($a->page,'aside')) $a->page['aside'] = ''; @@ -71,7 +71,7 @@ function profile_init(App &$a) { } -function profile_content(&$a, $update = 0) { +function profile_content(App $a, $update = 0) { $category = $datequery = $datequery2 = ''; diff --git a/mod/profile_photo.php b/mod/profile_photo.php index c600dd1f86..f9bf60cf54 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -2,7 +2,7 @@ require_once("include/Photo.php"); -function profile_photo_init(App &$a) { +function profile_photo_init(App $a) { if (! local_user()) { return; @@ -13,7 +13,7 @@ function profile_photo_init(App &$a) { } -function profile_photo_post(App &$a) { +function profile_photo_post(App $a) { if (! local_user()) { notice ( t('Permission denied.') . EOL ); @@ -174,13 +174,13 @@ function profile_photo_post(App &$a) { if(! function_exists('profile_photo_content')) { -function profile_photo_content(App &$a) { +function profile_photo_content(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL ); return; } - + $newuser = false; if($a->argc == 2 && $a->argv[1] === 'new') @@ -191,9 +191,9 @@ function profile_photo_content(App &$a) { notice( t('Permission denied.') . EOL ); return; }; - + // check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo'); - + $resource_id = $a->argv[2]; //die(":".local_user()); $r=q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' ORDER BY `scale` ASC", @@ -246,7 +246,7 @@ function profile_photo_content(App &$a) { if(! x($a->config,'imagecrop')) { - + $tpl = get_markup_template('profile_photo.tpl'); $o .= replace_macros($tpl,array( @@ -284,7 +284,7 @@ function profile_photo_content(App &$a) { if(! function_exists('profile_photo_crop_ui_head')) { -function profile_photo_crop_ui_head(&$a, $ph){ +function profile_photo_crop_ui_head(App $a, $ph) { $max_length = get_config('system','max_image_length'); if (! $max_length) { $max_length = MAX_IMAGE_LENGTH; @@ -303,11 +303,11 @@ function profile_photo_crop_ui_head(&$a, $ph){ } $hash = photo_new_resource(); - + $smallest = 0; - $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 ); + $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 ); if ($r) { info( t('Image uploaded successfully.') . EOL ); @@ -317,7 +317,7 @@ function profile_photo_crop_ui_head(&$a, $ph){ if ($width > 640 || $height > 640) { $ph->scaleImage(640); - $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 ); + $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 ); if ($r === false) { notice( sprintf(t('Image size reduction [%s] failed.'),"640") . EOL ); diff --git a/mod/profiles.php b/mod/profiles.php index bf2f20d2a9..abc9dda556 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -2,7 +2,7 @@ require_once("include/Contact.php"); require_once('include/Probe.php'); -function profiles_init(App &$a) { +function profiles_init(App $a) { nav_set_selected('profiles'); @@ -160,7 +160,7 @@ function profile_clean_keywords($keywords) { return $keywords; } -function profiles_post(App &$a) { +function profiles_post(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL); @@ -601,7 +601,7 @@ function profile_activity($changed, $value) { } -function profiles_content(App &$a) { +function profiles_content(App $a) { if (! local_user()) { notice( t('Permission denied.') . EOL); diff --git a/mod/profperm.php b/mod/profperm.php index bbb055b021..a414d8947b 100644 --- a/mod/profperm.php +++ b/mod/profperm.php @@ -1,6 +1,6 @@ '; - if($change) + if($change) $o = ''; - + $o .= '
        '; $o .= '

        ' . t('Visible To') . '

        '; $o .= '
        '; diff --git a/mod/pubsub.php b/mod/pubsub.php index 308e237d5d..2ba1958a25 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -26,7 +26,7 @@ function hub_post_return() { -function pubsub_init(App &$a) { +function pubsub_init(App $a) { $nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : ''); $contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 ); @@ -57,7 +57,7 @@ function pubsub_init(App &$a) { $sql_extra = ((strlen($hub_verify)) ? sprintf(" AND `hub-verify` = '%s' ", dbesc($hub_verify)) : ''); - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d AND `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1", intval($contact_id), intval($owner['uid']) @@ -75,7 +75,7 @@ function pubsub_init(App &$a) { $contact = $r[0]; - // We must initiate an unsubscribe request with a verify_token. + // We must initiate an unsubscribe request with a verify_token. // Don't allow outsiders to unsubscribe us. if($hub_mode === 'unsubscribe') { @@ -98,7 +98,7 @@ function pubsub_init(App &$a) { require_once('include/security.php'); -function pubsub_post(App &$a) { +function pubsub_post(App $a) { $xml = file_get_contents('php://input'); diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index a6c36631ae..dceb16ae1f 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -4,7 +4,7 @@ function post_var($name) { return (x($_POST, $name)) ? notags(trim($_POST[$name])) : ''; } -function pubsubhubbub_init(App &$a) { +function pubsubhubbub_init(App $a) { // PuSH subscription must be considered "public" so just block it // if public access isn't enabled. if (get_config('system', 'block_public')) { diff --git a/mod/qsearch.php b/mod/qsearch.php index 118c93d9fa..8512bea51e 100644 --- a/mod/qsearch.php +++ b/mod/qsearch.php @@ -1,6 +1,6 @@ diff --git a/mod/salmon.php b/mod/salmon.php index 6c3aea2114..69809f5234 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -19,7 +19,7 @@ function salmon_return($val) { } -function salmon_post(App &$a) { +function salmon_post(App $a) { $xml = file_get_contents('php://input'); @@ -156,7 +156,7 @@ function salmon_post(App &$a) { if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) { $result = new_contact($importer['uid'],$author_link); if($result['success']) { - $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s') + $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s') AND `uid` = %d LIMIT 1", dbesc(NETWORK_OSTATUS), dbesc($author_link), diff --git a/mod/search.php b/mod/search.php index 22879f7f9e..df604e367c 100644 --- a/mod/search.php +++ b/mod/search.php @@ -43,7 +43,7 @@ function search_saved_searches() { } -function search_init(App &$a) { +function search_init(App $a) { $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); @@ -81,13 +81,13 @@ function search_init(App &$a) { -function search_post(App &$a) { +function search_post(App $a) { if(x($_POST,'search')) $a->data['search'] = $_POST['search']; } -function search_content(App &$a) { +function search_content(App $a) { if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { notice( t('Public access denied.') . EOL); diff --git a/mod/session.php b/mod/session.php index 22c855edba..a73bcc78fa 100644 --- a/mod/session.php +++ b/mod/session.php @@ -1,5 +1,5 @@ argc > 1) ? intval($a->argv[1]) : 0); if((! $post_id) || (! local_user())) killme(); - $r = q("SELECT item.*, contact.network FROM `item` - inner join contact on `item`.`contact-id` = `contact`.`id` + $r = q("SELECT item.*, contact.network FROM `item` + inner join contact on `item`.`contact-id` = `contact`.`id` WHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1", intval($post_id), diff --git a/mod/smilies.php b/mod/smilies.php index 8e04d5d054..4d8ab6bcaa 100644 --- a/mod/smilies.php +++ b/mod/smilies.php @@ -6,7 +6,7 @@ require_once("include/Smilies.php"); -function smilies_content(App &$a) { +function smilies_content(App $a) { if ($a->argv[1]==="json"){ $tmp = Smilies::get_list(); $results = array(); diff --git a/mod/starred.php b/mod/starred.php index c23b07b8b5..46d3fcff66 100644 --- a/mod/starred.php +++ b/mod/starred.php @@ -1,7 +1,7 @@ tab where wanted -function uexport_content(App &$a){ +function uexport_content(App $a) { if ($a->argc > 1) { header("Content-type: application/json"); @@ -124,7 +124,7 @@ function uexport_account($a){ /** * echoes account data and items as separated json, one per line */ -function uexport_all(App &$a) { +function uexport_all(App $a) { uexport_account($a); echo "\n"; diff --git a/mod/uimport.php b/mod/uimport.php index 15bc8322b9..e9934393e8 100644 --- a/mod/uimport.php +++ b/mod/uimport.php @@ -6,7 +6,7 @@ require_once("include/uimport.php"); -function uimport_post(App &$a) { +function uimport_post(App $a) { switch($a->config['register_policy']) { case REGISTER_OPEN: $blocked = 0; @@ -28,7 +28,7 @@ function uimport_post(App &$a) { $verified = 0; break; } - + if (x($_FILES,'accountfile')){ /// @TODO Pass $blocked / $verified, send email to admin on REGISTER_APPROVE import_account($a, $_FILES['accountfile']); @@ -36,8 +36,8 @@ function uimport_post(App &$a) { } } -function uimport_content(App &$a) { - +function uimport_content(App $a) { + if((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) { notice("Permission denied." . EOL); return; @@ -52,8 +52,8 @@ function uimport_content(App &$a) { return; } } - - + + if(x($_SESSION,'theme')) unset($_SESSION['theme']); if(x($_SESSION,'mobile-theme')) diff --git a/mod/update_community.php b/mod/update_community.php index 179e9c61c4..9a39489dcf 100644 --- a/mod/update_community.php +++ b/mod/update_community.php @@ -4,7 +4,7 @@ require_once("mod/community.php"); -function update_community_content(App &$a) { +function update_community_content(App $a) { header("Content-type: text/html"); echo "\r\n"; diff --git a/mod/update_display.php b/mod/update_display.php index 230bbaa0b4..86f4db8259 100644 --- a/mod/update_display.php +++ b/mod/update_display.php @@ -5,7 +5,7 @@ require_once("mod/display.php"); require_once("include/group.php"); -function update_display_content(App &$a) { +function update_display_content(App $a) { $profile_uid = intval($_GET["p"]); diff --git a/mod/update_network.php b/mod/update_network.php index c6d33132cc..869973ace4 100644 --- a/mod/update_network.php +++ b/mod/update_network.php @@ -5,7 +5,7 @@ require_once("mod/network.php"); require_once("include/group.php"); -function update_network_content(App &$a) { +function update_network_content(App $a) { $profile_uid = intval($_GET["p"]); diff --git a/mod/update_notes.php b/mod/update_notes.php index b21f698054..d27cc4ca96 100644 --- a/mod/update_notes.php +++ b/mod/update_notes.php @@ -7,7 +7,7 @@ require_once("mod/notes.php"); -function update_notes_content(App &$a) { +function update_notes_content(App $a) { $profile_uid = intval($_GET["p"]); diff --git a/mod/update_profile.php b/mod/update_profile.php index e16b0b5ccc..b77a9cdcfc 100644 --- a/mod/update_profile.php +++ b/mod/update_profile.php @@ -7,7 +7,7 @@ require_once("mod/profile.php"); -function update_profile_content(App &$a) { +function update_profile_content(App $a) { $profile_uid = intval($_GET["p"]); diff --git a/mod/videos.php b/mod/videos.php index 433ce5fc63..3828b8f1fe 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -6,7 +6,7 @@ require_once('include/security.php'); require_once('include/redir.php'); -function videos_init(App &$a) { +function videos_init(App $a) { if($a->argc > 1) auto_redir($a, $a->argv[1]); @@ -102,7 +102,7 @@ function videos_init(App &$a) { -function videos_post(App &$a) { +function videos_post(App $a) { $owner_uid = $a->data['user']['uid']; @@ -182,7 +182,7 @@ function videos_post(App &$a) { -function videos_content(App &$a) { +function videos_content(App $a) { // URLs (most aren't currently implemented): // videos/name diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index 9c72a46e9c..55afda9b63 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -2,7 +2,7 @@ require_once('include/Contact.php'); require_once('include/contact_selectors.php'); -function viewcontacts_init(App &$a) { +function viewcontacts_init(App $a) { if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { return; @@ -29,7 +29,7 @@ function viewcontacts_init(App &$a) { } -function viewcontacts_content(App &$a) { +function viewcontacts_content(App $a) { require_once("mod/proxy.php"); if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { diff --git a/mod/viewsrc.php b/mod/viewsrc.php index 8510bd5395..a3f0affb53 100644 --- a/mod/viewsrc.php +++ b/mod/viewsrc.php @@ -1,7 +1,7 @@ $limit)) { - $msg = upgrade_message(true); - if ($r_json) { - echo json_encode(array('error'=>$msg)); - } else { - echo $msg. EOL ; - } - @unlink($src); - killme(); - } + if ($limit) { + $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ", + intval($page_owner_uid) + ); + $size = $r[0]['total']; + if (($size + strlen($imagedata)) > $limit) { + $msg = upgrade_message(true); + if ($r_json) { + echo json_encode(array('error'=>$msg)); + } else { + echo $msg. EOL ; + } + @unlink($src); + killme(); + } + } $filedata = @file_get_contents($src); $mimetype = z_mime_content_type($filename); diff --git a/mod/wall_upload.php b/mod/wall_upload.php index eb2a92323a..82cd3652b3 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -2,7 +2,7 @@ require_once('include/Photo.php'); -function wall_upload_post(&$a, $desktopmode = true) { +function wall_upload_post(App $a, $desktopmode = true) { logger("wall upload: starting new upload", LOGGER_DEBUG); @@ -166,21 +166,19 @@ function wall_upload_post(&$a, $desktopmode = true) { intval($page_owner_uid) ); $size = $r[0]['total']; - } else - $size = 0; - if(($limit !== false) && (($size + strlen($imagedata)) > $limit)) { - $msg = upgrade_message(true); - if ($r_json) { - echo json_encode(array('error'=>$msg)); - } else { - echo $msg. EOL; + if (($size + strlen($imagedata)) > $limit) { + $msg = upgrade_message(true); + if ($r_json) { + echo json_encode(array('error'=>$msg)); + } else { + echo $msg. EOL; + } + @unlink($src); + killme(); } - @unlink($src); - killme(); } - $imagedata = @file_get_contents($src); $ph = new Photo($imagedata, $filetype); diff --git a/mod/wallmessage.php b/mod/wallmessage.php index e0c702cdb0..c0a30bdcf4 100644 --- a/mod/wallmessage.php +++ b/mod/wallmessage.php @@ -2,7 +2,7 @@ require_once('include/message.php'); -function wallmessage_post(App &$a) { +function wallmessage_post(App $a) { $replyto = get_my_url(); if(! $replyto) { @@ -73,7 +73,7 @@ function wallmessage_post(App &$a) { } -function wallmessage_content(App &$a) { +function wallmessage_content(App $a) { if(! get_my_url()) { notice( t('Permission denied.') . EOL); @@ -134,9 +134,9 @@ function wallmessage_content(App &$a) { '$nickname' => $user['nickname'], '$linkurl' => t('Please enter a link URL:') )); - - + + $tpl = get_markup_template('wallmessage.tpl'); $o .= replace_macros($tpl,array( '$header' => t('Send Private Message'), diff --git a/mod/webfinger.php b/mod/webfinger.php index f08451ba70..eee0580e31 100644 --- a/mod/webfinger.php +++ b/mod/webfinger.php @@ -1,7 +1,7 @@ Webfinger Diagnostic'; diff --git a/mod/xrd.php b/mod/xrd.php index a56c7fbdff..7b812a7f9d 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -2,7 +2,7 @@ require_once('include/crypto.php'); -function xrd_init(App &$a) { +function xrd_init(App $a) { $uri = urldecode(notags(trim($_GET['uri']))); diff --git a/update.php b/update.php index 3bd9cbe610..058536d821 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ t('default'), + 'default' =>t('default'), 'greenzero' =>t('greenzero'), 'purplezero' =>t('purplezero'), 'easterbunny' =>t('easterbunny'), diff --git a/view/theme/duepuntozero/theme.php b/view/theme/duepuntozero/theme.php index 2ddfc29884..c674a99d99 100644 --- a/view/theme/duepuntozero/theme.php +++ b/view/theme/duepuntozero/theme.php @@ -1,6 +1,6 @@ ReadMe. * Version: V.0.7 * Author: Rabuzarus - * + * */ $frio = "view/theme/frio"; global $frio; -function frio_init(App &$a) { +function frio_init(App $a) { // disable the events module link in the profile tab $a->theme_events_in_profile = false; @@ -63,18 +63,18 @@ function frio_uninstall() { logger("uninstalled theme frio"); } /** - * @brief Replace friendica photo links - * + * @brief Replace friendica photo links hook + * * This function does replace the links to photos * of other friendica users. Original the photos are * linked to the photo page. Now they will linked directly * to the photo file. This function is nessesary to use colorbox * in the network stream - * - * @param App $a + * + * @param App $a Unused but required by hook definition * @param array $body_info The item and its html output */ -function frio_item_photo_links(&$a, &$body_info) { +function frio_item_photo_links(App $a, &$body_info) { require_once('include/Photo.php'); $phototypes = Photo::supportedTypes(); @@ -104,16 +104,16 @@ function frio_item_photo_links(&$a, &$body_info) { } /** - * @brief Replace links of the item_photo_menu - * + * @brief Replace links of the item_photo_menu hook + * * This function replaces the original poke and the message links * to call the addToModal javascript function so this pages can * be loaded in a bootstrap modal - * - * @param app $a The app data + * + * @param App $a Unused but required by the hook definition * @param array $arr Contains item data and the original photo_menu */ -function frio_item_photo_menu($a, &$arr){ +function frio_item_photo_menu(App $a, &$arr) { foreach($arr["menu"] as $k =>$v) { if(strpos($v,'poke/?f=&c=') === 0 || strpos($v,'message/new/') === 0) { @@ -126,17 +126,17 @@ function frio_item_photo_menu($a, &$arr){ /** * @brief Replace links of the contact_photo_menu - * + * * This function replaces the original poke and the message links * to call the addToModal javascript function so this pages can * be loaded in a bootstrap modal * Additionally the profile, status and photo page links will be changed * to don't open in a new tab if the contact is a friendica contact. - * + * * @param app $a The app data * @param array $args Contains contact data and the original photo_menu */ -function frio_contact_photo_menu($a, &$args){ +function frio_contact_photo_menu(App $a, &$args){ $pokelink = ""; $pmlink = ""; @@ -152,7 +152,7 @@ function frio_contact_photo_menu($a, &$args){ // friendicas "magic-link" which indicates a friendica user on froreign // friendica servers as remote user or visitor // - // The value for opening in a new tab is e.g. when + // The value for opening in a new tab is e.g. when // $args["menu"]["status"][2] is true. If the value of the [2] key is true // and if it's a friendica contact we set it to false foreach($args["menu"] as $k =>$v) { @@ -176,15 +176,15 @@ function frio_contact_photo_menu($a, &$args){ /** * @brief Construct remote nav menu - * + * * It creates a remote baseurl form $_SESSION for remote users and friendica - * visitors. This url will be added to some of the nav links. With this behaviour + * visitors. This url will be added to some of the nav links. With this behaviour * the user will come back to her/his own pages on his/her friendica server. * Not all possible links are available (notifications, administrator, manage, * notes aren't available because we have no way the check remote permissions).. * Some links will point to the local pages because the user would expect * local page (these pages are: search, community, help, apps, directory). - * + * * @param app $a The App class * @param array $nav The original nav menu */ @@ -196,11 +196,11 @@ function frio_remote_nav($a,&$nav) { // split up the url in it's parts (protocol,domain/directory, /profile/, nickname // I'm not familiar with regex, so someone might find a better solutionen - // + // // E.g $homelink = 'https://friendica.domain.com/profile/mickey' should result in an array // with 0 => 'https://friendica.domain.com/profile/mickey' 1 => 'https://', // 2 => 'friendica.domain.com' 3 => '/profile/' 4 => 'mickey' - // + // //$server_url = preg_match('/^(https?:\/\/.*?)\/profile\//2', $homelink); preg_match('/^(https?:\/\/)?(.*?)(\/profile\/)(.*)/', $homelink, $url_parts); @@ -219,8 +219,8 @@ function frio_remote_nav($a,&$nav) { // empty the server url for local user because we won't need it $server_url = ''; // user info - $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid'])); - + $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self`", intval($a->user['uid'])); + $r[0]['photo'] = (dbm::is_result($r) ? $a->remove_baseurl($r[0]['micro']) : "images/person-48.jpg"); $r[0]['name'] = $a->user['username']; @@ -263,14 +263,14 @@ function frio_remote_nav($a,&$nav) { } /** * @brief: Search for contacts - * + * * This function search for a users contacts. The code is copied from contact search * in /mod/contacts.php. With this function the contacts will permitted to acl_lookup() - * and can grabbed as json. For this we use the type="r". This is usful to to let js + * and can grabbed as json. For this we use the type="r". This is usful to to let js * grab the contact data. * We use this to give the data to textcomplete and have a filter function at the * contact page. - * + * * @param App $a The app data @TODO Unused * @param array $results The array with the originals from acl_lookup() */ @@ -298,7 +298,7 @@ function frio_acl_lookup($a, &$results) { $r = q("SELECT COUNT(*) AS `total` FROM `contact` - WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ", + WHERE `uid` = %d AND NOT `self` AND NOT `pending` $sql_extra $sql_extra2 ", intval($_SESSION['uid'])); if (dbm::is_result($r)) { $total = $r[0]["total"]; @@ -306,7 +306,7 @@ function frio_acl_lookup($a, &$results) { $sql_extra3 = unavailable_networks(); - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 $sql_extra3 ORDER BY `name` ASC LIMIT 100 ", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `pending` $sql_extra $sql_extra2 $sql_extra3 ORDER BY `name` ASC LIMIT 100 ", intval($_SESSION['uid']) ); diff --git a/view/theme/frost-mobile/theme.php b/view/theme/frost-mobile/theme.php index 4ca592f4c8..7e4262cb6a 100644 --- a/view/theme/frost-mobile/theme.php +++ b/view/theme/frost-mobile/theme.php @@ -9,7 +9,7 @@ * Maintainer: Zach P */ -function frost_mobile_init(App &$a) { +function frost_mobile_init(App $a) { $a->sourcename = 'Friendica mobile web'; $a->videowidth = 250; $a->videoheight = 200; @@ -18,7 +18,7 @@ function frost_mobile_init(App &$a) { set_template_engine($a, 'smarty3'); } -function frost_mobile_content_loaded(App &$a) { +function frost_mobile_content_loaded(App $a) { // I could do this in style.php, but by having the CSS in a file the browser will cache it, // making pages load faster diff --git a/view/theme/frost/theme.php b/view/theme/frost/theme.php index 7746109e56..4c22f0a118 100644 --- a/view/theme/frost/theme.php +++ b/view/theme/frost/theme.php @@ -9,14 +9,14 @@ * Maintainer: Zach P */ -function frost_init(App &$a) { +function frost_init(App $a) { $a->videowidth = 400; $a->videoheight = 330; $a->theme_thread_allow = false; set_template_engine($a, 'smarty3'); } -function frost_content_loaded(App &$a) { +function frost_content_loaded(App $a) { // I could do this in style.php, but by having the CSS in a file the browser will cache it, // making pages load faster @@ -43,7 +43,7 @@ function frost_uninstall() { logger("uninstalled theme frost"); } -function frost_item_photo_links(&$a, &$body_info) { +function frost_item_photo_links(App $a, &$body_info) { require_once('include/Photo.php'); $phototypes = Photo::supportedTypes(); @@ -68,7 +68,7 @@ function frost_item_photo_links(&$a, &$body_info) { $body_info['html'] = str_replace($link, $newlink, $body_info['html']); } - + $p = bb_find_open_close($body_info['html'], "", $occurence); } } diff --git a/view/theme/quattro/config.php b/view/theme/quattro/config.php index 6c80afdc22..5af58a18da 100644 --- a/view/theme/quattro/config.php +++ b/view/theme/quattro/config.php @@ -3,7 +3,7 @@ * Theme settings */ -function theme_content(App &$a){ +function theme_content(App $a) { if (!local_user()) { return; } @@ -16,7 +16,7 @@ function theme_content(App &$a){ return quattro_form($a,$align, $color, $tfs, $pfs); } -function theme_post(App &$a){ +function theme_post(App $a) { if (! local_user()) { return; } @@ -29,7 +29,7 @@ function theme_post(App &$a){ } } -function theme_admin(App &$a){ +function theme_admin(App $a) { $align = get_config('quattro', 'align' ); $color = get_config('quattro', 'color' ); $tfs = get_config("quattro","tfs"); @@ -38,7 +38,7 @@ function theme_admin(App &$a){ return quattro_form($a,$align, $color, $tfs, $pfs); } -function theme_admin_post(App &$a){ +function theme_admin_post(App $a) { if (isset($_POST['quattro-settings-submit'])){ set_config('quattro', 'align', $_POST['quattro_align']); set_config('quattro', 'color', $_POST['quattro_color']); @@ -48,7 +48,7 @@ function theme_admin_post(App &$a){ } /// @TODO $a is no longer used here -function quattro_form(App &$a, $align, $color, $tfs, $pfs){ +function quattro_form(App $a, $align, $color, $tfs, $pfs) { $colors = array( "dark" => "Quattro", "lilac" => "Lilac", diff --git a/view/theme/quattro/theme.php b/view/theme/quattro/theme.php index ae8f4f9065..fc908522a1 100644 --- a/view/theme/quattro/theme.php +++ b/view/theme/quattro/theme.php @@ -7,7 +7,7 @@ * Maintainer: Tobias */ -function quattro_init(App &$a) { +function quattro_init(App $a) { $a->page['htmlhead'] .= ''; $a->page['htmlhead'] .= '';; } diff --git a/view/theme/smoothly/theme.php b/view/theme/smoothly/theme.php index 0dbbd47cc3..62713e00cd 100644 --- a/view/theme/smoothly/theme.php +++ b/view/theme/smoothly/theme.php @@ -10,7 +10,7 @@ * Screenshot: Screenshot */ -function smoothly_init(App &$a) { +function smoothly_init(App $a) { set_template_engine($a, 'smarty3'); $cssFile = null; diff --git a/view/theme/vier/config.php b/view/theme/vier/config.php index 5326498908..9fd19e8aba 100644 --- a/view/theme/vier/config.php +++ b/view/theme/vier/config.php @@ -5,7 +5,7 @@ -function theme_content(App &$a){ +function theme_content(App $a) { if (!local_user()) { return; } @@ -35,7 +35,7 @@ function theme_content(App &$a){ $show_services, $show_friends, $show_lastusers); } -function theme_post(App &$a){ +function theme_post(App $a) { if (! local_user()) { return; } @@ -52,7 +52,7 @@ function theme_post(App &$a){ } -function theme_admin(App &$a){ +function theme_admin(App $a) { if (!function_exists('get_vier_config')) return; @@ -81,7 +81,7 @@ function theme_admin(App &$a){ return $o; } -function theme_admin_post(App &$a){ +function theme_admin_post(App $a) { if (isset($_POST['vier-settings-submit'])){ set_config('vier', 'style', $_POST['vier_style']); set_config('vier', 'show_pages', $_POST['vier_show_pages']); @@ -95,7 +95,7 @@ function theme_admin_post(App &$a){ } /// @TODO $a is no longer used -function vier_form(&$a, $style, $show_pages, $show_profiles, $show_helpers, $show_services, $show_friends, $show_lastusers){ +function vier_form(App $a, $style, $show_pages, $show_profiles, $show_helpers, $show_services, $show_friends, $show_lastusers) { $styles = array( "plus"=>"Plus", "breathe"=>"Breathe", diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 4e7190dbfb..a35afa719b 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -13,7 +13,7 @@ require_once("include/plugin.php"); require_once("include/socgraph.php"); require_once("mod/proxy.php"); -function vier_init(App &$a) { +function vier_init(App $a) { $a->theme_events_in_profile = false;