]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
Merge branch 'master' of git://github.com/friendika/friendika
[friendica.git] / boot.php
index 7d96eac9f7a819b6805e17bee2f123ddac8cc2eb..49247eb23fff4634679cd22fc7b17858d7941172 100644 (file)
--- 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.992' );
+define ( 'FRIENDIKA_VERSION',      '2.2.1012' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
-define ( 'DB_UPDATE_VERSION',      1058      );
+define ( 'DB_UPDATE_VERSION',      1063      );
 
 define ( 'EOL',                    "<br />\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
@@ -481,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);
                }
        }
 
@@ -682,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));
@@ -2196,12 +2206,13 @@ function smilies($s) {
        $a = get_app();
 
        return str_replace(
-       array( '&lt;3', '&lt;/3', '&lt;\\3', ':-)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O'),
+       array( '&lt;3', '&lt;/3', '&lt;\\3', ':-)', ':)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O'),
        array(
                '<img src="' . $a->get_baseurl() . '/images/smiley-heart.gif" alt="<3" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":-)" />',
+               '<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":)" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";-)" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":-(" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":(" />',
@@ -2552,7 +2563,7 @@ function prepare_body($item,$attach = false) {
                foreach($arr as $r) {
                        $matches = false;
                        $icon = '';
-                       $cnt = preg_match('|\[attach\]href=\"(.+?)\" size=\"(.+?)\" type=\"(.+?)\" title=\"(.+?)\"\[\/attach\]|',$r,$matches);
+                       $cnt = preg_match('|\[attach\]href=\"(.*?)\" size=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches);
                        if($cnt) {
                                $icontype = strtolower(substr($matches[3],0,strpos($matches[3],'/')));
                                switch($icontype) {
@@ -2756,12 +2767,14 @@ function unamp($s) {
 if(! function_exists('lang_selector')) {
 function lang_selector() {
        global $lang;
+       $o .= '<div id="lang-select-icon" class="icon language" title="' . t('Select an alternate language') . '" onclick="openClose(\'language-selector\');" ></div>';
        $o .= '<div id="language-selector" style="display: none;" >';
        $o .= '<form action="" method="post" ><select name="system_language" onchange="this.form.submit();" >';
        $langs = glob('view/*/strings.php');
        if(is_array($langs) && count($langs)) {
                if(! in_array('view/en/strings.php',$langs))
                        $langs[] = 'view/en/';
+               asort($langs);
                foreach($langs as $l) {
                        $ll = substr($l,5);
                        $ll = substr($ll,0,strrpos($ll,'/'));
@@ -2775,16 +2788,23 @@ function lang_selector() {
 
 
 if(! function_exists('parse_xml_string')) {
-function parse_xml_string($s) {
-       if(! strstr($s,'<?xml'))
-               return false;
-       $s2 = substr($s,strpos($s,'<?xml'));
+function parse_xml_string($s,$strict = true) {
+       if($strict) {
+               if(! strstr($s,'<?xml'))
+                       return false;
+               $s2 = substr($s,strpos($s,'<?xml'));
+       }
+       else
+               $s2 = $s;
        libxml_use_internal_errors(true);
+
        $x = @simplexml_load_string($s2);
-       if(count(libxml_get_errors()))
+       if(! $x) {
+               logger('libxml: parse: error: ' . $s2, LOGGER_DATA);
                foreach(libxml_get_errors() as $err)
                        logger('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA);
-       libxml_clear_errors();
+               libxml_clear_errors();
+       }
        return $x;
 }}