Fix upcoming killme() in index.php change

- Add killme() in controllers instead of relying on index.php
- Fix formatting
This commit is contained in:
Hypolite Petovan 2017-08-01 21:33:50 -04:00
parent 4601c4bd8a
commit 687eef90f7
7 changed files with 73 additions and 59 deletions

View File

@ -79,4 +79,6 @@ function directory_content(App $a)
'results' => $r,
'filter' => $forums ? 'forums' : '',
));
killme();
}

View File

@ -1,10 +1,13 @@
<?php
use Friendica\Directory\Rendering\View;
if(! function_exists('help_content')) {
function help_content(&$a) {
$view = new View('help');
$view->output();
}
}
if (!function_exists('help_content')) {
function help_content(&$a)
{
$view = new View('help');
$view->output();
killme();
}
}

View File

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

View File

@ -94,4 +94,6 @@ function search_content(App $a)
'filter' => $filter,
'query' => x($_GET, 'query') ? $_GET['query'] : ''
));
killme();
}

View File

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

View File

@ -1,10 +1,14 @@
<?php
use Friendica\Directory\Rendering\View;
if(! function_exists('stats_content')) {
function stats_content(&$a) {
$view = new View('stats');
$view->output();
}
if (!function_exists('stats_content')) {
function stats_content(&$a)
{
$view = new View('stats');
$view->output();
killme();
}
}

View File

@ -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.
</p>
<div class="feeling-lucky">
<a class="btn surprise" href="/servers/surprise">Surprise me &raquo;</a>
</div>
<h3>Recommending <?php echo $total; ?> public servers</h3>
<?php
foreach ($sites as $site)