From 98406dfcaff61971615b314c521821ee0f6b9141 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
Date: Sun, 25 Jun 2017 10:17:26 -0400
Subject: [PATCH 1/6] Fix deprecated constant MYSQL_ASSOC
- Add maintenance HTML file
---
include/dba.php | 2 +-
maintenance.html | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 maintenance.html
diff --git a/include/dba.php b/include/dba.php
index 89f141d8..b0f2c5d7 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -70,7 +70,7 @@ class dba
$r = array();
if ($result->num_rows) {
- while ($x = $result->fetch_array(MYSQL_ASSOC)) {
+ while ($x = $result->fetch_array(MYSQLI_ASSOC)) {
$r[] = $x;
}
$result->free_result();
diff --git a/maintenance.html b/maintenance.html
new file mode 100644
index 00000000..5757d32d
--- /dev/null
+++ b/maintenance.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+ Friendica Directory
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Directory under maintenance
+
+
+
+ The Friendica Directory is unavailable at this time, please connect with hypolite@friendica.mrpetovan.com for updates about its status.
+
+
+
+
--
2.49.1
From e5416b002330fabdf9b13f0821a9456f6a968870 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
Date: Sun, 25 Jun 2017 10:17:26 -0400
Subject: [PATCH 2/6] Fix deprecated constant MYSQL_ASSOC
- Add maintenance HTML file
---
include/dba.php | 2 +-
maintenance.html | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 maintenance.html
diff --git a/include/dba.php b/include/dba.php
index 89f141d8..b0f2c5d7 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -70,7 +70,7 @@ class dba
$r = array();
if ($result->num_rows) {
- while ($x = $result->fetch_array(MYSQL_ASSOC)) {
+ while ($x = $result->fetch_array(MYSQLI_ASSOC)) {
$r[] = $x;
}
$result->free_result();
diff --git a/maintenance.html b/maintenance.html
new file mode 100644
index 00000000..5757d32d
--- /dev/null
+++ b/maintenance.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+ Friendica Directory
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Directory under maintenance
+
+
+
+ The Friendica Directory is unavailable at this time, please connect with hypolite@friendica.mrpetovan.com for updates about its status.
+
+
+
+
--
2.49.1
From 4601c4bd8a8e242987bd0aa6209e7aac67f962ee Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
Date: Tue, 1 Aug 2017 21:02:24 -0400
Subject: [PATCH 3/6] Fix "PHP Warning: session_write_close(): Failed to write
session data (user)" errors
- Changed returning true when there's a session ID but no session data
in ref_session_write()
- Moved session.php requires around
---
boot.php | 2 ++
include/notifier.php | 1 -
include/poller.php | 1 -
include/rockstar.php | 1 -
include/session.php | 8 ++++++--
index.php | 2 --
6 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/boot.php b/boot.php
index d2f8634e..0f4f36a4 100644
--- a/boot.php
+++ b/boot.php
@@ -1,5 +1,7 @@
set_baseurl(get_config('system', 'url'));
diff --git a/include/session.php b/include/session.php
index e51dbc1b..a125679f 100644
--- a/include/session.php
+++ b/include/session.php
@@ -30,10 +30,14 @@ function ref_session_write($id, $data)
{
global $session_exists, $session_expire;
- if (!$id || !$data) {
+ if (!$id) {
return false;
}
+ if (!$data) {
+ return true;
+ }
+
$expire = time() + $session_expire;
$default_expire = time() + 300;
@@ -65,7 +69,7 @@ function ref_session_gc($expire)
{
q("DELETE FROM `session` WHERE `expire` < %d", dbesc(time()));
q("OPTIMIZE TABLE `sess_data`");
-
+
return true;
}
diff --git a/index.php b/index.php
index 082f0c0e..07ddb75a 100644
--- a/index.php
+++ b/index.php
@@ -24,8 +24,6 @@ unset($db_host, $db_user, $db_pass, $db_data);
$a->init_pagehead();
$a->page['aside'] = 'Your friends. Your web.
';
-require_once 'session.php';
-
session_start();
if ((x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || ($a->module === 'login')) {
--
2.49.1
From 687eef90f7631490caaea84037b1907df99d108f Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
Date: Tue, 1 Aug 2017 21:33:50 -0400
Subject: [PATCH 4/6] 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.
-
+
-
+
Recommending public servers
Date: Tue, 1 Aug 2017 21:34:09 -0400
Subject: [PATCH 5/6] Change Friendica self-hosting URL
---
src/templates/view/servers.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/templates/view/servers.php b/src/templates/view/servers.php
index 7a1d9b79..f6c52880 100644
--- a/src/templates/view/servers.php
+++ b/src/templates/view/servers.php
@@ -2,7 +2,7 @@
Public servers
- If you are not interested in hosting your own server , you can still use Friendica.
+ If you are not interested in hosting your own server , you can still use Friendica.
Here are some public server run by enthousiasts that you can join.
We recommend these based on their health .
--
2.49.1
From 9a7503d4dd35ccc0b226cea251a1dfcb0da6fe78 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
Date: Thu, 3 Aug 2017 21:42:47 -0400
Subject: [PATCH 6/6] Normalize formatting
---
mod/servers.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mod/servers.php b/mod/servers.php
index 92bda888..15f4da89 100644
--- a/mod/servers.php
+++ b/mod/servers.php
@@ -4,8 +4,7 @@ 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.
@@ -14,8 +13,9 @@ function servers_content(&$a)
foreach ($r as $rr) {
$site = parse_site_from_url($rr['homepage']);
if ($site) {
- if (!isset($sites[$site]))
+ if (!isset($sites[$site])) {
$sites[$site] = 0;
+ }
$sites[$site] ++;
}
}
--
2.49.1