mirror of
https://github.com/friendica/friendica
synced 2024-12-23 04:00:15 +00:00
hidden plugins (add .hidden file to dir)
This commit is contained in:
parent
25afec0f81
commit
d48cd0f9a3
7 changed files with 111 additions and 12 deletions
8
boot.php
8
boot.php
|
@ -11,7 +11,7 @@ require_once('include/cache.php');
|
||||||
define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
||||||
define ( 'FRIENDICA_VERSION', '2.3.1328' );
|
define ( 'FRIENDICA_VERSION', '2.3.1328' );
|
||||||
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
||||||
define ( 'DB_UPDATE_VERSION', 1140 );
|
define ( 'DB_UPDATE_VERSION', 1141 );
|
||||||
|
|
||||||
define ( 'EOL', "<br />\r\n" );
|
define ( 'EOL', "<br />\r\n" );
|
||||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||||
|
@ -1519,6 +1519,12 @@ function get_my_url() {
|
||||||
return false;
|
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) {
|
function zrl($s,$force = false) {
|
||||||
if(! strlen($s))
|
if(! strlen($s))
|
||||||
return $s;
|
return $s;
|
||||||
|
|
|
@ -16,9 +16,11 @@ CREATE TABLE IF NOT EXISTS `addon` (
|
||||||
`name` char(255) NOT NULL,
|
`name` char(255) NOT NULL,
|
||||||
`version` char(255) NOT NULL,
|
`version` char(255) NOT NULL,
|
||||||
`installed` tinyint(1) NOT NULL DEFAULT '0',
|
`installed` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
`hidden` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
`timestamp` bigint(20) NOT NULL DEFAULT '0',
|
`timestamp` bigint(20) NOT NULL DEFAULT '0',
|
||||||
`plugin_admin` tinyint(1) 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;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|
60
include/gprobe.php
Normal file
60
include/gprobe.php
Normal 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();
|
||||||
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
if (! function_exists('uninstall_plugin')){
|
if (! function_exists('uninstall_plugin')){
|
||||||
function uninstall_plugin($plugin){
|
function uninstall_plugin($plugin){
|
||||||
logger("Addons: uninstalling " . $plugin);
|
logger("Addons: uninstalling " . $plugin);
|
||||||
q("DELETE FROM `addon` WHERE `name` = '%s' LIMIT 1",
|
q("DELETE FROM `addon` WHERE `name` = '%s' ",
|
||||||
dbesc($plugin)
|
dbesc($plugin)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -37,6 +37,16 @@ function install_plugin($plugin) {
|
||||||
intval($t),
|
intval($t),
|
||||||
$plugin_admin
|
$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;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -92,13 +92,10 @@ if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
|
||||||
load_translation_table($lang);
|
load_translation_table($lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x($_GET,'zrl')) {
|
if((x($_GET,'zrl')) && (! $install)) {
|
||||||
$_SESSION['my_url'] = $_GET['zrl'];
|
$_SESSION['my_url'] = $_GET['zrl'];
|
||||||
$a->query_string = preg_replace('/[\?&]zrl=(.*?)([\?&]|$)/is','',$a->query_string);
|
$a->query_string = preg_replace('/[\?&]zrl=(.*?)([\?&]|$)/is','',$a->query_string);
|
||||||
if(! $install) {
|
zrl_init($a);
|
||||||
$arr = array('zrl' => $_SESSION['my_url'], 'url' => $a->cmd);
|
|
||||||
call_hooks('zrl_init',$arr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,10 +18,18 @@ function friendica_init(&$a) {
|
||||||
$admin = false;
|
$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(
|
$data = Array(
|
||||||
'version' => FRIENDICA_VERSION,
|
'version' => FRIENDICA_VERSION,
|
||||||
'url' => z_root(),
|
'url' => z_root(),
|
||||||
'plugins' => $a->plugins,
|
'plugins' => $visible_plugins,
|
||||||
'register_policy' => $register_policy[$a->config['register_policy']],
|
'register_policy' => $register_policy[$a->config['register_policy']],
|
||||||
'admin' => $admin,
|
'admin' => $admin,
|
||||||
'site_name' => $a->config['sitename'],
|
'site_name' => $a->config['sitename'],
|
||||||
|
@ -54,9 +62,18 @@ function friendica_content(&$a) {
|
||||||
|
|
||||||
$o .= '<p></p>';
|
$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>';
|
$o .= '<p>' . t('Installed plugins/addons/apps:') . '</p>';
|
||||||
$sorted = $a->plugins;
|
$sorted = $visible_plugins;
|
||||||
$s = '';
|
$s = '';
|
||||||
sort($sorted);
|
sort($sorted);
|
||||||
foreach($sorted as $p) {
|
foreach($sorted as $p) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define( 'UPDATE_VERSION' , 1140 );
|
define( 'UPDATE_VERSION' , 1141 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -1223,3 +1223,10 @@ function update_1139() {
|
||||||
return UPDATE_FAILED ;
|
return UPDATE_FAILED ;
|
||||||
return UPDATE_SUCCESS ;
|
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 ;
|
||||||
|
}
|
Loading…
Reference in a new issue