hidden plugins (add .hidden file to dir)

This commit is contained in:
friendica 2012-04-30 23:07:52 -07:00
parent 25afec0f81
commit d48cd0f9a3
7 changed files with 111 additions and 12 deletions

View File

@ -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;

View File

@ -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;
-- --------------------------------------------------------

60
include/gprobe.php Normal file
View File

@ -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();
}

View File

@ -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 {

View File

@ -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);
}
/**

View File

@ -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) {

View File

@ -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 ;
}