From 687eef90f7631490caaea84037b1907df99d108f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 1 Aug 2017 21:33:50 -0400 Subject: [PATCH] Fix upcoming killme() in index.php change - Add killme() in controllers instead of relying on index.php - Fix formatting --- mod/directory.php | 2 + mod/help.php | 15 +++--- mod/home.php | 7 +-- mod/search.php | 2 + mod/servers.php | 88 +++++++++++++++++----------------- mod/stats.php | 14 ++++-- src/templates/view/servers.php | 4 +- 7 files changed, 73 insertions(+), 59 deletions(-) diff --git a/mod/directory.php b/mod/directory.php index 5ef83b3a..9f1aa9c3 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -79,4 +79,6 @@ function directory_content(App $a) 'results' => $r, 'filter' => $forums ? 'forums' : '', )); + + killme(); } diff --git a/mod/help.php b/mod/help.php index db14e7a6..2d8764ac 100644 --- a/mod/help.php +++ b/mod/help.php @@ -1,10 +1,13 @@ output(); - } -} +if (!function_exists('help_content')) { + function help_content(&$a) + { + $view = new View('help'); + $view->output(); + killme(); + } +} diff --git a/mod/home.php b/mod/home.php index 28c9432c..65aad378 100644 --- a/mod/home.php +++ b/mod/home.php @@ -5,13 +5,14 @@ use Friendica\Directory\Helper\Profile as ProfileHelper; if(! function_exists('home_content')) { function home_content(&$a) { - + $profiles = q("SELECT * FROM profile WHERE comm=1 AND LENGTH(pdesc)>0 ORDER BY RAND() LIMIT 3"); - + $view = new View('homepage', 'minimal'); $view->addHelper('photoUrl', ProfileHelper::get('photoUrl')); $view->output(array( 'profiles' => $profiles )); - + + killme(); }} diff --git a/mod/search.php b/mod/search.php index 9847f14b..c88795c7 100644 --- a/mod/search.php +++ b/mod/search.php @@ -94,4 +94,6 @@ function search_content(App $a) 'filter' => $filter, 'query' => x($_GET, 'query') ? $_GET['query'] : '' )); + + killme(); } diff --git a/mod/servers.php b/mod/servers.php index 8ad4776a..92bda888 100644 --- a/mod/servers.php +++ b/mod/servers.php @@ -4,17 +4,17 @@ use Friendica\Directory\Rendering\View; require_once 'include/site-health.php'; -function servers_content(&$a) { - +function servers_content(&$a) +{ $sites = array(); //Find the user count per site. $r = q("SELECT `homepage` FROM `profile`"); - if(count($r)) { - foreach($r as $rr) { + if (count($r)) { + foreach ($r as $rr) { $site = parse_site_from_url($rr['homepage']); - if($site) { - if(!isset($sites[$site])) + if ($site) { + if (!isset($sites[$site])) $sites[$site] = 0; $sites[$site] ++; } @@ -26,8 +26,8 @@ function servers_content(&$a) { $site_healths = array(); $r = q("SELECT * FROM `site-health` WHERE `reg_policy`='REGISTER_OPEN' AND `ssl_state` = 1"); - if(count($r)) { - foreach($r as $rr) { + if (count($r)) { + foreach ($r as $rr) { if (isset($sites[$rr['base_url']])) { $sites_with_health[$rr['base_url']] = (($sites[$rr['base_url']] / 100) + 10) * intval($rr['health_score']); $site_healths[$rr['base_url']] = $rr; @@ -38,17 +38,20 @@ function servers_content(&$a) { arsort($sites_with_health); $total = 0; $public_sites = array(); - foreach($sites_with_health as $k => $v) - { + foreach ($sites_with_health as $k => $v) { //Stop at unhealthy sites. $site = $site_healths[$k]; - if($site['health_score'] <= 20) break; + if ($site['health_score'] <= 20) { + break; + } //Skip small sites. $users = $sites[$k]; - if($users < 5) continue; + if ($users < 5) { + continue; + } //Add health score name and user count. $site['health_score_name'] = health_score_to_name($site['health_score']); @@ -57,33 +60,33 @@ function servers_content(&$a) { //Figure out what this server supports. $plugins = explode("\r\n", $site['plugins']); $site['plugins'] = $plugins; - $hasPlugin = function(array $input)use($plugins){ + $hasPlugin = function (array $input) use ($plugins) { return !!count(array_intersect($input, $plugins)); }; $site['supports'] = array( - 'HTTPS' => $site['ssl_state'] == 1, - 'Twitter' => $hasPlugin(array('buffer', 'twitter')), - 'Facebook' => $hasPlugin(array('buffer')), - 'Google+' => $hasPlugin(array('buffer', 'gpluspost')), - 'RSS/Atom' => true, //Built-in. - 'Diaspora*' => $hasPlugin(array('diaspora')), - 'pump.io' => $hasPlugin(array('pumpio')), - 'StatusNet' => $hasPlugin(array('statusnet')), - 'Tumblr' => $hasPlugin(array('tumblr')), - 'Blogger' => $hasPlugin(array('blogger')), - 'Dreamwidth' => $hasPlugin(array('dwpost')), - 'Wordpress' => $hasPlugin(array('wppost')), - 'LiveJournal' => $hasPlugin(array('ljpost')), + 'HTTPS' => $site['ssl_state'] == 1, + 'Twitter' => $hasPlugin(array('buffer', 'twitter')), + 'Facebook' => $hasPlugin(array('buffer')), + 'Google+' => $hasPlugin(array('buffer', 'gpluspost')), + 'RSS/Atom' => true, //Built-in. + 'Diaspora*' => $hasPlugin(array('diaspora')), + 'pump.io' => $hasPlugin(array('pumpio')), + 'StatusNet' => $hasPlugin(array('statusnet')), + 'Tumblr' => $hasPlugin(array('tumblr')), + 'Blogger' => $hasPlugin(array('blogger')), + 'Dreamwidth' => $hasPlugin(array('dwpost')), + 'Wordpress' => $hasPlugin(array('wppost')), + 'LiveJournal' => $hasPlugin(array('ljpost')), 'Insanejournal' => $hasPlugin(array('ijpost')), - 'Libertree' => $hasPlugin(array('libertree')) + 'Libertree' => $hasPlugin(array('libertree')) ); //Subset of the full support list, to show popular items. $site['popular_supports'] = array( - 'HTTPS' => $site['supports']['HTTPS'], - 'Twitter' => $site['supports']['Twitter'], - 'Google+' => $site['supports']['Google+'], + 'HTTPS' => $site['supports']['HTTPS'], + 'Twitter' => $site['supports']['Twitter'], + 'Google+' => $site['supports']['Google+'], 'Wordpress' => $site['supports']['Wordpress'] ); @@ -92,9 +95,9 @@ function servers_content(&$a) { //Get the difference. $site['supports_more'] = 0; - foreach ($site['supports'] as $key => $value){ - if($value && !array_key_exists($key, $site['popular_supports'])){ - $site['supports_more']++; + foreach ($site['supports'] as $key => $value) { + if ($value && !array_key_exists($key, $site['popular_supports'])) { + $site['supports_more'] ++; } } @@ -103,25 +106,24 @@ function servers_content(&$a) { //Count the result. $total ++; - } //In case we asked for a surprise, pick a random one from the top 10! :D - if($a->argc > 1 && $a->argv[1] == 'surprise'){ + if ($a->argc > 1 && $a->argv[1] == 'surprise') { $max = min(count($public_sites), 10); - $i = mt_rand(0, $max-1); + $i = mt_rand(0, $max - 1); $surpriseSite = $public_sites[$i]; - header('Location:'.$surpriseSite['base_url'].'/register'); + header('Location:' . $surpriseSite['base_url'] . '/register'); exit; } - //Show results. - $view = new View('servers'); + $view = new View('servers'); - $view->output(array( - 'total' => number_format($total), - 'sites' => $public_sites - )); + $view->output(array( + 'total' => number_format($total), + 'sites' => $public_sites + )); + killme(); } diff --git a/mod/stats.php b/mod/stats.php index 866b33cd..cc5faea5 100644 --- a/mod/stats.php +++ b/mod/stats.php @@ -1,10 +1,14 @@ output(); - } +if (!function_exists('stats_content')) { + function stats_content(&$a) + { + $view = new View('stats'); + $view->output(); + + killme(); + } } diff --git a/src/templates/view/servers.php b/src/templates/view/servers.php index 4cc8f6dc..7a1d9b79 100644 --- a/src/templates/view/servers.php +++ b/src/templates/view/servers.php @@ -10,11 +10,11 @@ Keep in mind that different servers may support different features like communicating with additional networks besides Friendica. It's best to pick the one that best suits your needs.

- +
Surprise me »
- +

Recommending public servers