aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-04-30 23:07:52 -0700
committerfriendica <info@friendica.com>2012-04-30 23:07:52 -0700
commitd48cd0f9a3210c14bb98a502188358982261d9df (patch)
treed5b13e587c7b8f2d140b559f3a67fd299afdedd3
parent25afec0f81961665717e159aba216d1e9d9f9d86 (diff)
downloadvolse-hubzilla-d48cd0f9a3210c14bb98a502188358982261d9df.tar.gz
volse-hubzilla-d48cd0f9a3210c14bb98a502188358982261d9df.tar.bz2
volse-hubzilla-d48cd0f9a3210c14bb98a502188358982261d9df.zip
hidden plugins (add .hidden file to dir)
-rw-r--r--boot.php8
-rw-r--r--database.sql4
-rw-r--r--include/gprobe.php60
-rw-r--r--include/plugin.php12
-rw-r--r--index.php7
-rw-r--r--mod/friendica.php23
-rw-r--r--update.php9
7 files changed, 111 insertions, 12 deletions
diff --git a/boot.php b/boot.php
index 55cac73ac..44a8d8c32 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', "<br />\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 80a9197fa..16e3964b5 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 000000000..26254ad28
--- /dev/null
+++ b/include/gprobe.php
@@ -0,0 +1,60 @@
+<?php
+
+require_once("boot.php");
+require_once('include/Scrape.php');
+
+function gprobe_run($argv, $argc){
+ global $a, $db;
+
+ if(is_null($a)) {
+ $a = new App;
+ }
+
+ if(is_null($db)) {
+ @include(".htconfig.php");
+ require_once("dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+ };
+
+ require_once('include/session.php');
+ require_once('include/datetime.php');
+
+ load_config('config');
+ load_config('system');
+
+ $a->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 8196e8756..4ff78a8b4 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 442173eeb..a409f47b4 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 52a064224..28807b5b5 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 .= '<p></p>';
- 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 .= '<p>' . t('Installed plugins/addons/apps:') . '</p>';
- $sorted = $a->plugins;
+ $sorted = $visible_plugins;
$s = '';
sort($sorted);
foreach($sorted as $p) {
diff --git a/update.php b/update.php
index 3c2ecebb6..f793b89dd 100644
--- a/update.php
+++ b/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1140 );
+define( 'UPDATE_VERSION' , 1141 );
/**
*
@@ -1223,3 +1223,10 @@ function update_1139() {
return UPDATE_FAILED ;
return UPDATE_SUCCESS ;
}
+
+function update_1140() {
+ $r = q("alter table addon add hidden tinyint(1) not null default '0' after installed, add index(hidden) ");
+ if(! $r)
+ return UPDATE_FAILED ;
+ return UPDATE_SUCCESS ;
+} \ No newline at end of file