X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=6759e805f245ab4e994278d6b98a5885ee3c4277;hb=d7fc8d7c127ac64db4eb2d604f7c31512b3f7716;hp=200c7e794e3d75ba30bf60ca982504ca21320903;hpb=373bb0822b2040d54fc17717840b5adfe15d1223;p=friendica.git diff --git a/boot.php b/boot.php index 200c7e794e..6759e805f2 100644 --- a/boot.php +++ b/boot.php @@ -17,9 +17,9 @@ require_once('include/dbstructure.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Lily of the valley'); -define ( 'FRIENDICA_VERSION', '3.4.0' ); +define ( 'FRIENDICA_VERSION', '3.4.3-rc' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1185 ); +define ( 'DB_UPDATE_VERSION', 1191 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -84,6 +84,15 @@ define ( 'LOGGER_DEBUG', 2 ); define ( 'LOGGER_DATA', 3 ); define ( 'LOGGER_ALL', 4 ); +/** + * cache levels + */ + +define ( 'CACHE_MONTH', 0 ); +define ( 'CACHE_WEEK', 1 ); +define ( 'CACHE_DAY', 2 ); +define ( 'CACHE_HOUR', 3 ); + /** * registration policies */ @@ -154,7 +163,8 @@ define ( 'NETWORK_TWITTER', 'twit'); // Twitter define ( 'NETWORK_DIASPORA2', 'dspc'); // Diaspora connector define ( 'NETWORK_STATUSNET', 'stac'); // Statusnet connector define ( 'NETWORK_APPNET', 'apdn'); // app.net - +define ( 'NETWORK_NEWS', 'nntp'); // Network News Transfer Protocol +define ( 'NETWORK_ICALENDAR', 'ical'); // iCalendar define ( 'NETWORK_PHANTOM', 'unkn'); // Place holder /** @@ -180,7 +190,9 @@ $netgroup_ids = array( NETWORK_TWITTER => (-14), NETWORK_DIASPORA2 => (-15), NETWORK_STATUSNET => (-16), - NETWORK_APPNET => (-17), + NETWORK_APPNET => (-17), + NETWORK_NEWS => (-18), + NETWORK_ICALENDAR => (-19), NETWORK_PHANTOM => (-127), ); @@ -261,6 +273,10 @@ define ( 'NAMESPACE_ATOM1', 'http://www.w3.org/2005/Atom' ); define ( 'ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like' ); define ( 'ACTIVITY_DISLIKE', NAMESPACE_DFRN . '/dislike' ); +define ( 'ACTIVITY_ATTEND', NAMESPACE_ZOT . '/activity/attendyes' ); +define ( 'ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno' ); +define ( 'ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe' ); + define ( 'ACTIVITY_OBJ_HEART', NAMESPACE_DFRN . '/heart' ); define ( 'ACTIVITY_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'make-friend' ); @@ -274,6 +290,7 @@ define ( 'ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post' ); define ( 'ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update' ); define ( 'ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag' ); define ( 'ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite' ); +define ( 'ACTIVITY_SHARE', NAMESPACE_ACTIVITY_SCHEMA . 'share' ); define ( 'ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke' ); define ( 'ACTIVITY_MOOD', NAMESPACE_ZOT . '/activity/mood' ); @@ -398,6 +415,7 @@ if(! class_exists('App')) { public $videoheight = 350; public $force_max_items = 0; public $theme_thread_allow = true; + public $theme_events_in_profile = true; // An array for all theme-controllable parameters // Mostly unimplemented yet. Only options 'stylesheet' and @@ -622,6 +640,9 @@ if(! class_exists('App')) { if ($basepath == "") $basepath = $_SERVER["PWD"]; + if ($basepath == "") + $basepath = dirname(__FILE__); + return($basepath); } @@ -716,10 +737,22 @@ if(! class_exists('App')) { function init_pagehead() { $interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000); + + // If the update is "deactivated" set it to the highest integer number (~24 days) + if ($interval < 0) + $interval = 2147483647; + if($interval < 10000) $interval = 40000; - $this->page['title'] = $this->config['sitename']; + // compose the page title from the sitename and the + // current module called + if (!$this->module=='') + { + $this->page['title'] = $this->config['sitename'].' ('.$this->module.')'; + } else { + $this->page['title'] = $this->config['sitename']; + } /* put the head template at the beginning of page['htmlhead'] * since the code added by the modules frequently depends on it @@ -828,7 +861,7 @@ if(! class_exists('App')) { $v = get_class_vars( $class ); if(x($v,"name")) $name = $v['name']; } - if ($name===""){ + if ($name===""){ echo "template engine $class cannot be registered without a name.\n"; killme(); } @@ -1422,8 +1455,46 @@ if(! function_exists('proc_run')) { if(! $arr['run_cmd']) return; - if(count($args) && $args[0] === 'php') + if(count($args) && $args[0] === 'php') { + + if (get_config("system", "worker")) { + $argv = $args; + array_shift($argv); + + $parameters = json_encode($argv); + $found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'", + dbesc($parameters)); + + if (!$found) + q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`) + VALUES ('%s', '%s', %d)", + dbesc($parameters), + dbesc(datetime_convert()), + intval(0)); + + // Should we quit and wait for the poller to be called as a cronjob? + if (get_config("system", "worker_dont_fork")) + return; + + // Checking number of workers + $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'"); + + // Get number of allowed number of worker threads + $queues = intval(get_config("system", "worker_queues")); + + if ($queues == 0) + $queues = 4; + + // If there are already enough workers running, don't fork another one + if ($workers[0]["workers"] >= $queues) + return; + + // Now call the poller to execute the jobs that we just added to the queue + $args = array("php", "include/poller.php", "no_cron"); + } + $args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); + } // add baseurl to args. cli scripts can't construct it $args[] = $a->get_baseurl(); @@ -1431,9 +1502,8 @@ if(! function_exists('proc_run')) { for($x = 0; $x < count($args); $x ++) $args[$x] = escapeshellarg($args[$x]); - - $cmdline = implode($args," "); + if(get_config('system','proc_windows')) proc_close(proc_open('cmd /c start /b ' . $cmdline,array(),$foo,dirname(__FILE__))); else @@ -1448,10 +1518,10 @@ if(! function_exists('current_theme')) { $a = get_app(); $page_theme = null; - + // Find the theme that belongs to the user whose stuff we are looking at - if($a->profile_uid && $a->profile_uid != local_user()) { + if($a->profile_uid && ($a->profile_uid != local_user())) { $r = q("select theme from user where uid = %d limit 1", intval($a->profile_uid) ); @@ -1462,7 +1532,7 @@ if(! function_exists('current_theme')) { // Allow folks to over-rule user themes and always use their own on their own site. // This works only if the user is on the same server - if($page_theme && local_user() && local_user() != $a->profile_url) { + if($page_theme && local_user() && (local_user() != $a->profile_uid)) { if(get_pconfig(local_user(),'system','always_my_theme')) $page_theme = null; } @@ -1476,17 +1546,20 @@ if(! function_exists('current_theme')) { if($is_mobile) { if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) { - $system_theme = ''; - $theme_name = ''; + $system_theme = $standard_system_theme; + $theme_name = $standard_theme_name; } else { - $system_theme = ((isset($a->config['system']['mobile-theme'])) ? $a->config['system']['mobile-theme'] : ''); + $system_theme = ((isset($a->config['system']['mobile-theme'])) ? $a->config['system']['mobile-theme'] : $standard_system_theme); $theme_name = ((isset($_SESSION) && x($_SESSION,'mobile-theme')) ? $_SESSION['mobile-theme'] : $system_theme); if($theme_name === '---') { // user has selected to have the mobile theme be the same as the normal one - $system_theme = ''; - $theme_name = ''; + $system_theme = $standard_system_theme; + $theme_name = $standard_theme_name; + + if($page_theme) + $theme_name = $page_theme; } } } @@ -1529,7 +1602,7 @@ if(! function_exists('current_theme_url')) { $opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : ''); if (file_exists('view/theme/' . $t . '/style.php')) return($a->get_baseurl() . '/view/theme/' . $t . '/style.pcss' . $opts); - + return($a->get_baseurl() . '/view/theme/' . $t . '/style.css'); } } @@ -1607,7 +1680,7 @@ if(! function_exists('load_contact_links')) { if(! $uid || x($a->contacts,'empty')) return; - $r = q("SELECT `id`,`network`,`url`,`thumb` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `thumb` != ''", + $r = q("SELECT `id`,`network`,`url`,`thumb`, `rel` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `thumb` != ''", intval($uid) ); if(count($r)) { @@ -1615,9 +1688,9 @@ if(! function_exists('load_contact_links')) { $url = normalise_link($rr['url']); $ret[$url] = $rr; } - } - else + } else $ret['empty'] = true; + $a->contacts = $ret; return; } @@ -1630,24 +1703,24 @@ if(! function_exists('load_contact_links')) { * @return string */ function build_querystring($params, $name=null) { - $ret = ""; - foreach($params as $key=>$val) { - if(is_array($val)) { - if($name==null) { - $ret .= build_querystring($val, $key); - } else { - $ret .= build_querystring($val, $name."[$key]"); - } - } else { - $val = urlencode($val); - if($name!=null) { - $ret.=$name."[$key]"."=$val&"; - } else { - $ret.= "$key=$val&"; - } - } - } - return $ret; + $ret = ""; + foreach($params as $key=>$val) { + if(is_array($val)) { + if($name==null) { + $ret .= build_querystring($val, $key); + } else { + $ret .= build_querystring($val, $name."[$key]"); + } + } else { + $val = urlencode($val); + if($name!=null) { + $ret.=$name."[$key]"."=$val&"; + } else { + $ret.= "$key=$val&"; + } + } + } + return $ret; } function explode_querystring($query) { @@ -1655,8 +1728,7 @@ function explode_querystring($query) { if($arg_st !== false) { $base = substr($query, 0, $arg_st); $arg_st += 1; - } - else { + } else { $base = ''; $arg_st = 0; } @@ -1705,6 +1777,15 @@ function random_digits($digits) { return $rn; } +function get_server() { + $server = get_config("system", "directory"); + + if ($server == "") + $server = "http://dir.friendi.ca"; + + return($server); +} + function get_cachefile($file, $writemode = true) { $cache = get_itemcachepath(); @@ -1742,16 +1823,16 @@ function clear_cache($basepath = "", $path = "") { $cachetime = 86400; if (is_writable($path)){ - if ($dh = opendir($path)) { - while (($file = readdir($dh)) !== false) { - $fullpath = $path."/".$file; - if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != "..")) - clear_cache($basepath, $fullpath); - if ((filetype($fullpath) == "file") and (filectime($fullpath) < (time() - $cachetime))) - unlink($fullpath); + if ($dh = opendir($path)) { + while (($file = readdir($dh)) !== false) { + $fullpath = $path."/".$file; + if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != "..")) + clear_cache($basepath, $fullpath); + if ((filetype($fullpath) == "file") and (filectime($fullpath) < (time() - $cachetime))) + unlink($fullpath); + } + closedir($dh); } - closedir($dh); - } } } @@ -1790,7 +1871,11 @@ function get_lockpath() { if ($temppath != "") { $lockpath = $temppath."/lock"; - mkdir($lockpath); + + if (!is_dir($lockpath)) + mkdir($lockpath); + elseif (!is_writable($lockpath)) + $lockpath = $temppath; if (is_dir($lockpath) AND is_writable($lockpath)) { set_config("system", "lockpath", $lockpath); @@ -1801,14 +1886,22 @@ function get_lockpath() { } function get_temppath() { + $a = get_app(); + $temppath = get_config("system","temppath"); if (($temppath != "") AND is_dir($temppath) AND is_writable($temppath)) return($temppath); $temppath = sys_get_temp_dir(); if (($temppath != "") AND is_dir($temppath) AND is_writable($temppath)) { - set_config("system", "temppath", $temppath); - return($temppath); + $temppath .= "/".$a->get_hostname(); + if (!is_dir($temppath)) + mkdir($temppath); + + if (is_dir($temppath) AND is_writable($temppath)) { + set_config("system", "temppath", $temppath); + return($temppath); + } } return(""); @@ -1827,3 +1920,31 @@ if(!function_exists('exif_imagetype')) { return($size[2]); } } + +function validate_include(&$file) { + $orig_file = $file; + + $file = realpath($file); + + if (strpos($file, getcwd()) !== 0) + return false; + + $file = str_replace(getcwd()."/", "", $file, $count); + if ($count != 1) + return false; + + if ($orig_file !== $file) + return false; + + $valid = false; + if (strpos($file, "include/") === 0) + $valid = true; + + if (strpos($file, "addon/") === 0) + $valid = true; + + if (!$valid) + return false; + + return true; +}