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
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.
-- ------------------------------------------
-- Friendica 3.5.1-dev (Asparagus)
--- DB_UPDATE_VERSION 1211
+-- DB_UPDATE_VERSION 1212
-- ------------------------------------------
`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;
--
`deny_cid` mediumtext,
`deny_gid` mediumtext,
PRIMARY KEY(`id`),
- INDEX `uid` (`uid`)
+ INDEX `uid_start` (`uid`,`start`)
) DEFAULT CHARSET=utf8mb4;
--
`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;
--
`posturl` varchar(255) NOT NULL DEFAULT '',
`key` text,
PRIMARY KEY(`id`),
- INDEX `server` (`server`)
+ INDEX `server` (`server`(32))
) DEFAULT CHARSET=utf8mb4;
--
`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;
`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;
`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;
--
`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;
--
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`),
PRIMARY KEY(`id`),
INDEX `uid` (`uid`),
INDEX `sid` (`sid`),
- INDEX `service` (`service`),
+ INDEX `service` (`service`(32)),
INDEX `iid` (`iid`)
) DEFAULT CHARSET=utf8mb4;
`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;
--
`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;
--
`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;
--
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;
--
`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;
--
`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;
--
`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;
`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;
--
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;
`deny_gid` mediumtext,
`openidserver` text,
PRIMARY KEY(`uid`),
- INDEX `nickname` (`nickname`)
+ INDEX `nickname` (`nickname`(32))
) DEFAULT CHARSET=utf8mb4;
--
`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;
--
* **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.
* **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.
$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",
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" $tabindex >\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())
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex >\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())
// 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())
);
// 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),
// 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'];
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 ",
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 ",
}
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 ",
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();
}
* @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");
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]);
$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);
$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()) {
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()) {
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()) {
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()) {
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()) {
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()) {
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()) {
}
// 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');
}
}
),
"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(
),
"indexes" => array(
"PRIMARY" => array("id"),
- "uid" => array("uid"),
+ "uid_start" => array("uid", "start"),
)
);
$database["fcontact"] = array(
),
"indexes" => array(
"PRIMARY" => array("id"),
- "addr" => array("addr"),
+ "addr" => array("addr(32)"),
)
);
$database["ffinder"] = array(
),
"indexes" => array(
"PRIMARY" => array("id"),
- "server" => array("server"),
+ "server" => array("server(32)"),
)
);
$database["fsuggest"] = array(
),
"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"),
)
);
),
"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"),
)
),
"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(
),
"indexes" => array(
"PRIMARY" => array("id"),
- "nurl" => array("nurl"),
+ "nurl" => array("nurl(32)"),
)
);
$database["hook"] = array(
"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"),
"PRIMARY" => array("id"),
"uid" => array("uid"),
"sid" => array("sid"),
- "service" => array("service"),
+ "service" => array("service(32)"),
"iid" => array("iid"),
)
);
"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(
),
"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(
"indexes" => array(
"PRIMARY" => array("id"),
"master-parent-item" => array("master-parent-item"),
- "receiver-uid" => array("receiver-uid"),
)
);
$database["oembed"] = array(
"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(
),
"indexes" => array(
"PRIMARY" => array("id"),
- "hometown" => array("hometown"),
)
);
$database["profile_check"] = array(
"indexes" => array(
"PRIMARY" => array("id"),
"uid" => array("uid"),
- "term" => array("term"),
)
);
$database["session"] = array(
),
"indexes" => array(
"PRIMARY" => array("id"),
- "sid" => array("sid"),
+ "sid" => array("sid(64)"),
"expire" => array("expire"),
)
);
"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(
"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"),
)
),
"indexes" => array(
"PRIMARY" => array("uid"),
- "nickname" => array("nickname"),
+ "nickname" => array("nickname(32)"),
)
);
$database["userd"] = array(
),
"indexes" => array(
"PRIMARY" => array("id"),
- "username" => array("username"),
+ "username" => array("username(32)"),
)
);
$database["workerqueue"] = array(
* @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];
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;
}
dbesc($guid)
);
- if ($r) {
+ if (dbm::is_result($r)) {
logger("message ".$guid." already exists for user ".$uid);
return $r[0]["id"];
}
// 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),
// 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']),
* @brief Functions related to photo handling.
*/
+use \Friendica\Core\Config;
+use \Friendica\Core\PConfig;
+
function getGps($exifCoord, $hemi) {
$degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
$minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;
$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;
$baseurl = substr($baseurl, $domain_st + 3);
$nurl = normalise_link($baseurl);
-
- $r = q("SELECT id FROM contact WHERE uid = ( SELECT uid FROM user WHERE nickname = '%s' LIMIT 1 )
- AND nick = '%s' AND self = 0 AND ( url LIKE '%%%s%%' or nurl LIKE '%%%s%%' ) AND blocked = 0 AND pending = 0 LIMIT 1",
- dbesc($contact_nick),
- dbesc($a->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()) {
require_once("mod/hostxrd.php");\r
require_once("mod/nodeinfo.php");\r
\r
-function _well_known_init(App &$a){\r
+function _well_known_init(App $a) {\r
if ($a->argc > 1) {\r
switch($a->argv[1]) {\r
case "host-meta":\r
killme();\r
}\r
\r
-function wk_social_relay(App &$a) {\r
+function wk_social_relay(App $a) {\r
\r
define('SR_SCOPE_ALL', 'all');\r
define('SR_SCOPE_TAGS', 'tags');\r
require_once('include/Scrape.php');
-function acctlink_init(App &$a) {
+function acctlink_init(App $a) {
if(x($_GET,'addr')) {
$addr = trim($_GET['addr']);
require_once("include/acl_selectors.php");
-function acl_init(App &$a){
+function acl_init(App $a) {
acl_lookup($a);
}
/**
* @file mod/admin.php
- *
+ *
* @brief Friendica admin
*/
* @param App $a
*
*/
-function admin_post(App &$a){
+function admin_post(App $a) {
if(!is_site_admin()) {
$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'];
* @param App $a
* @return string
*/
-function admin_content(App &$a) {
+function admin_content(App $a) {
if(!is_site_admin()) {
return login(false);
* @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
//
$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));
* @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`
* @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",
/**
* @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;
}
* @param App $a
* @return string
*/
-function admin_page_site(App &$a) {
+function admin_page_site(App $a) {
/* Installed langs */
$lang_choices = get_available_languages();
* @param App $a
* @return string
**/
-function admin_page_dbsync(App &$a) {
+function admin_page_dbsync(App $a) {
$o = '';
/**
* @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'] : '');
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']);
* @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));
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 //
* @param App $a
* @return string
*/
-function admin_page_plugins(App &$a){
+function admin_page_plugins(App $a) {
/*
* Single plugin
'$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"),
));
* @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);
$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'];
/**
* @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');
* @param App $a
* @return string
*/
-function admin_page_logs(App &$a){
+function admin_page_logs(App $a) {
$log_choices = array(
LOGGER_NORMAL => 'Normal',
LOGGER_DATA => 'Data',
LOGGER_ALL => 'All'
);
-
+
if (ini_get('log_errors')) {
$phplogenabled = t('PHP log currently enabled.');
} else {
* @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 = '';
/**
* @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');
/**
* @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);
);
}
}
-
+
$tpl = get_markup_template("admin_settings_features.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("admin_manage_features"),
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()) {
<?php
-function amcd_content(App &$a) {
+function amcd_content(App $a) {
//header("Content-type: text/json");
echo <<< EOT
{
return $r[0];
}
-function api_post(App &$a) {
+function api_post(App $a) {
if (! local_user()) {
notice( t('Permission denied.') . EOL);
}
-function api_content(App &$a) {
+function api_content(App $a) {
if ($a->cmd=='api/oauth/authorize'){
/*
* api/oauth/authorize interact with the user. return a standard page
<?php
-function apps_content(App &$a) {
+function apps_content(App $a) {
$privateaddons = get_config('config','private_addons');
if ($privateaddons === "1") {
if((! (local_user()))) {
'$apps' => $a->apps,
));
-
+
}
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);
return str_replace("\n",'<br />', $s);
}
-function babel_content(App &$a) {
+function babel_content(App $a) {
$o .= '<h1>Babel Diagnostic</h1>';
$o .= '<form action="babel" method="post">';
$o .= t('Source (bbcode) text:') . EOL . '<textarea name="text" >' . htmlspecialchars($_REQUEST['text']) .'</textarea>' . EOL;
- $o .= '<input type="submit" name="submit" value="Submit" /></form>';
+ $o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
$o .= '<form action="babel" method="post">';
$o .= t('Source (Diaspora) text to convert to BBcode:') . EOL . '<textarea name="d2bbtext" >' . htmlspecialchars($_REQUEST['d2bbtext']) .'</textarea>' . EOL;
- $o .= '<input type="submit" name="submit" value="Submit" /></form>';
+ $o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
if(x($_REQUEST,'text')) {
$text = trim($_REQUEST['text']);
- $o .= "<h2>" . t("Source input: ") . "</h2>" . EOL. EOL;
- $o .= visible_lf($text) . EOL. EOL;
+ $o .= "<h2>" . t("Source input: ") . "</h2>" . EOL. EOL;
+ $o .= visible_lf($text) . EOL. EOL;
$html = bbcode($text);
- $o .= "<h2>" . t("bb2html (raw HTML): ") . "</h2>" . EOL. EOL;
- $o .= htmlspecialchars($html). EOL. EOL;
+ $o .= "<h2>" . t("bb2html (raw HTML): ") . "</h2>" . EOL. EOL;
+ $o .= htmlspecialchars($html). EOL. EOL;
//$html = bbcode($text);
- $o .= "<h2>" . t("bb2html: ") . "</h2>" . EOL. EOL;
- $o .= $html. EOL. EOL;
+ $o .= "<h2>" . t("bb2html: ") . "</h2>" . EOL. EOL;
+ $o .= $html. EOL. EOL;
$bbcode = html2bbcode($html);
- $o .= "<h2>" . t("bb2html2bb: ") . "</h2>" . EOL. EOL;
- $o .= visible_lf($bbcode) . EOL. EOL;
+ $o .= "<h2>" . t("bb2html2bb: ") . "</h2>" . EOL. EOL;
+ $o .= visible_lf($bbcode) . EOL. EOL;
$diaspora = bb2diaspora($text);
- $o .= "<h2>" . t("bb2md: ") . "</h2>" . EOL. EOL;
- $o .= visible_lf($diaspora) . EOL. EOL;
+ $o .= "<h2>" . t("bb2md: ") . "</h2>" . EOL. EOL;
+ $o .= visible_lf($diaspora) . EOL. EOL;
$html = Markdown($diaspora);
- $o .= "<h2>" . t("bb2md2html: ") . "</h2>" . EOL. EOL;
- $o .= $html. EOL. EOL;
+ $o .= "<h2>" . t("bb2md2html: ") . "</h2>" . EOL. EOL;
+ $o .= $html. EOL. EOL;
$bbcode = diaspora2bb($diaspora);
- $o .= "<h2>" . t("bb2dia2bb: ") . "</h2>" . EOL. EOL;
- $o .= visible_lf($bbcode) . EOL. EOL;
+ $o .= "<h2>" . t("bb2dia2bb: ") . "</h2>" . EOL. EOL;
+ $o .= visible_lf($bbcode) . EOL. EOL;
$bbcode = html2bbcode($html);
- $o .= "<h2>" . t("bb2md2html2bb: ") . "</h2>" . EOL. EOL;
- $o .= visible_lf($bbcode) . EOL. EOL;
+ $o .= "<h2>" . t("bb2md2html2bb: ") . "</h2>" . EOL. EOL;
+ $o .= visible_lf($bbcode) . EOL. EOL;
if(x($_REQUEST,'d2bbtext')) {
$d2bbtext = trim($_REQUEST['d2bbtext']);
- $o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL. EOL;
- $o .= visible_lf($d2bbtext) . EOL. EOL;
+ $o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL. EOL;
+ $o .= visible_lf($d2bbtext) . EOL. EOL;
$bb = diaspora2bb($d2bbtext);
- $o .= "<h2>" . t("diaspora2bb: ") . "</h2>" . EOL. EOL;
- $o .= visible_lf($bb) . EOL. EOL;
+ $o .= "<h2>" . t("diaspora2bb: ") . "</h2>" . EOL. EOL;
+ $o .= visible_lf($bb) . EOL. EOL;
}
return $o;
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 = '<h2>'.t('Login').'</h2>';
$o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true);
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]);
return;
}
-function cal_content(App &$a) {
+function cal_content(App $a) {
nav_set_selected('events');
$editselect = 'none';
*/
-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;
require_once('include/contact_selectors.php');
require_once('mod/contacts.php');
-function common_content(App &$a) {
+function common_content(App $a) {
$o = '';
<?php
-function community_init(App &$a) {
+function community_init(App $a) {
if (! local_user()) {
unset($_SESSION['theme']);
unset($_SESSION['mobile-theme']);
}
-function community_content(&$a, $update = 0) {
+function community_content(App $a, $update = 0) {
$o = '';
return(community_getpublicitems($start, $itemspage));
$r = qu("SELECT %s
- FROM `thread` FORCE INDEX (`wall_private_received`)
+ FROM `thread`
INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
require_once('include/group.php');
-function contactgroup_content(App &$a) {
+function contactgroup_content(App $a) {
if (! local_user()) {
require_once('mod/proxy.php');
require_once('include/Photo.php');
-function contacts_init(App &$a) {
+function contacts_init(App $a) {
if (! local_user()) {
return;
}
}
-function contacts_batch_actions(App &$a){
+function contacts_batch_actions(App $a) {
$contacts_id = $_POST['contact_batch'];
if (!is_array($contacts_id)) return;
}
-function contacts_post(App &$a) {
+function contacts_post(App $a) {
if (! local_user()) {
return;
}
-function contacts_content(App &$a) {
+function contacts_content(App $a) {
$sort_type = 0;
$o = '';
/**
* @brief List of pages for the Contact TabBar
- *
+ *
* Available Pages are 'Status', 'Profile', 'Contacts' and 'Common Friends'
- *
+ *
* @param app $a
* @param int $contact_id The ID of the contact
* @param int $active_tab 1 if tab should be marked as active
- *
+ *
* @return array with with contact TabBar data
*/
function contacts_tab($a, $contact_id, $active_tab) {
/**
* @brief Gives a array with actions which can performed to a given contact
- *
+ *
* This includes actions like e.g. 'block', 'hide', 'archive', 'delete' and others
- *
+ *
* @param array $contact Data about the Contact
* @return array with contact related actions
*/
$contact_actions['delete'] = array(
'label' => t('Delete'),
- 'url' => 'contacts/' . $contact['id'] . '/drop',
+ 'url' => 'contacts/' . $contact['id'] . '/drop',
'title' => t('Delete contact'),
'sel' => '',
'id' => 'delete',
// 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');
$o = '';
-
+
$contact_id = $a->cid;
$def_acl = array('allow_cid' => $str);
}
-
+
$sql_options = (($star) ? " and starred = 1 " : '');
$sql_options .= (($bmark) ? " and bookmark = 1 " : '');
}
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)
);
-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');
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');
|| (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'];
$drop = array(
'dropping' => $dropping,
- 'select' => t('Select'),
+ 'select' => t('Select'),
'delete' => t('Delete'),
);
$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) {
$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 = '';
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'];
$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';
}
$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) { */
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'],
$drop = array(
'dropping' => $dropping,
- 'select' => t('Select'),
+ 'select' => t('Select'),
'delete' => t('Delete'),
);
* 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'));
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;
}
}
}
-function crepair_post(App &$a) {
+function crepair_post(App $a) {
if (! local_user()) {
return;
}
-function crepair_content(App &$a) {
+function crepair_content(App $a) {
if (! local_user()) {
notice( t('Permission denied.') . EOL);
<?php
require_once('mod/settings.php');
-function delegate_init(App &$a) {
+function delegate_init(App $a) {
return settings_init($a);
}
-function delegate_content(App &$a) {
+function delegate_content(App $a) {
if (! local_user()) {
notice( t('Permission denied.') . EOL);
// find every contact who might be a candidate for delegation
- $r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s'
+ $r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s'
and contact.uid = %d and contact.self = 0 and network = '%s' ",
dbesc(normalise_link(App::get_baseurl())),
intval(local_user()),
dbesc(NETWORK_DFRN)
- );
+ );
if (! dbm::is_result($r)) {
notice( t('No potential page delegates located.') . EOL);
require_once('include/group.php');
require_once('include/Probe.php');
-function dfrn_confirm_post(&$a,$handsfree = null) {
+function dfrn_confirm_post(App $a, $handsfree = null) {
if(is_array($handsfree)) {
require_once('library/defuse/php-encryption-1.2.1/Crypto.php');
-function dfrn_notify_post(App &$a) {
+function dfrn_notify_post(App $a) {
logger(__function__, LOGGER_TRACE);
$dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : '');
$dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
}
-function dfrn_notify_content(App &$a) {
+function dfrn_notify_content(App $a) {
if(x($_GET,'dfrn_id')) {
require_once('include/dfrn.php');
-function dfrn_poll_init(App &$a) {
+function dfrn_poll_init(App $a) {
$dfrn_id = ((x($_GET,'dfrn_id')) ? $_GET['dfrn_id'] : '');
if($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
- // did not decode properly - cannot trust this site
+ // did not decode properly - cannot trust this site
xml_status(3, 'Bad decryption');
}
-function dfrn_poll_post(App &$a) {
+function dfrn_poll_post(App $a) {
$dfrn_id = ((x($_POST,'dfrn_id')) ? $_POST['dfrn_id'] : '');
$challenge = ((x($_POST,'challenge')) ? $_POST['challenge'] : '');
if($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
- // did not decode properly - cannot trust this site
+ // did not decode properly - cannot trust this site
xml_status(3, 'Bad decryption');
}
}
}
-function dfrn_poll_content(App &$a) {
+function dfrn_poll_content(App $a) {
$dfrn_id = ((x($_GET,'dfrn_id')) ? $_GET['dfrn_id'] : '');
$type = ((x($_GET,'type')) ? $_GET['type'] : 'data');
require_once('include/Probe.php');
require_once('include/group.php');
-function dfrn_request_init(App &$a) {
+function dfrn_request_init(App $a) {
if($a->argc > 1)
$which = $a->argv[1];
* 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));
}
-function dfrn_request_content(App &$a) {
+function dfrn_request_content(App $a) {
if (($a->argc != 2) || (! count($a->profile))) {
return "";
<?php
-function directory_init(App &$a) {
+function directory_init(App $a) {
$a->set_pager_itemspage(60);
if(local_user()) {
}
-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;
}
// if(strlen($rr['dob'])) {
// if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
-// $details .= '<br />' . t('Age: ') . $years ;
+// $details .= '<br />' . t('Age: ') . $years ;
// }
// if(strlen($rr['gender']))
// $details .= '<br />' . t('Gender: ') . $rr['gender'];
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 );
-function dirfind_content(&$a, $prefix = "") {
+function dirfind_content(App $a, $prefix = "") {
$community = false;
$discover_user = false;
<?php
-function display_init(App &$a) {
+function display_init(App $a) {
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
return($profiledata);
}
-function display_content(&$a, $update = 0) {
+function display_content(App $a, $update = 0) {
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice(t('Public access denied.') . EOL);
require_once('include/acl_selectors.php');
-function editpost_content(App &$a) {
+function editpost_content(App $a) {
$o = '';
require_once('include/event.php');
require_once('include/items.php');
-function events_init(App &$a) {
+function events_init(App $a) {
if (! local_user()) {
return;
}
return;
}
-function events_post(App &$a) {
+function events_post(App $a) {
logger('post: ' . print_r($_REQUEST,true));
-function events_content(App &$a) {
+function events_content(App $a) {
if (! local_user()) {
notice( t('Permission denied.') . EOL);
/**
* @param App $a
*/
-function fbrowser_content(App &$a){
+function fbrowser_content(App $a) {
if (!local_user())
killme();
require_once("include/diaspora.php");
require_once("include/xml.php");
-/// @TODO You always make it like this: function foo(&$a)
-/// @TODO This means that the value of $a can be changed in anything, remove & and use App as type-hint
-function fetch_init(App &$a){
+function fetch_init(App $a) {
if (($a->argc != 3) OR (!in_array($a->argv[1], array("post", "status_message", "reshare")))) {
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
require_once('include/items.php');
-function filer_content(App &$a) {
+function filer_content(App $a) {
if (! local_user()) {
killme();
'$field' => array('term', t("Save to Folder:"), '', '', $filetags, t('- select -')),
'$submit' => t('Save'),
));
-
+
echo $o;
}
killme();
<?php
-function filerm_content(App &$a) {
+function filerm_content(App $a) {
if (! local_user()) {
killme();
require_once('include/Contact.php');
require_once('include/contact_selectors.php');
-function follow_content(App &$a) {
+function follow_content(App $a) {
if (! local_user()) {
notice( t('Permission denied.') . EOL);
return $o;
}
-function follow_post(App &$a) {
+function follow_post(App $a) {
if (! local_user()) {
notice( t('Permission denied.') . EOL);
<?php
-function friendica_init(App &$a) {
+function friendica_init(App $a) {
if ($a->argv[1]=="json"){
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
-function friendica_content(App &$a) {
+function friendica_content(App $a) {
$o = '';
$o .= '<h3>Friendica</h3>';
$o .= t('This is Friendica, version') . ' ' . FRIENDICA_VERSION . ' ';
$o .= t('running at web location') . ' ' . z_root() . '</p><p>';
- $o .= t('Please visit <a href="http://friendica.com">Friendica.com</a> to learn more about the Friendica project.') . '</p><p>';
+ $o .= t('Please visit <a href="http://friendica.com">Friendica.com</a> to learn more about the Friendica project.') . '</p><p>';
$o .= t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">'.t('the bugtracker at github').'</a></p><p>';
$o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendica - dot com') . '</p>';
else
$o .= '<p>' . t('No installed plugins/addons/apps') . '</p>';
- call_hooks('about_hook', $o);
+ call_hooks('about_hook', $o);
return $o;
<?php
-function fsuggest_post(App &$a) {
+function fsuggest_post(App $a) {
if (! local_user()) {
return;
VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
intval(local_user()),
intval($contact_id),
- dbesc($r[0]['name']),
- dbesc($r[0]['url']),
- dbesc($r[0]['request']),
- dbesc($r[0]['photo']),
- dbesc($hash),
+ dbesc($r[0]['name']),
+ dbesc($r[0]['url']),
+ dbesc($r[0]['request']),
+ dbesc($r[0]['photo']),
+ dbesc($hash),
dbesc(datetime_convert())
);
$r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
-function fsuggest_content(App &$a) {
+function fsuggest_content(App $a) {
require_once('include/acl_selectors.php');
$o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
- $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));
$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));
-function group_post(App &$a) {
+function group_post(App $a) {
if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
-function group_content(App &$a) {
+function group_content(App $a) {
$change = false;
if (! local_user()) {
<?php
-function hcard_init(App &$a) {
+function hcard_init(App $a) {
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
}
-function help_content(App &$a) {
+function help_content(App $a) {
nav_set_selected('help');
<?php
if(! function_exists('home_init')) {
-function home_init(App &$a) {
+function home_init(App $a) {
$ret = array();
call_hooks('home_init',$ret);
}}
if(! function_exists('home_content')) {
-function home_content(App &$a) {
+function home_content(App $a) {
$o = '';
require_once('include/crypto.php');
-function hostxrd_init(App &$a) {
+function hostxrd_init(App $a) {
header('Access-Control-Allow-Origin: *');
header("Content-type: text/xml");
$pubkey = get_config('system','site_pubkey');
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
$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);
if (! $ph->is_valid()) {
killme();
}
- $r = q("select sum(octet_length(data)) as total from attach where uid = %d ",
- intval($page_owner_uid)
- );
-
$limit = service_class_fetch($page_owner_uid,'attach_upload_limit');
- if(($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
- $msg = upgrade_message(true);
- if ($r_json) {
- echo json_encode(array('error'=>$msg));
- } else {
- echo $msg. EOL ;
+ 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();
}
- @unlink($src);
- killme();
}
-
$filedata = @file_get_contents($src);
$mimetype = z_mime_content_type($filename);
$hash = get_guid(64);
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);
<?php
-define('UPDATE_VERSION' , 1211);
+define('UPDATE_VERSION' , 1212);
/**
*
* Theme settings
*/
-function theme_content(App &$a){
+function theme_content(App $a) {
if (!local_user()) {
return;
}
return clean_form($a, $colorset, $user);
}
-function theme_post(App &$a){
+function theme_post(App $a) {
if (! local_user()) {
return;
}
}
}
-function theme_admin(App &$a){
+function theme_admin(App $a) {
$colorset = get_config( 'duepuntozero', 'colorset');
$user = false;
return clean_form($a, $colorset, $user);
}
-function theme_admin_post(App &$a){
+function theme_admin_post(App $a) {
if (isset($_POST['duepuntozero-settings-submit'])){
set_config('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
}
}
/// @TODO $a is no longer used
-function clean_form(&$a, &$colorset, $user){
+function clean_form(App $a, &$colorset, $user) {
$colorset = array(
- 'default' =>t('default'),
+ 'default' =>t('default'),
'greenzero' =>t('greenzero'),
'purplezero' =>t('purplezero'),
'easterbunny' =>t('easterbunny'),
<?php
-function duepuntozero_init(App &$a) {
+function duepuntozero_init(App $a) {
set_template_engine($a, 'smarty3');
$a->page['htmlhead'] .= <<< EOT
<script>
function insertFormatting(comment,BBcode,id) {
-
+
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == comment) {
tmpStr = "";
selected = document.selection.createRange();
if (BBcode == "url"){
selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
- } else
+ } else
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
} else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart;
<?php
require_once('view/theme/frio/php/Image.php');
-function theme_content(App &$a) {
+function theme_content(App $a) {
if (!local_user()) {
return;
}
$arr["background_image"] = get_pconfig(local_user(),'frio', 'background_image' );
$arr["bg_image_option"] = get_pconfig(local_user(),'frio', 'bg_image_option' );
- return frio_form($a, $arr);
+ return frio_form($arr);
}
-function theme_post(App &$a) {
+function theme_post(App $a) {
if (!local_user()) {
return;
}
}
}
-function frio_form(&$a, $arr) {
+function frio_form($arr) {
require_once("view/theme/frio/php/schema.php");
-
+
$scheme_info = get_schema_info($arr["schema"]);
$disable = $scheme_info["overwrites"];
if (!is_array($disable)) $disable = array();
/**
* @file view/theme/frio/php/frio_boot.php
- *
+ *
* @brief This file contains functions for page contstruction
- *
+ *
*/
/**
* @brief Load page template in dependence of the template mode
- *
+ *
* @todo Check if this is really needed.
*/
-function load_page(App &$a) {
+function load_page(App $a) {
if(isset($_GET["mode"]) AND ($_GET["mode"] == "minimal")) {
require "view/theme/frio/minimal.php";
} elseif((isset($_GET["mode"]) AND ($_GET["mode"] == "none"))) {
require_once(str_replace('theme/' . current_theme() . '/', '', $template));
}
-
+
}
/**
* @brief Check if page is a modal page
- *
+ *
* This function checks if $_REQUEST['pagename'] is
* a defined in a $modalpages
- *
+ *
* @return bool
*/
function is_modal() {
$is_modal = true;
}
}
-
+
return $is_modal;
}
/**
* @brief Array with modalpages
- *
+ *
* The array contains the page names of the pages
* which should displayed as modals
- *
+ *
* @return array Pagenames as path
*/
function get_modalpage_list() {
/**
* @brief Array with standard pages
- *
+ *
* The array contains the page names of the pages
* which should displayed as standard-page
- *
+ *
* @return array Pagenames as path
*/
function get_standard_page_list() {
/**
* @brief Check if page is standard page
- *
+ *
* This function checks if $_REQUEST['pagename'] is
* a defined $standardpages
- *
+ *
* @param string $pagetitle Title of the actual page
* @return bool
*/
$is_standard_page = true;
}
}
-
+
return $is_standard_page;
}
/**
* @brief Get the typ of the page
- *
+ *
* @param type $pagetitle
* @return string
*/
* Description: Bootstrap V3 theme. The theme is currently under construction, so it is far from finished. For further information have a look at the <a href="https://github.com/friendica/friendica/tree/develop/view/theme/frio/README.md">ReadMe</a>.
* Version: V.0.7
* Author: Rabuzarus <https://friendica.kommune4.de/profile/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;
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();
}
/**
- * @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) {
/**
* @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 = "";
// 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) {
/**
* @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
*/
// 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);
// 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'];
}
/**
* @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()
*/
$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"];
$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'])
);
* Maintainer: Zach P <techcity@f.shmuz.in>
*/
-function frost_mobile_init(App &$a) {
+function frost_mobile_init(App $a) {
$a->sourcename = 'Friendica mobile web';
$a->videowidth = 250;
$a->videoheight = 200;
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
* Maintainer: Zach P <techcity@f.shmuz.in>
*/
-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
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();
$body_info['html'] = str_replace($link, $newlink, $body_info['html']);
}
-
+
$p = bb_find_open_close($body_info['html'], "<a", ">", $occurence);
}
}
* Theme settings
*/
-function theme_content(App &$a){
+function theme_content(App $a) {
if (!local_user()) {
return;
}
return quattro_form($a,$align, $color, $tfs, $pfs);
}
-function theme_post(App &$a){
+function theme_post(App $a) {
if (! local_user()) {
return;
}
}
}
-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");
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']);
}
/// @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",
* Maintainer: Tobias <https://diekershoff.homeunix.net/friendica/profile/tobias>
*/
-function quattro_init(App &$a) {
+function quattro_init(App $a) {
$a->page['htmlhead'] .= '<script src="'.App::get_baseurl().'/view/theme/quattro/tinycon.min.js"></script>';
$a->page['htmlhead'] .= '<script src="'.App::get_baseurl().'/view/theme/quattro/js/quattro.js"></script>';;
}
* Screenshot: <a href="screenshot.png">Screenshot</a>
*/
-function smoothly_init(App &$a) {
+function smoothly_init(App $a) {
set_template_engine($a, 'smarty3');
$cssFile = null;
<script>
function insertFormatting(comment,BBcode,id) {
-
+
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == comment) {
tmpStr = "";
selected = document.selection.createRange();
if (BBcode == "url"){
selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
- } else
+ } else
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
} else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart;
-function theme_content(App &$a){
+function theme_content(App $a) {
if (!local_user()) {
return;
}
$show_services, $show_friends, $show_lastusers);
}
-function theme_post(App &$a){
+function theme_post(App $a) {
if (! local_user()) {
return;
}
}
-function theme_admin(App &$a){
+function theme_admin(App $a) {
if (!function_exists('get_vier_config'))
return;
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']);
}
/// @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",
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;