]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
set permalink on photo tags
[friendica.git] / boot.php
index 84e252eb1bec8c05bb43ce1ea10a0beffb2c0d03..1c7a1570526cfb88f5c4b19012d30ae31fed0f2b 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.976' );
+define ( 'FRIENDIKA_VERSION',      '2.2.1005' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
-define ( 'DB_UPDATE_VERSION',      1054      );
+define ( 'DB_UPDATE_VERSION',      1063      );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
@@ -481,17 +481,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 +691,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));
@@ -1007,6 +1016,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
 
@@ -1508,6 +1524,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);
 
@@ -1672,6 +1690,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();
@@ -1971,15 +1992,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;
                }
        }
 
@@ -2056,7 +2077,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;
@@ -2075,20 +2096,29 @@ function micropro($contact, $redirect = false, $class = '') {
        $click = ((x($contact,'click')) ? ' onclick="' . $contact['click'] . '" ' : '');
        if($click)
                $url = '';
-       return '<div class="contact-block-div' . $class . '"><a class="contact-block-link' . $class . $sparkle 
-               . (($click) ? ' fakelink' : '') . '" '
-               . (($url) ? ' href="' . $url . '"' : '') . $click . ' ><img class="contact-block-img' . $class . $sparkle . '" src="' 
-               . $contact['micro'] . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name'] 
-               . '" /></a></div>' . "\r\n";
+       if($textmode) {
+               return '<div class="contact-block-textdiv' . $class . '"><a class="contact-block-link' . $class . $sparkle 
+                       . (($click) ? ' fakelink' : '') . '" '
+                       . (($url) ? ' href="' . $url . '"' : '') . $click
+                       . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name'] 
+                       . '" >'. $contact['name'] . '</a></div>' . "\r\n";
+       }
+       else {
+               return '<div class="contact-block-div' . $class . '"><a class="contact-block-link' . $class . $sparkle 
+                       . (($click) ? ' fakelink' : '') . '" '
+                       . (($url) ? ' href="' . $url . '"' : '') . $click . ' ><img class="contact-block-img' . $class . $sparkle . '" src="' 
+                       . $contact['micro'] . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name'] 
+                       . '" /></a></div>' . "\r\n";
+       }
 }}
 
 
 
 if(! function_exists('search')) {
-function search($s) {
+function search($s,$id='search-box',$url='/search') {
        $a = get_app();
-       $o  = '<div id="search-box">';
-       $o .= '<form action="' . $a->get_baseurl() . '/search' . '" method="get" >';
+       $o  = '<div id="' . $id . '">';
+       $o .= '<form action="' . $a->get_baseurl() . $url . '" method="get" >';
        $o .= '<input type="text" name="search" id="search-text" value="' . $s .'" />';
        $o .= '<input type="submit" name="submit" id="search-submit" value="' . t('Search') . '" />'; 
        $o .= '</form></div>';
@@ -2175,12 +2205,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=":(" />',
@@ -2340,6 +2371,10 @@ function profile_sidebar($profile) {
 
        $homepage = ((x($profile,'homepage') == 1) ? '<div class="homepage"><span class="homepage-label">' . t('Homepage:') . ' </span><span class="homepage-url">' . linkify($profile['homepage']) . '</span></div><div class="profile-clear"></div>' : '');
 
+       if($profile['hidewall'] && (! local_user()) && (! remote_user())) {
+               $location = $gender = $marital = $homepage = '';
+       }
+
        $tpl = get_markup_template('profile_vcard.tpl');
 
        $o .= replace_macros($tpl, array(
@@ -2515,8 +2550,41 @@ function link_compare($a,$b) {
 
 
 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 .= '<div class="body-attach">';
+               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 = '<div class="attachtype type-' . $icontype . '"></div>';
+                                               break;
+                                       default:
+                                               $icon = '<div class="attachtype type-unkn"></div>';
+                                               break;
+                               }
+                               $title = ((strlen(trim($matches[4]))) ? escape_tags(trim($matches[4])) : escape_tags($matches[1]));
+                               $title .= ' ' . $matches[2] . ' ' . t('bytes');
+
+                               $s .= '<a href="' . strip_tags($matches[1]) . '" title="' . $title . '" class="attachlink" target="external-link" >' . $icon . '</a>';
+                       }
+               }
+               $s .= '<div class="clear"></div></div>';
+       }
+       return $s;
 }}
 
 if(! function_exists('prepare_text')) {
@@ -2693,15 +2761,19 @@ 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,'/'));
@@ -2727,3 +2799,12 @@ function parse_xml_string($s) {
        libxml_clear_errors();
        return $x;
 }}
+
+if(! function_exists('is_site_admin')) {
+function is_site_admin() {
+       $a = get_app();
+       if(local_user() && x($a->user,'email') && x($a->config,'admin_email') && ($a->user['email'] === $a->config['admin_email']))
+               return true;
+       return false;
+}}
+