From: friendica Date: Tue, 1 May 2012 06:07:52 +0000 (-0700) Subject: hidden plugins (add .hidden file to dir) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d48cd0f9a3210c14bb98a502188358982261d9df;p=friendica.git hidden plugins (add .hidden file to dir) --- diff --git a/boot.php b/boot.php index 55cac73aca..44a8d8c32a 100644 --- a/boot.php +++ b/boot.php @@ -11,7 +11,7 @@ require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_VERSION', '2.3.1328' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1140 ); +define ( 'DB_UPDATE_VERSION', 1141 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -1519,6 +1519,12 @@ function get_my_url() { return false; } +function zrl_init(&$a) { + proc_run('php','include/gprobe.php',bin2hex(get_my_url())); + $arr = array('zrl' => get_my_url(), 'url' => $a->cmd); + call_hooks('zrl_init',$arr); +} + function zrl($s,$force = false) { if(! strlen($s)) return $s; diff --git a/database.sql b/database.sql index 80a9197fa5..16e3964b58 100644 --- a/database.sql +++ b/database.sql @@ -16,9 +16,11 @@ CREATE TABLE IF NOT EXISTS `addon` ( `name` char(255) NOT NULL, `version` char(255) NOT NULL, `installed` tinyint(1) NOT NULL DEFAULT '0', + `hidden` tinyint(1) NOT NULL DEFAULT '0', `timestamp` bigint(20) NOT NULL DEFAULT '0', `plugin_admin` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `hidden` (`hidden`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- diff --git a/include/gprobe.php b/include/gprobe.php new file mode 100644 index 0000000000..26254ad28b --- /dev/null +++ b/include/gprobe.php @@ -0,0 +1,60 @@ +set_baseurl(get_config('system','url')); + + load_hooks(); + + if($argc != 2) + return; + + $url = hex2bin($argv[1]); + + $r = q("select * from gcontact where nurl = '%s' limit 1", + dbesc(normalise_link($url)) + ); + + if(count($r)) + return; + + $arr = probe_url($url); + + if(count($arr) && x($arr,'network') && $arr['network'] === NETWORK_DFRN) { + q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`) + values ( '%s', '%s', '%s', '%s') ", + dbesc($arr['name']), + dbesc($arr['url']), + dbesc(normalise_link($arr['url'])), + dbesc($arr['photo']) + ); + } + + return; +} + +if (array_search(__file__,get_included_files())===0){ + gprobe_run($argv,$argc); + killme(); +} diff --git a/include/plugin.php b/include/plugin.php index 8196e87561..4ff78a8b4d 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -5,7 +5,7 @@ if (! function_exists('uninstall_plugin')){ function uninstall_plugin($plugin){ logger("Addons: uninstalling " . $plugin); - q("DELETE FROM `addon` WHERE `name` = '%s' LIMIT 1", + q("DELETE FROM `addon` WHERE `name` = '%s' ", dbesc($plugin) ); @@ -37,6 +37,16 @@ function install_plugin($plugin) { intval($t), $plugin_admin ); + + // we can add the following with the previous SQL + // once most site tables have been updated. + // This way the system won't fall over dead during the update. + + if(file_exists('addon/' . $plugin . '/.hidden')) { + q("update addon set hidden = 1 where name = '%s' limit 1", + dbesc($plugin) + ); + } return true; } else { diff --git a/index.php b/index.php index 442173eeb8..a409f47b41 100644 --- a/index.php +++ b/index.php @@ -92,13 +92,10 @@ if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) { load_translation_table($lang); } -if(x($_GET,'zrl')) { +if((x($_GET,'zrl')) && (! $install)) { $_SESSION['my_url'] = $_GET['zrl']; $a->query_string = preg_replace('/[\?&]zrl=(.*?)([\?&]|$)/is','',$a->query_string); - if(! $install) { - $arr = array('zrl' => $_SESSION['my_url'], 'url' => $a->cmd); - call_hooks('zrl_init',$arr); - } + zrl_init($a); } /** diff --git a/mod/friendica.php b/mod/friendica.php index 52a064224a..28807b5b50 100644 --- a/mod/friendica.php +++ b/mod/friendica.php @@ -18,10 +18,18 @@ function friendica_init(&$a) { $admin = false; } + $visible_plugins = array(); + if(is_array($a->plugins) && count($a->plugins)) { + $r = q("select * from addon where hidden = 0"); + if(count($r)) + foreach($r as $rr) + $visible_plugins[] = $rr['name']; + } + $data = Array( 'version' => FRIENDICA_VERSION, 'url' => z_root(), - 'plugins' => $a->plugins, + 'plugins' => $visible_plugins, 'register_policy' => $register_policy[$a->config['register_policy']], 'admin' => $admin, 'site_name' => $a->config['sitename'], @@ -54,9 +62,18 @@ function friendica_content(&$a) { $o .= '

'; - if(count($a->plugins)) { + $visible_plugins = array(); + if(is_array($a->plugins) && count($a->plugins)) { + $r = q("select * from addon where hidden = 0"); + if(count($r)) + foreach($r as $rr) + $visible_plugins[] = $rr['name']; + } + + + if(count($visible_plugins)) { $o .= '

' . t('Installed plugins/addons/apps:') . '

'; - $sorted = $a->plugins; + $sorted = $visible_plugins; $s = ''; sort($sorted); foreach($sorted as $p) { diff --git a/update.php b/update.php index 3c2ecebb6b..f793b89dd5 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@