X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=1364385a1b12863ad388e0e23ed2d43862b2dfc2;hb=b86ae9de7f8982f22c6ab086bda8fa82977d3ae7;hp=f72f4dd7fc11488e76a91a05b2c1399d5ee0bb0e;hpb=040fc247a0caa51e0d4da4169980dc32e80ee804;p=friendica.git diff --git a/boot.php b/boot.php index f72f4dd7fc..1364385a1b 100644 --- a/boot.php +++ b/boot.php @@ -4,9 +4,9 @@ set_time_limit(0); ini_set('pcre.backtrack_limit', 250000); -define ( 'FRIENDIKA_VERSION', '2.2.989' ); +define ( 'FRIENDIKA_VERSION', '2.2.1016' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); -define ( 'DB_UPDATE_VERSION', 1055 ); +define ( 'DB_UPDATE_VERSION', 1064 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -150,6 +150,7 @@ define ( 'ACTIVITY_OBJ_PERSON', NAMESPACE_ACTIVITY_SCHEMA . 'person' ); define ( 'ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo' ); define ( 'ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo' ); define ( 'ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album' ); +define ( 'ACTIVITY_OBJ_EVENT', NAMESPACE_ACTIVITY_SCHEMA . 'event' ); /** * item weight for query ordering @@ -452,6 +453,41 @@ function system_unavailable() { killme(); }} + +// install and uninstall plugin +if (! function_exists('uninstall_plugin')){ +function uninstall_plugin($plugin){ + logger("Addons: uninstalling " . $plugin); + q("DELETE FROM `addon` WHERE `name` = '%s' LIMIT 1", + dbesc($plugin) + ); + + @include_once('addon/' . $plugin . '/' . $plugin . '.php'); + if(function_exists($plugin . '_uninstall')) { + $func = $plugin . '_uninstall'; + $func(); + } +}} + +if (! function_exists('install_plugin')){ +function install_plugin($plugin){ + logger("Addons: installing " . $plugin); + $t = filemtime('addon/' . $plugin . '/' . $plugin . '.php'); + @include_once('addon/' . $plugin . '/' . $plugin . '.php'); + if(function_exists($plugin . '_install')) { + $func = $plugin . '_install'; + $func(); + + $plugin_admin = (function_exists($plugin."_plugin_admin")?1:0); + + $r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ", + dbesc($plugin), + intval($t), + $plugin_admin + ); + } +}} + // Primarily involved with database upgrade, but also sets the // base url for use in cmdline programs which don't have // $_SERVER variables, and synchronising the state of installed plugins. @@ -481,17 +517,26 @@ function check_config(&$a) { $stored = intval($build); $current = intval(DB_UPDATE_VERSION); if(($stored < $current) && file_exists('update.php')) { + // We're reporting a different version than what is currently installed. // Run any existing update scripts to bring the database up to current. require_once('update.php'); - for($x = $stored; $x < $current; $x ++) { - if(function_exists('update_' . $x)) { - $func = 'update_' . $x; - $func($a); + + // make sure that boot.php and update.php are the same release, we might be + // updating right this very second and the correct version of the update.php + // file may not be here yet. This can happen on a very busy site. + + if(DB_UPDATE_VERSION == UPDATE_VERSION) { + + for($x = $stored; $x < $current; $x ++) { + if(function_exists('update_' . $x)) { + $func = 'update_' . $x; + $func($a); + } } + set_config('system','build', DB_UPDATE_VERSION); } - set_config('system','build', DB_UPDATE_VERSION); } } @@ -528,16 +573,7 @@ function check_config(&$a) { if(count($installed)) { foreach($installed as $i) { if(! in_array($i['name'],$plugins_arr)) { - logger("Addons: uninstalling " . $i['name']); - q("DELETE FROM `addon` WHERE `id` = %d LIMIT 1", - intval($i['id']) - ); - - @include_once('addon/' . $i['name'] . '/' . $i['name'] . '.php'); - if(function_exists($i['name'] . '_uninstall')) { - $func = $i['name'] . '_uninstall'; - $func(); - } + uninstall_plugin($i['name']); } else $installed_arr[] = $i['name']; @@ -547,17 +583,7 @@ function check_config(&$a) { if(count($plugins_arr)) { foreach($plugins_arr as $p) { if(! in_array($p,$installed_arr)) { - logger("Addons: installing " . $p); - $t = filemtime('addon/' . $p . '/' . $p . '.php'); - @include_once('addon/' . $p . '/' . $p . '.php'); - if(function_exists($p . '_install')) { - $func = $p . '_install'; - $func(); - $r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`) VALUES ( '%s', 1, %d ) ", - dbesc($p), - intval($t) - ); - } + install_plugin($p); } } } @@ -682,7 +708,7 @@ function fetch_url($url,$binary = false, &$redirects = 0) { $s = substr($s,strlen($header)+4); $header = substr($s,0,strpos($s,"\r\n\r\n")); } - if($http_code == 301 || $http_code == 302 || $http_code == 303) { + if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) { $matches = array(); preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches); $url = trim(array_pop($matches)); @@ -1221,8 +1247,10 @@ function get_config($family, $key, $instore = false) { dbesc($key) ); if(count($ret)) { - $a->config[$family][$key] = $ret[0]['v']; - return $ret[0]['v']; + // manage array value + $val = (preg_match("|^a:[0-9]+:{.*}$|", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']); + $a->config[$family][$key] = $val; + return $val; } else { $a->config[$family][$key] = '!!'; @@ -1236,22 +1264,25 @@ function get_config($family, $key, $instore = false) { if(! function_exists('set_config')) { function set_config($family,$key,$value) { - global $a; + + // manage array value + $dbvalue = (is_array($value)?serialize($value):$value); if(get_config($family,$key,true) === false) { $a->config[$family][$key] = $value; $ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ", dbesc($family), dbesc($key), - dbesc($value) + dbesc($dbvalue) ); if($ret) return $value; return $ret; } + $ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1", - dbesc($value), + dbesc($dbvalue), dbesc($family), dbesc($key) ); @@ -1983,15 +2014,15 @@ function get_tags($s) { $s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s); if(preg_match_all('/([@#][^ \x0D\x0A,:?]+)([ \x0D\x0A,:?]|$)/',$s,$match)) { - foreach($match[1] as $match) { - if(strstr($match,"]")) { + foreach($match[1] as $mtch) { + if(strstr($mtch,"]")) { // we might be inside a bbcode color tag - leave it alone continue; } - if(substr($match,-1,1) === '.') - $ret[] = substr($match,0,-1); + if(substr($mtch,-1,1) === '.') + $ret[] = substr($mtch,0,-1); else - $ret[] = $match; + $ret[] = $mtch; } } @@ -2106,10 +2137,10 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) { if(! function_exists('search')) { -function search($s) { +function search($s,$id='search-box',$url='/search') { $a = get_app(); - $o = '