X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=b8b0dc05935c0a9980a95565d08395beba9480a8;hb=494288ab9f9370bdf4f7b4ab9990b64f05adbd9d;hp=b0412e05148f3d963c95a25af525de118afafaf2;hpb=bd65c0c7b2c25f766da7f6a85124e003b2ffd93d;p=friendica.git diff --git a/boot.php b/boot.php index b0412e0514..b8b0dc0593 100644 --- a/boot.php +++ b/boot.php @@ -1,15 +1,27 @@ \r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'DOWN_ARROW', '⇩' ); - + +/** + * + * Image storage quality. Lower numbers save space at cost of image detail. + * For ease of upgrade, please do not change here. Change jpeg quality with + * set_config('system','jpeg_quality',n) in .htconfig.php + * where n is netween 1 and 100, and with very poor results below about 50 + * + */ + +define ( 'JPEG_QUALITY', 100 ); /** * SSL redirection policies @@ -138,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 @@ -201,6 +214,7 @@ class App { public $user; public $cid; public $contact; + public $contacts; public $page_contact; public $content; public $data; @@ -277,7 +291,7 @@ class App { $this->argv = explode('/',$this->cmd); $this->argc = count($this->argv); if((array_key_exists('0',$this->argv)) && strlen($this->argv[0])) { - $this->module = $this->argv[0]; + $this->module = str_replace(".", "_", $this->argv[0]); } else { $this->module = 'home'; @@ -365,9 +379,9 @@ class App { function init_pagehead() { $this->page['title'] = $this->config['sitename']; - $tpl = load_view_file('view/head.tpl'); + $tpl = file_get_contents('view/head.tpl'); $this->page['htmlhead'] = replace_macros($tpl,array( - '$baseurl' => $this->get_baseurl() . '/', + '$baseurl' => $this->get_baseurl(), '$generator' => 'Friendika' . ' ' . FRIENDIKA_VERSION, '$delitem' => t('Delete this item?'), '$comment' => t('Comment') @@ -468,17 +482,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); } } @@ -669,7 +692,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)); @@ -815,7 +838,7 @@ function escape_tags($string) { if(! function_exists('login')) { function login($register = false) { $o = ""; - $register_tpl = (($register) ? load_view_file("view/register-link.tpl") : ""); + $register_tpl = (($register) ? get_markup_template("register-link.tpl") : ""); $register_html = replace_macros($register_tpl,array( '$title' => t('Create a New Account'), @@ -839,14 +862,16 @@ function login($register = false) { $lostlink = t('Password Reset'); if(local_user()) { - $tpl = load_view_file("view/logout.tpl"); + $tpl = get_markup_template("logout.tpl"); } else { - $tpl = load_view_file("view/login.tpl"); + $tpl = get_markup_template("login.tpl"); } - - $o = replace_macros($tpl,array( + + $o = ''; + + $o .= replace_macros($tpl,array( '$logout' => t('Logout'), '$register_html' => $register_html, '$classname' => $classname, @@ -992,6 +1017,13 @@ function notice($s) { if($a->interactive) $_SESSION['sysmsg'] .= $s; }} +if(! function_exists('info')) { +function info($s) { + $a = get_app(); + if($a->interactive) + $_SESSION['sysmsg_info'] .= $s; +}} + // wrapper around config to limit the text length of an incoming message @@ -1493,6 +1525,8 @@ function lrdd($uri) { logger('lrdd: host_meta: ' . $xml, LOGGER_DATA); $h = parse_xml_string($xml); + if(! $h) + return array(); $arr = convert_xml_element_to_array($h); @@ -1657,6 +1691,9 @@ function fetch_xrd_links($url) { logger('fetch_xrd_links: ' . $xml, LOGGER_DATA); $h = parse_xml_string($xml); + if(! $h) + return array(); + $arr = convert_xml_element_to_array($h); $links = array(); @@ -1849,6 +1886,8 @@ function allowed_email($email) { // wrapper to load a view template, checking for alternate // languages before falling back to the default +// obsolete, deprecated. + if(! function_exists('load_view_file')) { function load_view_file($s) { global $lang, $a; @@ -1867,6 +1906,37 @@ function load_view_file($s) { return file_get_contents($s); }} +if(! function_exists('get_intltext_template')) { +function get_intltext_template($s) { + global $lang; + + if(! isset($lang)) + $lang = 'en'; + + if(file_exists("view/$lang/$s")) + return file_get_contents("view/$lang/$s"); + elseif(file_exists("view/en/$s")) + return file_get_contents("view/en/$s"); + else + return file_get_contents("view/$s"); +}} + +if(! function_exists('get_markup_template')) { +function get_markup_template($s) { + + $theme = current_theme(); + + if(file_exists("view/theme/$theme/$s")) + return file_get_contents("view/theme/$theme/$s"); + else + return file_get_contents("view/$s"); + +}} + + + + + // for html,xml parsing - let's say you've got // an attribute foobar="class1 class2 class3" // and you want to find out if it contains 'class3'. @@ -1923,15 +1993,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; } } @@ -2008,7 +2078,7 @@ function contact_block() { }} if(! function_exists('micropro')) { -function micropro($contact, $redirect = false, $class = '') { +function micropro($contact, $redirect = false, $class = '', $textmode = false) { if($class) $class = ' ' . $class; @@ -2027,20 +2097,29 @@ function micropro($contact, $redirect = false, $class = '') { $click = ((x($contact,'click')) ? ' onclick="' . $contact['click'] . '" ' : ''); if($click) $url = ''; - return '
' . $contact['name'] 
-		. '
' . "\r\n"; + if($textmode) { + return '
'. $contact['name'] . '
' . "\r\n"; + } + else { + return '
' . $contact['name'] 
+			. '
' . "\r\n"; + } }} if(! function_exists('search')) { -function search($s) { +function search($s,$id='search-box',$url='/search') { $a = get_app(); - $o = ''; } + return $o; +}} - return $o; +if(! function_exists('normalise_link')) { +function normalise_link($url) { + $ret = str_replace(array('https:','//www.'), array('http:','//'), $url); + return(rtrim($ret,'/')); }} /** @@ -2454,17 +2544,48 @@ function get_birthdays() { if(! function_exists('link_compare')) { function link_compare($a,$b) { - $a1 = str_replace(array('https:','//www.'), array('http:','//'), $a); - $b1 = str_replace(array('https:','//www.'), array('http:','//'), $b); - if(strcasecmp($a1,$b1) === 0) + if(strcasecmp(normalise_link($a),normalise_link($b)) === 0) return true; return false; }} if(! function_exists('prepare_body')) { -function prepare_body($item) { - return prepare_text($item['body']); +function prepare_body($item,$attach = false) { + + $s = prepare_text($item['body']); + if(! $attach) + return $s; + + $arr = explode(',',$item['attach']); + if(count($arr)) { + $s .= '
'; + foreach($arr as $r) { + $matches = false; + $icon = ''; + $cnt = preg_match('|\[attach\]href=\"(.*?)\" size=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches); + if($cnt) { + $icontype = strtolower(substr($matches[3],0,strpos($matches[3],'/'))); + switch($icontype) { + case 'video': + case 'audio': + case 'image': + case 'text': + $icon = '
'; + break; + default: + $icon = '
'; + break; + } + $title = ((strlen(trim($matches[4]))) ? escape_tags(trim($matches[4])) : escape_tags($matches[1])); + $title .= ' ' . $matches[2] . ' ' . t('bytes'); + + $s .= '' . $icon . ''; + } + } + $s .= '
'; + } + return $s; }} if(! function_exists('prepare_text')) { @@ -2631,7 +2752,7 @@ if(! function_exists('get_plink')) { function get_plink($item) { $a = get_app(); $plink = (((x($item,'plink')) && (! $item['private'])) ? '' : ''); + . $item['plink'] . '" title="' . t('link to source') . '" target="external-link" class="icon remote-link">' : ''); return $plink; }} @@ -2641,15 +2762,19 @@ function unamp($s) { }} + + if(! function_exists('lang_selector')) { function lang_selector() { global $lang; + $o .= '
'; $o .= '