aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2015-11-30 07:50:21 -0500
committerAndrew Manning <tamanning@zoho.com>2015-11-30 07:50:21 -0500
commitd4b04d22eda4e60f5c6d11d1cb2223dee912783a (patch)
treef50541fa6c275b53a284f14694b7462e5763caa4
parentb1f4b9759b34249540d81aed724aa023153e2b53 (diff)
parent650f882265cc0256fa85046baacca9dc6db56d24 (diff)
downloadvolse-hubzilla-d4b04d22eda4e60f5c6d11d1cb2223dee912783a.tar.gz
volse-hubzilla-d4b04d22eda4e60f5c6d11d1cb2223dee912783a.tar.bz2
volse-hubzilla-d4b04d22eda4e60f5c6d11d1cb2223dee912783a.zip
Merge branch 'master' of https://github.com/redmatrix/hubzilla into update-addon-script
-rw-r--r--include/externals.php16
-rw-r--r--include/network.php159
-rw-r--r--include/zot.php14
-rwxr-xr-xmod/setup.php2
-rw-r--r--mod/siteinfo.php100
-rw-r--r--mod/siteinfo_json.php8
6 files changed, 177 insertions, 122 deletions
diff --git a/include/externals.php b/include/externals.php
index 4ac9754e2..3a3a32420 100644
--- a/include/externals.php
+++ b/include/externals.php
@@ -40,19 +40,11 @@ function externals_run($argv, $argc){
$url = $r[0]['site_url'];
}
- // Note: blacklisted sites must be stored in the config as an array.
- // No simple way to turn this into a personal config because we have no identity here.
- // For that we probably need a variant of superblock.
-
$blacklisted = false;
- $bl1 = get_config('system','blacklisted_sites');
- if(is_array($bl1) && $bl1) {
- foreach($bl1 as $bl) {
- if($bl && strpos($url,$bl) !== false) {
- $blacklisted = true;
- break;
- }
- }
+
+ if(! check_siteallowed($url)) {
+ logger('blacklisted site: ' . $url);
+ $blacklisted = true;
}
$attempts ++;
diff --git a/include/network.php b/include/network.php
index 026f5ee0a..e906fc7cb 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1709,3 +1709,162 @@ function do_delivery($deliveries) {
}
+
+
+function get_site_info() {
+
+ global $db;
+ global $a;
+
+ $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
+ $directory_mode = Array('DIRECTORY_MODE_NORMAL', 'DIRECTORY_MODE_SECONDARY','DIRECTORY_MODE_PRIMARY', 256 => 'DIRECTORY_MODE_STANDALONE');
+
+ $sql_extra = '';
+
+ $r = q("select * from channel left join account on account_id = channel_account_id where ( account_roles & 4096 )>0 and account_default_channel = channel_id");
+
+
+ if($r) {
+ $admin = array();
+ foreach($r as $rr) {
+ if($rr['channel_pageflags'] & PAGE_HUBADMIN)
+ $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . get_app()->get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']);
+ }
+ if(! $admin) {
+ foreach($r as $rr) {
+ $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . get_app()->get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']);
+ }
+ }
+ }
+ else {
+ $admin = false;
+ }
+
+ $def_service_class = get_config('system','default_service_class');
+ if($def_service_class)
+ $service_class = get_config('service_class',$def_service_class);
+ else
+ $service_class = 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'];
+ }
+ sort($visible_plugins);
+
+ if(@is_dir('.git') && function_exists('shell_exec'))
+ $commit = trim(@shell_exec('git log -1 --format="%h"'));
+ if(! isset($commit) || strlen($commit) > 16)
+ $commit = '';
+
+ $site_info = get_config('system','info');
+ $site_name = get_config('system','sitename');
+ if(! get_config('system','hidden_version_siteinfo')) {
+ $version = RED_VERSION;
+ if(@is_dir('.git') && function_exists('shell_exec')) {
+ $commit = trim( @shell_exec('git log -1 --format="%h"'));
+ if(! get_config('system','hidden_tag_siteinfo'))
+ $tag = trim( @shell_exec('git describe --tags --abbrev=0'));
+ else
+ $tag = '';
+ }
+ if(! isset($commit) || strlen($commit) > 16)
+ $commit = '';
+ }
+ else {
+ $version = $commit = '';
+ }
+
+ //Statistics
+ $channels_total_stat = intval(get_config('system','channels_total_stat'));
+ $channels_active_halfyear_stat = intval(get_config('system','channels_active_halfyear_stat'));
+ $channels_active_monthly_stat = intval(get_config('system','channels_active_monthly_stat'));
+ $local_posts_stat = intval(get_config('system','local_posts_stat'));
+ $hide_in_statistics = intval(get_config('system','hide_in_statistics'));
+ $site_expire = intval(get_config('system', 'default_expire_days'));
+
+
+ $data = Array(
+ 'version' => $version,
+ 'version_tag' => $tag,
+ 'commit' => $commit,
+ 'url' => z_root(),
+ 'plugins' => $visible_plugins,
+ 'register_policy' => $register_policy[get_config('system','register_policy')],
+ 'directory_mode' => $directory_mode[get_config('system','directory_mode')],
+ 'language' => get_config('system','language'),
+ 'rss_connections' => get_config('system','feed_contacts'),
+ 'expiration' => $site_expire,
+ 'default_service_restrictions' => $service_class,
+ 'admin' => $admin,
+ 'site_name' => (($site_name) ? $site_name : ''),
+ 'platform' => PLATFORM_NAME,
+ 'dbdriver' => $db->getdriver(),
+ 'lastpoll' => get_config('system','lastpoll'),
+ 'info' => (($site_info) ? $site_info : ''),
+ 'channels_total' => $channels_total_stat,
+ 'channels_active_halfyear' => $channels_active_halfyear_stat,
+ 'channels_active_monthly' => $channels_active_monthly_stat,
+ 'local_posts' => $local_posts_stat,
+ 'hide_in_statistics' => $hide_in_statistics
+ );
+ return $data;
+}
+
+
+
+function check_siteallowed($url) {
+
+ $retvalue = true;
+
+ $bl1 = get_config('system','whitelisted_sites');
+ if(is_array($bl1) && $bl1) {
+ foreach($bl1 as $bl) {
+ if($bl1 === '*')
+ $retvalue = true;
+ if($bl && strpos($url,$bl) !== false)
+ return true;
+ }
+ }
+ $bl1 = get_config('system','blacklisted_sites');
+ if(is_array($bl1) && $bl1) {
+ foreach($bl1 as $bl) {
+ if($bl1 === '*')
+ $retvalue = false;
+ if($bl && strpos($url,$bl) !== false) {
+ return false;
+ }
+ }
+ }
+ return $retvalue;
+}
+
+function check_channelallowed($hash) {
+
+ $retvalue = true;
+
+ $bl1 = get_config('system','whitelisted_channels');
+ if(is_array($bl1) && $bl1) {
+ foreach($bl1 as $bl) {
+ if($bl1 === '*')
+ $retvalue = true;
+ if($bl && strpos($hash,$bl) !== false)
+ return true;
+ }
+ }
+ $bl1 = get_config('system','blacklisted_channels');
+ if(is_array($bl1) && $bl1) {
+ foreach($bl1 as $bl) {
+ if($bl1 === '*')
+ $retvalue = false;
+ if($bl && strpos($hash,$bl) !== false) {
+ return false;
+ }
+ }
+ }
+ return $retvalue;
+}
+
diff --git a/include/zot.php b/include/zot.php
index e575f3d05..6764072aa 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -554,18 +554,8 @@ function zot_gethub($arr,$multiple = false) {
if($arr['guid'] && $arr['guid_sig'] && $arr['url'] && $arr['url_sig']) {
- $blacklisted = false;
- $bl1 = get_config('system','blacklisted_sites');
- if(is_array($bl1) && $bl1) {
- foreach($bl1 as $bl) {
- if($bl && strpos($arr['url'],$bl) !== false) {
- $blacklisted = true;
- break;
- }
- }
- }
- if($blacklisted) {
- logger('zot_gethub: blacklisted site: ' . $arr['url']);
+ if(! check_siteallowed($arr['url'])) {
+ logger('blacklisted site: ' . $arr['url']);
return null;
}
diff --git a/mod/setup.php b/mod/setup.php
index e5ac25965..5c9e988d9 100755
--- a/mod/setup.php
+++ b/mod/setup.php
@@ -14,7 +14,7 @@ $install_wizard_pass = 1;
*
* @param[in,out] App &$a
*/
-function setup_init(&$a){
+function setup_init(&$a) {
// Ensure that if somebody hasn't read the install documentation and doesn't have all
// the required modules or has a totally borked shared hosting provider and they can't
diff --git a/mod/siteinfo.php b/mod/siteinfo.php
index 231427290..4c5782abe 100644
--- a/mod/siteinfo.php
+++ b/mod/siteinfo.php
@@ -1,104 +1,10 @@
<?php
function siteinfo_init(&$a) {
- global $db;
-
- if ($a->argv[1]=="json"){
- $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
- $directory_mode = Array('DIRECTORY_MODE_NORMAL', 'DIRECTORY_MODE_SECONDARY','DIRECTORY_MODE_PRIMARY', 'DIRECTORY_MODE_STANDALONE');
-
- $sql_extra = '';
-
- $r = q("select * from channel left join account on account_id = channel_account_id where ( account_roles & 4096 )>0 and account_default_channel = channel_id");
-
-
- if($r) {
- $admin = array();
- foreach($r as $rr) {
- if($rr['channel_pageflags'] & PAGE_HUBADMIN)
- $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . get_app()->get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']);
- }
- if(! $admin) {
- foreach($r as $rr) {
- $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . get_app()->get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']);
- }
- }
- }
- else {
- $admin = false;
- }
- $def_service_class = get_config('system','default_service_class');
- if($def_service_class)
- $service_class = get_config('service_class',$def_service_class);
- else
- $service_class = 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'];
- }
- sort($visible_plugins);
-
- if(@is_dir('.git') && function_exists('shell_exec'))
- $commit = trim(@shell_exec('git log -1 --format="%h"'));
- if(! isset($commit) || strlen($commit) > 16)
- $commit = '';
-
- $site_info = get_config('system','info');
- $site_name = get_config('system','sitename');
- if(! get_config('system','hidden_version_siteinfo')) {
- $version = RED_VERSION;
- if(@is_dir('.git') && function_exists('shell_exec')) {
- $commit = trim( @shell_exec('git log -1 --format="%h"'));
- if(! get_config('system','hidden_tag_siteinfo'))
- $tag = trim( @shell_exec('git describe --tags --abbrev=0'));
- else
- $tag = '';
- }
- if(! isset($commit) || strlen($commit) > 16)
- $commit = '';
- }
- else {
- $version = $commit = '';
- }
-
- //Statistics
- $channels_total_stat = intval(get_config('system','channels_total_stat'));
- $channels_active_halfyear_stat = intval(get_config('system','channels_active_halfyear_stat'));
- $channels_active_monthly_stat = intval(get_config('system','channels_active_monthly_stat'));
- $local_posts_stat = intval(get_config('system','local_posts_stat'));
- $hide_in_statistics = intval(get_config('system','hide_in_statistics'));
- $site_expire = intval(get_config('system', 'default_expire_days'));
-
-
- $data = Array(
- 'version' => $version,
- 'version_tag' => $tag,
- 'commit' => $commit,
- 'url' => z_root(),
- 'plugins' => $visible_plugins,
- 'register_policy' => $register_policy[get_config('system','register_policy')],
- 'directory_mode' => $directory_mode[get_config('system','directory_mode')],
- 'language' => get_config('system','language'),
- 'rss_connections' => get_config('system','feed_contacts'),
- 'expiration' => $site_expire,
- 'default_service_restrictions' => $service_class,
- 'admin' => $admin,
- 'site_name' => (($site_name) ? $site_name : ''),
- 'platform' => PLATFORM_NAME,
- 'dbdriver' => $db->getdriver(),
- 'lastpoll' => get_config('system','lastpoll'),
- 'info' => (($site_info) ? $site_info : ''),
- 'channels_total' => $channels_total_stat,
- 'channels_active_halfyear' => $channels_active_halfyear_stat,
- 'channels_active_monthly' => $channels_active_monthly_stat,
- 'local_posts' => $local_posts_stat,
- 'hide_in_statistics' => $hide_in_statistics
- );
+
+ if (argv(1) === 'json') {
+ $data = get_site_info();
json_return_and_die($data);
}
}
diff --git a/mod/siteinfo_json.php b/mod/siteinfo_json.php
new file mode 100644
index 000000000..35697917c
--- /dev/null
+++ b/mod/siteinfo_json.php
@@ -0,0 +1,8 @@
+<?php
+
+function siteinfo_json_init(&$a) {
+
+ $data = get_site_info();
+ json_return_and_die($data);
+
+}