]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
how the heck did favicon get into the repo? Gone now...
[friendica.git] / boot.php
index 49247eb23fff4634679cd22fc7b17858d7941172..54206d7fe4300d292f78df4fc64ff494d26df286 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.1012' );
+define ( 'FRIENDIKA_VERSION',      '2.2.1025' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
-define ( 'DB_UPDATE_VERSION',      1063      );
+define ( 'DB_UPDATE_VERSION',      1070      );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
@@ -128,6 +128,8 @@ define ( 'NAMESPACE_OSTATUSSUB',      'http://ostatus.org/schema/1.0/subscribe'
 define ( 'NAMESPACE_GEORSS',          'http://www.georss.org/georss' );
 define ( 'NAMESPACE_POCO',            'http://portablecontacts.net/spec/1.0' );
 define ( 'NAMESPACE_FEED',            'http://schemas.google.com/g/2010#updates-from' );
+define ( 'NAMESPACE_OSTATUS',         'http://ostatus.org/schema/1.0' );
+define ( 'NAMESPACE_STATUSNET',       'http://status.net/schema/api/1/' );
 
 /**
  * activity stream defines
@@ -453,6 +455,41 @@ function system_unavailable() {
        killme();
 }}
 
+
+// install and uninstall plugin
+if (! function_exists('uninstall_plugin')){
+function uninstall_plugin($plugin){
+       logger("Addons: uninstalling " . $plugin);
+       q("DELETE FROM `addon` WHERE `name` = '%s' LIMIT 1",
+               dbesc($plugin)
+       );
+
+       @include_once('addon/' . $plugin . '/' . $plugin . '.php');
+       if(function_exists($plugin . '_uninstall')) {
+               $func = $plugin . '_uninstall';
+               $func();
+       }
+}}
+
+if (! function_exists('install_plugin')){
+function install_plugin($plugin){
+       logger("Addons: installing " . $plugin);
+       $t = filemtime('addon/' . $plugin . '/' . $plugin . '.php');
+       @include_once('addon/' . $plugin . '/' . $plugin . '.php');
+       if(function_exists($plugin . '_install')) {
+               $func = $plugin . '_install';
+               $func();
+               
+               $plugin_admin = (function_exists($plugin."_plugin_admin")?1:0);
+               
+               $r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ",
+                       dbesc($plugin),
+                       intval($t),
+                       $plugin_admin
+               );
+       }
+}}
+
 // Primarily involved with database upgrade, but also sets the 
 // base url for use in cmdline programs which don't have
 // $_SERVER variables, and synchronising the state of installed plugins.
@@ -538,16 +575,7 @@ function check_config(&$a) {
        if(count($installed)) {
                foreach($installed as $i) {
                        if(! in_array($i['name'],$plugins_arr)) {
-                               logger("Addons: uninstalling " . $i['name']);
-                               q("DELETE FROM `addon` WHERE `id` = %d LIMIT 1",
-                                       intval($i['id'])
-                               );
-
-                               @include_once('addon/' . $i['name'] . '/' . $i['name'] . '.php');
-                               if(function_exists($i['name'] . '_uninstall')) {
-                                       $func = $i['name'] . '_uninstall';
-                                       $func();
-                               }
+                               uninstall_plugin($i['name']);
                        }
                        else
                                $installed_arr[] = $i['name'];
@@ -557,17 +585,7 @@ function check_config(&$a) {
        if(count($plugins_arr)) {
                foreach($plugins_arr as $p) {
                        if(! in_array($p,$installed_arr)) {
-                               logger("Addons: installing " . $p);
-                               $t = filemtime('addon/' . $p . '/' . $p . '.php');
-                               @include_once('addon/' . $p . '/' . $p . '.php');
-                               if(function_exists($p . '_install')) {
-                                       $func = $p . '_install';
-                                       $func();
-                                       $r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`) VALUES ( '%s', 1, %d ) ",
-                                               dbesc($p),
-                                               intval($t)
-                                       );
-                               }
+                               install_plugin($p);
                        }
                }
        }
@@ -1231,8 +1249,10 @@ function get_config($family, $key, $instore = false) {
                dbesc($key)
        );
        if(count($ret)) {
-               $a->config[$family][$key] = $ret[0]['v'];
-               return $ret[0]['v'];
+               // manage array value
+               $val = (preg_match("|^a:[0-9]+:{.*}$|", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
+               $a->config[$family][$key] = $val;
+               return $val;
        }
        else {
                $a->config[$family][$key] = '!<unset>!';
@@ -1246,22 +1266,25 @@ function get_config($family, $key, $instore = false) {
 
 if(! function_exists('set_config')) {
 function set_config($family,$key,$value) {
-
        global $a;
+       
+       // manage array value
+       $dbvalue = (is_array($value)?serialize($value):$value);
 
        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),
-                       dbesc($value)
+                       dbesc($dbvalue)
                );
                if($ret) 
                        return $value;
                return $ret;
        }
+       
        $ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
-               dbesc($value),
+               dbesc($dbvalue),
                dbesc($family),
                dbesc($key)
        );
@@ -1662,8 +1685,10 @@ function fetch_lrdd_template($host) {
        $url1 = 'https://' . $host . '/.well-known/host-meta' ;
        $url2 = 'http://' . $host . '/.well-known/host-meta' ;
        $links = fetch_xrd_links($url1);
+       logger('fetch_lrdd_template from: ' . $url1);
        logger('template (https): ' . print_r($links,true));
        if(! count($links)) {
+               logger('fetch_lrdd_template from: ' . $url2);
                $links = fetch_xrd_links($url2);
                logger('template (http): ' . print_r($links,true));
        }
@@ -2767,7 +2792,7 @@ 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="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');
@@ -2816,3 +2841,55 @@ function is_site_admin() {
        return false;
 }}
 
+/*
+ * parse plugin comment in search of plugin infos.
+ * like
+ *     
+ *      * Name: Plugin
+ *   * Description: A plugin which plugs in
+ *      * Version: 1.2.3
+ *   * Author: John <profile url>
+ *   * Author: Jane <email>
+ *   *
+ */
+
+if (! function_exists('get_plugin_info')){
+function get_plugin_info($plugin){
+       if (!is_file("addon/$plugin/$plugin.php")) return false;
+       
+       $f = file_get_contents("addon/$plugin/$plugin.php");
+       $r = preg_match("|/\*.*\*/|msU", $f, $m);
+       
+       $info=Array(
+               'name' => $plugin,
+               'description' => "",
+               'author' => array(),
+               'version' => ""
+       );
+       
+       if ($r){
+               $ll = explode("\n", $m[0]);
+               foreach( $ll as $l ) {
+                       $l = trim($l,"\t\n\r */");
+                       if ($l!=""){
+                               list($k,$v) = array_map("trim", explode(":",$l,2));
+                               $k= strtolower($k);
+                               if ($k=="author"){
+                                       $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
+                                       if ($r) {
+                                               $info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
+                                       } else {
+                                               $info['author'][] = array('name'=>$v);
+                                       }
+                               } else {
+                                       if (array_key_exists($k,$info)){
+                                               $info[$k]=$v;
+                                       }
+                               }
+                               
+                       }
+               }
+               
+       }
+       return $info;
+}}