Merge pull request #758 from annando/master

Better use of APC,  	Preparations for the pumpio synchronisation, fix youtube for firefox
This commit is contained in:
fabrixxm 2013-09-06 07:55:03 -07:00
commit 51d934ee70
11 changed files with 90 additions and 30 deletions

View file

@ -139,6 +139,8 @@ define ( 'NETWORK_LINKEDIN', 'lnkd'); // LinkedIn
define ( 'NETWORK_XMPP', 'xmpp'); // XMPP
define ( 'NETWORK_MYSPACE', 'mysp'); // MySpace
define ( 'NETWORK_GPLUS', 'goog'); // Google+
define ( 'NETWORK_PUMPIO', 'pump'); // pump.io
define ( 'NETWORK_TWITTER', 'twit'); // Twitter
define ( 'NETWORK_PHANTOM', 'unkn'); // Place holder
@ -161,6 +163,8 @@ $netgroup_ids = array(
NETWORK_XMPP => (-10),
NETWORK_MYSPACE => (-11),
NETWORK_GPLUS => (-12),
NETWORK_PUMPIO => (-13),
NETWORK_TWITTER => (-14),
NETWORK_PHANTOM => (-127),
);

View file

@ -534,6 +534,9 @@ class Photo {
ob_start();
// Enable interlacing
imageinterlace($this->image, true);
switch($this->getType()){
case "image/png":
$quality = get_config('system','png_quality');
@ -676,6 +679,7 @@ function guess_image_type($filename, $fromcurl=false) {
*/
$image = new Imagick($filename);
$type = $image->getImageMimeType();
$image->setInterlaceScheme(Imagick::INTERLACE_PLANE);
} else {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$types = Photo::supportedTypes();

View file

@ -36,6 +36,10 @@ function stripcode_br_cb($s) {
function tryoembed($match){
$url = ((count($match)==2)?$match[1]:$match[2]);
// Always embed the SSL version
$url = str_replace("http://www.youtube.com/", "https://www.youtube.com/", $url);
//logger("tryoembed: $url");
$o = oembed_fetch_url($url);
@ -423,8 +427,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
// removing multiplicated newlines
if (get_config("system", "remove_multiplicated_lines")) {
$search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
$replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
$search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n");
$replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]");
do {
$oldtext = $Text;
$Text = str_replace($search, $replace, $Text);
@ -648,9 +652,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text);
if ($tryoembed)
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="http://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text);
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text);
else
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", "http://www.youtube.com/watch?v=$1", $Text);
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", "https://www.youtube.com/watch?v=$1", $Text);
if ($tryoembed) {
@ -730,6 +734,13 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
// $Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
//}
// Clean up some useless linebreaks in lists
//$Text = str_replace('<br /><ul','<ul ', $Text);
//$Text = str_replace('</ul><br />','</ul>', $Text);
//$Text = str_replace('</li><br />','</li>', $Text);
//$Text = str_replace('<br /><li>','<li>', $Text);
// $Text = str_replace('<br /><ul','<ul ', $Text);
// Remove all hashtag addresses
if (!$tryoembed AND get_config("system", "remove_hashtags_on_export")) {
$pattern = '/#<a.*?href="(.*?)".*?>(.*?)<\/a>/is';

View file

@ -18,6 +18,9 @@
if(! function_exists('load_config')) {
function load_config($family) {
global $a;
// To-Do: How to integrate APC here?
$r = q("SELECT * FROM `config` WHERE `cat` = '%s'", dbesc($family));
if(count($r)) {
foreach($r as $rr) {
@ -68,6 +71,10 @@ function get_config($family, $key, $instore = false) {
if (apc_exists($family."|".$key)) {
$val = apc_fetch($family."|".$key);
$a->config[$family][$key] = $val;
if ($val === '!<unset>!')
return false;
else
return $val;
}
@ -79,10 +86,19 @@ function get_config($family, $key, $instore = false) {
// manage array value
$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 (function_exists("apc_store"))
apc_store($family."|".$key, $val, 600);
return $val;
}
else {
$a->config[$family][$key] = '!<unset>!';
// If APC is enabled then store the data there
if (function_exists("apc_store"))
apc_store($family."|".$key, '!<unset>!', 600);
}
return false;
}}
@ -182,9 +198,14 @@ function get_pconfig($uid,$family, $key, $instore = false) {
if (apc_exists($uid."|".$family."|".$key)) {
$val = apc_fetch($uid."|".$family."|".$key);
$a->config[$uid][$family][$key] = $val;
if ($val === '!<unset>!')
return false;
else
return $val;
}
$ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
intval($uid),
dbesc($family),
@ -194,10 +215,19 @@ function get_pconfig($uid,$family, $key, $instore = false) {
if(count($ret)) {
$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 (function_exists("apc_store"))
apc_store($uid."|".$family."|".$key, $val, 600);
return $val;
}
else {
$a->config[$uid][$family][$key] = '!<unset>!';
// If APC is enabled then store the data there
if (function_exists("apc_store"))
apc_store($uid."|".$family."|".$key, '!<unset>!', 600);
}
return false;
}}

View file

@ -84,7 +84,8 @@ function network_to_name($s) {
NETWORK_XMPP => t('XMPP/IM'),
NETWORK_MYSPACE => t('MySpace'),
NETWORK_MAIL2 => t('Email'),
NETWORK_GPLUS => t('Google+')
NETWORK_GPLUS => t('Google+'),
NETWORK_PUMPIO => t('pump.io')
);
call_hooks('network_to_name', $nets);

View file

@ -558,6 +558,9 @@ function delivery_run(&$argv, &$argc){
case NETWORK_FACEBOOK :
if(get_config('system','dfrn_only'))
break;
case NETWORK_PUMPIO :
if(get_config('system','dfrn_only'))
break;
default:
break;
}

View file

@ -25,7 +25,6 @@ function expire_run(&$argv, &$argc){
load_config('config');
load_config('system');
$a->set_baseurl(get_config('system','url'));

View file

@ -881,6 +881,9 @@ function notifier_run(&$argv, &$argc){
case NETWORK_FACEBOOK:
if(get_config('system','dfrn_only'))
break;
case NETWORK_PUMPIO:
if(get_config('system','dfrn_only'))
break;
default:
break;
}

View file

@ -76,7 +76,7 @@ function onepoll_run(&$argv, &$argc){
$contacts = q("SELECT `contact`.* FROM `contact`
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
AND NOT `network` IN ( '%s', '%s' )
AND NOT `network` IN ( '%s', '%s', '%s' )
AND `contact`.`id` = %d
AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
AND `contact`.`archive` = 0 LIMIT 1",
@ -84,6 +84,7 @@ function onepoll_run(&$argv, &$argc){
intval(CONTACT_IS_FRIEND),
dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_FACEBOOK),
dbesc(NETWORK_PUMPIO),
intval($contact_id)
);
@ -526,6 +527,9 @@ function onepoll_run(&$argv, &$argc){
elseif($contact['network'] === NETWORK_FACEBOOK) {
// This is picked up by the Facebook plugin on a cron hook.
// Ignored here.
} elseif($contact['network'] === NETWORK_PUMPIO) {
// This is picked up by the pump.io plugin on a cron hook.
// Ignored here.
}
if($xml) {

View file

@ -173,7 +173,7 @@ function poller_run(&$argv, &$argc){
$contacts = q("SELECT `contact`.`id` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
AND NOT `network` IN ( '%s', '%s' )
AND NOT `network` IN ( '%s', '%s', '%s' )
$sql_extra
AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
AND `contact`.`archive` = 0
@ -181,7 +181,8 @@ function poller_run(&$argv, &$argc){
intval(CONTACT_IS_SHARING),
intval(CONTACT_IS_FRIEND),
dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_FACEBOOK)
dbesc(NETWORK_FACEBOOK),
dbesc(NETWORK_PUMPIO)
);
if(! count($contacts)) {