X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=197b6d2381c98c9dd8927379f068d138f05b67c2;hb=7b6385df946db4a61e8fc330c1a89b1415ca68ef;hp=9cc4d0f34f91b57796c68667733b27af89feb109;hpb=ddec422de6707809aceb541e1191073b43aec18a;p=friendica.git
diff --git a/boot.php b/boot.php
index 9cc4d0f34f..197b6d2381 100644
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
set_time_limit(0);
-define ( 'BUILD_ID', 1027 );
+define ( 'BUILD_ID', 1030 );
define ( 'DFRN_PROTOCOL_VERSION', '2.0' );
define ( 'EOL', "
\r\n" );
@@ -35,6 +35,13 @@ define ( 'REL_VIP', 1);
define ( 'REL_FAN', 2);
define ( 'REL_BUD', 3);
+/**
+ * Hook array order
+ */
+
+define ( 'HOOK_HOOK', 0);
+define ( 'HOOK_FILE', 1);
+define ( 'HOOK_FUNCTION', 2);
/**
*
@@ -204,14 +211,14 @@ class App {
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=")
$this->query_string = substr($_SERVER['QUERY_STRING'],2);
if(x($_GET,'q'))
- $this->cmd = trim($_GET['q'],'/');
+ $this->cmd = trim($_GET['q'],'/\\');
/**
* Figure out if we are running at the top of a domain
* or in a sub-directory and adjust accordingly
*/
- $path = trim(dirname($_SERVER['SCRIPT_NAME']),'/');
+ $path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\');
if(isset($path) && strlen($path) && ($path != $this->path))
$this->path = $path;
@@ -372,7 +379,8 @@ function system_unavailable() {
// Primarily involved with database upgrade, but also sets the
// base url for use in cmdline programs which don't have
-// $_SERVER variables.
+// $_SERVER variables, and synchronising the state of installed plugins.
+
if(! function_exists('check_config')) {
function check_config(&$a) {
@@ -404,6 +412,70 @@ function check_config(&$a) {
set_config('system','build', BUILD_ID);
}
}
+
+ /**
+ *
+ * Synchronise plugins:
+ *
+ * $a->config['system']['addon'] contains a comma-separated list of names
+ * of plugins/addons which are used on this system.
+ * Go through the database list of already installed addons, and if we have
+ * an entry, but it isn't in the config list, call the uninstall procedure
+ * and mark it uninstalled in the database (for now we'll remove it).
+ * Then go through the config list and if we have a plugin that isn't installed,
+ * call the install procedure and add it to the database.
+ *
+ */
+
+ $r = q("SELECT * FROM `addon` WHERE `installed` = 1");
+ if(count($r))
+ $installed = $r;
+ else
+ $installed = array();
+
+ $plugins = get_config('system','addon');
+ $plugins_arr = array();
+
+ if($plugins)
+ $plugins_arr = explode(',',str_replace(' ', '',$plugins));
+
+ $installed_arr = array();
+
+ 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();
+ }
+ }
+ else
+ $installed_arr[] = $i['name'];
+ }
+ }
+
+ if(count($plugins_arr)) {
+ foreach($plugins_arr as $p) {
+ if(! in_array($p,$installed_arr)) {
+ logger("Addons: installing " . $p);
+ @include_once('addon/' . $p . '/' . $p . '.php');
+ if(function_exists($p . '_install')) {
+ $func = $p . '_install';
+ $func();
+ $r = q("INSERT INTO `addon` (`name`, `installed`) VALUES ( '%s', 1 ) ",
+ dbesc($p)
+ );
+ }
+ }
+ }
+ }
+
return;
}}
@@ -1046,6 +1118,23 @@ function set_config($family,$key,$value) {
}}
+if(! function_exists('load_pconfig')) {
+function load_pconfig($uid,$family) {
+ global $a;
+ $r = q("SELECT * FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d",
+ dbesc($family),
+ intval($uid)
+ );
+ if(count($r)) {
+ foreach($r as $rr) {
+ $k = $rr['k'];
+ $a->config[$uid][$family][$k] = $rr['v'];
+ }
+ }
+}}
+
+
+
if(! function_exists('get_pconfig')) {
function get_pconfig($uid,$family, $key, $instore = false) {
@@ -1110,11 +1199,12 @@ function set_pconfig($uid,$family,$key,$value) {
return $ret;
}
$ret = q("UPDATE `pconfig` SET `v` = '%s' WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
- intval($uid),
dbesc($value),
+ intval($uid),
dbesc($family),
dbesc($key)
);
+
if($ret)
return $value;
return $ret;
@@ -1652,6 +1742,11 @@ if(! function_exists('contact_block')) {
function contact_block() {
$o = '';
$a = get_app();
+
+ $shown = get_pconfig($a->profile['uid'],'system','display_friend_count');
+ if(! $shown)
+ $shown = 24;
+
if((! is_array($a->profile)) || ($a->profile['hide-friends']))
return $o;
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0",
@@ -1664,8 +1759,9 @@ function contact_block() {
$o .= '