Fix upcoming killme() in index.php change
- Add killme() in controllers instead of relying on index.php - Fix formatting
This commit is contained in:
parent
4601c4bd8a
commit
687eef90f7
7 changed files with 73 additions and 59 deletions
|
@ -79,4 +79,6 @@ function directory_content(App $a)
|
||||||
'results' => $r,
|
'results' => $r,
|
||||||
'filter' => $forums ? 'forums' : '',
|
'filter' => $forums ? 'forums' : '',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Friendica\Directory\Rendering\View;
|
use Friendica\Directory\Rendering\View;
|
||||||
|
|
||||||
if(! function_exists('help_content')) {
|
if (!function_exists('help_content')) {
|
||||||
function help_content(&$a) {
|
function help_content(&$a)
|
||||||
|
{
|
||||||
$view = new View('help');
|
$view = new View('help');
|
||||||
$view->output();
|
$view->output();
|
||||||
|
|
||||||
|
killme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,4 +14,5 @@ function home_content(&$a) {
|
||||||
'profiles' => $profiles
|
'profiles' => $profiles
|
||||||
));
|
));
|
||||||
|
|
||||||
|
killme();
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -94,4 +94,6 @@ function search_content(App $a)
|
||||||
'filter' => $filter,
|
'filter' => $filter,
|
||||||
'query' => x($_GET, 'query') ? $_GET['query'] : ''
|
'query' => x($_GET, 'query') ? $_GET['query'] : ''
|
||||||
));
|
));
|
||||||
|
|
||||||
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,17 @@ use Friendica\Directory\Rendering\View;
|
||||||
|
|
||||||
require_once 'include/site-health.php';
|
require_once 'include/site-health.php';
|
||||||
|
|
||||||
function servers_content(&$a) {
|
function servers_content(&$a)
|
||||||
|
{
|
||||||
$sites = array();
|
$sites = array();
|
||||||
|
|
||||||
//Find the user count per site.
|
//Find the user count per site.
|
||||||
$r = q("SELECT `homepage` FROM `profile`");
|
$r = q("SELECT `homepage` FROM `profile`");
|
||||||
if(count($r)) {
|
if (count($r)) {
|
||||||
foreach($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
$site = parse_site_from_url($rr['homepage']);
|
$site = parse_site_from_url($rr['homepage']);
|
||||||
if($site) {
|
if ($site) {
|
||||||
if(!isset($sites[$site]))
|
if (!isset($sites[$site]))
|
||||||
$sites[$site] = 0;
|
$sites[$site] = 0;
|
||||||
$sites[$site] ++;
|
$sites[$site] ++;
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ function servers_content(&$a) {
|
||||||
$site_healths = array();
|
$site_healths = array();
|
||||||
|
|
||||||
$r = q("SELECT * FROM `site-health` WHERE `reg_policy`='REGISTER_OPEN' AND `ssl_state` = 1");
|
$r = q("SELECT * FROM `site-health` WHERE `reg_policy`='REGISTER_OPEN' AND `ssl_state` = 1");
|
||||||
if(count($r)) {
|
if (count($r)) {
|
||||||
foreach($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
if (isset($sites[$rr['base_url']])) {
|
if (isset($sites[$rr['base_url']])) {
|
||||||
$sites_with_health[$rr['base_url']] = (($sites[$rr['base_url']] / 100) + 10) * intval($rr['health_score']);
|
$sites_with_health[$rr['base_url']] = (($sites[$rr['base_url']] / 100) + 10) * intval($rr['health_score']);
|
||||||
$site_healths[$rr['base_url']] = $rr;
|
$site_healths[$rr['base_url']] = $rr;
|
||||||
|
@ -38,17 +38,20 @@ function servers_content(&$a) {
|
||||||
arsort($sites_with_health);
|
arsort($sites_with_health);
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$public_sites = array();
|
$public_sites = array();
|
||||||
foreach($sites_with_health as $k => $v)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
foreach ($sites_with_health as $k => $v) {
|
||||||
//Stop at unhealthy sites.
|
//Stop at unhealthy sites.
|
||||||
$site = $site_healths[$k];
|
$site = $site_healths[$k];
|
||||||
|
|
||||||
if($site['health_score'] <= 20) break;
|
if ($site['health_score'] <= 20) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
//Skip small sites.
|
//Skip small sites.
|
||||||
$users = $sites[$k];
|
$users = $sites[$k];
|
||||||
if($users < 5) continue;
|
if ($users < 5) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//Add health score name and user count.
|
//Add health score name and user count.
|
||||||
$site['health_score_name'] = health_score_to_name($site['health_score']);
|
$site['health_score_name'] = health_score_to_name($site['health_score']);
|
||||||
|
@ -57,7 +60,7 @@ function servers_content(&$a) {
|
||||||
//Figure out what this server supports.
|
//Figure out what this server supports.
|
||||||
$plugins = explode("\r\n", $site['plugins']);
|
$plugins = explode("\r\n", $site['plugins']);
|
||||||
$site['plugins'] = $plugins;
|
$site['plugins'] = $plugins;
|
||||||
$hasPlugin = function(array $input)use($plugins){
|
$hasPlugin = function (array $input) use ($plugins) {
|
||||||
return !!count(array_intersect($input, $plugins));
|
return !!count(array_intersect($input, $plugins));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,9 +95,9 @@ function servers_content(&$a) {
|
||||||
|
|
||||||
//Get the difference.
|
//Get the difference.
|
||||||
$site['supports_more'] = 0;
|
$site['supports_more'] = 0;
|
||||||
foreach ($site['supports'] as $key => $value){
|
foreach ($site['supports'] as $key => $value) {
|
||||||
if($value && !array_key_exists($key, $site['popular_supports'])){
|
if ($value && !array_key_exists($key, $site['popular_supports'])) {
|
||||||
$site['supports_more']++;
|
$site['supports_more'] ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,19 +106,17 @@ function servers_content(&$a) {
|
||||||
|
|
||||||
//Count the result.
|
//Count the result.
|
||||||
$total ++;
|
$total ++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//In case we asked for a surprise, pick a random one from the top 10! :D
|
//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);
|
$max = min(count($public_sites), 10);
|
||||||
$i = mt_rand(0, $max-1);
|
$i = mt_rand(0, $max - 1);
|
||||||
$surpriseSite = $public_sites[$i];
|
$surpriseSite = $public_sites[$i];
|
||||||
header('Location:'.$surpriseSite['base_url'].'/register');
|
header('Location:' . $surpriseSite['base_url'] . '/register');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Show results.
|
//Show results.
|
||||||
$view = new View('servers');
|
$view = new View('servers');
|
||||||
|
|
||||||
|
@ -124,4 +125,5 @@ function servers_content(&$a) {
|
||||||
'sites' => $public_sites
|
'sites' => $public_sites
|
||||||
));
|
));
|
||||||
|
|
||||||
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Friendica\Directory\Rendering\View;
|
use Friendica\Directory\Rendering\View;
|
||||||
|
|
||||||
if(! function_exists('stats_content')) {
|
if (!function_exists('stats_content')) {
|
||||||
function stats_content(&$a) {
|
function stats_content(&$a)
|
||||||
|
{
|
||||||
$view = new View('stats');
|
$view = new View('stats');
|
||||||
$view->output();
|
$view->output();
|
||||||
|
|
||||||
|
killme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue