]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
contact edit tool buttons a bit crowded
[friendica.git] / boot.php
index 9bf331cee5e46ce48d68a6e411db985133b63d15..67e3d65ae170e4d2f9a90681b847c1a024ccb430 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -1,15 +1,26 @@
 <?php
 
 set_time_limit(0);
+ini_set('pcre.backtrack_limit', 250000);
 
-define ( 'FRIENDIKA_VERSION',      '2.1.947' );
+define ( 'FRIENDIKA_VERSION',      '2.1.969' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
-define ( 'DB_UPDATE_VERSION',      1050      );
+define ( 'DB_UPDATE_VERSION',      1054      );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
 define ( 'DOWN_ARROW',             '&#x21e9;'       );
-         
+
+/**
+ *
+ * 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
@@ -290,7 +301,7 @@ class App {
 
                if($this->cmd === '.well-known/host-meta') {
                        require_once('include/hostxrd.php');
-                       hostxrd($this->hostname);
+                       hostxrd($this->get_baseurl());
                        // NOTREACHED
                }
 
@@ -608,19 +619,14 @@ function reload_plugins() {
 // For instance if 'test' => "foo" and 'testing' => "bar", testing could become either bar or fooing, 
 // depending on the order in which they were declared in the array.   
 
+require_once("include/template_processor.php");
+
 if(! function_exists('replace_macros')) {  
 function replace_macros($s,$r) {
+       global $t;
+       
+       return $t->replace($s,$r);
 
-       $search = array();
-       $replace = array();
-
-       if(is_array($r) && count($r)) {
-               foreach ($r as $k => $v ) {
-                       $search[] =  $k;
-                       $replace[] = $v;
-               }
-       }
-       return str_replace($search,$replace,$s);
 }}
 
 
@@ -850,8 +856,10 @@ function login($register = false) {
                $tpl = load_view_file("view/login.tpl");
 
        }
-       
-       $o = replace_macros($tpl,array(
+
+       $o = '<script type="text/javascript"> $(document).ready(function() { $("#login-name").focus();} );</script>';   
+
+       $o .= replace_macros($tpl,array(
                '$logout'        => t('Logout'),
                '$register_html' => $register_html, 
                '$classname'     => $classname,
@@ -1223,6 +1231,7 @@ function set_config($family,$key,$value) {
        global $a;
 
        if(get_config($family,$key,true) === false) {
+               $a->config[$family][$key] = $value;
                $ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ",
                        dbesc($family),
                        dbesc($key),
@@ -1317,6 +1326,7 @@ function set_pconfig($uid,$family,$key,$value) {
        global $a;
 
        if(get_pconfig($uid,$family,$key,true) === false) {
+               $a->config[$uid][$family][$key] = $value;
                $ret = q("INSERT INTO `pconfig` ( `uid`, `cat`, `k`, `v` ) VALUES ( %d, '%s', '%s', '%s' ) ",
                        intval($uid),
                        dbesc($family),
@@ -1854,13 +1864,19 @@ function allowed_email($email) {
 
 if(! function_exists('load_view_file')) {
 function load_view_file($s) {
-       global $lang;
+       global $lang, $a;
        if(! isset($lang))
                $lang = 'en';
        $b = basename($s);
        $d = dirname($s);
        if(file_exists("$d/$lang/$b"))
                return file_get_contents("$d/$lang/$b");
+       
+       $theme = current_theme();
+       
+       if(file_exists("$d/theme/$theme/$b"))
+               return file_get_contents("$d/theme/$theme/$b");
+                       
        return file_get_contents($s);
 }}
 
@@ -2026,7 +2042,7 @@ function micropro($contact, $redirect = false, $class = '') {
                $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="' 
+               . (($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";
 }}
@@ -2124,7 +2140,7 @@ function smilies($s) {
        $a = get_app();
 
        return str_replace(
-       array( '&lt;3', '&lt;/3', '&lt;\\3', ':-)', ';-)', ':-(', ':(', ':-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" />',
@@ -2134,6 +2150,7 @@ function smilies($s) {
                '<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":-(" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":(" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" />',
+               '<img src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":P" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-\"" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" />',
                '<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" />',
@@ -2251,8 +2268,15 @@ function profile_sidebar($profile) {
 
        $photo = '<div id="profile-photo-wrapper"><img class="photo" src="' . $profile['photo'] . '" alt="' . $profile['name'] . '" /></div>';
 
+       // don't show connect link to yourself
+       
        $connect = (($profile['uid'] != local_user()) ? '<li><a id="dfrn-request-link" href="dfrn_request/' . $profile['nickname'] . '">' . t('Connect') . '</a></li>' : '');
+
+       // don't show connect link to authenticated visitors either
+
+       if((remote_user()) && ($_SESSION['visitor_visiting'] == $profile['uid']))
+               $connect = ''; 
+
        if((x($profile,'address') == 1) 
                || (x($profile,'locality') == 1) 
                || (x($profile,'region') == 1) 
@@ -2498,34 +2522,38 @@ function proc_run($cmd){
        proc_close(proc_open($cmdline." &",array(),$foo));
 }}
 
-/*
- * Return full URL to theme which is currently in effect.
- * Provide a sane default if nothing is chosen or the specified theme does not exist.
- */
-
-if(! function_exists('current_theme_url')) {
-function current_theme_url() {
-
+if(! function_exists('current_theme')) {
+function current_theme(){
        $app_base_themes = array('duepuntozero', 'loozah');
-
+       
        $a = get_app();
-
+       
        $system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
-       $theme_name = ((x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme);
-
+       $theme_name = ((is_array($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme);
+       
        if($theme_name && file_exists('view/theme/' . $theme_name . '/style.css'))
-               return($a->get_baseurl() . '/view/theme/' . $theme_name . '/style.css'); 
-
+               return($theme_name);
+       
        foreach($app_base_themes as $t) {
                if(file_exists('view/theme/' . $t . '/style.css'))
-                       return($a->get_baseurl() . '/view/theme/' . $t . '/style.css'); 
-       }       
-
+                       return($t);
+       }
+       
        $fallback = glob('view/theme/*/style.css');
        if(count($fallback))
-               return($a->get_baseurl() . $fallback[0]);
+               return (str_replace('view/theme/','', str_replace("/style.css","",$fallback[0])));
 
-       
+}}
+
+/*
+* Return full URL to theme which is currently in effect.
+* Provide a sane default if nothing is chosen or the specified theme does not exist.
+*/
+if(! function_exists('current_theme_url')) {
+function current_theme_url() {
+       global $a;
+       $t = current_theme();
+       return($a->get_baseurl() . '/view/theme/' . $t . '/style.css');
 }}
 
 if(! function_exists('feed_birthday')) {
@@ -2616,7 +2644,7 @@ if(! function_exists('get_plink')) {
 function get_plink($item) {
        $a = get_app(); 
        $plink = (((x($item,'plink')) && (! $item['private'])) ? '<div class="wall-item-links-wrapper"><a href="' 
-                       . $item['plink'] . '" title="' . t('link to source') . '" target="external-link" ><img src="' . $a->get_baseurl() . '/images/remote-link.gif" alt="' . t('link to source') . '" /></a></div>' : '');
+                       . $item['plink'] . '" title="' . t('link to source') . '" target="external-link" class="icon remote-link"></a></div>' : '');
        return $plink;
 }}
 
@@ -2656,7 +2684,7 @@ function parse_xml_string($s) {
        $x = @simplexml_load_string($s2);
        if(count(libxml_get_errors()))
                foreach(libxml_get_errors() as $err)
-                       logger('libxml: parse: ' . $err, LOGGER_DATA);
+                       logger('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA);
        libxml_clear_errors();
        return $x;
 }}