diff --git a/boot.php b/boot.php index a784b37b05..55318e1ec5 100644 --- a/boot.php +++ b/boot.php @@ -14,7 +14,7 @@ require_once('include/features.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_VERSION', '3.2.1748' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1169 ); +define ( 'DB_UPDATE_VERSION', 1170 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -739,7 +739,7 @@ if(! class_exists('App')) { if($this->cached_profile_picdate[$common_filename]){ $this->cached_profile_image[$avatar_image] = $avatar_image . $this->cached_profile_picdate[$common_filename]; } else { - $r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like \"%%/%s\"", + $r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'", $common_filename); if(! count($r)){ $this->cached_profile_image[$avatar_image] = $avatar_image; @@ -1328,7 +1328,7 @@ if(! function_exists('profile_load')) { if($profile) { $profile_int = intval($profile); $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` - left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid` + INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1", dbesc($nickname), intval($profile_int) @@ -1336,7 +1336,7 @@ if(! function_exists('profile_load')) { } if((! $r) && (! count($r))) { $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` - left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid` + INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1", dbesc($nickname) ); @@ -1591,7 +1591,7 @@ if(! function_exists('get_birthdays')) { $bd_short = t('F d'); $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event` - LEFT JOIN `contact` ON `contact`.`id` = `event`.`cid` + INNER JOIN `contact` ON `contact`.`id` = `event`.`cid` WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s' ORDER BY `start` ASC ", intval(local_user()), diff --git a/database.sql b/database.sql index 92805ef001..0d45dda106 100644 --- a/database.sql +++ b/database.sql @@ -1192,3 +1192,44 @@ CREATE TABLE IF NOT EXISTS `unique_contacts` ( PRIMARY KEY (`id`), KEY `url` (`url`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `thread` +-- + +CREATE TABLE IF NOT EXISTS `thread` ( + `iid` int(10) unsigned NOT NULL DEFAULT '0', + `uid` int(10) unsigned NOT NULL DEFAULT '0', + `contact-id` int(11) unsigned NOT NULL DEFAULT '0', + `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `received` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `wall` tinyint(1) NOT NULL DEFAULT '0', + `private` tinyint(1) NOT NULL DEFAULT '0', + `pubmail` tinyint(1) NOT NULL DEFAULT '0', + `moderated` tinyint(1) NOT NULL DEFAULT '0', + `visible` tinyint(1) NOT NULL DEFAULT '0', + `spam` tinyint(1) NOT NULL DEFAULT '0', + `starred` tinyint(1) NOT NULL DEFAULT '0', + `bookmark` tinyint(1) NOT NULL DEFAULT '0', + `unseen` tinyint(1) NOT NULL DEFAULT '1', + `deleted` tinyint(1) NOT NULL DEFAULT '0', + `origin` tinyint(1) NOT NULL DEFAULT '0', + `forum_mode` tinyint(1) NOT NULL DEFAULT '0', + `mention` tinyint(1) NOT NULL DEFAULT '0', + `network` char(32) NOT NULL, + PRIMARY KEY (`iid`), + KEY `created` (`created`), + KEY `commented` (`commented`), + KEY `uid_network_commented` (`uid`,`network`,`commented`), + KEY `uid_network_created` (`uid`,`network`,`created`), + KEY `uid_contactid_commented` (`uid`,`contact-id`,`commented`), + KEY `uid_contactid_created` (`uid`,`contact-id`,`created`), + KEY `wall_private_received` (`wall`,`private`,`received`), + KEY `uid_created` (`uid`,`created`), + KEY `uid_commented` (`uid`,`commented`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/include/Contact.php b/include/Contact.php index af77869989..a6429bbf49 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -64,13 +64,13 @@ function contact_remove($id) { $archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts'); if($archive) { - q("update contact set `archive` = 1, `network` = 'none', `writable` = 0 where id = %d limit 1", + q("update contact set `archive` = 1, `network` = 'none', `writable` = 0 where id = %d", intval($id) ); return; } - q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1", + q("DELETE FROM `contact` WHERE `id` = %d", intval($id) ); q("DELETE FROM `item` WHERE `contact-id` = %d ", @@ -148,7 +148,7 @@ function mark_for_death($contact) { return; if($contact['term-date'] == '0000-00-00 00:00:00') { - q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1", + q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d", dbesc(datetime_convert()), intval($contact['id']) ); @@ -166,7 +166,7 @@ function mark_for_death($contact) { // archive them rather than delete // though if the owner tries to unarchive them we'll start the whole process over again - q("update contact set `archive` = 1 where id = %d limit 1", + q("update contact set `archive` = 1 where id = %d", intval($contact['id']) ); q("UPDATE `item` SET `private` = 2 WHERE `contact-id` = %d AND `uid` = %d", intval($contact['id']), intval($contact['uid'])); @@ -181,7 +181,7 @@ function mark_for_death($contact) { if(! function_exists('unmark_for_death')) { function unmark_for_death($contact) { // It's a miracle. Our dead contact has inexplicably come back to life. - q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1", + q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d", dbesc('0000-00-00 00:00:00'), intval($contact['id']) ); diff --git a/include/Photo.php b/include/Photo.php index f1c9128d36..45164333dd 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -595,7 +595,7 @@ class Photo { `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' - where id = %d limit 1", + where id = %d", intval($uid), intval($cid), diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 72c434692c..ee74ccc16a 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -399,19 +399,19 @@ function acl_lookup(&$a, $out_type = 'json') { } else { $sql_extra = $sql_extra2 = ""; } - + // count groups and contacts if ($type=='' || $type=='g'){ - $r = q("SELECT COUNT(`id`) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra", + $r = q("SELECT COUNT(*) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra", intval(local_user()) ); $group_count = (int)$r[0]['g']; } else { $group_count = 0; } - + if ($type=='' || $type=='c'){ - $r = q("SELECT COUNT(`id`) AS c FROM `contact` + $r = q("SELECT COUNT(*) AS c FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != '' $sql_extra2" , @@ -423,7 +423,7 @@ function acl_lookup(&$a, $out_type = 'json') { // autocomplete for Private Messages - $r = q("SELECT COUNT(`id`) AS c FROM `contact` + $r = q("SELECT COUNT(*) AS c FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `network` IN ('%s','%s','%s') $sql_extra2" , @@ -439,7 +439,7 @@ function acl_lookup(&$a, $out_type = 'json') { // autocomplete for Contacts - $r = q("SELECT COUNT(`id`) AS c FROM `contact` + $r = q("SELECT COUNT(*) AS c FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra2" , intval(local_user()) diff --git a/include/api.php b/include/api.php index d98ad970d5..ea1ba27e40 100644 --- a/include/api.php +++ b/include/api.php @@ -384,26 +384,26 @@ intval(api_user()) ); + //AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''", // count public wall messages - $r = q("SELECT COUNT(`id`) as `count` FROM `item` + $r = q("SELECT count(*) as `count` FROM `item` WHERE `uid` = %d - AND `type`='wall' - AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''", + AND `type`='wall'", intval($uinfo[0]['uid']) ); $countitms = $r[0]['count']; } else { - $r = q("SELECT COUNT(`id`) as `count` FROM `item` - WHERE `contact-id` = %d - AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''", + //AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''", + $r = q("SELECT count(*) as `count` FROM `item` + WHERE `contact-id` = %d", intval($uinfo[0]['id']) ); $countitms = $r[0]['count']; } // count friends - $r = q("SELECT COUNT(`id`) as `count` FROM `contact` + $r = q("SELECT count(*) as `count` FROM `contact` WHERE `uid` = %d AND `rel` IN ( %d, %d ) AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0", intval($uinfo[0]['uid']), @@ -412,7 +412,7 @@ ); $countfriends = $r[0]['count']; - $r = q("SELECT COUNT(`id`) as `count` FROM `contact` + $r = q("SELECT count(*) as `count` FROM `contact` WHERE `uid` = %d AND `rel` IN ( %d, %d ) AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0", intval($uinfo[0]['uid']), @@ -421,7 +421,7 @@ ); $countfollowers = $r[0]['count']; - $r = q("SELECT count(`id`) as `count` FROM item where starred = 1 and uid = %d and deleted = 0", + $r = q("SELECT count(*) as `count` FROM item where starred = 1 and uid = %d and deleted = 0", intval($uinfo[0]['uid']) ); $starred = $r[0]['count']; @@ -528,7 +528,8 @@ $status_user["protected"] = (($item["allow_cid"] != "") OR ($item["allow_gid"] != "") OR ($item["deny_cid"] != "") OR - ($item["deny_gid"] != "")); + ($item["deny_gid"] != "") OR + $item["private"]); return ($status_user); } @@ -745,12 +746,27 @@ logger('api_status_show: user_info: '.print_r($user_info, true), LOGGER_DEBUG); // get last public wall message - $lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `c`.`nick` as `reply_author`, `i`.`author-link` AS `item-author` - FROM `item`, `contact`, `item` as `i`, `contact` as `c` + //$lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `c`.`nick` as `reply_author`, `i`.`author-link` AS `item-author` + // FROM `item`, `contact`, `item` as `i`, `contact` as `c` + // WHERE `item`.`contact-id` = %d + // AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s'))) + // AND `i`.`id` = `item`.`parent` + // AND `contact`.`id`=`item`.`contact-id` AND `c`.`id`=`i`.`contact-id` AND `contact`.`self`=1 + // AND `item`.`type`!='activity' + // AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`='' + // ORDER BY `item`.`created` DESC + // LIMIT 1", + // intval($user_info['cid']), + // dbesc($user_info['url']), + // dbesc(normalise_link($user_info['url'])), + // dbesc($user_info['url']), + // dbesc(normalise_link($user_info['url'])) + //); + $lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `i`.`author-link` AS `item-author` + FROM `item`, `item` as `i` WHERE `item`.`contact-id` = %d AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s'))) AND `i`.`id` = `item`.`parent` - AND `contact`.`id`=`item`.`contact-id` AND `c`.`id`=`i`.`contact-id` AND `contact`.`self`=1 AND `item`.`type`!='activity' AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`='' ORDER BY `item`.`created` DESC @@ -773,8 +789,6 @@ if ($lastwall['parent']!=$lastwall['id']) { $in_reply_to_status_id= intval($lastwall['parent']); $in_reply_to_status_id_str = (string) intval($lastwall['parent']); - //$in_reply_to_user_id = $lastwall['reply_uid']; - //$in_reply_to_screen_name = $lastwall['reply_author']; $r = q("SELECT * FROM unique_contacts WHERE `url` = '%s'", dbesc(normalise_link($lastwall['item-author']))); if ($r) { @@ -807,6 +821,9 @@ 'statusnet_conversation_id' => $lastwall['parent'], ); + if ($lastwall['title'] != "") + $status_info['statusnet_html'] = "

".bbcode($lastwall['title'])."

\n".$status_info['statusnet_html']; + $entities = api_get_entitities($status_info['text'], $lastwall['body']); if (count($entities) > 0) $status_info['entities'] = $entities; @@ -842,13 +859,14 @@ $lastwall = q("SELECT `item`.* FROM `item`, `contact` - WHERE `item`.`contact-id` = %d + WHERE `item`.`uid` = %d AND `item`.`contact-id` = %d AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s'))) AND `contact`.`id`=`item`.`contact-id` AND `type`!='activity' AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`='' ORDER BY `created` DESC LIMIT 1", + intval(api_user()), intval($user_info['cid']), dbesc($user_info['url']), dbesc(normalise_link($user_info['url'])), @@ -900,6 +918,9 @@ 'statusnet_conversation_id' => $lastwall['parent'], ); + if ($lastwall['title'] != "") + $user_info['statusnet_html'] = "

".bbcode($lastwall['title'])."

\n".$user_info['statusnet_html']; + $entities = api_get_entitities($user_info['text'], $lastwall['body']); if (count($entities) > 0) $user_info['entities'] = $entities; @@ -1041,8 +1062,8 @@ `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `user`.`nickname`, `user`.`hidewall` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` + FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + INNER JOIN `user` ON `user`.`uid` = `item`.`uid` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' @@ -1827,6 +1848,9 @@ 'statusnet_conversation_id' => $item['parent'], ); + if ($item['title'] != "") + $status['statusnet_html'] = "

".bbcode($item['title'])."

\n".$status['statusnet_html']; + $entities = api_get_entitities($status['text'], $item['body']); if (count($entities) > 0) $status['entities'] = $entities; diff --git a/include/bbcode.php b/include/bbcode.php index 7f70563c7a..342cd7be5f 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -2,6 +2,35 @@ require_once("include/oembed.php"); require_once('include/event.php'); +function bb_rearrange_link($shared) { + if ($shared[1] != "type-link") + return($shared[0]); + + $newshare = trim($shared[2]); + $newshare = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $newshare); + + if (!strpos($shared[0], "[bookmark")) + $newshare = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $newshare, 1); + + preg_match("/\[img\](.*?)\[\/img\]/ism", $newshare, $matches); + + if ($matches) { + $newshare = str_replace($matches[0], '', $newshare); + $newshare = "[img]".$matches[1]."[/img]\n".$newshare; + } + + $search = array("\n\n", "\n ", " \n"); + $replace = array("\n", "\n", "\n"); + do { + $oldtext = $newshare; + $newshare = str_replace($search, $replace, $newshare); + } while ($oldtext != $newshare); + + $newshare = "[class=type-link]".$newshare."[/class]"; + + return($newshare); +} + function bb_remove_share_information($Text) { $Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism","bb_cleanup_share",$Text); return($Text); @@ -670,6 +699,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace("/\n\[code\]/ism", "[code]", $Text); $Text = preg_replace("/\[\/code\]\n/ism", "[/code]", $Text); + // Rearrange shared links + if (get_config("system", "rearrange_shared_links") AND (!$simplehtml OR $tryoembed)) + $Text = preg_replace_callback("(\[class=(.*?)\](.*?)\[\/class\])ism","bb_rearrange_link",$Text); + // when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems if (!$tryoembed) $Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text); diff --git a/include/cache.php b/include/cache.php index e6ea8f045d..86539310af 100644 --- a/include/cache.php +++ b/include/cache.php @@ -47,7 +47,7 @@ * dbesc($key) * ); * if(count($r)) { - * q("UPDATE `cache` SET `v` = '%s', `updated = '%s' WHERE `k` = '%s' limit 1", + * q("UPDATE `cache` SET `v` = '%s', `updated = '%s' WHERE `k` = '%s'", * dbesc($value), * dbesc(datetime_convert()), * dbesc($key)); diff --git a/include/config.php b/include/config.php index 2664b78a88..e9da8e7b3d 100644 --- a/include/config.php +++ b/include/config.php @@ -66,12 +66,22 @@ function get_config($family, $key, $instore = false) { } } - // If APC is enabled then fetch the data from there + // If APC is enabled then fetch the data from there, else try XCache if (function_exists("apc_fetch") AND function_exists("apc_exists")) if (apc_exists($family."|".$key)) { $val = apc_fetch($family."|".$key); $a->config[$family][$key] = $val; + if ($val === '!!') + return false; + else + return $val; + } + elseif (function_exists("xcache_fetch") AND function_exists("xcache_isset")) + if (xcache_isset($family."|".$key)) { + $val = xcache_fetch($family."|".$key); + $a->config[$family][$key] = $val; + if ($val === '!!') return false; else @@ -87,18 +97,22 @@ function get_config($family, $key, $instore = false) { $val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']); $a->config[$family][$key] = $val; - // If APC is enabled then store the data there + // If APC is enabled then store the data there, else try XCache if (function_exists("apc_store")) apc_store($family."|".$key, $val, 600); + elseif (function_exists("xcache_set")) + xcache_set($family."|".$key, $val, 600); return $val; } else { $a->config[$family][$key] = '!!'; - // If APC is enabled then store the data there + // If APC is enabled then store the data there, else try XCache if (function_exists("apc_store")) apc_store($family."|".$key, '!!', 600); + elseif (function_exists("xcache_set")) + xcache_set($family."|".$key, '!!', 600); } return false; }} @@ -134,7 +148,7 @@ function set_config($family,$key,$value) { return $ret; } - $ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1", + $ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s'", dbesc($dbvalue), dbesc($family), dbesc($key) @@ -142,9 +156,11 @@ function set_config($family,$key,$value) { $a->config[$family][$key] = $value; - // If APC is enabled then store the data there + // If APC is enabled then store the data there, else try XCache if (function_exists("apc_store")) apc_store($family."|".$key, $value, 600); + elseif (function_exists("xcache_set")) + xcache_set($family."|".$key, $value, 600); if($ret) return $value; @@ -193,7 +209,7 @@ function get_pconfig($uid,$family, $key, $instore = false) { } } - // If APC is enabled then fetch the data from there + // If APC is enabled then fetch the data from there, else try XCache if (function_exists("apc_fetch") AND function_exists("apc_exists")) if (apc_exists($uid."|".$family."|".$key)) { $val = apc_fetch($uid."|".$family."|".$key); @@ -204,6 +220,16 @@ function get_pconfig($uid,$family, $key, $instore = false) { else return $val; } + elseif (function_exists("xcache_get") AND function_exists("xcache_isset")) + if (xcache_isset($uid."|".$family."|".$key)) { + $val = xcache_get($uid."|".$family."|".$key); + $a->config[$uid][$family][$key] = $val; + + if ($val === '!!') + return false; + else + return $val; + } $ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1", @@ -216,18 +242,22 @@ function get_pconfig($uid,$family, $key, $instore = false) { $val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']); $a->config[$uid][$family][$key] = $val; - // If APC is enabled then store the data there + // If APC is enabled then store the data there, else try XCache if (function_exists("apc_store")) apc_store($uid."|".$family."|".$key, $val, 600); + elseif (function_exists("xcache_set")) + xcache_set($uid."|".$family."|".$key, $val, 600); return $val; } else { $a->config[$uid][$family][$key] = '!!'; - // If APC is enabled then store the data there + // If APC is enabled then store the data there, else try XCache if (function_exists("apc_store")) apc_store($uid."|".$family."|".$key, '!!', 600); + elseif (function_exists("xcache_set")) + xcache_set($uid."|".$family."|".$key, '!!', 600); } return false; }} @@ -238,13 +268,15 @@ function del_config($family,$key) { global $a; if(x($a->config[$family],$key)) unset($a->config[$family][$key]); - $ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1", + $ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s'", dbesc($family), dbesc($key) ); - // If APC is enabled then store the data there + // If APC is enabled then delete the data from there, else try XCache if (function_exists("apc_delete")) apc_delete($family."|".$key); + elseif (function_exists("xcache_unset")) + xcache_unset($family."|".$key); return $ret; }} @@ -274,7 +306,7 @@ function set_pconfig($uid,$family,$key,$value) { return $value; return $ret; } - $ret = q("UPDATE `pconfig` SET `v` = '%s' WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1", + $ret = q("UPDATE `pconfig` SET `v` = '%s' WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s'", dbesc($dbvalue), intval($uid), dbesc($family), @@ -283,9 +315,11 @@ function set_pconfig($uid,$family,$key,$value) { $a->config[$uid][$family][$key] = $value; - // If APC is enabled then store the data there + // If APC is enabled then store the data there, else try XCache if (function_exists("apc_store")) apc_store($uid."|".$family."|".$key, $value, 600); + elseif (function_exists("xcache_set")) + xcache_set($uid."|".$family."|".$key, $value, 600); if($ret) @@ -299,7 +333,7 @@ function del_pconfig($uid,$family,$key) { global $a; if(x($a->config[$uid][$family],$key)) unset($a->config[$uid][$family][$key]); - $ret = q("DELETE FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1", + $ret = q("DELETE FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s'", intval($uid), dbesc($family), dbesc($key) diff --git a/include/datetime.php b/include/datetime.php index efcfa0a177..3ad9ea3a10 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -19,7 +19,7 @@ if(! function_exists('select_timezone')) { function select_timezone($current = 'America/Los_Angeles') { $timezone_identifiers = DateTimeZone::listIdentifiers(); - + $o ='