]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
more ssl_policy cleanup, allow manual feed update per contact when hub is whacked...
[friendica.git] / boot.php
index 7e71a38d9e07de55d423af40e7deced7efb32a76..6cbb4f07c7200da51d3305c42e4d85e10cf427c6 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -2,13 +2,24 @@
 
 set_time_limit(0);
 
-define ( 'BUILD_ID',               1031   );
+define ( 'BUILD_ID',               1033   );
+define ( 'FRIENDIKA_VERSION',      '2.10.0902' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.0'  );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
 define ( 'DOWN_ARROW',             '&#x21e9;'       );
          
+
+/**
+ * SSL redirection policies
+ */
+
+define ( 'SSL_POLICY_NONE',         0 );
+define ( 'SSL_POLICY_FULL',         1 );
+define ( 'SSL_POLICY_SELFSIGN',     2 );
+
+
 /**
  * log levels
  */
@@ -269,10 +280,17 @@ class App {
        }
 
        function get_baseurl($ssl = false) {
-               if(strlen($this->baseurl))
-                       return $this->baseurl;
 
-               $this->baseurl = (($ssl) ? 'https' : $this->scheme) . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
+               $scheme = $this->scheme;
+
+               if(x($this->config,'ssl_policy')) {
+                       if(($ssl) || ($this->config['ssl_policy'] == SSL_POLICY_FULL)) 
+                               $scheme = 'https';
+                       if(($this->config['ssl_policy'] == SSL_POLICY_SELFSIGN) && (local_user() || x($_POST,'auth-params')))
+                               $scheme = 'https';
+               }
+
+               $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
                return $this->baseurl;
        }
 
@@ -311,7 +329,8 @@ class App {
                $this->page['title'] = $this->config['sitename'];
                $tpl = load_view_file("view/head.tpl");
                $this->page['htmlhead'] = replace_macros($tpl,array(
-                       '$baseurl' => $this->get_baseurl() . '/'
+                       '$baseurl' => $this->get_baseurl() . '/',
+                       '$generator' => 'Friendika' . ' ' . FRIENDIKA_VERSION
                ));
        }
 
@@ -908,7 +927,6 @@ function xmlify($str) {
                        case "'" :
                                $buffer .= '&apos;';
                                break;
-
                        case "\"" :
                                $buffer .= '&quot;';
                                break;
@@ -944,6 +962,11 @@ function unxmlify($s) {
 
 if(! function_exists('hex2bin')) {
 function hex2bin($s) {
+       if(! ctype_xdigit($s)) {
+               logger('hex2bin: illegal input: ' . print_r(debug_backtrace(), true));
+               return($s);
+       }
+
        return(pack("H*",$s));
 }}
 
@@ -1649,7 +1672,6 @@ function attribute_contains($attr,$s) {
 
 if(! function_exists('logger')) {
 function logger($msg,$level = 0) {
-
        $debugging = get_config('system','debugging');
        $loglevel  = intval(get_config('system','loglevel'));
        $logfile   = get_config('system','logfile');
@@ -1681,7 +1703,12 @@ function activity_match($haystack,$needle) {
 if(! function_exists('get_tags')) {
 function get_tags($s) {
        $ret = array();
-       if(preg_match_all('/([@#][^ \x0D\x0A,:?]*)([ \x0D\x0A,:?]|$)/',$s,$match)) {
+
+       // ignore anything in a code block
+
+       $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,"]")) {
                                // we might be inside a bbcode color tag - leave it alone
@@ -1867,7 +1894,7 @@ function aes_encrypt($val,$ky)
 
 if(! function_exists('linkify')) {
 function linkify($s) {
-       $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", ' <a href="$1" >$1</a>', $s);
+       $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", ' <a href="$1" target="external-link">$1</a>', $s);
        return($s);
 }}
 
@@ -2003,8 +2030,12 @@ function profile_sidebar($profile) {
        if((! is_array($profile)) && (! count($profile)))
                return $o;
 
+       call_hooks('profile_sidebar_enter', $profile);
+
        $fullname = '<div class="fn">' . $profile['name'] . '</div>';
 
+       $pdesc = '<div class="title">' . $profile['pdesc'] . '</div>';
+
        $tabs = '';
 
        $photo = '<div id="profile=photo-wrapper"><img class="photo" src="' . $profile['photo'] . '" alt="' . $profile['name'] . '" /></div>';
@@ -2043,6 +2074,7 @@ function profile_sidebar($profile) {
 
        $o .= replace_macros($tpl, array(
                '$fullname' => $fullname,
+               '$pdesc'    => $pdesc,
                '$tabs'     => $tabs,
                '$photo'    => $photo,
                '$connect'  => $connect,                
@@ -2053,7 +2085,10 @@ function profile_sidebar($profile) {
                '$homepage' => $homepage
        ));
 
-       call_hooks('profile_sidebar', $o);
+
+       $arr = array('profile' => $profile, 'entry' => $o);
+
+       call_hooks('profile_sidebar', $arr);
 
        return $o;
 }}
@@ -2162,11 +2197,12 @@ function get_birthdays() {
 
                foreach($r as $rr) {
                        $now = strtotime('now');
-                       $today = (((strtotime($rr['start']) < $now) && (strtotime($rr['finish']) > $now)) ? true : false); 
+                       $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false); 
 
                        $o .= '<div class="birthday-list" id="birthday-' . $rr['eid'] . '"><a class="sparkle" href="' 
                        . $a->get_baseurl() . '/redir/'  . $rr['cid'] . '">' . $rr['name'] . '</a> ' 
-                       . day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $bd_format)) . (($today) ?  ' ' . t('[today]') : '') ;
+                       . day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $bd_format)) . (($today) ?  ' ' . t('[today]') : '')
+                       . '</div>' ;
                }
 
                $o .= '</div>';
@@ -2176,3 +2212,60 @@ function get_birthdays() {
 
 }}
 
+/**
+ *
+ * Compare two URLs to see if they are the same, but ignore
+ * slight but hopefully insignificant differences such as if one 
+ * is https and the other isn't, or if one is www.something and 
+ * the other isn't - and also ignore case differences.
+ *
+ * Return true if the URLs match, otherwise false.
+ *
+ */
+
+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)
+               return true;
+       return false;
+}}
+
+
+if(! function_exists('prepare_body')) {
+function prepare_body($item) {
+
+       require_once('include/bbcode.php');
+
+       $s = smilies(bbcode($item['body']));
+
+       return $s;
+}}
+
+/**
+ * 
+ * Wrap calls to proc_close(proc_open()) and call hook
+ * so plugins can take part in process :)
+ * 
+ * args:
+ * $cmd program to run
+ *  next args are passed as $cmd command line
+ * 
+ * e.g.: proc_run("ls","-la","/tmp");
+ * 
+ * $cmd and string args are surrounded with ""
+ */
+
+if(! function_exists('run_proc')) {
+function proc_run($cmd){
+       $args = func_get_args();
+       call_hooks("proc_run", $args);
+       
+       foreach ($args as &$arg){
+               if(is_string($arg)) $arg='"'.$arg.'"';
+       }
+       $cmdline = implode($args," ");
+       proc_close(proc_open($cmdline." &",array(),$foo));
+}}
+