From c75d6ad850b0106994269fa203a884e1b89eee9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 12:03:02 +0100
Subject: [PATCH 01/68] More dbm::is_result() instead of count()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/Core/Config.php | 2 +-
include/Core/PConfig.php | 2 +-
include/salmon.php | 2 +-
mod/dfrn_confirm.php | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/Core/Config.php b/include/Core/Config.php
index 7b7045a9e..523572886 100644
--- a/include/Core/Config.php
+++ b/include/Core/Config.php
@@ -97,7 +97,7 @@ class Config {
dbesc($family),
dbesc($key)
);
- if (count($ret)) {
+ if (dbm::is_result($ret)) {
// manage array value
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
$a->config[$family][$key] = $val;
diff --git a/include/Core/PConfig.php b/include/Core/PConfig.php
index 43735018e..49b69a1f7 100644
--- a/include/Core/PConfig.php
+++ b/include/Core/PConfig.php
@@ -92,7 +92,7 @@ class PConfig {
dbesc($key)
);
- if (count($ret)) {
+ if (dbm::is_result($ret)) {
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
$a->config[$uid][$family][$key] = $val;
diff --git a/include/salmon.php b/include/salmon.php
index 5e9c4fa61..c5c3d7223 100644
--- a/include/salmon.php
+++ b/include/salmon.php
@@ -24,7 +24,7 @@ function get_salmon_key($uri,$keyhash) {
// We have found at least one key URL
// If it's inline, parse it - otherwise get the key
- if(count($ret)) {
+ if(count($ret) > 0) {
for($x = 0; $x < count($ret); $x ++) {
if(substr($ret[$x],0,5) === 'data:') {
if(strstr($ret[$x],','))
diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php
index 23c62cb0a..df663f7cd 100644
--- a/mod/dfrn_confirm.php
+++ b/mod/dfrn_confirm.php
@@ -584,7 +584,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
dbesc($decrypted_source_url),
intval($local_uid)
);
- if(! count($ret)) {
+ if(! dbm::is_result($ret)) {
if(strstr($decrypted_source_url,'http:'))
$newurl = str_replace('http:','https:',$decrypted_source_url);
else
@@ -594,7 +594,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
dbesc($newurl),
intval($local_uid)
);
- if(! count($ret)) {
+ if(! dbm::is_result($ret)) {
// this is either a bogus confirmation (?) or we deleted the original introduction.
$message = t('Contact record was not found for you on our site.');
xml_status(3,$message);
From d5b4e09ec4c516aec98d7f33fc238f6054d3c8e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 12:45:11 +0100
Subject: [PATCH 02/68] added lint.sh which needs to be executed like this:
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
$ ./util/lint.sh
No parameters needed. It will use "php -l" (current interpreter) for checking
for syntax errors in all PHP scripts.
Signed-off-by: Roland Häder
---
util/lint.sh | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100755 util/lint.sh
diff --git a/util/lint.sh b/util/lint.sh
new file mode 100755
index 000000000..ef1530f85
--- /dev/null
+++ b/util/lint.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+if ! test -e "index.php"; then
+ echo "$0: Please execute this script from root directory."
+ exit 1
+fi
+
+echo "$0: Analysing PHP scripts for syntax errors (lint) ..."
+LINT=`find -type f -name "*.php" -exec php -l -f {} 2>&1 \; | grep -v "No syntax errors detected in" | grep -v "FUSE_EDEADLK" | sort --unique`
+
+if test "${LINT}" != ""; then
+ echo "${LINT}"
+else
+ echo "$0: No syntax errors found."
+fi
From 09a24955dfaa26180d4e76e9bd42526146c6e744 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 12:51:20 +0100
Subject: [PATCH 03/68] Use [] instead of test.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
util/lint.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/util/lint.sh b/util/lint.sh
index ef1530f85..844a0eadd 100755
--- a/util/lint.sh
+++ b/util/lint.sh
@@ -1,6 +1,7 @@
#!/bin/sh
-if ! test -e "index.php"; then
+if [ ! -e "index.php" ]
+then
echo "$0: Please execute this script from root directory."
exit 1
fi
@@ -8,7 +9,8 @@ fi
echo "$0: Analysing PHP scripts for syntax errors (lint) ..."
LINT=`find -type f -name "*.php" -exec php -l -f {} 2>&1 \; | grep -v "No syntax errors detected in" | grep -v "FUSE_EDEADLK" | sort --unique`
-if test "${LINT}" != ""; then
+if [ -n "${LINT}" ]
+then
echo "${LINT}"
else
echo "$0: No syntax errors found."
From a85470b172c26408c061116f82c5fbd0085ee0ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 16:36:32 +0100
Subject: [PATCH 04/68] Opps, this has vanished by accident, thanks to @annando
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
mod/dfrn_request.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
index 390eaff86..7525f8389 100644
--- a/mod/dfrn_request.php
+++ b/mod/dfrn_request.php
@@ -465,6 +465,8 @@ function dfrn_request_post(&$a) {
$network = NETWORK_DFRN;
}
+ logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG);
+
if($network === NETWORK_DFRN) {
$ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1",
intval($uid),
From b21a1437f47e6d4b3ca788453acbd27cfbafd368 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 16:39:39 +0100
Subject: [PATCH 05/68] Also removed this, seems to come in from wrong merging?
#3010 Thanks to @annando
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/notifier.php | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/include/notifier.php b/include/notifier.php
index a55a60efd..2f9599d07 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -424,19 +424,6 @@ function notifier_run(&$argv, &$argc){
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
}
- $probed_contact = probe_url($thr_parent[0]['author-link']);
- if ($probed_contact["notify"] != "") {
- logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
- $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
- }
-
- // Send a salmon to the parent owner
- $probed_contact = probe_url($thr_parent[0]['owner-link']);
- if ($probed_contact["notify"] != "") {
- logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
- $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
- }
-
// Send a salmon notification to every person we mentioned in the post
$arr = explode(',',$target_item['tag']);
foreach($arr as $x) {
From 4b860e7575d0fab1dc4c354ddbad1924cec187c0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 16:43:03 +0100
Subject: [PATCH 06/68] No more needed ... util/typo.php is there.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
util/lint.sh | 17 -----------------
1 file changed, 17 deletions(-)
delete mode 100755 util/lint.sh
diff --git a/util/lint.sh b/util/lint.sh
deleted file mode 100755
index 844a0eadd..000000000
--- a/util/lint.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-if [ ! -e "index.php" ]
-then
- echo "$0: Please execute this script from root directory."
- exit 1
-fi
-
-echo "$0: Analysing PHP scripts for syntax errors (lint) ..."
-LINT=`find -type f -name "*.php" -exec php -l -f {} 2>&1 \; | grep -v "No syntax errors detected in" | grep -v "FUSE_EDEADLK" | sort --unique`
-
-if [ -n "${LINT}" ]
-then
- echo "${LINT}"
-else
- echo "$0: No syntax errors found."
-fi
From 23d4db5149b0c30f09342428a0693a3ae877caca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 16:59:35 +0100
Subject: [PATCH 07/68] Continued with #3010: - removed added debug messages
(maybe they will come back in accordance to code-style guidelines?) -
converted $a->get_baseurl() back to App::get_baseurl() - reverted back other
code I have touched/merged as this was double: (substr($url, 0, 4) !==
'http') on $url = 'https://bla'; will be FALSE (means found http at start),
too.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/api.php | 18 +++++++++---------
include/dfrn.php | 8 +++-----
include/enotify.php | 2 +-
include/event.php | 2 +-
include/network.php | 13 ++-----------
5 files changed, 16 insertions(+), 27 deletions(-)
diff --git a/include/api.php b/include/api.php
index 1ec657620..757954ed0 100644
--- a/include/api.php
+++ b/include/api.php
@@ -693,7 +693,7 @@
'follow_request_sent' => false,
'statusnet_blocking' => false,
'notifications' => false,
- //'statusnet_profile_url' => $a->get_baseurl()."/contacts/".$uinfo[0]['cid'],
+ //'statusnet_profile_url' => App::get_baseurl()."/contacts/".$uinfo[0]['cid'],
'statusnet_profile_url' => $uinfo[0]['url'],
'uid' => intval($uinfo[0]['uid']),
'cid' => intval($uinfo[0]['cid']),
@@ -1078,8 +1078,8 @@
if ($r) {
$phototypes = Photo::supportedTypes();
$ext = $phototypes[$r[0]['type']];
- $_REQUEST['body'] .= "\n\n".'[url='.$a->get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']';
- $_REQUEST['body'] .= '[img]'.$a->get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]";
+ $_REQUEST['body'] .= "\n\n".'[url='.App::get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']';
+ $_REQUEST['body'] .= '[img]'.App::get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]";
}
}
@@ -2302,7 +2302,7 @@
$text = preg_replace_callback(
"|data:image/([^;]+)[^=]+=*|m",
function($match) use ($item) {
- return $a->get_baseurl()."/display/".$item['guid'];
+ return App::get_baseurl()."/display/".$item['guid'];
},
$text);
return $text;
@@ -2690,7 +2690,7 @@
$name = $a->config['sitename'];
$server = $a->get_hostname();
- $logo = $a->get_baseurl() . '/images/friendica-64.png';
+ $logo = App::get_baseurl() . '/images/friendica-64.png';
$email = $a->config['admin_email'];
$closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false');
$private = (($a->config['system']['block_public']) ? 'true' : 'false');
@@ -2698,7 +2698,7 @@
if($a->config['api_import_size'])
$texlimit = string($a->config['api_import_size']);
$ssl = (($a->config['system']['have_ssl']) ? 'true' : 'false');
- $sslserver = (($ssl === 'true') ? str_replace('http:','https:',$a->get_baseurl()) : '');
+ $sslserver = (($ssl === 'true') ? str_replace('http:','https:',App::get_baseurl()) : '');
$config = array(
'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '',
@@ -3075,7 +3075,7 @@
$photo['album'] = $rr['album'];
$photo['filename'] = $rr['filename'];
$photo['type'] = $rr['type'];
- $thumb = $a->get_baseurl()."/photo/".$rr['resource-id']."-".$rr['scale'].".".$typetoext[$rr['type']];
+ $thumb = App::get_baseurl()."/photo/".$rr['resource-id']."-".$rr['scale'].".".$typetoext[$rr['type']];
if ($type == "xml")
$data['photo'][] = array("@attributes" => $photo, "1" => $thumb);
@@ -3124,11 +3124,11 @@
for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++)
$data['photo']['links'][$k.":link"]["@attributes"] = array("type" => $data['photo']['type'],
"scale" => $k,
- "href" => $a->get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]);
+ "href" => App::get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]);
} else {
$data['photo']['link'] = array();
for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++) {
- $data['photo']['link'][$k] = $a->get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']];
+ $data['photo']['link'][$k] = App::get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']];
}
}
unset($data['photo']['resource-id']);
diff --git a/include/dfrn.php b/include/dfrn.php
index 3a8bf1224..6451b8521 100644
--- a/include/dfrn.php
+++ b/include/dfrn.php
@@ -1525,7 +1525,7 @@ class dfrn {
"to_email" => $importer["email"],
"uid" => $importer["importer_uid"],
"item" => $suggest,
- "link" => $a->get_baseurl()."/notifications/intros",
+ "link" => App::get_baseurl()."/notifications/intros",
"source_name" => $importer["name"],
"source_link" => $importer["url"],
"source_photo" => $importer["photo"],
@@ -1792,8 +1792,6 @@ class dfrn {
* @param int $posted_id The record number of item record that was just posted
*/
private function do_poke($item, $importer, $posted_id) {
- $a = get_app();
-
$verb = urldecode(substr($item["verb"],strpos($item["verb"], "#")+1));
if(!$verb)
return;
@@ -1813,7 +1811,7 @@ class dfrn {
}
}
- if($Blink && link_compare($Blink,$a->get_baseurl()."/profile/".$importer["nickname"])) {
+ if($Blink && link_compare($Blink,App::get_baseurl()."/profile/".$importer["nickname"])) {
// send a notification
notification(array(
@@ -1824,7 +1822,7 @@ class dfrn {
"to_email" => $importer["email"],
"uid" => $importer["importer_uid"],
"item" => $item,
- "link" => $a->get_baseurl()."/display/".urlencode(get_item_guid($posted_id)),
+ "link" => App::get_baseurl()."/display/".urlencode(get_item_guid($posted_id)),
"source_name" => stripslashes($item["author-name"]),
"source_link" => $item["author-link"],
"source_photo" => ((link_compare($item["author-link"],$importer["url"]))
diff --git a/include/enotify.php b/include/enotify.php
index aa736492f..c6e0506e9 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -721,7 +721,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$params["to_email"] = $user[0]["email"];
$params["item"] = $item[0];
$params["parent"] = $item[0]["parent"];
- $params["link"] = $a->get_baseurl().'/display/'.urlencode($item[0]["guid"]);
+ $params["link"] = App::get_baseurl().'/display/'.urlencode($item[0]["guid"]);
$params["otype"] = 'item';
$params["source_name"] = $item[0]["author-name"];
$params["source_link"] = $item[0]["author-link"];
diff --git a/include/event.php b/include/event.php
index 6a292a2c0..3a41dad4e 100644
--- a/include/event.php
+++ b/include/event.php
@@ -590,7 +590,7 @@ function process_events ($arr) {
$is_first = ($d !== $last_date);
$last_date = $d;
- $edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
+ $edit = ((! $rr['cid']) ? array(App::get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
if(! $title) {
list($title, $_trash) = explode("
Date: Wed, 14 Dec 2016 17:28:18 +0100
Subject: [PATCH 08/68] 3 slashes for Doxygen, 2 are enough for PHP ... :-(
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/network.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/network.php b/include/network.php
index 8b67aa627..df46d3593 100644
--- a/include/network.php
+++ b/include/network.php
@@ -398,7 +398,7 @@ function validate_url(&$url) {
if(substr($url,0,4) != 'http')
$url = 'http://' . $url;
- // @TODO Really supress function outcomes? Why not find them + debug them?
+ /// @TODO Really supress function outcomes? Why not find them + debug them?
$h = @parse_url($url);
if((is_array($h)) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
From cef6fce7f0e1f836f5f5e5e875c3436998389d44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 17:41:28 +0100
Subject: [PATCH 09/68] reverted change (which duplicated above query), thanks
to @annano to point this out. #3010
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/queue_fn.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 3030acc28..f262072e6 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -31,9 +31,7 @@ function was_recently_delayed($cid) {
if (dbm::is_result($r))
return true;
- // Are there queue entries that were recently added?
- $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
- AND `last` > UTC_TIMESTAMP() - interval 15 minute LIMIT 1",
+ $r = q("select `term-date` from contact where id = %d and `term-date` != '' and `term-date` != '0000-00-00 00:00:00' limit 1",
intval($cid)
);
From c830bfcd9630aa4ec9eca0b3ceca48a0d12d9b1c Mon Sep 17 00:00:00 2001
From: Roland Haeder
Date: Wed, 14 Dec 2016 20:50:39 +0100
Subject: [PATCH 10/68] fixed SQL writing: keywords upper-case, column/table
names in back-ticks. #3010
Signed-off-by: Roland Haeder
---
include/queue_fn.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/queue_fn.php b/include/queue_fn.php
index f262072e6..81bcf0f2b 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -24,14 +24,14 @@ function remove_queue_item($id) {
*/
function was_recently_delayed($cid) {
- $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
- and last > UTC_TIMESTAMP() - interval 15 minute limit 1",
+ $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
+ AND `last` > UTC_TIMESTAMP() - INTVAL 15 MINUTE LIMIT 1",
intval($cid)
);
if (dbm::is_result($r))
return true;
- $r = q("select `term-date` from contact where id = %d and `term-date` != '' and `term-date` != '0000-00-00 00:00:00' limit 1",
+ $r = q("SELECT `term-date` FROM `contact` WHERE `id` = %d AND `term-date` != '' AND `term-date` != '0000-00-00 00:00:00' LIMIT 1",
intval($cid)
);
From 6cef88c24ead66ed59d7fde4b9f975714c0ddddc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 15 Dec 2016 09:22:38 +0100
Subject: [PATCH 11/68] Also reverted these + added spaces for nicer
appearance.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/api.php | 14 +++++++-------
mod/content.php | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/include/api.php b/include/api.php
index 757954ed0..2ae1aeaa0 100644
--- a/include/api.php
+++ b/include/api.php
@@ -408,13 +408,13 @@
if (is_null($user_info)) $user_info = api_get_user($a);
$arr['$user'] = $user_info;
$arr['$rss'] = array(
- 'alternate' => $user_info['url'],
- 'self' => $a->get_baseurl(). "/". $a->query_string,
- 'base' => $a->get_baseurl(),
- 'updated' => api_date(null),
+ 'alternate' => $user_info['url'],
+ 'self' => App::get_baseurl(). "/". $a->query_string,
+ 'base' => App::get_baseurl(),
+ 'updated' => api_date(null),
'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME),
- 'language' => $user_info['language'],
- 'logo' => $a->get_baseurl()."/images/friendica-32.png",
+ 'language' => $user_info['language'],
+ 'logo' => App::get_baseurl()."/images/friendica-32.png",
);
return $arr;
@@ -1777,7 +1777,7 @@
$start = $page*$count;
// Ugly code - should be changed
- $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
+ $myurl = App::get_baseurl() . '/profile/'. $a->user['nickname'];
$myurl = substr($myurl,strpos($myurl,'://')+3);
//$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
$myurl = str_replace('www.','',$myurl);
diff --git a/mod/content.php b/mod/content.php
index 87960d712..1e2307f55 100644
--- a/mod/content.php
+++ b/mod/content.php
@@ -197,7 +197,7 @@ function content_content(&$a, $update = 0) {
}
if($conv) {
- $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
+ $myurl = App::get_baseurl() . '/profile/'. $a->user['nickname'];
$myurl = substr($myurl,strpos($myurl,'://')+3);
$myurl = str_replace('www.','',$myurl);
$diasp_url = str_replace('/profile/','/u/',$myurl);
From 7849b3f8e32e49be1bf44f904356c9203b92855c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 15 Dec 2016 09:32:32 +0100
Subject: [PATCH 12/68] more reverts ...
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/Probe.php | 2 +-
include/feed.php | 6 ------
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/include/Probe.php b/include/Probe.php
index 779476bce..5c2ba86cc 100644
--- a/include/Probe.php
+++ b/include/Probe.php
@@ -232,7 +232,7 @@ class Probe {
if ($data["photo"] != "")
$data["baseurl"] = matching_url(normalise_link($data["baseurl"]), normalise_link($data["photo"]));
else
- $data["photo"] = $a->get_baseurl().'/images/person-175.jpg';
+ $data["photo"] = App::get_baseurl().'/images/person-175.jpg';
if (!isset($data["name"]) OR ($data["name"] == "")) {
if (isset($data["nick"]))
diff --git a/include/feed.php b/include/feed.php
index 7ce0729c6..579ff7caa 100644
--- a/include/feed.php
+++ b/include/feed.php
@@ -59,8 +59,6 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
if ($attributes->name == "href")
$author["author-link"] = $attributes->textContent;
- $author["author-id"] = $xpath->evaluate('/atom:feed/atom:author/atom:uri/text()')->item(0)->nodeValue;
-
if ($author["author-link"] == "")
$author["author-link"] = $author["author-id"];
@@ -144,10 +142,6 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
$author["owner-link"] = $contact["url"];
$author["owner-name"] = $contact["name"];
$author["owner-avatar"] = $contact["thumb"];
-
- // This is no field in the item table. So we have to unset it.
- unset($author["author-nick"]);
- unset($author["author-id"]);
}
$header = array();
From f42935421e80f638aded3e75bc9fa560ea39cb72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 15 Dec 2016 09:49:00 +0100
Subject: [PATCH 13/68] And more reverts: - $a->get_baseurl() ->
App::get_baseurl() - was_recently_delayed() (entirely)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/oembed.php | 14 ++++++--------
include/queue_fn.php | 19 +++++++++++++------
2 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/include/oembed.php b/include/oembed.php
index f860a545f..a1945894f 100755
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -149,8 +149,6 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
}
function oembed_format_object($j){
- $a = get_app();
-
require_once("mod/proxy.php");
$embedurl = $j->embedurl;
@@ -167,12 +165,12 @@ function oembed_format_object($j){
$th=120; $tw = $th*$tr;
$tpl=get_markup_template('oembed_video.tpl');
$ret.=replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
- '$embedurl'=>$embedurl,
- '$escapedhtml'=>base64_encode($jhtml),
- '$tw'=>$tw,
- '$th'=>$th,
- '$turl'=>$j->thumbnail_url,
+ '$baseurl' => App::get_baseurl(),
+ '$embedurl' => $embedurl,
+ '$escapedhtml' => base64_encode($jhtml),
+ '$tw' => $tw,
+ '$th' => $th,
+ '$turl' => $j->thumbnail_url,
));
} else {
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 81bcf0f2b..3b5eddf1a 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -23,19 +23,26 @@ function remove_queue_item($id) {
* @return bool The communication with this contact has currently problems
*/
function was_recently_delayed($cid) {
+ $was_delayed = false;
+ // Are there queue entries that were recently added?
$r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
AND `last` > UTC_TIMESTAMP() - INTVAL 15 MINUTE LIMIT 1",
intval($cid)
);
- if (dbm::is_result($r))
- return true;
- $r = q("SELECT `term-date` FROM `contact` WHERE `id` = %d AND `term-date` != '' AND `term-date` != '0000-00-00 00:00:00' LIMIT 1",
- intval($cid)
- );
+ $was_delayed = dbm::is_result($r);
- return (dbm::is_result($r));
+ // We set "term-date" to a current date if the communication has problems.
+ // If the communication works again we reset this value.
+ if ($was_delayed) {
+ $r = q("SELECT `term-date` FROM `contact` WHERE `id` = %d AND `term-date` <= '1000-01-01' LIMIT 1",
+ intval($cid)
+ );
+ $was_delayed = !dbm::is_result($r);
+ }
+
+ return $was_delayed;;
}
From 8ad1bdaac19fe44d8702d18bda292fb14a26121b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 15 Dec 2016 09:51:06 +0100
Subject: [PATCH 14/68] Opps, tpzo found ...
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/queue_fn.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 3b5eddf1a..d7d327913 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -27,7 +27,7 @@ function was_recently_delayed($cid) {
// Are there queue entries that were recently added?
$r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
- AND `last` > UTC_TIMESTAMP() - INTVAL 15 MINUTE LIMIT 1",
+ AND `last` > UTC_TIMESTAMP() - INTERVAL 15 MINUTE LIMIT 1",
intval($cid)
);
From d26009e4087a9005dae098c21629ba748dee0634 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 15 Dec 2016 09:52:15 +0100
Subject: [PATCH 15/68] Garrr ...
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/queue_fn.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/queue_fn.php b/include/queue_fn.php
index d7d327913..9dcefdd24 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -42,7 +42,7 @@ function was_recently_delayed($cid) {
$was_delayed = !dbm::is_result($r);
}
- return $was_delayed;;
+ return $was_delayed;
}
From 8e1796bb1f5e85efb58481a29c333445f7b83d95 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 15 Dec 2016 09:57:55 +0100
Subject: [PATCH 16/68] Continued with #3010: - more reverts of
$a->get_baseurl() - you always do: function foo (&$a), please read my TODO
why it is not so good. - for now I have fixed this inconsistency (compared to
other method signatures)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/socgraph.php | 6 ++----
mod/fetch.php | 6 ++++--
mod/p.php | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/socgraph.php b/include/socgraph.php
index c7f0c7091..349fd0b2c 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -1728,8 +1728,6 @@ function update_gcontact_from_probe($url) {
* @param int $uid User ID
*/
function update_gcontact_for_user($uid) {
- $a = get_app();
-
$r = q("SELECT `profile`.`locality`, `profile`.`region`, `profile`.`country-name`,
`profile`.`name`, `profile`.`about`, `profile`.`gender`,
`profile`.`pub_keywords`, `profile`.`dob`, `profile`.`photo`,
@@ -1746,7 +1744,7 @@ function update_gcontact_for_user($uid) {
// The "addr" field was added in 3.4.3 so it can be empty for older users
if ($r[0]["addr"] != "")
- $addr = $r[0]["nickname"].'@'.str_replace(array("http://", "https://"), "", $a->get_baseurl());
+ $addr = $r[0]["nickname"].'@'.str_replace(array("http://", "https://"), "", App::get_baseurl());
else
$addr = $r[0]["addr"];
@@ -1756,7 +1754,7 @@ function update_gcontact_for_user($uid) {
"notify" => $r[0]["notify"], "url" => $r[0]["url"],
"hide" => ($r[0]["hidewall"] OR !$r[0]["net-publish"]),
"nick" => $r[0]["nickname"], "addr" => $addr,
- "connect" => $addr, "server_url" => $a->get_baseurl(),
+ "connect" => $addr, "server_url" => App::get_baseurl(),
"generation" => 1, "network" => NETWORK_DFRN);
update_gcontact($gcontact);
diff --git a/mod/fetch.php b/mod/fetch.php
index 6e4c7bb16..04bdf5188 100644
--- a/mod/fetch.php
+++ b/mod/fetch.php
@@ -6,7 +6,9 @@ require_once("include/crypto.php");
require_once("include/diaspora.php");
require_once("include/xml.php");
-function fetch_init($a){
+/// @TODO You always make it like this: function foo(&$a)
+/// @TODO This means that the value of $a can be changed in anything, remove & and use App as type-hint
+function fetch_init(&$a){
if (($a->argc != 3) OR (!in_array($a->argv[1], array("post", "status_message", "reshare")))) {
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
@@ -27,7 +29,7 @@ function fetch_init($a){
$parts = parse_url($r[0]["author-link"]);
$host = $parts["scheme"]."://".$parts["host"];
- if (normalise_link($host) != normalise_link($a->get_baseurl())) {
+ if (normalise_link($host) != normalise_link(App::get_baseurl())) {
$location = $host."/fetch/".$a->argv[1]."/".urlencode($guid);
header("HTTP/1.1 301 Moved Permanently");
diff --git a/mod/p.php b/mod/p.php
index f456a09c6..4db8f5529 100644
--- a/mod/p.php
+++ b/mod/p.php
@@ -31,7 +31,7 @@ function p_init($a){
$parts = parse_url($r[0]["author-link"]);
$host = $parts["scheme"]."://".$parts["host"];
- if (normalise_link($host) != normalise_link($a->get_baseurl())) {
+ if (normalise_link($host) != normalise_link(App::get_baseurl())) {
$location = $host."/p/".urlencode($guid).".xml";
header("HTTP/1.1 301 Moved Permanently");
From b54c22666c8328f6d8e171b9febb890629962f41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 15 Dec 2016 10:03:06 +0100
Subject: [PATCH 17/68] get_basepath() uses a lot $this (which means
object-referenced calls, or non-static calls). but still it is called
statically in many places.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
mod/photo.php | 2 +-
mod/proxy.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mod/photo.php b/mod/photo.php
index d324818b2..a94a3ac2c 100644
--- a/mod/photo.php
+++ b/mod/photo.php
@@ -197,7 +197,7 @@ function photo_init(&$a) {
// If the photo is public and there is an existing photo directory store the photo there
if ($public and ($file != "")) {
// If the photo path isn't there, try to create it
- $basepath = App::get_basepath();
+ $basepath = $a->get_basepath();
if (!is_dir($basepath."/photo"))
if (is_writable($basepath))
mkdir($basepath."/photo");
diff --git a/mod/proxy.php b/mod/proxy.php
index 6434cf8e6..1d27d7038 100644
--- a/mod/proxy.php
+++ b/mod/proxy.php
@@ -44,7 +44,7 @@ function proxy_init() {
$thumb = false;
$size = 1024;
$sizetype = "";
- $basepath = App::get_basepath();
+ $basepath = $a->get_basepath();
// If the cache path isn't there, try to create it
if (!is_dir($basepath."/proxy"))
From 2eb3727542eca75c2a090ef1c9d4e0b2a47a206b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 15 Dec 2016 10:05:18 +0100
Subject: [PATCH 18/68] Again, static *OR* object-referencing calls? Blue or
red pill?
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/cron.php | 6 +++---
mod/proxy.php | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/cron.php b/include/cron.php
index 008260592..d7771c08b 100644
--- a/include/cron.php
+++ b/include/cron.php
@@ -362,14 +362,14 @@ function cron_clear_cache(&$a) {
clear_cache();
// clear cache for photos
- clear_cache(App::get_basepath(), App::get_basepath()."/photo");
+ clear_cache($a->get_basepath(), $a->get_basepath()."/photo");
// clear smarty cache
- clear_cache(App::get_basepath()."/view/smarty3/compiled", App::get_basepath()."/view/smarty3/compiled");
+ clear_cache($a->get_basepath()."/view/smarty3/compiled", $a->get_basepath()."/view/smarty3/compiled");
// clear cache for image proxy
if (!get_config("system", "proxy_disabled")) {
- clear_cache(App::get_basepath(), App::get_basepath()."/proxy");
+ clear_cache($a->get_basepath(), $a->get_basepath()."/proxy");
$cachetime = get_config('system','proxy_cache_time');
if (!$cachetime) $cachetime = PROXY_DEFAULT_TIME;
diff --git a/mod/proxy.php b/mod/proxy.php
index 1d27d7038..612dc910a 100644
--- a/mod/proxy.php
+++ b/mod/proxy.php
@@ -267,7 +267,7 @@ function proxy_url($url, $writemode = false, $size = '') {
$url = html_entity_decode($url, ENT_NOQUOTES, 'utf-8');
// Creating a sub directory to reduce the amount of files in the cache directory
- $basepath = App::get_basepath() . '/proxy';
+ $basepath = $a->get_basepath() . '/proxy';
$shortpath = hash('md5', $url);
$longpath = substr($shortpath, 0, 2);
From 2c9d28213654b5cbb10667595552cc25eca52bdc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 15 Dec 2016 10:11:25 +0100
Subject: [PATCH 19/68] Convention: SQL keywords all upper-case, columns and
table names (better) lower-cased and always in back-ticks.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
mod/dfrn_request.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
index 7525f8389..236970a2e 100644
--- a/mod/dfrn_request.php
+++ b/mod/dfrn_request.php
@@ -431,7 +431,7 @@ function dfrn_request_post(&$a) {
$hash = random_string();
- $r = q("INSERT INTO intro ( uid, `contact-id`, knowyou, note, hash, datetime, blocked )
+ $r = q("INSERT INTO `intro` ( `uid`, `contact-id`, knowyou, note, hash, datetime, blocked )
VALUES( %d , %d, %d, '%s', '%s', '%s', %d ) ",
intval($uid),
intval($contact_id),
From 7f1da5b1a9b3cc63dbc158d1e18b26f09e5c9865 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 12:45:11 +0100
Subject: [PATCH 20/68] added lint.sh which needs to be executed like this:
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
$ ./util/lint.sh
No parameters needed. It will use "php -l" (current interpreter) for checking
for syntax errors in all PHP scripts.
Signed-off-by: Roland Häder
---
util/lint.sh | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100755 util/lint.sh
diff --git a/util/lint.sh b/util/lint.sh
new file mode 100755
index 000000000..ef1530f85
--- /dev/null
+++ b/util/lint.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+if ! test -e "index.php"; then
+ echo "$0: Please execute this script from root directory."
+ exit 1
+fi
+
+echo "$0: Analysing PHP scripts for syntax errors (lint) ..."
+LINT=`find -type f -name "*.php" -exec php -l -f {} 2>&1 \; | grep -v "No syntax errors detected in" | grep -v "FUSE_EDEADLK" | sort --unique`
+
+if test "${LINT}" != ""; then
+ echo "${LINT}"
+else
+ echo "$0: No syntax errors found."
+fi
From e06cac420b0eb92c04d5cc74f65bc542b217c24f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 12:51:20 +0100
Subject: [PATCH 21/68] Use [] instead of test.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
util/lint.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/util/lint.sh b/util/lint.sh
index ef1530f85..844a0eadd 100755
--- a/util/lint.sh
+++ b/util/lint.sh
@@ -1,6 +1,7 @@
#!/bin/sh
-if ! test -e "index.php"; then
+if [ ! -e "index.php" ]
+then
echo "$0: Please execute this script from root directory."
exit 1
fi
@@ -8,7 +9,8 @@ fi
echo "$0: Analysing PHP scripts for syntax errors (lint) ..."
LINT=`find -type f -name "*.php" -exec php -l -f {} 2>&1 \; | grep -v "No syntax errors detected in" | grep -v "FUSE_EDEADLK" | sort --unique`
-if test "${LINT}" != ""; then
+if [ -n "${LINT}" ]
+then
echo "${LINT}"
else
echo "$0: No syntax errors found."
From c43389f79ab390d31d9da5352bf4b5fb14d33f0e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 14 Dec 2016 16:43:03 +0100
Subject: [PATCH 22/68] No more needed ... util/typo.php is there.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
util/lint.sh | 17 -----------------
1 file changed, 17 deletions(-)
delete mode 100755 util/lint.sh
diff --git a/util/lint.sh b/util/lint.sh
deleted file mode 100755
index 844a0eadd..000000000
--- a/util/lint.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-if [ ! -e "index.php" ]
-then
- echo "$0: Please execute this script from root directory."
- exit 1
-fi
-
-echo "$0: Analysing PHP scripts for syntax errors (lint) ..."
-LINT=`find -type f -name "*.php" -exec php -l -f {} 2>&1 \; | grep -v "No syntax errors detected in" | grep -v "FUSE_EDEADLK" | sort --unique`
-
-if [ -n "${LINT}" ]
-then
- echo "${LINT}"
-else
- echo "$0: No syntax errors found."
-fi
From 884f44ce94de8fdf26a40751dfd4b61b29765d29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Mon, 19 Dec 2016 14:26:13 +0100
Subject: [PATCH 23/68] *much* more usage of App::get_baseurl() instead of
$a->get_baseurl() (coding convention applied)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/Contact.php | 16 +++++------
include/Photo.php | 26 ++++++++---------
include/auth.php | 3 +-
include/bb2diaspora.php | 6 ++--
include/bbcode.php | 12 ++++----
include/contact_widgets.php | 3 +-
include/conversation.php | 8 +++---
include/dbstructure.php | 4 +--
include/delivery.php | 2 +-
include/enotify.php | 10 +++----
include/event.php | 2 +-
include/follow.php | 2 +-
include/identity.php | 36 ++++++++++++------------
include/items.php | 37 ++++++++++++-------------
include/like.php | 4 +--
include/message.php | 13 ++++-----
include/nav.php | 4 +--
include/network.php | 6 ++--
include/notifier.php | 2 +-
include/oauth.php | 2 +-
include/plugin.php | 5 ++--
include/pubsubpublish.php | 2 +-
include/redir.php | 2 +-
include/security.php | 8 +++---
include/socgraph.php | 10 +++----
include/tags.php | 6 ++--
include/text.php | 2 +-
include/threads.php | 4 +--
include/uimport.php | 4 +--
mod/admin.php | 36 ++++++++++++------------
mod/allfriends.php | 2 +-
mod/bookmarklet.php | 2 +-
mod/cal.php | 12 ++++----
mod/contacts.php | 10 +++----
mod/content.php | 8 +++---
mod/delegate.php | 14 +++++-----
mod/dfrn_confirm.php | 8 +++---
mod/dfrn_poll.php | 8 +++---
mod/dfrn_request.php | 18 ++++++------
mod/dirfind.php | 2 +-
mod/display.php | 6 ++--
mod/editpost.php | 6 ++--
mod/events.php | 20 ++++++-------
mod/fbrowser.php | 11 ++++----
mod/friendica.php | 4 +--
mod/group.php | 10 +++----
mod/hcard.php | 8 +++---
mod/home.php | 8 +++---
mod/ignored.php | 2 +-
mod/install.php | 16 +++++------
mod/invite.php | 4 +--
mod/item.php | 20 ++++++-------
mod/like.php | 2 +-
mod/localtime.php | 2 +-
mod/lostpass.php | 12 ++++----
mod/manage.php | 2 +-
mod/message.php | 22 +++++++--------
mod/mood.php | 2 +-
mod/msearch.php | 4 +--
mod/navigation.php | 2 +-
mod/network.php | 2 +-
mod/nodeinfo.php | 2 +-
mod/noscrape.php | 4 +--
mod/notice.php | 2 +-
mod/notify.php | 6 ++--
mod/oexchange.php | 4 +--
mod/openid.php | 2 +-
mod/opensearch.php | 2 +-
mod/ostatus_subscribe.php | 4 +--
mod/photos.php | 20 ++++++-------
mod/ping.php | 10 +++----
mod/poke.php | 8 +++---
mod/profile.php | 16 +++++------
mod/profile_photo.php | 20 ++++++-------
mod/profiles.php | 6 ++--
mod/proxy.php | 8 +++---
mod/randprof.php | 2 +-
mod/register.php | 10 +++----
mod/regmod.php | 8 +++---
mod/repair_ostatus.php | 2 +-
mod/rsd_xml.php | 2 +-
mod/settings.php | 18 ++++++------
mod/starred.php | 2 +-
mod/suggest.php | 6 ++--
mod/tagger.php | 16 +++++------
mod/tagrm.php | 16 +++++------
mod/toggle_mobile.php | 2 +-
mod/uexport.php | 4 +--
mod/videos.php | 28 +++++++++----------
mod/wall_upload.php | 12 ++++----
mod/xrd.php | 20 ++++++-------
view/php/default.php | 2 +-
view/php/minimal.php | 2 +-
view/theme/duepuntozero/config.php | 8 +++---
view/theme/frio/config.php | 2 +-
view/theme/frio/php/default.php | 4 +--
view/theme/frio/php/standard.php | 4 +--
view/theme/frio/theme.php | 2 +-
view/theme/frost-mobile/php/default.php | 2 +-
view/theme/frost-mobile/theme.php | 4 +--
view/theme/frost/php/default.php | 2 +-
view/theme/frost/theme.php | 4 +--
view/theme/quattro/config.php | 4 +--
view/theme/quattro/theme.php | 4 +--
view/theme/smoothly/php/default.php | 2 +-
view/theme/smoothly/theme.php | 4 +--
view/theme/vier/config.php | 4 +--
view/theme/vier/theme.php | 2 +-
108 files changed, 407 insertions(+), 437 deletions(-)
diff --git a/include/Contact.php b/include/Contact.php
index 7ca45a21b..a4d6211fa 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -8,7 +8,6 @@
function user_remove($uid) {
if(! $uid)
return;
- $a = get_app();
logger('Removing user: ' . $uid);
$r = q("select * from user where uid = %d limit 1", intval($uid));
@@ -54,7 +53,7 @@ function user_remove($uid) {
if($uid == local_user()) {
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
- goaway($a->get_baseurl());
+ goaway(App::get_baseurl());
}
}
@@ -86,7 +85,6 @@ function contact_remove($id) {
function terminate_friendship($user,$self,$contact) {
-
$a = get_app();
require_once('include/datetime.php');
@@ -361,7 +359,7 @@ function contact_photo_menu($contact, $uid = 0)
$sparkle = false;
if ($contact['network'] === NETWORK_DFRN) {
$sparkle = true;
- $profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
+ $profile_link = App::get_baseurl() . '/redir/' . $contact['id'];
} else {
$profile_link = $contact['url'];
}
@@ -377,17 +375,17 @@ function contact_photo_menu($contact, $uid = 0)
}
if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) {
- $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
+ $pm_url = App::get_baseurl() . '/message/new/' . $contact['id'];
}
if ($contact['network'] == NETWORK_DFRN) {
- $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id'];
+ $poke_link = App::get_baseurl() . '/poke/?f=&c=' . $contact['id'];
}
- $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
+ $contact_url = App::get_baseurl() . '/contacts/' . $contact['id'];
- $posts_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
- $contact_drop_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
+ $posts_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
+ $contact_drop_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
/**
* menu array:
diff --git a/include/Photo.php b/include/Photo.php
index 014cca7d2..1a97fe2fe 100644
--- a/include/Photo.php
+++ b/include/Photo.php
@@ -794,8 +794,6 @@ function update_contact_avatar($avatar, $uid, $cid, $force = false) {
function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
- $a = get_app();
-
$r = q("SELECT `resource-id` FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `scale` = 4 AND `album` = 'Contact Photos' LIMIT 1",
intval($uid),
intval($cid)
@@ -841,9 +839,9 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
$photo_failure = true;
}
- $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
- $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
- $micro = $a->get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
+ $photo = App::get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
+ $thumb = App::get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
+ $micro = App::get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
} else {
$photo_failure = true;
}
@@ -853,9 +851,9 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
}
if ($photo_failure) {
- $photo = $a->get_baseurl() . '/images/person-175.jpg';
- $thumb = $a->get_baseurl() . '/images/person-80.jpg';
- $micro = $a->get_baseurl() . '/images/person-48.jpg';
+ $photo = App::get_baseurl() . '/images/person-175.jpg';
+ $thumb = App::get_baseurl() . '/images/person-80.jpg';
+ $micro = App::get_baseurl() . '/images/person-48.jpg';
}
return(array($photo,$thumb,$micro));
@@ -1044,18 +1042,18 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
return(array());
}
- $image = array("page" => $a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
- "full" => $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
+ $image = array("page" => App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
+ "full" => App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
if ($width > 800 || $height > 800) {
- $image["large"] = $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
+ $image["large"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
}
if ($width > 640 || $height > 640) {
$ph->scaleImage(640);
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
if ($r) {
- $image["medium"] = $a->get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
+ $image["medium"] = App::get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
}
}
@@ -1063,7 +1061,7 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
$ph->scaleImage(320);
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
if ($r) {
- $image["small"] = $a->get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
+ $image["small"] = App::get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
}
}
@@ -1088,7 +1086,7 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
if ($r) {
- $image["thumb"] = $a->get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
+ $image["thumb"] = App::get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
}
}
diff --git a/include/auth.php b/include/auth.php
index 2ca9c3efb..e3c8d92ee 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -125,8 +125,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
$openid = new LightOpenID;
$openid->identity = $openid_url;
$_SESSION['openid'] = $openid_url;
- $a = get_app();
- $openid->returnUrl = $a->get_baseurl(true).'/openid';
+ $openid->returnUrl = App::get_baseurl(true).'/openid';
goaway($openid->authUrl());
} catch (Exception $e) {
notice(t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.').' '.t('The error message was:').' '.$e->getMessage());
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 0c637dc3a..842dbf0b1 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -144,8 +144,6 @@ function unescape_underscores_in_links($m) {
function format_event_diaspora($ev) {
- $a = get_app();
-
if(! ((is_array($ev)) && count($ev)))
return '';
@@ -160,7 +158,7 @@ function format_event_diaspora($ev) {
$ev['start'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['start'] , $bd_format)))
- . '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
+ . '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
if(! $ev['nofinish'])
$o .= t('Finishes:') . ' ' . '['
@@ -168,7 +166,7 @@ function format_event_diaspora($ev) {
$ev['finish'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format )))
- . '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
+ . '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
if(strlen($ev['location']))
$o .= t('Location:') . bb2diaspora($ev['location'])
diff --git a/include/bbcode.php b/include/bbcode.php
index 27213007c..c05173f47 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -613,9 +613,7 @@ function GetProfileUsername($profile, $username, $compact = false, $getnetwork =
}
function bb_DiasporaLinks($match) {
- $a = get_app();
-
- return "[url=".$a->get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]";
+ return "[url=".App::get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]";
}
function bb_RemovePictureLinks($match) {
@@ -894,7 +892,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
// we may need to restrict this further if it picks up too many strays
// link acct:user@host to a webfinger profile redirector
- $Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', 'acct:$1@$2 ',$Text);
+ $Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', 'acct:$1@$2 ',$Text);
// Perform MAIL Search
$Text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '$1 ', $Text);
@@ -1063,9 +1061,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
return(bb_ShareAttributes($match, $simplehtml));
},$Text);
- $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",' ', $Text);
- $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",' ', $Text);
- //$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",' ', $Text);
+ $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",' ', $Text);
+ $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",' ', $Text);
+ //$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",' ', $Text);
// Try to Oembed
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index f66d23c51..a74080e75 100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -116,7 +116,6 @@ function networks_widget($baseurl,$selected = '') {
}
function fileas_widget($baseurl,$selected = '') {
- $a = get_app();
if(! local_user())
return '';
@@ -235,7 +234,7 @@ function common_friends_visitor_widget($profile_uid) {
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
- '$base' => $a->get_baseurl(),
+ '$base' => App::get_baseurl(),
'$uid' => $profile_uid,
'$cid' => (($cid) ? $cid : '0'),
'$linkmore' => (($t > 5) ? 'true' : ''),
diff --git a/include/conversation.php b/include/conversation.php
index 567bf83e1..916a9e229 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -864,7 +864,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
}
$o = replace_macros($page_template, array(
- '$baseurl' => $a->get_baseurl($ssl_state),
+ '$baseurl' => App::get_baseurl($ssl_state),
'$return_path' => $a->query_string,
'$live_update' => $live_update_div,
'$remove' => t('remove'),
@@ -1183,7 +1183,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
$tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array(
'$newpost' => 'true',
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$geotag' => $geotag,
'$nickname' => $x['nickname'],
@@ -1201,7 +1201,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
$tpl = get_markup_template('jot-end.tpl');
$a->page['end'] .= replace_macros($tpl, array(
'$newpost' => 'true',
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$geotag' => $geotag,
'$nickname' => $x['nickname'],
@@ -1267,7 +1267,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
'$ptyp' => (($notes_cid) ? 'note' : 'wall'),
'$content' => $x['content'],
'$post_id' => $x['post_id'],
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$defloc' => $x['default_location'],
'$visitor' => $x['visitor'],
'$pvisit' => (($notes_cid) ? 'none' : $x['visitor']),
diff --git a/include/dbstructure.php b/include/dbstructure.php
index c694014f6..be1158eab 100644
--- a/include/dbstructure.php
+++ b/include/dbstructure.php
@@ -56,11 +56,11 @@ function update_fail($update_id, $error_message){
$email_tpl = get_intltext_template("update_fail_eml.tpl");
$email_msg = replace_macros($email_tpl, array(
'$sitename' => $a->config['sitename'],
- '$siteurl' => $a->get_baseurl(),
+ '$siteurl' => App::get_baseurl(),
'$update' => DB_UPDATE_VERSION,
'$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
));
- $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
+ $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
require_once('include/email.php');
$subject = email_header_encode($subject,'UTF-8');
mail($a->config['admin_email'], $subject, $email_msg,
diff --git a/include/delivery.php b/include/delivery.php
index a7aebe709..db2f03c8f 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -323,7 +323,7 @@ function delivery_run(&$argv, &$argc){
// perform local delivery if we are on the same site
- if (link_compare($basepath,$a->get_baseurl())) {
+ if (link_compare($basepath,App::get_baseurl())) {
$nickname = basename($contact['url']);
if ($contact['issued-id'])
diff --git a/include/enotify.php b/include/enotify.php
index c6e0506e9..aa29e117a 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -23,7 +23,7 @@ function notification($params) {
$banner = t('Friendica Notification');
$product = FRIENDICA_PLATFORM;
- $siteurl = $a->get_baseurl(true);
+ $siteurl = App::get_baseurl(true);
$thanks = t('Thank You,');
$sitename = $a->config['sitename'];
if (!x($a->config['admin_name']))
@@ -58,7 +58,7 @@ function notification($params) {
$additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
$additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
$additional_mail_header .= "List-ID: \n";
- $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
+ $additional_mail_header .= "List-Archive: <".App::get_baseurl()."/notifications/system>\n";
if (array_key_exists('item', $params)) {
$title = $params['item']['title'];
@@ -494,7 +494,7 @@ function notification($params) {
}
- $itemlink = $a->get_baseurl().'/notify/view/'.$notify_id;
+ $itemlink = App::get_baseurl().'/notify/view/'.$notify_id;
$msg = replace_macros($epreamble, array('$itemlink' => $itemlink));
$msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg)));
$r = q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d",
@@ -648,8 +648,6 @@ function notification($params) {
* @param str $defaulttype (Optional) Forces a notification with this type.
*/
function check_item_notification($itemid, $uid, $defaulttype = "") {
- $a = get_app();
-
$notification_data = array("uid" => $uid, "profiles" => array());
call_hooks('check_item_notification', $notification_data);
@@ -667,7 +665,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$profiles[] = $owner[0]["url"];
// Notifications from Diaspora are often with an URL in the Diaspora format
- $profiles[] = $a->get_baseurl()."/u/".$user[0]["nickname"];
+ $profiles[] = App::get_baseurl()."/u/".$user[0]["nickname"];
$profiles2 = array();
diff --git a/include/event.php b/include/event.php
index 3a41dad4e..4abe3ffef 100644
--- a/include/event.php
+++ b/include/event.php
@@ -408,7 +408,7 @@ function event_store($arr) {
intval($arr['uid'])
);
//if (dbm::is_result($r))
- // $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
+ // $plink = App::get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
if($item_id) {
diff --git a/include/follow.php b/include/follow.php
index 7a3514b3a..d7066bcb5 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -99,7 +99,7 @@ function new_contact($uid,$url,$interactive = false) {
if($ret['network'] === NETWORK_DFRN) {
if($interactive) {
if(strlen($a->path))
- $myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']);
+ $myaddr = bin2hex(App::get_baseurl() . '/profile/' . $a->user['nickname']);
else
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
diff --git a/include/identity.php b/include/identity.php
index bf05a0051..1307b42b1 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -232,7 +232,7 @@ function profile_sidebar($profile, $block = 0) {
if (isset($profile["url"]))
$profile_url = normalise_link($profile["url"]);
else
- $profile_url = normalise_link($a->get_baseurl()."/profile/".$profile["nickname"]);
+ $profile_url = normalise_link(App::get_baseurl()."/profile/".$profile["nickname"]);
$r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
local_user(), $profile_url);
@@ -279,7 +279,7 @@ function profile_sidebar($profile, $block = 0) {
// show edit profile to yourself
if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
- $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
+ $profile['edit'] = array(App::get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
$r = q("SELECT * FROM `profile` WHERE `uid` = %d",
local_user());
@@ -308,7 +308,7 @@ function profile_sidebar($profile, $block = 0) {
}
}
if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) {
- $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
+ $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
$profile['menu'] = array(
'chg_photo' => t('Change profile photo'),
'cr_new' => null,
@@ -349,15 +349,15 @@ function profile_sidebar($profile, $block = 0) {
if ($profile['guid'] != "")
$diaspora = array(
'guid' => $profile['guid'],
- 'podloc' => $a->get_baseurl(),
+ 'podloc' => App::get_baseurl(),
'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
'nickname' => $profile['nickname'],
'fullname' => $profile['name'],
'firstname' => $firstname,
'lastname' => $lastname,
- 'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
- 'photo100' => $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
- 'photo50' => $a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg',
+ 'photo300' => App::get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
+ 'photo100' => App::get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
+ 'photo50' => App::get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg',
);
else
$diaspora = false;
@@ -489,7 +489,7 @@ function get_birthdays() {
$url = $rr['url'];
if($rr['network'] === NETWORK_DFRN) {
$sparkle = " sparkle";
- $url = $a->get_baseurl() . '/redir/' . $rr['cid'];
+ $url = App::get_baseurl() . '/redir/' . $rr['cid'];
}
$rr['link'] = $url;
@@ -503,7 +503,7 @@ function get_birthdays() {
}
$tpl = get_markup_template("birthdays_reminder.tpl");
return replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$classtoday' => $classtoday,
'$count' => $total,
'$event_reminders' => t('Birthday Reminders'),
@@ -587,7 +587,7 @@ function get_events() {
$tpl = get_markup_template("events_reminder.tpl");
return replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$classtoday' => $classtoday,
'$count' => count($r) - $skip,
'$event_reminders' => t('Event Reminders'),
@@ -685,7 +685,7 @@ function advanced_profile(&$a) {
}
if ($a->profile['uid'] == local_user())
- $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
+ $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
return replace_macros($tpl, array(
'$title' => t('Profile'),
@@ -707,7 +707,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
if(x($_GET,'tab'))
$tab = notags(trim($_GET['tab']));
- $url = $a->get_baseurl() . '/profile/' . $nickname;
+ $url = App::get_baseurl() . '/profile/' . $nickname;
$tabs = array(
array(
@@ -728,7 +728,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
),
array(
'label' => t('Photos'),
- 'url' => $a->get_baseurl() . '/photos/' . $nickname,
+ 'url' => App::get_baseurl() . '/photos/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''),
'title' => t('Photo Albums'),
'id' => 'photo-tab',
@@ -736,7 +736,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
),
array(
'label' => t('Videos'),
- 'url' => $a->get_baseurl() . '/videos/' . $nickname,
+ 'url' => App::get_baseurl() . '/videos/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='videos')?'active':''),
'title' => t('Videos'),
'id' => 'video-tab',
@@ -748,7 +748,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
if ($is_owner && $a->theme_events_in_profile) {
$tabs[] = array(
'label' => t('Events'),
- 'url' => $a->get_baseurl() . '/events',
+ 'url' => App::get_baseurl() . '/events',
'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''),
'title' => t('Events and Calendar'),
'id' => 'events-tab',
@@ -759,7 +759,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
} elseif (! $is_owner) {
$tabs[] = array(
'label' => t('Events'),
- 'url' => $a->get_baseurl() . '/cal/' . $nickname,
+ 'url' => App::get_baseurl() . '/cal/' . $nickname,
'sel' =>((!isset($tab)&&$a->argv[0]=='cal')?'active':''),
'title' => t('Events and Calendar'),
'id' => 'events-tab',
@@ -770,7 +770,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
if ($is_owner){
$tabs[] = array(
'label' => t('Personal Notes'),
- 'url' => $a->get_baseurl() . '/notes',
+ 'url' => App::get_baseurl() . '/notes',
'sel' =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''),
'title' => t('Only You Can See This'),
'id' => 'notes-tab',
@@ -781,7 +781,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) {
$tabs[] = array(
'label' => t('Contacts'),
- 'url' => $a->get_baseurl() . '/viewcontacts/' . $nickname,
+ 'url' => App::get_baseurl() . '/viewcontacts/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''),
'title' => t('Contacts'),
'id' => 'viewcontacts-tab',
diff --git a/include/items.php b/include/items.php
index da9147fad..e91c7088a 100644
--- a/include/items.php
+++ b/include/items.php
@@ -208,13 +208,12 @@ function add_page_info_data($data) {
$hashtags = "";
if (isset($data["keywords"]) AND count($data["keywords"])) {
- $a = get_app();
$hashtags = "\n";
foreach ($data["keywords"] AS $keyword) {
/// @todo make a positive list of allowed characters
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"),
array("","", "", "", "", "", "", "", "", "", "", ""), $keyword);
- $hashtags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] ";
+ $hashtags .= "#[url=".App::get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] ";
}
}
@@ -251,7 +250,6 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa
$tags = "";
if (isset($data["keywords"]) AND count($data["keywords"])) {
- $a = get_app();
foreach ($data["keywords"] AS $keyword) {
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"),
array("","", "", "", "", ""), $keyword);
@@ -259,7 +257,7 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa
if ($tags != "")
$tags .= ",";
- $tags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]";
+ $tags .= "#[url=".App::get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]";
}
}
@@ -557,8 +555,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
logger("Both author-link and owner-link are empty. Called by: ".App::callstack(), LOGGER_DEBUG);
if ($arr['plink'] == "") {
- $a = get_app();
- $arr['plink'] = $a->get_baseurl().'/display/'.urlencode($arr['guid']);
+ $arr['plink'] = App::get_baseurl().'/display/'.urlencode($arr['guid']);
}
if ($arr['network'] == "") {
@@ -709,7 +706,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
$u = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($arr['uid']));
if (count($u)) {
$a = get_app();
- $self = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+ $self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
if ((normalise_link($arr['author-link']) == $self) OR (normalise_link($arr['owner-link']) == $self)) {
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id));
@@ -1068,10 +1065,10 @@ function item_body_set_hashtags(&$item) {
// All hashtags should point to the home server
//$item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
- // "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]);
+ // "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]);
//$item["tag"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
- // "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]);
+ // "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]);
// mask hashtags inside of url, bookmarks and attachments to avoid urls in urls
$item["body"] = preg_replace_callback("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
@@ -1103,7 +1100,7 @@ function item_body_set_hashtags(&$item) {
$basetag = str_replace('_',' ',substr($tag,1));
- $newtag = '#[url='.$a->get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]';
+ $newtag = '#[url='.App::get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]';
$item["body"] = str_replace($tag, $newtag, $item["body"]);
@@ -1207,12 +1204,12 @@ function tag_deliver($uid,$item_id) {
$item = $i[0];
- $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+ $link = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
// Diaspora uses their own hardwired link URL in @-tags
// instead of the one we supply with webfinger
- $dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']);
+ $dlink = normalise_link(App::get_baseurl() . '/u/' . $u[0]['nickname']);
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if ($cnt) {
@@ -1312,12 +1309,12 @@ function tgroup_check($uid,$item) {
$prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false);
- $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+ $link = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
// Diaspora uses their own hardwired link URL in @-tags
// instead of the one we supply with webfinger
- $dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']);
+ $dlink = normalise_link(App::get_baseurl() . '/u/' . $u[0]['nickname']);
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if ($cnt) {
@@ -1572,7 +1569,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
'to_name' => $r[0]['username'],
'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'],
- 'link' => $a->get_baseurl() . '/notifications/intro',
+ 'link' => App::get_baseurl() . '/notifications/intro',
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : t('[Name Withheld]')),
'source_link' => $contact_record['url'],
'source_photo' => $contact_record['photo'],
@@ -1665,7 +1662,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) {
$a = get_app();
logger('fix_private_photos: check for photos', LOGGER_DEBUG);
- $site = substr($a->get_baseurl(),strpos($a->get_baseurl(),'://'));
+ $site = substr(App::get_baseurl(),strpos(App::get_baseurl(),'://'));
$orig_body = $s;
$new_body = '';
@@ -1929,7 +1926,7 @@ function drop_item($id,$interactive = true) {
if (! $interactive)
return 0;
notice( t('Item not found.') . EOL);
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
}
$item = $r[0];
@@ -1977,7 +1974,7 @@ function drop_item($id,$interactive = true) {
}
// Now check how the user responded to the confirmation query
if ($_REQUEST['canceled']) {
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
}
logger('delete item: ' . $item['id'], LOGGER_DEBUG);
@@ -2127,13 +2124,13 @@ function drop_item($id,$interactive = true) {
if (! $interactive)
return $owner;
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
//NOTREACHED
} else {
if (! $interactive)
return 0;
notice( t('Permission denied.') . EOL);
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
//NOTREACHED
}
diff --git a/include/like.php b/include/like.php
index 5b6d1b9e6..8239633e6 100644
--- a/include/like.php
+++ b/include/like.php
@@ -164,7 +164,7 @@ function do_like($item_id, $verb) {
if($item['object-type'] === ACTIVITY_OBJ_EVENT)
$post_type = t('event');
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
- $link = xmlify(' ' . "\n") ;
+ $link = xmlify(' ' . "\n") ;
$body = $item['body'];
$obj = <<< EOT
@@ -214,7 +214,7 @@ EOT;
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
- $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
+ $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
$arr['verb'] = $activity;
diff --git a/include/message.php b/include/message.php
index ea2fcef3b..e5ebe6f91 100644
--- a/include/message.php
+++ b/include/message.php
@@ -27,7 +27,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
}
$guid = get_guid(32);
- $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $guid;
+ $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
$convid = 0;
$reply = false;
@@ -53,7 +53,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
$recip_host = substr($recip_host,0,strpos($recip_host,'/'));
$recip_handle = (($contact[0]['addr']) ? $contact[0]['addr'] : $contact[0]['nick'] . '@' . $recip_host);
- $sender_handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $sender_handle = $a->user['nickname'] . '@' . substr(App::get_baseurl(), strpos(App::get_baseurl(),'://') + 3);
$conv_guid = get_guid(32);
$convuri = $recip_handle.':'.$conv_guid;
@@ -134,7 +134,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
$images = $match[1];
if(count($images)) {
foreach($images as $image) {
- if(! stristr($image,$a->get_baseurl() . '/photo/'))
+ if(! stristr($image,App::get_baseurl() . '/photo/'))
continue;
$image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
@@ -164,16 +164,13 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
- $a = get_app();
-
-
if(! $recipient) return -1;
if(! strlen($subject))
$subject = t('[no subject]');
$guid = get_guid(32);
- $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $guid;
+ $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
$convid = 0;
$reply = false;
@@ -187,7 +184,7 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
$conv_guid = get_guid(32);
- $recip_handle = $recipient['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $recip_handle = $recipient['nickname'] . '@' . substr(App::get_baseurl(), strpos(App::get_baseurl(),'://') + 3);
$sender_nick = basename($replyto);
$sender_host = substr($replyto,strpos($replyto,'://')+3);
diff --git a/include/nav.php b/include/nav.php
index 2a9f24ca9..f71272f3b 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -28,7 +28,7 @@ function nav(&$a) {
$tpl = get_markup_template('nav.tpl');
$a->page['nav'] .= replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$sitelocation' => $nav_info['sitelocation'],
'$nav' => $nav_info['nav'],
'$banner' => $nav_info['banner'],
@@ -65,7 +65,7 @@ function nav_info(App $a)
$myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
- $sitelocation = $myident . substr($a->get_baseurl($ssl_state), strpos($a->get_baseurl($ssl_state), '//') + 2 );
+ $sitelocation = $myident . substr(App::get_baseurl($ssl_state), strpos(App::get_baseurl($ssl_state), '//') + 2 );
// nav links: array of array('href', 'text', 'extra css classes', 'title')
$nav = array();
diff --git a/include/network.php b/include/network.php
index df46d3593..cac77fcdf 100644
--- a/include/network.php
+++ b/include/network.php
@@ -513,8 +513,6 @@ function allowed_email($email) {
function avatar_img($email) {
- $a = get_app();
-
$avatar['size'] = 175;
$avatar['email'] = $email;
$avatar['url'] = '';
@@ -523,7 +521,7 @@ function avatar_img($email) {
call_hooks('avatar_lookup', $avatar);
if(! $avatar['success'])
- $avatar['url'] = $a->get_baseurl() . '/images/person-175.jpg';
+ $avatar['url'] = App::get_baseurl() . '/images/person-175.jpg';
logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG);
return $avatar['url'];
@@ -569,7 +567,7 @@ function scale_external_images($srctext, $include_link = true, $scale_replace =
foreach($matches as $mtch) {
logger('scale_external_image: ' . $mtch[1]);
- $hostname = str_replace('www.','',substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3));
+ $hostname = str_replace('www.','',substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3));
if(stristr($mtch[1],$hostname))
continue;
diff --git a/include/notifier.php b/include/notifier.php
index 2f9599d07..c4e7df47a 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -649,7 +649,7 @@ function notifier_run(&$argv, &$argc){
} else {
- $params = 'hub.mode=publish&hub.url=' . urlencode( $a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
+ $params = 'hub.mode=publish&hub.url=' . urlencode( App::get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
post_url($h,$params);
logger('publish for item '.$item_id.' ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code());
}
diff --git a/include/oauth.php b/include/oauth.php
index a30232df4..3d4533d3e 100644
--- a/include/oauth.php
+++ b/include/oauth.php
@@ -148,7 +148,7 @@ class FKOAuth1 extends OAuthServer {
$_SESSION['mobile-theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme');
$_SESSION['authenticated'] = 1;
$_SESSION['page_flags'] = $record['page-flags'];
- $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $record['nickname'];
+ $_SESSION['my_url'] = App::get_baseurl() . '/profile/' . $record['nickname'];
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
$_SESSION["allow_api"] = true;
diff --git a/include/plugin.php b/include/plugin.php
index 487ab5751..4242b730b 100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -410,13 +410,12 @@ function get_theme_info($theme){
* @return string
*/
function get_theme_screenshot($theme) {
- $a = get_app();
$exts = array('.png','.jpg');
foreach($exts as $ext) {
if(file_exists('view/theme/' . $theme . '/screenshot' . $ext))
- return($a->get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
+ return(App::get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
}
- return($a->get_baseurl() . '/images/blank.png');
+ return(App::get_baseurl() . '/images/blank.png');
}
// install and uninstall theme
diff --git a/include/pubsubpublish.php b/include/pubsubpublish.php
index 85637facb..abf973a28 100644
--- a/include/pubsubpublish.php
+++ b/include/pubsubpublish.php
@@ -21,7 +21,7 @@ function handle_pubsubhubbub($id) {
$headers = array("Content-type: application/atom+xml",
sprintf("Link: <%s>;rel=hub,<%s>;rel=self",
- $a->get_baseurl().'/pubsubhubbub',
+ App::get_baseurl().'/pubsubhubbub',
$rr['topic']),
"X-Hub-Signature: sha1=".$hmac_sig);
diff --git a/include/redir.php b/include/redir.php
index 8d8a035f1..8d65089de 100644
--- a/include/redir.php
+++ b/include/redir.php
@@ -20,7 +20,7 @@ function auto_redir(&$a, $contact_nick) {
//
// We also have to make sure that I'm a legitimate contact--I'm not blocked or pending.
- $baseurl = $a->get_baseurl();
+ $baseurl = App::get_baseurl();
$domain_st = strpos($baseurl, "://");
if($domain_st === false)
return;
diff --git a/include/security.php b/include/security.php
index fa698c1b1..7e14146d9 100644
--- a/include/security.php
+++ b/include/security.php
@@ -9,8 +9,8 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$_SESSION['mobile-theme'] = get_pconfig($user_record['uid'], 'system', 'mobile_theme');
$_SESSION['authenticated'] = 1;
$_SESSION['page_flags'] = $user_record['page-flags'];
- $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname'];
- $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
+ $_SESSION['my_url'] = App::get_baseurl() . '/profile/' . $user_record['nickname'];
+ $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3);
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
$a->user = $user_record;
@@ -98,7 +98,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
call_hooks('logged_in', $a->user);
if(($a->module !== 'home') && isset($_SESSION['return_url']))
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
}
}
@@ -378,7 +378,7 @@ function check_form_security_token_redirectOnErr($err_redirect, $typename = '',
logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
notice( check_form_security_std_err_msg() );
- goaway($a->get_baseurl() . $err_redirect );
+ goaway(App::get_baseurl() . $err_redirect );
}
}
function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') {
diff --git a/include/socgraph.php b/include/socgraph.php
index 349fd0b2c..8a9512654 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -207,7 +207,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
$orig_updated = $updated;
// The global contacts should contain the original picture, not the cached one
- if (($generation != 1) AND stristr(normalise_link($profile_photo), normalise_link($a->get_baseurl()."/photo/")))
+ if (($generation != 1) AND stristr(normalise_link($profile_photo), normalise_link(App::get_baseurl()."/photo/")))
$profile_photo = "";
$r = q("SELECT `network` FROM `contact` WHERE `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1",
@@ -1181,9 +1181,9 @@ function update_suggestions() {
$done = array();
/// TODO Check if it is really neccessary to poll the own server
- poco_load(0,0,0,$a->get_baseurl() . '/poco');
+ poco_load(0,0,0,App::get_baseurl() . '/poco');
- $done[] = $a->get_baseurl() . '/poco';
+ $done[] = App::get_baseurl() . '/poco';
if(strlen(get_config('system','directory'))) {
$x = fetch_url(get_server()."/pubsites");
@@ -1771,8 +1771,6 @@ function gs_fetch_users($server) {
logger("Fetching users from GNU Social server ".$server, LOGGER_DEBUG);
- $a = get_app();
-
$url = $server."/main/statistics";
$result = z_fetch_url($url);
@@ -1811,7 +1809,7 @@ function gs_fetch_users($server) {
"nick" => $user->nickname,
"about" => $user->bio,
"network" => NETWORK_OSTATUS,
- "photo" => $a->get_baseurl()."/images/person-175.jpg");
+ "photo" => App::get_baseurl()."/images/person-175.jpg");
get_gcontact_id($contact);
}
}
diff --git a/include/tags.php b/include/tags.php
index 6c1d01d74..0a0943847 100644
--- a/include/tags.php
+++ b/include/tags.php
@@ -1,13 +1,11 @@
get_baseurl();
+ $profile_base = App::get_baseurl();
$profile_data = parse_url($profile_base);
$profile_base_friendica = $profile_data['host'].$profile_data['path']."/profile/";
$profile_base_diaspora = $profile_data['host'].$profile_data['path']."/u/";
- $searchpath = $a->get_baseurl()."/search?tag=";
+ $searchpath = App::get_baseurl()."/search?tag=";
$messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `created`, `received`, `title`, `body`, `tag`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
diff --git a/include/text.php b/include/text.php
index 5856226c3..a2c474d32 100644
--- a/include/text.php
+++ b/include/text.php
@@ -23,7 +23,7 @@ function replace_macros($s,$r) {
$a = get_app();
// pass $baseurl to all templates
- $r['$baseurl'] = $a->get_baseurl();
+ $r['$baseurl'] = App::get_baseurl();
$t = $a->template_engine();
diff --git a/include/threads.php b/include/threads.php
index 48391174e..c214cf264 100644
--- a/include/threads.php
+++ b/include/threads.php
@@ -267,12 +267,10 @@ function update_threads() {
}
function update_threads_mention() {
- $a = get_app();
-
$users = q("SELECT `uid`, `nickname` FROM `user` ORDER BY `uid`");
foreach ($users AS $user) {
- $self = normalise_link($a->get_baseurl() . '/profile/' . $user['nickname']);
+ $self = normalise_link(App::get_baseurl() . '/profile/' . $user['nickname']);
$selfhttps = str_replace("http://", "https://", $self);
$parents = q("SELECT DISTINCT(`parent`) FROM `item` WHERE `uid` = %d AND
((`owner-link` IN ('%s', '%s')) OR (`author-link` IN ('%s', '%s')))",
diff --git a/include/uimport.php b/include/uimport.php
index 51672d92b..0d9ffc35f 100644
--- a/include/uimport.php
+++ b/include/uimport.php
@@ -133,7 +133,7 @@ function import_account(&$a, $file) {
}
$oldbaseurl = $account['baseurl'];
- $newbaseurl = $a->get_baseurl();
+ $newbaseurl = App::get_baseurl();
$olduid = $account['user']['uid'];
unset($account['user']['uid']);
@@ -290,5 +290,5 @@ function import_account(&$a, $file) {
proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $newuid);
info(t("Done. You can now login with your username and password"));
- goaway($a->get_baseurl() . "/login");
+ goaway(App::get_baseurl() . "/login");
}
diff --git a/mod/admin.php b/mod/admin.php
index cf0d8d9ac..832ca470f 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -376,7 +376,7 @@ function admin_page_federation(&$a) {
'$counts' => $counts,
'$version' => FRIENDICA_VERSION,
'$legendtext' => sprintf(t('Currently this node is aware of %d nodes from the following platforms:'), $total),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
));
}
@@ -489,7 +489,7 @@ function admin_page_summary(&$a) {
'$accounts' => $accounts,
'$pending' => array(t('Pending registrations'), $pending),
'$version' => array(t('Version'), FRIENDICA_VERSION),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$platform' => FRIENDICA_PLATFORM,
'$codename' => FRIENDICA_CODENAME,
'$build' => get_config('system','build'),
@@ -527,7 +527,7 @@ function admin_page_site_post(&$a) {
* send relocate for every local user
* */
- $old_url = $a->get_baseurl(true);
+ $old_url = App::get_baseurl(true);
// Generate host names for relocation the addresses in the format user@address.tld
$new_host = str_replace("http://", "@", normalise_link($new_url));
@@ -961,7 +961,7 @@ function admin_page_site(&$a) {
'$performance' => t('Performance'),
'$worker_title' => t('Worker'),
'$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
// name, label, value, help string, extra data...
'$sitename' => array('sitename', t("Site name"), $a->config['sitename'],''),
'$hostname' => array('hostname', t("Host name"), $a->config['hostname'], ""),
@@ -1043,7 +1043,7 @@ function admin_page_site(&$a) {
'$old_pager' => array('old_pager', t("Enable old style pager"), get_config('system','old_pager'), t("The old style pager has page numbers but slows down massively the page speed.")),
'$only_tag_search' => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")),
- '$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
+ '$relocate_url' => array('relocate_url', t("New base url"), App::get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
'$rino' => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")),
'$embedly' => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("Embedly is used to fetch additional data for web pages. This is an optional parameter.")),
@@ -1131,13 +1131,13 @@ function admin_page_dbsync(&$a) {
}
if(! count($failed)) {
$o = replace_macros(get_markup_template('structure_check.tpl'),array(
- '$base' => $a->get_baseurl(true),
+ '$base' => App::get_baseurl(true),
'$banner' => t('No failed updates.'),
'$check' => t('Check database structure'),
));
} else {
$o = replace_macros(get_markup_template('failed_updates.tpl'),array(
- '$base' => $a->get_baseurl(true),
+ '$base' => App::get_baseurl(true),
'$banner' => t('Failed Updates'),
'$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
'$mark' => t('Mark success (if update was manually applied)'),
@@ -1205,7 +1205,7 @@ function admin_page_users_post(&$a){
Thank you and welcome to %4$s.'));
$preamble = sprintf($preamble, $nu['username'], $a->config['sitename']);
- $body = sprintf($body, $a->get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']);
+ $body = sprintf($body, App::get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']);
notification(array(
'type' => "SYSTEM_EMAIL",
@@ -1430,7 +1430,7 @@ function admin_page_users(&$a){
'$form_security_token' => get_form_security_token("admin_users"),
// values //
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$pending' => $pending,
'deleted' => $deleted,
@@ -1522,7 +1522,7 @@ function admin_page_plugins(&$a){
'$page' => t('Plugins'),
'$toggle' => t('Toggle'),
'$settings' => t('Settings'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$plugin' => $plugin,
'$status' => $status,
@@ -1547,10 +1547,10 @@ function admin_page_plugins(&$a){
*/
if(x($_GET,"a") && $_GET['a']=="r") {
- check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/plugins', 'admin_themes', 't');
+ check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/plugins', 'admin_themes', 't');
reload_plugins();
info("Plugins reloaded");
- goaway($a->get_baseurl().'/admin/plugins');
+ goaway(App::get_baseurl().'/admin/plugins');
}
$plugins = array();
@@ -1582,7 +1582,7 @@ function admin_page_plugins(&$a){
'$page' => t('Plugins'),
'$submit' => t('Save Settings'),
'$reload' => t('Reload active plugins'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$function' => 'plugins',
'$plugins' => $plugins,
'$pcount' => count($plugins),
@@ -1780,7 +1780,7 @@ function admin_page_themes(&$a){
'$page' => t('Themes'),
'$toggle' => t('Toggle'),
'$settings' => t('Settings'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$plugin' => $theme,
'$status' => $status,
'$action' => $action,
@@ -1799,7 +1799,7 @@ function admin_page_themes(&$a){
// reload active themes
if(x($_GET,"a") && $_GET['a']=="r") {
- check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/themes', 'admin_themes', 't');
+ check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/themes', 'admin_themes', 't');
if($themes) {
foreach($themes as $th) {
if($th['allowed']) {
@@ -1809,7 +1809,7 @@ function admin_page_themes(&$a){
}
}
info("Themes reloaded");
- goaway($a->get_baseurl().'/admin/themes');
+ goaway(App::get_baseurl().'/admin/themes');
}
/*
@@ -1830,7 +1830,7 @@ function admin_page_themes(&$a){
'$page' => t('Themes'),
'$submit' => t('Save Settings'),
'$reload' => t('Reload active themes'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$function' => 'themes',
'$plugins' => $xthemes,
'$pcount' => count($themes),
@@ -1904,7 +1904,7 @@ function admin_page_logs(&$a){
'$page' => t('Logs'),
'$submit' => t('Save Settings'),
'$clear' => t('Clear'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$logname' => get_config('system','logfile'),
// name, label, value, help string, extra data...
diff --git a/mod/allfriends.php b/mod/allfriends.php
index 240aa524b..1f2c043ce 100644
--- a/mod/allfriends.php
+++ b/mod/allfriends.php
@@ -60,7 +60,7 @@ function allfriends_content(&$a) {
$photo_menu = contact_photo_menu ($rr);
}
else {
- $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url'];
+ $connlnk = App::get_baseurl() . '/follow/?url=' . $rr['url'];
$photo_menu = array(
'profile' => array(t("View Profile"), zrl($rr['url'])),
'follow' => array(t("Connect/Follow"), $connlnk)
diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php
index be8645c1f..cb8320013 100644
--- a/mod/bookmarklet.php
+++ b/mod/bookmarklet.php
@@ -15,7 +15,7 @@ function bookmarklet_content(&$a) {
}
$referer = normalise_link($_SERVER["HTTP_REFERER"]);
- $page = normalise_link($a->get_baseurl()."/bookmarklet");
+ $page = normalise_link(App::get_baseurl()."/bookmarklet");
if (!strstr($referer, $page)) {
$content = add_page_info($_REQUEST["url"]);
diff --git a/mod/cal.php b/mod/cal.php
index ba4339328..1899a9899 100644
--- a/mod/cal.php
+++ b/mod/cal.php
@@ -80,7 +80,7 @@ function cal_content(&$a) {
$htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$module_url' => '/cal/' . $a->data['user']['nickname'],
'$modparams' => 2,
'$i18n' => $i18n,
@@ -89,7 +89,7 @@ function cal_content(&$a) {
$etpl = get_markup_template('event_end.tpl');
$a->page['end'] .= replace_macros($etpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$editselect' => $editselect
));
@@ -232,7 +232,7 @@ function cal_content(&$a) {
foreach($r as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
if(! x($links,$j))
- $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+ $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
}
}
@@ -270,12 +270,12 @@ function cal_content(&$a) {
}
$o = replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$tabs' => $tabs,
'$title' => t('Events'),
'$view' => t('View'),
- '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
- '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
+ '$previus' => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
+ '$next' => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
'$calendar' => cal($y,$m,$links, ' eventcal'),
'$events' => $events,
diff --git a/mod/contacts.php b/mod/contacts.php
index 735ccec72..37cc09cab 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -78,13 +78,13 @@ function contacts_init(&$a) {
$base = z_root();
$tpl = get_markup_template("contacts-head.tpl");
$a->page['htmlhead'] .= replace_macros($tpl,array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$base' => $base
));
$tpl = get_markup_template("contacts-end.tpl");
$a->page['end'] .= replace_macros($tpl,array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$base' => $base
));
@@ -480,11 +480,11 @@ function contacts_content(&$a) {
$editselect = 'exact';
$a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => $editselect,
));
$a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => $editselect,
));
@@ -564,7 +564,7 @@ function contacts_content(&$a) {
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND
($contact['rel'] == CONTACT_IS_FOLLOWER))
- $follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
+ $follow = App::get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
// Load contactact related actions like hide, suggest, delete and others
$contact_actions = contact_actions($contact);
diff --git a/mod/content.php b/mod/content.php
index 1e2307f55..bc98f7e51 100644
--- a/mod/content.php
+++ b/mod/content.php
@@ -117,7 +117,7 @@ function content_content(&$a, $update = 0) {
if($update)
killme();
notice( t('No such group') . EOL );
- goaway($a->get_baseurl(true) . '/network');
+ goaway(App::get_baseurl(true) . '/network');
// NOTREACHED
}
@@ -509,8 +509,8 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
'like' => '',
'dislike' => '',
'comment' => '',
- //'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
- 'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state).'/display/'.$item['guid'], 'title'=> t('View in context'))),
+ //'conv' => (($preview) ? '' : array('href'=> App::get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
+ 'conv' => (($preview) ? '' : array('href'=> App::get_baseurl($ssl_state).'/display/'.$item['guid'], 'title'=> t('View in context'))),
'previewing' => $previewing,
'wait' => t('Please wait'),
);
@@ -743,7 +743,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
}
if(local_user() && link_compare($a->contact['url'],$item['author-link']))
- $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
+ $edpost = array(App::get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
else
$edpost = false;
diff --git a/mod/delegate.php b/mod/delegate.php
index 71628aed0..343e1e303 100644
--- a/mod/delegate.php
+++ b/mod/delegate.php
@@ -18,7 +18,7 @@ function delegate_content(&$a) {
// delegated admins can view but not change delegation permissions
if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
- goaway($a->get_baseurl() . '/delegate');
+ goaway(App::get_baseurl() . '/delegate');
$id = $a->argv[2];
@@ -29,7 +29,7 @@ function delegate_content(&$a) {
if (dbm::is_result($r)) {
$r = q("select id from contact where uid = %d and nurl = '%s' limit 1",
intval(local_user()),
- dbesc(normalise_link($a->get_baseurl() . '/profile/' . $r[0]['nickname']))
+ dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname']))
);
if (dbm::is_result($r)) {
q("insert into manage ( uid, mid ) values ( %d , %d ) ",
@@ -38,7 +38,7 @@ function delegate_content(&$a) {
);
}
}
- goaway($a->get_baseurl() . '/delegate');
+ goaway(App::get_baseurl() . '/delegate');
}
if($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
@@ -46,13 +46,13 @@ function delegate_content(&$a) {
// delegated admins can view but not change delegation permissions
if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
- goaway($a->get_baseurl() . '/delegate');
+ goaway(App::get_baseurl() . '/delegate');
q("delete from manage where uid = %d and mid = %d limit 1",
intval($a->argv[2]),
intval(local_user())
);
- goaway($a->get_baseurl() . '/delegate');
+ goaway(App::get_baseurl() . '/delegate');
}
@@ -92,7 +92,7 @@ function delegate_content(&$a) {
$r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s'
and contact.uid = %d and contact.self = 0 and network = '%s' ",
- dbesc(normalise_link($a->get_baseurl())),
+ dbesc(normalise_link(App::get_baseurl())),
intval(local_user()),
dbesc(NETWORK_DFRN)
);
@@ -128,7 +128,7 @@ function delegate_content(&$a) {
$o = replace_macros(get_markup_template('delegate.tpl'),array(
'$header' => t('Delegate Page Management'),
- '$base' => $a->get_baseurl(),
+ '$base' => App::get_baseurl(),
'$desc' => t('Delegates are able to manage all aspects of this account/page except for basic account settings. Please do not delegate your personal account to anybody that you do not trust completely.'),
'$head_managers' => t('Existing Page Managers'),
'$managers' => $full_managers,
diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php
index df663f7cd..7097b0117 100644
--- a/mod/dfrn_confirm.php
+++ b/mod/dfrn_confirm.php
@@ -194,7 +194,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$params['public_key'] = $public_key;
- $my_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
+ $my_url = App::get_baseurl() . '/profile/' . $user[0]['nickname'];
openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
$params['source_url'] = bin2hex($params['source_url']);
@@ -504,7 +504,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
// do anything special with this new friend.
if($handsfree === null)
- goaway($a->get_baseurl() . '/contacts/' . intval($contact_id));
+ goaway(App::get_baseurl() . '/contacts/' . intval($contact_id));
else
return;
//NOTREACHED
@@ -664,7 +664,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
if (dbm::is_result($r))
$photo = $r[0]['photo'];
else
- $photo = $a->get_baseurl() . '/images/person-175.jpg';
+ $photo = App::get_baseurl() . '/images/person-175.jpg';
require_once("include/Photo.php");
@@ -726,7 +726,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
'to_name' => $r[0]['username'],
'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'],
- 'link' => $a->get_baseurl() . '/contacts/' . $dfrn_record,
+ 'link' => App::get_baseurl() . '/contacts/' . $dfrn_record,
'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
'source_link' => $r[0]['url'],
'source_photo' => $r[0]['photo'],
diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php
index 91cd33f49..7c3fced12 100644
--- a/mod/dfrn_poll.php
+++ b/mod/dfrn_poll.php
@@ -112,7 +112,7 @@ function dfrn_poll_init(&$a) {
}
}
$profile = $r[0]['nickname'];
- goaway((strlen($destination_url)) ? $destination_url : $a->get_baseurl() . '/profile/' . $profile);
+ goaway((strlen($destination_url)) ? $destination_url : App::get_baseurl() . '/profile/' . $profile);
}
goaway(z_root());
@@ -499,14 +499,14 @@ function dfrn_poll_content(&$a) {
switch($destination_url) {
case 'profile':
- $dest = $a->get_baseurl() . '/profile/' . $profile . '?f=&tab=profile';
+ $dest = App::get_baseurl() . '/profile/' . $profile . '?f=&tab=profile';
break;
case 'photos':
- $dest = $a->get_baseurl() . '/photos/' . $profile;
+ $dest = App::get_baseurl() . '/photos/' . $profile;
break;
case 'status':
case '':
- $dest = $a->get_baseurl() . '/profile/' . $profile;
+ $dest = App::get_baseurl() . '/profile/' . $profile;
break;
default:
$dest = $destination_url . '?f=&redir=1';
diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
index 236970a2e..24a1dc072 100644
--- a/mod/dfrn_request.php
+++ b/mod/dfrn_request.php
@@ -193,9 +193,9 @@ function dfrn_request_post(&$a) {
if (isset($photo))
update_contact_avatar($photo, local_user(), $r[0]["id"], true);
- $forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id'];
+ $forwardurl = App::get_baseurl()."/contacts/".$r[0]['id'];
} else
- $forwardurl = $a->get_baseurl()."/contacts";
+ $forwardurl = App::get_baseurl()."/contacts";
/*
* Allow the blocked remote notification to complete
@@ -501,13 +501,13 @@ function dfrn_request_post(&$a) {
else {
if(! validate_url($url)) {
notice( t('Invalid profile URL.') . EOL);
- goaway($a->get_baseurl() . '/' . $a->cmd);
+ goaway(App::get_baseurl() . '/' . $a->cmd);
return; // NOTREACHED
}
if(! allowed_url($url)) {
notice( t('Disallowed profile URL.') . EOL);
- goaway($a->get_baseurl() . '/' . $a->cmd);
+ goaway(App::get_baseurl() . '/' . $a->cmd);
return; // NOTREACHED
}
@@ -518,7 +518,7 @@ function dfrn_request_post(&$a) {
if(! count($parms)) {
notice( t('Profile location is not valid or does not contain profile information.') . EOL );
- goaway($a->get_baseurl() . '/' . $a->cmd);
+ goaway(App::get_baseurl() . '/' . $a->cmd);
}
else {
if(! x($parms,'fn'))
@@ -605,7 +605,7 @@ function dfrn_request_post(&$a) {
// "Homecoming" - send the requestor back to their site to record the introduction.
- $dfrn_url = bin2hex($a->get_baseurl() . '/profile/' . $nickname);
+ $dfrn_url = bin2hex(App::get_baseurl() . '/profile/' . $nickname);
$aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
@@ -634,7 +634,7 @@ function dfrn_request_post(&$a) {
$uri = urlencode($uri);
} else
- $uri = $a->get_baseurl().'/profile/'.$nickname;
+ $uri = App::get_baseurl().'/profile/'.$nickname;
$url = str_replace('{uri}', $uri, $url);
goaway($url);
@@ -742,7 +742,7 @@ function dfrn_request_content(&$a) {
'to_name' => $r[0]['username'],
'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'],
- 'link' => $a->get_baseurl() . '/notifications/intros',
+ 'link' => App::get_baseurl() . '/notifications/intros',
'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
'source_link' => $r[0]['url'],
'source_photo' => $r[0]['photo'],
@@ -806,7 +806,7 @@ function dfrn_request_content(&$a) {
$myaddr = $_GET['address'];
elseif(local_user()) {
if(strlen($a->path)) {
- $myaddr = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
+ $myaddr = App::get_baseurl() . '/profile/' . $a->user['nickname'];
}
else {
$myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
diff --git a/mod/dirfind.php b/mod/dirfind.php
index 215731978..1e3f6f354 100644
--- a/mod/dirfind.php
+++ b/mod/dirfind.php
@@ -197,7 +197,7 @@ function dirfind_content(&$a, $prefix = "") {
} else
$photo_menu = array();
} else {
- $connlnk = $a->get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
+ $connlnk = App::get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
$conntxt = t('Connect');
$photo_menu = array(
'profile' => array(t("View Profile"), zrl($jj->url)),
diff --git a/mod/display.php b/mod/display.php
index 293156cf1..6ebe16ae8 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -81,8 +81,8 @@ function display_init(&$a) {
$profiledata = display_fetchauthor($a, $r[0]);
- if (strstr(normalise_link($profiledata["url"]), normalise_link($a->get_baseurl()))) {
- $nickname = str_replace(normalise_link($a->get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
+ if (strstr(normalise_link($profiledata["url"]), normalise_link(App::get_baseurl()))) {
+ $nickname = str_replace(normalise_link(App::get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
if (($nickname != $a->user["nickname"])) {
$r = qu("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
@@ -184,7 +184,7 @@ function display_fetchauthor($a, $item) {
if (local_user()) {
if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
- $profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
+ $profiledata["remoteconnect"] = App::get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
}
} elseif ($profiledata["network"] == NETWORK_DFRN) {
$connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
diff --git a/mod/editpost.php b/mod/editpost.php
index 217d793f5..eccd498d1 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -42,7 +42,7 @@ function editpost_content(&$a) {
$tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$ispublic' => ' ', // t('Visible to everybody '),
'$geotag' => $geotag,
@@ -51,7 +51,7 @@ function editpost_content(&$a) {
$tpl = get_markup_template('jot-end.tpl');
$a->page['end'] .= replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$ispublic' => ' ', // t('Visible to everybody '),
'$geotag' => $geotag,
@@ -126,7 +126,7 @@ function editpost_content(&$a) {
'$ptyp' => $itm[0]['type'],
'$content' => undo_post_tagging($itm[0]['body']),
'$post_id' => $post_id,
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$defloc' => $a->user['default-location'],
'$visitor' => 'none',
'$pvisit' => 'none',
diff --git a/mod/events.php b/mod/events.php
index 7cb171f9e..9dbf7efb5 100644
--- a/mod/events.php
+++ b/mod/events.php
@@ -89,7 +89,7 @@ function events_post(&$a) {
$type = 'event';
$action = ($event_id == '') ? 'new' : "event/" . $event_id;
- $onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
+ $onerror_url = App::get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
if(strcmp($finish,$start) < 0 && !$nofinish) {
notice( t('Event can not end before it has started.') . EOL);
@@ -192,7 +192,7 @@ function events_content(&$a) {
}
if($a->argc == 1)
- $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
+ $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
$r = q("update event set ignore = 1 where id = %d and uid = %d",
@@ -222,7 +222,7 @@ function events_content(&$a) {
$htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$module_url' => '/events',
'$modparams' => 1,
'$i18n' => $i18n,
@@ -231,7 +231,7 @@ function events_content(&$a) {
$etpl = get_markup_template('event_end.tpl');
$a->page['end'] .= replace_macros($etpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$editselect' => $editselect
));
@@ -337,7 +337,7 @@ function events_content(&$a) {
foreach($r as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
if(! x($links,$j))
- $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+ $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
}
}
@@ -375,13 +375,13 @@ function events_content(&$a) {
}
$o = replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$tabs' => $tabs,
'$title' => t('Events'),
'$view' => t('View'),
- '$new_event' => array($a->get_baseurl().'/events/new',t('Create New Event'),'',''),
- '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
- '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
+ '$new_event' => array(App::get_baseurl().'/events/new',t('Create New Event'),'',''),
+ '$previus' => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
+ '$next' => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
'$calendar' => cal($y,$m,$links, ' eventcal'),
'$events' => $events,
@@ -475,7 +475,7 @@ function events_content(&$a) {
$tpl = get_markup_template('event_form.tpl');
$o .= replace_macros($tpl,array(
- '$post' => $a->get_baseurl() . '/events',
+ '$post' => App::get_baseurl() . '/events',
'$eid' => $eid,
'$cid' => $cid,
'$uri' => $uri,
diff --git a/mod/fbrowser.php b/mod/fbrowser.php
index 11ac2d825..6af97368f 100644
--- a/mod/fbrowser.php
+++ b/mod/fbrowser.php
@@ -10,6 +10,7 @@ require_once('include/Photo.php');
/**
* @param App $a
*/
+/// @TODO & is missing or App ?
function fbrowser_content($a){
if (!local_user())
@@ -83,9 +84,9 @@ function fbrowser_content($a){
$scale = $rr['loq'];
return array(
- $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
+ App::get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
$filename_e,
- $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
+ App::get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
);
}
$files = array_map("_map_files1", $r);
@@ -94,7 +95,7 @@ function fbrowser_content($a){
$o = replace_macros($tpl, array(
'$type' => 'image',
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$path' => $path,
'$folders' => $albums,
'$files' =>$files,
@@ -122,7 +123,7 @@ function fbrowser_content($a){
$filename_e = $rr['filename'];
}
- return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
+ return array( App::get_baseurl() . '/attach/' . $rr['id'], $filename_e, App::get_baseurl() . '/images/icons/16/' . $filetype . '.png');
}
$files = array_map("_map_files2", $files);
@@ -130,7 +131,7 @@ function fbrowser_content($a){
$tpl = get_markup_template($template_file);
$o = replace_macros($tpl, array(
'$type' => 'file',
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$path' => array( array( "", t("Files")) ),
'$folders' => false,
'$files' =>$files,
diff --git a/mod/friendica.php b/mod/friendica.php
index fb25f40e4..5d8e43e6c 100644
--- a/mod/friendica.php
+++ b/mod/friendica.php
@@ -15,7 +15,7 @@ function friendica_init(&$a) {
$r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($adminlist[0]));
$admin = array(
'name' => $r[0]['username'],
- 'profile'=> $a->get_baseurl().'/profile/'.$r[0]['nickname'],
+ 'profile'=> App::get_baseurl().'/profile/'.$r[0]['nickname'],
);
} else {
$admin = false;
@@ -49,7 +49,7 @@ function friendica_init(&$a) {
'site_name' => $a->config['sitename'],
'platform' => FRIENDICA_PLATFORM,
'info' => ((x($a->config,'info')) ? $a->config['info'] : ''),
- 'no_scrape_url' => $a->get_baseurl().'/noscrape'
+ 'no_scrape_url' => App::get_baseurl().'/noscrape'
);
echo json_encode($data);
diff --git a/mod/group.php b/mod/group.php
index db92ed7de..33b819ed5 100644
--- a/mod/group.php
+++ b/mod/group.php
@@ -29,11 +29,11 @@ function group_post(&$a) {
info( t('Group created.') . EOL );
$r = group_byname(local_user(),$name);
if($r)
- goaway($a->get_baseurl() . '/group/' . $r);
+ goaway(App::get_baseurl() . '/group/' . $r);
}
else
notice( t('Could not create group.') . EOL );
- goaway($a->get_baseurl() . '/group');
+ goaway(App::get_baseurl() . '/group');
return; // NOTREACHED
}
if(($a->argc == 2) && (intval($a->argv[1]))) {
@@ -45,7 +45,7 @@ function group_post(&$a) {
);
if(! dbm::is_result($r)) {
notice( t('Group not found.') . EOL );
- goaway($a->get_baseurl() . '/contacts');
+ goaway(App::get_baseurl() . '/contacts');
return; // NOTREACHED
}
$group = $r[0];
@@ -114,7 +114,7 @@ function group_content(&$a) {
else
notice( t('Unable to remove group.') . EOL);
}
- goaway($a->get_baseurl() . '/group');
+ goaway(App::get_baseurl() . '/group');
// NOTREACHED
}
@@ -138,7 +138,7 @@ function group_content(&$a) {
);
if(! dbm::is_result($r)) {
notice( t('Group not found.') . EOL );
- goaway($a->get_baseurl() . '/contacts');
+ goaway(App::get_baseurl() . '/contacts');
}
$group = $r[0];
$members = group_get_members($group['id']);
diff --git a/mod/hcard.php b/mod/hcard.php
index 6d2d9e2eb..1231d71e6 100644
--- a/mod/hcard.php
+++ b/mod/hcard.php
@@ -38,14 +38,14 @@ function hcard_init(&$a) {
}
$a->page['htmlhead'] .= ' ' . "\r\n" ;
- $a->page['htmlhead'] .= ' ' . "\r\n" ;
+ $a->page['htmlhead'] .= ' ' . "\r\n" ;
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
- $a->page['htmlhead'] .= ' ' . "\r\n";
- header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
+ $a->page['htmlhead'] .= ' ' . "\r\n";
+ header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
foreach($dfrn_pages as $dfrn)
- $a->page['htmlhead'] .= " get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
+ $a->page['htmlhead'] .= " \r\n";
}
diff --git a/mod/home.php b/mod/home.php
index cdf4b3715..62ee9868f 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -7,11 +7,11 @@ function home_init(&$a) {
call_hooks('home_init',$ret);
if(local_user() && ($a->user['nickname']))
- goaway($a->get_baseurl()."/network");
- //goaway($a->get_baseurl()."/profile/".$a->user['nickname']);
+ goaway(App::get_baseurl()."/network");
+ //goaway(App::get_baseurl()."/profile/".$a->user['nickname']);
if(strlen(get_config('system','singleuser')))
- goaway($a->get_baseurl()."/profile/" . get_config('system','singleuser'));
+ goaway(App::get_baseurl()."/profile/" . get_config('system','singleuser'));
}}
@@ -28,7 +28,7 @@ function home_content(&$a) {
if(file_exists('home.html')){
if(file_exists('home.css')){
- $a->page['htmlhead'] .= ' ';}
+ $a->page['htmlhead'] .= ' ';}
$o .= file_get_contents('home.html');}
diff --git a/mod/ignored.php b/mod/ignored.php
index ba55c55e3..eec204c70 100644
--- a/mod/ignored.php
+++ b/mod/ignored.php
@@ -35,7 +35,7 @@ function ignored_init(&$a) {
if(strpos($return_path, '?')) $rand = "&$rand";
else $rand = "?$rand";
- goaway($a->get_baseurl() . "/" . $return_path . $rand);
+ goaway(App::get_baseurl() . "/" . $return_path . $rand);
}
// the json doesn't really matter, it will either be 0 or 1
diff --git a/mod/install.php b/mod/install.php
index b5af1373a..c5baa17db 100755
--- a/mod/install.php
+++ b/mod/install.php
@@ -15,7 +15,7 @@ function install_init(&$a){
// We overwrite current theme css, because during install we could not have a working mod_rewrite
// so we could not have a css at all. Here we set a static css file for the install procedure pages
$a->config['system']['theme'] = "../install";
- $a->theme['stylesheet'] = $a->get_baseurl()."/view/install/style.css";
+ $a->theme['stylesheet'] = App::get_baseurl()."/view/install/style.css";
@@ -231,7 +231,7 @@ function install_content(&$a) {
'$next' => t('Next'),
'$reload' => t('Check again'),
'$phpath' => $phpath,
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
));
return $o;
}; break;
@@ -265,7 +265,7 @@ function install_content(&$a) {
'$lbl_10' => t('Please select a default timezone for your website'),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$phpath' => $phpath,
@@ -305,7 +305,7 @@ function install_content(&$a) {
'$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''),
'$language' => array('language', t('System Language:'), 'en', t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
@@ -518,14 +518,13 @@ function check_smarty3(&$checks) {
}
function check_htaccess(&$checks) {
- $a = get_app();
$status = true;
$help = "";
if (function_exists('curl_init')){
- $test = fetch_url($a->get_baseurl()."/install/testrewrite");
+ $test = fetch_url(App::get_baseurl()."/install/testrewrite");
if ($test!="ok")
- $test = fetch_url(normalise_link($a->get_baseurl()."/install/testrewrite"));
+ $test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite"));
if ($test!="ok") {
$status = false;
@@ -599,8 +598,7 @@ function load_database($db) {
}
function what_next() {
- $a = get_app();
- $baseurl = $a->get_baseurl();
+ $baseurl = App::get_baseurl();
return
t('What next ')
."".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.')
diff --git a/mod/invite.php b/mod/invite.php
index ccf876c7c..5964acac4 100644
--- a/mod/invite.php
+++ b/mod/invite.php
@@ -119,7 +119,7 @@ function invite_content(&$a) {
if($a->config['register_policy'] == REGISTER_CLOSED)
$linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo');
elseif($a->config['register_policy'] != REGISTER_CLOSED)
- $linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), $a->get_baseurl())
+ $linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), App::get_baseurl())
. "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo');
}
else {
@@ -135,7 +135,7 @@ function invite_content(&$a) {
'$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
. $linktxt
. "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:')
- . "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname']
+ . "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname']
. "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n" ,
'$submit' => t('Submit')
));
diff --git a/mod/item.php b/mod/item.php
index 9ef82616c..c741f1614 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -62,7 +62,7 @@ function item_post(&$a) {
if(!$preview && x($_REQUEST['post_id_random'])) {
if(x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
logger("item post: duplicate post", LOGGER_DEBUG);
- item_post_return($a->get_baseurl(), $api_source, $return_path);
+ item_post_return(App::get_baseurl(), $api_source, $return_path);
}
else
$_SESSION['post-random'] = $_REQUEST['post_id_random'];
@@ -449,7 +449,7 @@ function item_post(&$a) {
$objecttype = ACTIVITY_OBJ_IMAGE;
foreach($images as $image) {
- if(! stristr($image,$a->get_baseurl() . '/photo/'))
+ if(! stristr($image,App::get_baseurl() . '/photo/'))
continue;
$image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
@@ -640,7 +640,7 @@ function item_post(&$a) {
if (dbm::is_result($r)) {
if(strlen($attachments))
$attachments .= ',';
- $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
+ $attachments .= '[attach]href="' . App::get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
}
$body = str_replace($match[1],'',$body);
}
@@ -732,7 +732,7 @@ function item_post(&$a) {
// $datarray['prvnets'] = $user['prvnets'];
$datarray['parent-uri'] = ($parent == 0) ? $uri : $parent_item['uri'];
- $datarray['plink'] = $a->get_baseurl().'/display/'.urlencode($datarray['guid']);
+ $datarray['plink'] = App::get_baseurl().'/display/'.urlencode($datarray['guid']);
$datarray['last-child'] = 1;
$datarray['visible'] = 1;
@@ -766,7 +766,7 @@ function item_post(&$a) {
$json = array('cancel' => 1);
if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
- $json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
+ $json['reload'] = App::get_baseurl() . '/' . $_REQUEST['jsreload'];
echo json_encode($json);
killme();
@@ -938,7 +938,7 @@ function item_post(&$a) {
'to_email' => $user['email'],
'uid' => $user['uid'],
'item' => $datarray,
- 'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']),
+ 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
@@ -970,7 +970,7 @@ function item_post(&$a) {
'to_email' => $user['email'],
'uid' => $user['uid'],
'item' => $datarray,
- 'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']),
+ 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
@@ -991,14 +991,14 @@ function item_post(&$a) {
continue;
$disclaimer = '
' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
. ' ';
- $disclaimer .= sprintf( t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
+ $disclaimer .= sprintf( t('You may visit them online at %s'), App::get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
$disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
if (!$datarray['title']=='') {
$subject = email_header_encode($datarray['title'],'UTF-8');
} else {
$subject = email_header_encode('[Friendica]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']),'UTF-8');
}
- $link = ' ';
+ $link = ' ';
$html = prepare_body($datarray);
$message = '' . $link . $html . $disclaimer . '';
include_once('include/html2plain.php');
@@ -1038,7 +1038,7 @@ function item_post(&$a) {
logger('post_complete');
- item_post_return($a->get_baseurl(), $api_source, $return_path);
+ item_post_return(App::get_baseurl(), $api_source, $return_path);
// NOTREACHED
}
diff --git a/mod/like.php b/mod/like.php
index 8d383b9ab..cbab9185e 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -24,7 +24,7 @@ function like_content(&$a) {
// See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
- like_content_return($a->get_baseurl(), $return_path);
+ like_content_return(App::get_baseurl(), $return_path);
killme(); // NOTREACHED
// return; // NOTREACHED
}
diff --git a/mod/localtime.php b/mod/localtime.php
index d1453bc52..ce6bf84a1 100644
--- a/mod/localtime.php
+++ b/mod/localtime.php
@@ -36,7 +36,7 @@ function localtime_content(&$a) {
$o .= '' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '
';
- $o .= '';
return $o;
-
+
}
diff --git a/mod/xrd.php b/mod/xrd.php
index 290c524a7..e4641f5a3 100644
--- a/mod/xrd.php
+++ b/mod/xrd.php
@@ -41,13 +41,15 @@ function xrd_init(&$a) {
$profile_url = App::get_baseurl().'/profile/'.$r[0]['nickname'];
- if ($acct)
+ if ($acct) {
$alias = $profile_url;
+ }
else {
$alias = 'acct:'.$r[0]['nickname'].'@'.$a->get_hostname();
- if ($a->get_path())
+ if ($a->get_path()) {
$alias .= '/'.$a->get_path();
+ }
}
$o = replace_macros($tpl, array(
@@ -65,7 +67,7 @@ function xrd_init(&$a) {
'$salmen' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention',
'$subscribe' => App::get_baseurl() . '/follow?url={uri}',
'$modexp' => 'data:application/magic-public-key,' . $salmon_key,
- '$bigkey' => salmon_key($r[0]['pubkey'])
+ '$bigkey' => salmon_key($r[0]['pubkey']),
));
From 3befdc6920727cf8cdca4044e2333819de81a549 Mon Sep 17 00:00:00 2001
From: Roland Haeder
Date: Tue, 20 Dec 2016 21:51:25 +0100
Subject: [PATCH 53/68] used more App::get_baseurl() instead of
get_app()->get_baseurl().
Signed-off-by: Roland Haeder
---
include/poller.php | 2 +-
mod/proxy.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/poller.php b/include/poller.php
index 44f4895cd..a6671f5ae 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -484,7 +484,7 @@ function call_worker() {
return;
}
- $url = get_app()->get_baseurl()."/worker";
+ $url = App::get_baseurl()."/worker";
fetch_url($url, false, $redirects, 1);
}
diff --git a/mod/proxy.php b/mod/proxy.php
index ff58bba7f..45c9e9456 100644
--- a/mod/proxy.php
+++ b/mod/proxy.php
@@ -326,7 +326,7 @@ function proxy_is_local_image($url) {
if (strtolower(substr($url, 0, 5)) == "data:") return true;
// links normalised - bug #431
- $baseurl = normalise_link(get_app()->get_baseurl());
+ $baseurl = normalise_link(App::get_baseurl());
$url = normalise_link($url);
return (substr($url, 0, strlen($baseurl)) == $baseurl);
}
From c0ec9c59077cdc3c7c98a2882fe5007ecc04438f Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
Date: Mon, 19 Dec 2016 20:19:26 -0500
Subject: [PATCH 54/68] proxy_url: Fix extension extraction for URLs containing
a . after a ?
---
mod/proxy.php | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/mod/proxy.php b/mod/proxy.php
index 45c9e9456..af0f91261 100644
--- a/mod/proxy.php
+++ b/mod/proxy.php
@@ -281,14 +281,14 @@ function proxy_url($url, $writemode = false, $size = '') {
$longpath .= '/' . strtr(base64_encode($url), '+/', '-_');
- // Checking for valid extensions. Only add them if they are safe
- $pos = strrpos($url, '.');
- if ($pos) {
- $extension = strtolower(substr($url, $pos + 1));
- $pos = strpos($extension, '?');
- if ($pos) {
- $extension = substr($extension, 0, $pos);
- }
+ // Extract the URL extension, disregarding GET parameters starting with ?
+ $question_mark_pos = strpos($url, '?');
+ if ($question_mark_pos === false) {
+ $question_mark_pos = strlen($url);
+ }
+ $dot_pos = strrpos($url, '.', $question_mark_pos - strlen($url));
+ if ($dot_pos !== false) {
+ $extension = strtolower(substr($url, $dot_pos + 1, $question_mark_pos - ($dot_pos + 1)));
}
$extensions = array('jpg', 'jpeg', 'gif', 'png');
From 1f94cb9aac1d329dcb49245493ec42a197b8f17a Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
Date: Tue, 20 Dec 2016 15:14:43 -0500
Subject: [PATCH 55/68] proxy: Simplify url extension extraction
---
mod/proxy.php | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/mod/proxy.php b/mod/proxy.php
index af0f91261..4f3c994d7 100644
--- a/mod/proxy.php
+++ b/mod/proxy.php
@@ -281,15 +281,8 @@ function proxy_url($url, $writemode = false, $size = '') {
$longpath .= '/' . strtr(base64_encode($url), '+/', '-_');
- // Extract the URL extension, disregarding GET parameters starting with ?
- $question_mark_pos = strpos($url, '?');
- if ($question_mark_pos === false) {
- $question_mark_pos = strlen($url);
- }
- $dot_pos = strrpos($url, '.', $question_mark_pos - strlen($url));
- if ($dot_pos !== false) {
- $extension = strtolower(substr($url, $dot_pos + 1, $question_mark_pos - ($dot_pos + 1)));
- }
+ // Extract the URL extension
+ $extension = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION);
$extensions = array('jpg', 'jpeg', 'gif', 'png');
if (in_array($extension, $extensions)) {
From 47f88bd625b85690414f1465cf8082e1ec83ef31 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
Date: Tue, 20 Dec 2016 15:23:08 -0500
Subject: [PATCH 56/68] proxy mod: Standards bearer
- Enforced PSR-2 standards
- Normalized concatenation formatting
- Normalized string delimiters
- Normalized condition operators
- Collapsed directly nested conditions
- Used dvm::is_result
- Added comments
---
mod/proxy.php | 289 +++++++++++++++++++++++++++-----------------------
1 file changed, 154 insertions(+), 135 deletions(-)
diff --git a/mod/proxy.php b/mod/proxy.php
index 4f3c994d7..3fdb250b5 100644
--- a/mod/proxy.php
+++ b/mod/proxy.php
@@ -1,20 +1,18 @@
-define("PROXY_DEFAULT_TIME", 86400); // 1 Day
+define('PROXY_DEFAULT_TIME', 86400); // 1 Day
-define("PROXY_SIZE_MICRO", "micro");
-define("PROXY_SIZE_THUMB", "thumb");
-define("PROXY_SIZE_SMALL", "small");
-define("PROXY_SIZE_MEDIUM", "medium");
-define("PROXY_SIZE_LARGE", "large");
+define('PROXY_SIZE_MICRO', 'micro');
+define('PROXY_SIZE_THUMB', 'thumb');
+define('PROXY_SIZE_SMALL', 'small');
+define('PROXY_SIZE_MEDIUM', 'medium');
+define('PROXY_SIZE_LARGE', 'large');
-require_once('include/security.php');
-require_once("include/Photo.php");
-
-function proxy_init() {
- global $a, $_SERVER;
+require_once 'include/security.php';
+require_once 'include/Photo.php';
+function proxy_init(App $a) {
// Pictures are stored in one of the following ways:
// 1. If a folder "proxy" exists and is writeable, then use this for caching
// 2. If a cache path is defined, use this
@@ -24,11 +22,12 @@ function proxy_init() {
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
header('HTTP/1.1 304 Not Modified');
- header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
- header('Etag: '.$_SERVER['HTTP_IF_NONE_MATCH']);
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
- header("Cache-Control: max-age=31536000");
- if(function_exists('header_remove')) {
+ header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
+ header('Etag: ' . $_SERVER['HTTP_IF_NONE_MATCH']);
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (31536000)) . ' GMT');
+ header('Cache-Control: max-age=31536000');
+
+ if (function_exists('header_remove')) {
header_remove('Last-Modified');
header_remove('Expires');
header_remove('Cache-Control');
@@ -36,140 +35,155 @@ function proxy_init() {
exit;
}
- if(function_exists('header_remove')) {
+ if (function_exists('header_remove')) {
header_remove('Pragma');
header_remove('pragma');
}
$thumb = false;
$size = 1024;
- $sizetype = "";
+ $sizetype = '';
$basepath = $a->get_basepath();
// If the cache path isn't there, try to create it
- if (!is_dir($basepath."/proxy"))
- if (is_writable($basepath))
- mkdir($basepath."/proxy");
+ if (!is_dir($basepath . '/proxy') AND is_writable($basepath)) {
+ mkdir($basepath . '/proxy');
+ }
// Checking if caching into a folder in the webroot is activated and working
- $direct_cache = (is_dir($basepath."/proxy") AND is_writable($basepath."/proxy"));
+ $direct_cache = (is_dir($basepath . '/proxy') AND is_writable($basepath . '/proxy'));
// Look for filename in the arguments
- if ((isset($a->argv[1]) OR isset($a->argv[2]) OR isset($a->argv[3])) AND !isset($_REQUEST["url"])) {
- if (isset($a->argv[3]))
+ if ((isset($a->argv[1]) OR isset($a->argv[2]) OR isset($a->argv[3])) AND !isset($_REQUEST['url'])) {
+ if (isset($a->argv[3])) {
$url = $a->argv[3];
- elseif (isset($a->argv[2]))
+ } elseif (isset($a->argv[2])) {
$url = $a->argv[2];
- else
+ } else {
$url = $a->argv[1];
-
- if (isset($a->argv[3]) and ($a->argv[3] == "thumb"))
- $size = 200;
-
- // thumb, small, medium and large.
- if (substr($url, -6) == ":micro") {
- $size = 48;
- $sizetype = ":micro";
- $url = substr($url, 0, -6);
- } elseif (substr($url, -6) == ":thumb") {
- $size = 80;
- $sizetype = ":thumb";
- $url = substr($url, 0, -6);
- } elseif (substr($url, -6) == ":small") {
- $size = 175;
- $url = substr($url, 0, -6);
- $sizetype = ":small";
- } elseif (substr($url, -7) == ":medium") {
- $size = 600;
- $url = substr($url, 0, -7);
- $sizetype = ":medium";
- } elseif (substr($url, -6) == ":large") {
- $size = 1024;
- $url = substr($url, 0, -6);
- $sizetype = ":large";
}
- $pos = strrpos($url, "=.");
- if ($pos)
- $url = substr($url, 0, $pos+1);
+ if (isset($a->argv[3]) AND ($a->argv[3] == 'thumb')) {
+ $size = 200;
+ }
- $url = str_replace(array(".jpg", ".jpeg", ".gif", ".png"), array("","","",""), $url);
+ // thumb, small, medium and large.
+ if (substr($url, -6) == ':micro') {
+ $size = 48;
+ $sizetype = ':micro';
+ $url = substr($url, 0, -6);
+ } elseif (substr($url, -6) == ':thumb') {
+ $size = 80;
+ $sizetype = ':thumb';
+ $url = substr($url, 0, -6);
+ } elseif (substr($url, -6) == ':small') {
+ $size = 175;
+ $url = substr($url, 0, -6);
+ $sizetype = ':small';
+ } elseif (substr($url, -7) == ':medium') {
+ $size = 600;
+ $url = substr($url, 0, -7);
+ $sizetype = ':medium';
+ } elseif (substr($url, -6) == ':large') {
+ $size = 1024;
+ $url = substr($url, 0, -6);
+ $sizetype = ':large';
+ }
+
+ $pos = strrpos($url, '=.');
+ if ($pos) {
+ $url = substr($url, 0, $pos + 1);
+ }
+
+ $url = str_replace(array('.jpg', '.jpeg', '.gif', '.png'), array('','','',''), $url);
$url = base64_decode(strtr($url, '-_', '+/'), true);
- if ($url)
+ if ($url) {
$_REQUEST['url'] = $url;
- } else
+ }
+ } else {
$direct_cache = false;
+ }
if (!$direct_cache) {
$urlhash = 'pic:' . sha1($_REQUEST['url']);
- $cachefile = get_cachefile(hash("md5", $_REQUEST['url']));
- if ($cachefile != '') {
- if (file_exists($cachefile)) {
- $img_str = file_get_contents($cachefile);
- $mime = image_type_to_mime_type(exif_imagetype($cachefile));
+ $cachefile = get_cachefile(hash('md5', $_REQUEST['url']));
+ if ($cachefile != '' AND file_exists($cachefile)) {
+ $img_str = file_get_contents($cachefile);
+ $mime = image_type_to_mime_type(exif_imagetype($cachefile));
- header("Content-type: $mime");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
- header('Etag: "'.md5($img_str).'"');
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
- header("Cache-Control: max-age=31536000");
+ header('Content-type: ' . $mime);
+ header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
+ header('Etag: "' . md5($img_str) . '"');
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (31536000)) . ' GMT');
+ header('Cache-Control: max-age=31536000');
- // reduce quality - if it isn't a GIF
- if ($mime != "image/gif") {
- $img = new Photo($img_str, $mime);
- if($img->is_valid()) {
- $img_str = $img->imageString();
- }
+ // reduce quality - if it isn't a GIF
+ if ($mime != 'image/gif') {
+ $img = new Photo($img_str, $mime);
+ if ($img->is_valid()) {
+ $img_str = $img->imageString();
}
-
- echo $img_str;
- killme();
}
+
+ echo $img_str;
+ killme();
}
- } else
- $cachefile = "";
+ } else {
+ $cachefile = '';
+ }
$valid = true;
- if (!$direct_cache AND ($cachefile == "")) {
+ if (!$direct_cache AND ($cachefile == '')) {
$r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
if (dbm::is_result($r)) {
+<<<<<<< origin/rewrites/app_get_baseurl_static
$img_str = $r[0]['data'];
$mime = $r[0]["desc"];
if ($mime == "") $mime = "image/jpeg";
+=======
+ $img_str = $r[0]['data'];
+ $mime = $r[0]['desc'];
+ if ($mime == '') {
+ $mime = 'image/jpeg';
+ }
+>>>>>>> HEAD~0
}
- } else
+ } else {
$r = array();
+ }
if (!dbm::is_result($r)) {
// It shouldn't happen but it does - spaces in URL
- $_REQUEST['url'] = str_replace(" ", "+", $_REQUEST['url']);
+ $_REQUEST['url'] = str_replace(' ', '+', $_REQUEST['url']);
$redirects = 0;
- $img_str = fetch_url($_REQUEST['url'],true, $redirects, 10);
+ $img_str = fetch_url($_REQUEST['url'], true, $redirects, 10);
- $tempfile = tempnam(get_temppath(), "cache");
+ $tempfile = tempnam(get_temppath(), 'cache');
file_put_contents($tempfile, $img_str);
$mime = image_type_to_mime_type(exif_imagetype($tempfile));
unlink($tempfile);
// If there is an error then return a blank image
- if ((substr($a->get_curl_code(), 0, 1) == "4") or (!$img_str)) {
- $img_str = file_get_contents("images/blank.png");
- $mime = "image/png";
- $cachefile = ""; // Clear the cachefile so that the dummy isn't stored
+ if ((substr($a->get_curl_code(), 0, 1) == '4') OR (!$img_str)) {
+ $img_str = file_get_contents('images/blank.png');
+ $mime = 'image/png';
+ $cachefile = ''; // Clear the cachefile so that the dummy isn't stored
$valid = false;
- $img = new Photo($img_str, "image/png");
- if($img->is_valid()) {
+ $img = new Photo($img_str, 'image/png');
+ if ($img->is_valid()) {
$img->scaleImage(10);
$img_str = $img->imageString();
}
- } else if (($mime != "image/jpeg") AND !$direct_cache AND ($cachefile == "")) {
+ } elseif ($mime != 'image/jpeg' AND !$direct_cache AND $cachefile == '') {
$image = @imagecreatefromstring($img_str);
- if($image === FALSE) die();
+ if ($image === FALSE) {
+ die();
+ }
q("INSERT INTO `photo`
( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `desc`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
@@ -177,7 +191,7 @@ function proxy_init() {
0, 0, get_guid(), dbesc($urlhash),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
- dbesc(basename(dbesc($_REQUEST["url"]))),
+ dbesc(basename(dbesc($_REQUEST['url']))),
dbesc(''),
intval(imagesy($image)),
intval(imagesx($image)),
@@ -190,9 +204,8 @@ function proxy_init() {
} else {
$img = new Photo($img_str, $mime);
- if($img->is_valid()) {
- if (!$direct_cache AND ($cachefile == ""))
- $img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
+ if ($img->is_valid() AND !$direct_cache AND ($cachefile == '')) {
+ $img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
}
}
}
@@ -200,9 +213,9 @@ function proxy_init() {
$img_str_orig = $img_str;
// reduce quality - if it isn't a GIF
- if ($mime != "image/gif") {
+ if ($mime != 'image/gif') {
$img = new Photo($img_str, $mime);
- if($img->is_valid()) {
+ if ($img->is_valid()) {
$img->scaleImage($size);
$img_str = $img->imageString();
}
@@ -212,20 +225,22 @@ function proxy_init() {
// advantage: real file access is really fast
// Otherwise write in cachefile
if ($valid AND $direct_cache) {
- file_put_contents($basepath."/proxy/".proxy_url($_REQUEST['url'], true), $img_str_orig);
- if ($sizetype <> '')
- file_put_contents($basepath."/proxy/".proxy_url($_REQUEST['url'], true).$sizetype, $img_str);
- } elseif ($cachefile != '')
+ file_put_contents($basepath . '/proxy/' . proxy_url($_REQUEST['url'], true), $img_str_orig);
+ if ($sizetype != '') {
+ file_put_contents($basepath . '/proxy/' . proxy_url($_REQUEST['url'], true) . $sizetype, $img_str);
+ }
+ } elseif ($cachefile != '') {
file_put_contents($cachefile, $img_str_orig);
+ }
- header("Content-type: $mime");
+ header('Content-type: ' . $mime);
// Only output the cache headers when the file is valid
if ($valid) {
- header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
- header('Etag: "'.md5($img_str).'"');
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
- header("Cache-Control: max-age=31536000");
+ header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
+ header('Etag: "' . md5($img_str) . '"');
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (31536000)) . ' GMT');
+ header('Cache-Control: max-age=31536000');
}
echo $img_str;
@@ -272,11 +287,9 @@ function proxy_url($url, $writemode = false, $size = '') {
$shortpath = hash('md5', $url);
$longpath = substr($shortpath, 0, 2);
- if (is_dir($basepath) and $writemode) {
- if (!is_dir($basepath . '/' . $longpath)) {
- mkdir($basepath . '/' . $longpath);
- chmod($basepath . '/' . $longpath, 0777);
- }
+ if (is_dir($basepath) AND $writemode AND !is_dir($basepath . '/' . $longpath)) {
+ mkdir($basepath . '/' . $longpath);
+ chmod($basepath . '/' . $longpath, 0777);
}
$longpath .= '/' . strtr(base64_encode($url), '+/', '-_');
@@ -314,9 +327,13 @@ function proxy_url($url, $writemode = false, $size = '') {
* @return boolean
*/
function proxy_is_local_image($url) {
- if ($url[0] == '/') return true;
+ if ($url[0] == '/') {
+ return true;
+ }
- if (strtolower(substr($url, 0, 5)) == "data:") return true;
+ if (strtolower(substr($url, 0, 5)) == 'data:') {
+ return true;
+ }
// links normalised - bug #431
$baseurl = normalise_link(App::get_baseurl());
@@ -324,42 +341,44 @@ function proxy_is_local_image($url) {
return (substr($url, 0, strlen($baseurl)) == $baseurl);
}
-function proxy_parse_query($var) {
- /**
- * Use this function to parse out the query array element from
- * the output of parse_url().
- */
- $var = parse_url($var, PHP_URL_QUERY);
- $var = html_entity_decode($var);
- $var = explode('&', $var);
- $arr = array();
+/**
+ * @brief Return the array of query string parameters from a URL
+ *
+ * @param string $url
+ * @return array Associative array of query string parameters
+ */
+function proxy_parse_query($url) {
+ $query = parse_url($url, PHP_URL_QUERY);
+ $query = html_entity_decode($query);
+ $query_list = explode('&', $query);
+ $arr = array();
- foreach($var as $val) {
- $x = explode('=', $val);
- $arr[$x[0]] = $x[1];
- }
+ foreach ($query_list as $key_value) {
+ $key_value_list = explode('=', $key_value);
+ $arr[$key_value_list[0]] = $key_value_list[1];
+ }
- unset($val, $x, $var);
- return $arr;
+ unset($url, $query_list, $url);
+ return $arr;
}
function proxy_img_cb($matches) {
-
// if the picture seems to be from another picture cache then take the original source
$queryvar = proxy_parse_query($matches[2]);
- if (($queryvar['url'] != "") AND (substr($queryvar['url'], 0, 4) == "http"))
+ if (($queryvar['url'] != '') AND (substr($queryvar['url'], 0, 4) == 'http')) {
$matches[2] = urldecode($queryvar['url']);
+ }
// following line changed per bug #431
- if (proxy_is_local_image($matches[2]))
+ if (proxy_is_local_image($matches[2])) {
return $matches[1] . $matches[2] . $matches[3];
+ }
- return $matches[1].proxy_url(htmlspecialchars_decode($matches[2])).$matches[3];
+ return $matches[1] . proxy_url(htmlspecialchars_decode($matches[2])) . $matches[3];
}
function proxy_parse_html($html) {
- $a = get_app();
- $html = str_replace(normalise_link(App::get_baseurl())."/", App::get_baseurl()."/", $html);
+ $html = str_replace(normalise_link(App::get_baseurl()) . '/', App::get_baseurl() . '/', $html);
- return preg_replace_callback("/( ]*src *= *[\"'])([^\"']+)([\"'][^>]*>)/siU", "proxy_img_cb", $html);
+ return preg_replace_callback('/( ]*src *= *["\'])([^"\']+)(["\'][^>]*>)/siU', 'proxy_img_cb', $html);
}
From bb37cac77281675251f5238e3a7a87a3faf4677c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Wed, 21 Dec 2016 09:30:49 +0100
Subject: [PATCH 57/68] added curly braces + space
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
mod/events.php | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/mod/events.php b/mod/events.php
index 9b5f7cce8..36d8f0cf7 100644
--- a/mod/events.php
+++ b/mod/events.php
@@ -13,15 +13,15 @@ function events_init(&$a) {
return;
}
- if($a->argc == 1) {
+ if ($a->argc == 1) {
// if it's a json request abort here becaus we don't
// need the widget data
- if($a->argv[1] === 'json')
+ if ($a->argv[1] === 'json')
return;
$cal_widget = widget_events();
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside'))
$a->page['aside'] = '';
$a->page['aside'] .= $cal_widget;
@@ -51,33 +51,35 @@ function events_post(&$a) {
// The default setting for the `private` field in event_store() is false, so mirror that
$private_event = false;
- if($start_text) {
+ if ($start_text) {
$start = $start_text;
}
else {
$start = sprintf('%d-%d-%d %d:%d:0',$startyear,$startmonth,$startday,$starthour,$startminute);
}
- if($nofinish) {
+ if ($nofinish) {
$finish = '0000-00-00 00:00:00';
}
- if($finish_text) {
+ if ($finish_text) {
$finish = $finish_text;
}
else {
$finish = sprintf('%d-%d-%d %d:%d:0',$finishyear,$finishmonth,$finishday,$finishhour,$finishminute);
}
- if($adjust) {
+ if ($adjust) {
$start = datetime_convert(date_default_timezone_get(),'UTC',$start);
- if(! $nofinish)
+ if (! $nofinish) {
$finish = datetime_convert(date_default_timezone_get(),'UTC',$finish);
+ }
}
else {
$start = datetime_convert('UTC','UTC',$start);
- if(! $nofinish)
+ if (! $nofinish) {
$finish = datetime_convert('UTC','UTC',$finish);
+ }
}
// Don't allow the event to finish before it begins.
@@ -93,9 +95,9 @@ function events_post(&$a) {
$action = ($event_id == '') ? 'new' : "event/" . $event_id;
$onerror_url = App::get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
- if(strcmp($finish,$start) < 0 && !$nofinish) {
+ if (strcmp($finish,$start) < 0 && !$nofinish) {
notice( t('Event can not end before it has started.') . EOL);
- if(intval($_REQUEST['preview'])) {
+ if (intval($_REQUEST['preview'])) {
echo( t('Event can not end before it has started.'));
killme();
}
From d80b82c55d912f4de356923d504fc7594c89918b Mon Sep 17 00:00:00 2001
From: Roland Haeder
Date: Wed, 21 Dec 2016 22:53:08 +0100
Subject: [PATCH 58/68] no need for this else block
Signed-off-by: Roland Haeder
---
mod/proxy.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mod/proxy.php b/mod/proxy.php
index e14f08570..a8c24cf08 100644
--- a/mod/proxy.php
+++ b/mod/proxy.php
@@ -136,6 +136,7 @@ function proxy_init(App $a) {
}
$valid = true;
+ $r = array();
if (!$direct_cache AND ($cachefile == '')) {
$r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
@@ -158,8 +159,6 @@ function proxy_init(App $a) {
=======
>>>>>>> upstream/develop
}
- } else {
- $r = array();
}
if (!dbm::is_result($r)) {
From d97b6a2eba8bfe3af636cb154246b7791d807337 Mon Sep 17 00:00:00 2001
From: Roland Haeder
Date: Wed, 21 Dec 2016 23:04:09 +0100
Subject: [PATCH 59/68] added curly braces/spaces + replace spaces with tabs to
fix code indending (or so?)
Signed-off-by: Roland Haeder
---
include/message.php | 3 +-
mod/dirfind.php | 13 +++----
mod/follow.php | 18 +++++-----
mod/home.php | 7 ++--
mod/install.php | 88 +++++++++++++++++++++++----------------------
mod/invite.php | 48 ++++++++++++-------------
mod/starred.php | 3 +-
7 files changed, 88 insertions(+), 92 deletions(-)
diff --git a/include/message.php b/include/message.php
index 5bd611f22..3d5d4d33a 100644
--- a/include/message.php
+++ b/include/message.php
@@ -153,8 +153,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
if ($post_id) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id);
return intval($post_id);
- }
- else {
+ } else {
return -3;
}
diff --git a/mod/dirfind.php b/mod/dirfind.php
index 1a7842167..0ac82f281 100644
--- a/mod/dirfind.php
+++ b/mod/dirfind.php
@@ -88,20 +88,19 @@ function dirfind_content(&$a, $prefix = "") {
if (get_config('system','diaspora_enabled')) {
$diaspora = NETWORK_DIASPORA;
- }
- else {
+ } else {
$diaspora = NETWORK_DFRN;
}
if (!get_config('system','ostatus_disabled')) {
$ostatus = NETWORK_OSTATUS;
- }
- else {
+ } else {
$ostatus = NETWORK_DFRN;
}
$search2 = "%".$search."%";
+ /// @TODO These 2 SELECTs are not checked on validity with dbm::is_result()
$count = q("SELECT count(*) AS `total` FROM `gcontact`
LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
AND `contact`.`network` = `gcontact`.`network`
@@ -200,8 +199,7 @@ function dirfind_content(&$a, $prefix = "") {
$photo_menu = contact_photo_menu($contact[0]);
$details = _contact_detail_for_template($contact[0]);
$alt_text = $details['alt_text'];
- }
- else {
+ } else {
$photo_menu = array();
}
} else {
@@ -243,8 +241,7 @@ function dirfind_content(&$a, $prefix = "") {
'$paginate' => paginate($a),
));
- }
- else {
+ } else {
info( t('No matches') . EOL);
}
diff --git a/mod/follow.php b/mod/follow.php
index eb5570e8a..2e970ad0c 100644
--- a/mod/follow.php
+++ b/mod/follow.php
@@ -56,10 +56,11 @@ function follow_content(&$a) {
// NOTREACHED
}
- if ($ret["network"] == NETWORK_MAIL)
+ if ($ret["network"] == NETWORK_MAIL) {
$ret["url"] = $ret["addr"];
+ }
- if($ret['network'] === NETWORK_DFRN) {
+ if ($ret['network'] === NETWORK_DFRN) {
$request = $ret["request"];
$tpl = get_markup_template('dfrn_request.tpl');
} else {
@@ -84,20 +85,22 @@ function follow_content(&$a) {
$r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
normalise_link($ret["url"]));
- if (!$r)
+ if (!$r) {
$r = array(array("location" => "", "about" => "", "keywords" => ""));
- else
+ } else {
$gcontact_id = $r[0]["id"];
+ }
- if($ret['network'] === NETWORK_DIASPORA) {
+ if ($ret['network'] === NETWORK_DIASPORA) {
$r[0]["location"] = "";
$r[0]["about"] = "";
}
$header = $ret["name"];
- if ($ret["addr"] != "")
+ if ($ret["addr"] != "") {
$header .= " <".$ret["addr"].">";
+ }
//$header .= " (".network_to_name($ret['network'], $ret['url']).")";
$header = t("Connect/Follow");
@@ -176,8 +179,7 @@ function follow_post(&$a) {
notice($result['message']);
}
goaway($return_url);
- }
- elseif ($result['cid']) {
+ } elseif ($result['cid']) {
goaway(App::get_baseurl().'/contacts/'.$result['cid']);
}
diff --git a/mod/home.php b/mod/home.php
index 0e83340cc..eb5d1e90b 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -16,7 +16,6 @@ function home_init(&$a) {
}}
-
if(! function_exists('home_content')) {
function home_content(&$a) {
@@ -35,9 +34,8 @@ function home_content(&$a) {
$a->page['htmlhead'] .= ' ';
}
- $o .= file_get_contents('home.html');}
-
- else {
+ $o .= file_get_contents('home.html');
+ } else {
$o .= ''.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").' ';
}
@@ -48,5 +46,4 @@ function home_content(&$a) {
return $o;
-
}}
diff --git a/mod/install.php b/mod/install.php
index 73216e7f8..b13da8c28 100755
--- a/mod/install.php
+++ b/mod/install.php
@@ -11,17 +11,16 @@ function install_init(&$a){
echo "ok";
killme();
}
-
+
// We overwrite current theme css, because during install we could not have a working mod_rewrite
// so we could not have a css at all. Here we set a static css file for the install procedure pages
$a->config['system']['theme'] = "../install";
$a->theme['stylesheet'] = App::get_baseurl()."/view/install/style.css";
-
-
-
+
global $install_wizard_pass;
- if (x($_POST,'pass'))
+ if (x($_POST,'pass')) {
$install_wizard_pass = intval($_POST['pass']);
+ }
}
@@ -63,7 +62,7 @@ function install_post(&$a) {
return;
}
}*/
- if(get_db_errno()) {
+ if (get_db_errno()) {
$a->data['db_conn_failed']=true;
}
@@ -107,17 +106,18 @@ function install_post(&$a) {
$result = file_put_contents('.htconfig.php', $txt);
- if(! $result) {
+ if (! $result) {
$a->data['txt'] = $txt;
}
$errors = load_database($db);
- if($errors)
+ if ($errors) {
$a->data['db_failed'] = $errors;
- else
+ } else {
$a->data['db_installed'] = true;
+ }
return;
break;
@@ -125,10 +125,11 @@ function install_post(&$a) {
}
function get_db_errno() {
- if(class_exists('mysqli'))
+ if (class_exists('mysqli')) {
return mysqli_connect_errno();
- else
+ } else {
return mysql_errno();
+ }
}
function install_content(&$a) {
@@ -140,23 +141,23 @@ function install_content(&$a) {
- if(x($a->data,'db_conn_failed')) {
+ if (x($a->data,'db_conn_failed')) {
$install_wizard_pass = 2;
$wizard_status = t('Could not connect to database.');
}
- if(x($a->data,'db_create_failed')) {
+ if (x($a->data,'db_create_failed')) {
$install_wizard_pass = 2;
$wizard_status = t('Could not create table.');
}
$db_return_text="";
- if(x($a->data,'db_installed')) {
+ if (x($a->data,'db_installed')) {
$txt = '';
$txt .= t('Your Friendica site database has been installed.') . EOL;
$db_return_text .= $txt;
}
- if(x($a->data,'db_failed')) {
+ if (x($a->data,'db_failed')) {
$txt = t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL;
$txt .= t('Please see the file "INSTALL.txt".') . EOL ."
" ;
$txt .= "".$a->data['db_failed'] . " ". EOL ;
@@ -176,7 +177,7 @@ function install_content(&$a) {
}
}
- if(x($a->data,'txt') && strlen($a->data['txt'])) {
+ if (x($a->data,'txt') && strlen($a->data['txt'])) {
$db_return_text .= manual_config($a);
}
@@ -205,16 +206,19 @@ function install_content(&$a) {
check_keys($checks);
- if(x($_POST,'phpath'))
+ if (x($_POST,'phpath')) {
$phpath = notags(trim($_POST['phpath']));
+ }
check_php($phpath, $checks);
- check_htaccess($checks);
+ check_htaccess($checks);
+ /// @TODO Maybe move this out?
function check_passed($v, $c){
- if ($c['required'])
+ if ($c['required']) {
$v = $v && $c['status'];
+ }
return $v;
}
$checkspassed = array_reduce($checks, "check_passed", true);
@@ -343,7 +347,7 @@ function check_php(&$phpath, &$checks) {
$passed = strlen($phpath);
}
$help = "";
- if(!$passed) {
+ if (!$passed) {
$help .= t('Could not find a command line version of PHP in the web server PATH.'). EOL;
$help .= t("If you don't have a command line version of PHP installed on server, you will not be able to run background polling via cron. See 'Setup the poller' ") . EOL ;
$help .= EOL . EOL ;
@@ -370,7 +374,7 @@ function check_php(&$phpath, &$checks) {
}
- if($passed2) {
+ if ($passed2) {
$str = autoname(8);
$cmd = "$phpath testargs.php $str";
$result = trim(shell_exec($cmd));
@@ -392,15 +396,17 @@ function check_keys(&$checks) {
$res = false;
- if(function_exists('openssl_pkey_new'))
- $res=openssl_pkey_new(array(
- 'digest_alg' => 'sha1',
- 'private_key_bits' => 4096,
- 'encrypt_key' => false ));
+ if (function_exists('openssl_pkey_new')) {
+ $res = openssl_pkey_new(array(
+ 'digest_alg' => 'sha1',
+ 'private_key_bits' => 4096,
+ 'encrypt_key' => false
+ ));
+ }
// Get private key
- if(! $res) {
+ if (! $res) {
$help .= t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys'). EOL;
$help .= t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".');
}
@@ -420,7 +426,7 @@ function check_funcs(&$checks) {
check_add($ck_funcs, t('XML PHP module'), true, true, "");
check_add($ck_funcs, t('iconv module'), true, true, "");
- if(function_exists('apache_get_modules')){
+ if (function_exists('apache_get_modules')){
if (! in_array('mod_rewrite',apache_get_modules())) {
check_add($ck_funcs, t('Apache mod_rewrite module'), false, true, t('Error: Apache webserver mod-rewrite module is required but not installed.'));
} else {
@@ -428,31 +434,31 @@ function check_funcs(&$checks) {
}
}
- if(! function_exists('curl_init')){
+ if (! function_exists('curl_init')){
$ck_funcs[0]['status']= false;
$ck_funcs[0]['help']= t('Error: libCURL PHP module required but not installed.');
}
- if(! function_exists('imagecreatefromjpeg')){
+ if (! function_exists('imagecreatefromjpeg')){
$ck_funcs[1]['status']= false;
$ck_funcs[1]['help']= t('Error: GD graphics PHP module with JPEG support required but not installed.');
}
- if(! function_exists('openssl_public_encrypt')) {
+ if (! function_exists('openssl_public_encrypt')) {
$ck_funcs[2]['status']= false;
$ck_funcs[2]['help']= t('Error: openssl PHP module required but not installed.');
}
- if(! function_exists('mysqli_connect')){
+ if (! function_exists('mysqli_connect')){
$ck_funcs[3]['status']= false;
$ck_funcs[3]['help']= t('Error: mysqli PHP module required but not installed.');
}
- if(! function_exists('mb_strlen')){
+ if (! function_exists('mb_strlen')){
$ck_funcs[4]['status']= false;
$ck_funcs[4]['help']= t('Error: mb_string PHP module required but not installed.');
}
- if(! function_exists('mcrypt_create_iv')){
+ if (! function_exists('mcrypt_create_iv')){
$ck_funcs[5]['status']= false;
$ck_funcs[5]['help']= t('Error: mcrypt PHP module required but not installed.');
}
- if(! function_exists('iconv_strlen')){
+ if (! function_exists('iconv_strlen')){
$ck_funcs[7]['status']= false;
$ck_funcs[7]['help']= t('Error: iconv PHP module required but not installed.');
}
@@ -487,7 +493,7 @@ function check_funcs(&$checks) {
function check_htconfig(&$checks) {
$status = true;
$help = "";
- if( (file_exists('.htconfig.php') && !is_writable('.htconfig.php')) ||
+ if ((file_exists('.htconfig.php') && !is_writable('.htconfig.php')) ||
(!file_exists('.htconfig.php') && !is_writable('.')) ) {
$status=false;
@@ -504,7 +510,7 @@ function check_htconfig(&$checks) {
function check_smarty3(&$checks) {
$status = true;
$help = "";
- if( !is_writable('view/smarty3') ) {
+ if (!is_writable('view/smarty3') ) {
$status=false;
$help = t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL;
@@ -532,8 +538,7 @@ function check_htaccess(&$checks) {
$help = t('Url rewrite in .htaccess is not working. Check your server configuration.');
}
check_add($checks, t('Url rewrite is working'), $status, true, $help);
- }
- else {
+ } else {
// cannot check modrewrite if libcurl is not installed
/// @TODO Maybe issue warning here?
}
@@ -552,8 +557,7 @@ function check_imagik(&$checks) {
}
if ($imagick == false) {
check_add($checks, t('ImageMagick PHP extension is not installed'), $imagick, false, "");
- }
- else {
+ } else {
check_add($checks, t('ImageMagick PHP extension is installed'), $imagick, false, "");
if ($imagick) {
check_add($checks, t('ImageMagick supports GIF'), $gif, false, "");
@@ -561,8 +565,6 @@ function check_imagik(&$checks) {
}
}
-
-
function manual_config(&$a) {
$data = htmlentities($a->data['txt'],ENT_COMPAT,'UTF-8');
$o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.');
diff --git a/mod/invite.php b/mod/invite.php
index 12f8306e8..441d39e6e 100644
--- a/mod/invite.php
+++ b/mod/invite.php
@@ -19,14 +19,15 @@ function invite_post(&$a) {
check_form_security_token_redirectOnErr('/', 'send_invite');
$max_invites = intval(get_config('system','max_invites'));
- if(! $max_invites)
+ if (! $max_invites) {
$max_invites = 50;
+ }
$current_invites = intval(get_pconfig(local_user(),'system','sent_invites'));
- if($current_invites > $max_invites) {
+ if ($current_invites > $max_invites) {
notice( t('Total invitation limit exceeded.') . EOL);
return;
- };
+ }
$recips = ((x($_POST,'recipients')) ? explode("\n",$_POST['recipients']) : array());
@@ -34,23 +35,24 @@ function invite_post(&$a) {
$total = 0;
- if(get_config('system','invitation_only')) {
+ if (get_config('system','invitation_only')) {
$invonly = true;
$x = get_pconfig(local_user(),'system','invites_remaining');
- if((! $x) && (! is_site_admin()))
+ if ((! $x) && (! is_site_admin())) {
return;
+ }
}
- foreach($recips as $recip) {
+ foreach ($recips as $recip) {
$recip = trim($recip);
- if(! valid_email($recip)) {
+ if (! valid_email($recip)) {
notice( sprintf( t('%s : Not a valid email address.'), $recip) . EOL);
continue;
}
-
- if($invonly && ($x || is_site_admin())) {
+
+ if ($invonly && ($x || is_site_admin())) {
$code = autoname(8) . srand(1000,9999);
$nmessage = str_replace('$invite_code',$code,$message);
@@ -59,16 +61,17 @@ function invite_post(&$a) {
dbesc(datetime_convert())
);
- if(! is_site_admin()) {
+ if (! is_site_admin()) {
$x --;
- if($x >= 0)
+ if ($x >= 0) {
set_pconfig(local_user(),'system','invites_remaining',$x);
- else
+ } else {
return;
+ }
}
- }
- else
+ } else {
$nmessage = $message;
+ }
$res = mail($recip, email_header_encode( t('Please join us on Friendica'),'UTF-8'),
$nmessage,
@@ -76,7 +79,7 @@ function invite_post(&$a) {
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit' );
- if($res) {
+ if ($res) {
$total ++;
$current_invites ++;
set_pconfig(local_user(),'system','sent_invites',$current_invites);
@@ -84,8 +87,7 @@ function invite_post(&$a) {
notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL);
return;
}
- }
- else {
+ } else {
notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL);
}
@@ -105,26 +107,24 @@ function invite_content(&$a) {
$tpl = get_markup_template('invite.tpl');
$invonly = false;
- if(get_config('system','invitation_only')) {
+ if (get_config('system','invitation_only')) {
$invonly = true;
$x = get_pconfig(local_user(),'system','invites_remaining');
- if((! $x) && (! is_site_admin())) {
+ if ((! $x) && (! is_site_admin())) {
notice( t('You have no more invitations available') . EOL);
return '';
}
}
$dirloc = get_config('system','directory');
- if(strlen($dirloc)) {
+ if (strlen($dirloc)) {
if ($a->config['register_policy'] == REGISTER_CLOSED) {
$linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo');
- }
- elseif($a->config['register_policy'] != REGISTER_CLOSED) {
+ } elseif($a->config['register_policy'] != REGISTER_CLOSED) {
$linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), App::get_baseurl())
. "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo');
}
- }
- else {
+ } else {
$o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
return $o;
}
diff --git a/mod/starred.php b/mod/starred.php
index beaa3b87d..84baa82ce 100644
--- a/mod/starred.php
+++ b/mod/starred.php
@@ -43,8 +43,7 @@ function starred_init(&$a) {
$rand = '_=' . time();
if (strpos($return_path, '?')) {
$rand = "&$rand";
- }
- else {
+ } else {
$rand = "?$rand";
}
From b3d33ee1e61782ebc6c317ee93ae32f067888796 Mon Sep 17 00:00:00 2001
From: Roland Haeder
Date: Wed, 21 Dec 2016 23:17:22 +0100
Subject: [PATCH 60/68] More curly braces added, left some TODOs behind
Signed-off-by: Roland Haeder
---
mod/settings.php | 100 +++++++++++++++++++++++------------------------
1 file changed, 50 insertions(+), 50 deletions(-)
diff --git a/mod/settings.php b/mod/settings.php
index d9c28ac37..298b5025c 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -671,9 +671,9 @@ function settings_content(&$a) {
- if(($a->argc > 1) && ($a->argv[1] === 'oauth')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'oauth')) {
- if(($a->argc > 2) && ($a->argv[2] === 'add')) {
+ if (($a->argc > 2) && ($a->argv[2] === 'add')) {
$tpl = get_markup_template("settings_oauth_edit.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_oauth"),
@@ -689,7 +689,7 @@ function settings_content(&$a) {
return $o;
}
- if(($a->argc > 3) && ($a->argv[2] === 'edit')) {
+ if (($a->argc > 3) && ($a->argv[2] === 'edit')) {
$r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d",
dbesc($a->argv[3]),
local_user());
@@ -725,7 +725,7 @@ function settings_content(&$a) {
return;
}
-
+ /// @TODO validate result with dbm::is_result()
$r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my
FROM clients
LEFT JOIN tokens ON clients.client_id=tokens.client_id
@@ -751,7 +751,7 @@ function settings_content(&$a) {
}
- if(($a->argc > 1) && ($a->argv[1] === 'addon')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'addon')) {
$settings_addons = "";
$r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
@@ -771,14 +771,14 @@ function settings_content(&$a) {
return $o;
}
- if(($a->argc > 1) && ($a->argv[1] === 'features')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'features')) {
$arr = array();
$features = get_features();
- foreach($features as $fname => $fdata) {
+ foreach ($features as $fname => $fdata) {
$arr[$fname] = array();
$arr[$fname][0] = $fdata[0];
- foreach(array_slice($fdata,1) as $f) {
+ foreach (array_slice($fdata,1) as $f) {
$arr[$fname][1][] = array('feature_' .$f[0],$f[1],((intval(feature_enabled(local_user(),$f[0]))) ? "1" : ''),$f[2],array(t('Off'),t('On')));
}
}
@@ -787,14 +787,14 @@ function settings_content(&$a) {
$tpl = get_markup_template("settings_features.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_features"),
- '$title' => t('Additional Features'),
- '$features' => $arr,
- '$submit' => t('Save Settings'),
+ '$title' => t('Additional Features'),
+ '$features' => $arr,
+ '$submit' => t('Save Settings'),
));
return $o;
}
- if(($a->argc > 1) && ($a->argv[1] === 'connectors')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'connectors')) {
$settings_connectors = '';
$settings_connectors .= ''. t('General Social Media Settings').' ';
@@ -860,8 +860,7 @@ function settings_content(&$a) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
local_user()
);
- }
- else {
+ } else {
$r = null;
}
@@ -878,10 +877,9 @@ function settings_content(&$a) {
$tpl = get_markup_template("settings_connectors.tpl");
- if(! service_class_allows(local_user(),'email_connect')) {
+ if (! service_class_allows(local_user(),'email_connect')) {
$mail_disabled_message = upgrade_bool_message();
- }
- else {
+ } else {
$mail_disabled_message = (($mail_disabled) ? t('Email access is disabled on this site.') : '');
}
@@ -919,38 +917,42 @@ function settings_content(&$a) {
/*
* DISPLAY SETTINGS
*/
- if(($a->argc > 1) && ($a->argv[1] === 'display')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'display')) {
$default_theme = get_config('system','theme');
- if(! $default_theme)
+ if (! $default_theme) {
$default_theme = 'default';
+ }
$default_mobile_theme = get_config('system','mobile-theme');
- if(! $mobile_default_theme)
+ if (! $mobile_default_theme) {
$mobile_default_theme = 'none';
+ }
$allowed_themes_str = get_config('system','allowed_themes');
$allowed_themes_raw = explode(',',$allowed_themes_str);
$allowed_themes = array();
- if(count($allowed_themes_raw))
- foreach($allowed_themes_raw as $x)
- if(strlen(trim($x)) && is_dir("view/theme/$x"))
+ if (count($allowed_themes_raw)) {
+ foreach ($allowed_themes_raw as $x) {
+ if (strlen(trim($x)) && is_dir("view/theme/$x")) {
$allowed_themes[] = trim($x);
+ }
+ }
+ }
$themes = array();
$mobile_themes = array("---" => t('No special theme for mobile devices'));
$files = glob('view/theme/*'); /* */
- if($allowed_themes) {
- foreach($allowed_themes as $th) {
+ if ($allowed_themes) {
+ foreach ($allowed_themes as $th) {
$f = $th;
$is_experimental = file_exists('view/theme/' . $th . '/experimental');
$unsupported = file_exists('view/theme/' . $th . '/unsupported');
$is_mobile = file_exists('view/theme/' . $th . '/mobile');
if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){
$theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
- if($is_mobile) {
+ if ($is_mobile) {
$mobile_themes[$f]=$theme_name;
- }
- else {
+ } else {
$themes[$f]=$theme_name;
}
}
@@ -962,8 +964,9 @@ function settings_content(&$a) {
$nowarn_insecure = intval(get_pconfig(local_user(), 'system', 'nowarn_insecure'));
$browser_update = intval(get_pconfig(local_user(), 'system','update_interval'));
- if (intval($browser_update) != -1)
+ if (intval($browser_update) != -1) {
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
+ }
$itemspage_network = intval(get_pconfig(local_user(), 'system','itemspage_network'));
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : 40); // default if not set: 40 items
@@ -1042,8 +1045,9 @@ function settings_content(&$a) {
$p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
intval(local_user())
);
- if(count($p))
+ if (count($p)) {
$profile = $p[0];
+ }
$username = $a->user['username'];
$email = $a->user['email'];
@@ -1090,8 +1094,9 @@ function settings_content(&$a) {
// nowarn_insecure
- if(! strlen($a->user['timezone']))
+ if (! strlen($a->user['timezone'])) {
$timezone = date_default_timezone_get();
+ }
// Set the account type to "Community" when the page is a community page but the account type doesn't fit
// This is only happening on the first visit after the update
@@ -1152,19 +1157,16 @@ function settings_content(&$a) {
$noid = get_config('system','no_openid');
- if($noid) {
+ if ($noid) {
$openid_field = false;
- }
- else {
+ } else {
$openid_field = array('openid_url', t('OpenID:'),$openid, t("\x28Optional\x29 Allow this OpenID to login to this account."), "", "", "url");
}
-
$opt_tpl = get_markup_template("field_yesno.tpl");
if(get_config('system','publish_all')) {
$profile_in_dir = ' ';
- }
- else {
+ } else {
$profile_in_dir = replace_macros($opt_tpl,array(
'$field' => array('profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], '', array(t('No'),t('Yes'))),
));
@@ -1174,12 +1176,10 @@ function settings_content(&$a) {
$profile_in_net_dir = replace_macros($opt_tpl,array(
'$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))),
));
- }
- else {
+ } else {
$profile_in_net_dir = '';
}
-
$hide_friends = replace_macros($opt_tpl,array(
'$field' => array('hide-friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', array(t('No'),t('Yes'))),
));
@@ -1194,19 +1194,16 @@ function settings_content(&$a) {
));
-
$blocktags = replace_macros($opt_tpl,array(
'$field' => array('blocktags', t('Allow friends to tag your posts?'), (intval($a->user['blocktags']) ? '0' : '1'), '', array(t('No'),t('Yes'))),
));
-
$suggestme = replace_macros($opt_tpl,array(
'$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', array(t('No'),t('Yes'))),
));
-
$unkmail = replace_macros($opt_tpl,array(
'$field' => array('unkmail', t('Permit unknown people to send you private mail?'), $unkmail, '', array(t('No'),t('Yes'))),
@@ -1215,9 +1212,9 @@ function settings_content(&$a) {
$invisible = (((! $profile['publish']) && (! $profile['net-publish']))
? true : false);
- if($invisible)
+ if ($invisible) {
info( t('Profile is not published .') . EOL );
-
+ }
//$subdir = ((strlen($a->get_path())) ? ' ' . t('or') . ' ' . 'profile/' . $nickname : '');
@@ -1244,27 +1241,30 @@ function settings_content(&$a) {
require_once('include/group.php');
$group_select = mini_group_select(local_user(),$a->user['def_gid']);
-
// Private/public post links for the non-JS ACL form
$private_post = 1;
- if($_REQUEST['public'])
+ if ($_REQUEST['public']) {
$private_post = 0;
+ }
$query_str = $a->query_string;
- if(strpos($query_str, 'public=1') !== false)
+ if (strpos($query_str, 'public=1') !== false) {
$query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
+ }
// I think $a->query_string may never have ? in it, but I could be wrong
// It looks like it's from the index.php?q=[etc] rewrite that the web
// server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
- if(strpos($query_str, '?') === false)
+ if (strpos($query_str, '?') === false) {
$public_post_link = '?public=1';
- else
+ } else {
$public_post_link = '&public=1';
+ }
/* Installed langs */
$lang_choices = get_available_languages();
+ /// @TODO Fix indending (or so)
$o .= replace_macros($stpl, array(
'$ptitle' => t('Account Settings'),
From 99c8fd36c06f1fa315675b841d6be3e78d1b560b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 22 Dec 2016 09:09:27 +0100
Subject: [PATCH 61/68] applied coding convention rule
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/like.php | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/include/like.php b/include/like.php
index feaffe011..b8909be32 100644
--- a/include/like.php
+++ b/include/like.php
@@ -48,10 +48,8 @@ function do_like($item_id, $verb) {
break;
}
-
logger('like: verb ' . $verb . ' item ' . $item_id);
-
$r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
dbesc($item_id),
dbesc($item_id)
@@ -109,8 +107,7 @@ function do_like($item_id, $verb) {
if ((local_user()) && (local_user() == $owner_uid)) {
$contact = $owner;
- }
- else {
+ } else {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($_SESSION['visitor_id']),
intval($owner_uid)
From ef5838bbd22134ee9ba2180e96b69e8efac2022b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 22 Dec 2016 09:10:17 +0100
Subject: [PATCH 62/68] was not missing in develop branch, but here. :-(
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/like.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/like.php b/include/like.php
index b8909be32..4df15b4b6 100644
--- a/include/like.php
+++ b/include/like.php
@@ -163,6 +163,7 @@ function do_like($item_id, $verb) {
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$post_type = t('event');
+ }
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
$link = xmlify(' ' . "\n") ;
$body = $item['body'];
From a314dbc56207eff751dbce5c88b055ae8e41ae30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 22 Dec 2016 09:14:14 +0100
Subject: [PATCH 63/68] removed conflict solving remains, took from
upstream/develop
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
mod/proxy.php | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/mod/proxy.php b/mod/proxy.php
index a8c24cf08..8046e4e96 100644
--- a/mod/proxy.php
+++ b/mod/proxy.php
@@ -141,23 +141,11 @@ function proxy_init(App $a) {
if (!$direct_cache AND ($cachefile == '')) {
$r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
if (dbm::is_result($r)) {
-<<<<<<< HEAD
-<<<<<<< origin/rewrites/app_get_baseurl_static
- $img_str = $r[0]['data'];
- $mime = $r[0]["desc"];
- if ($mime == "") $mime = "image/jpeg";
-=======
-=======
->>>>>>> upstream/develop
$img_str = $r[0]['data'];
$mime = $r[0]['desc'];
if ($mime == '') {
$mime = 'image/jpeg';
}
-<<<<<<< HEAD
->>>>>>> HEAD~0
-=======
->>>>>>> upstream/develop
}
}
From 5d0db51fdf560d9599af461664188451941d5295 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 22 Dec 2016 11:21:50 +0100
Subject: [PATCH 64/68] Beatification/coding convention: - added a lot spaces
to make it look nicer - added curly braces (coding convention) - added needed
spaces (coding convention)get_id - removed obsolete $a = get_app() call
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
object/Item.php | 383 ++++++++++++++++++++++++------------------------
1 file changed, 193 insertions(+), 190 deletions(-)
diff --git a/object/Item.php b/object/Item.php
index d14b5418c..e60344f7d 100644
--- a/object/Item.php
+++ b/object/Item.php
@@ -52,21 +52,22 @@ class Item extends BaseObject {
$ssl_state = ((local_user()) ? true : false);
$this->redirect_url = 'redir/' . $this->get_data_value('cid') ;
- if(get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel())
+ if (get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) {
$this->threaded = true;
+ }
// Prepare the children
- if(count($data['children'])) {
- foreach($data['children'] as $item) {
+ if (count($data['children'])) {
+ foreach ($data['children'] as $item) {
/*
* Only add will be displayed
*/
- if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
- continue;
- }
- if(! visible_activity($item)) {
+ if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
+ continue;
+ } elseif (! visible_activity($item)) {
continue;
}
+
$item['pagedrop'] = $data['pagedrop'];
$child = new Item($item);
$this->add_child($child);
@@ -91,11 +92,11 @@ class Item extends BaseObject {
$item = $this->get_data();
$edited = false;
if (strcmp($item['created'], $item['edited'])<>0) {
- $edited = array(
- 'label' => t('This entry was edited'),
- 'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'),
- 'relative' => relative_date($item['edited'])
- );
+ $edited = array(
+ 'label' => t('This entry was edited'),
+ 'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'),
+ 'relative' => relative_date($item['edited'])
+ );
}
$commentww = '';
$sparkle = '';
@@ -111,7 +112,6 @@ class Item extends BaseObject {
$conv = $this->get_conversation();
-
$lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
? t('Private Message')
@@ -134,22 +134,24 @@ class Item extends BaseObject {
$drop = array(
'dropping' => $dropping,
'pagedrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $item['pagedrop'] : ''),
- 'select' => t('Select'),
- 'delete' => t('Delete'),
+ 'select' => t('Select'),
+ 'delete' => t('Delete'),
);
$filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false);
$diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
$profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
- if($item['author-link'] && (! $item['author-name']))
+ if ($item['author-link'] && (! $item['author-name'])) {
$profile_name = $item['author-link'];
+ }
$sp = false;
$profile_link = best_link_url($item,$sp);
if ($profile_link === 'mailbox') {
$profile_link = '';
}
+
if ($sp) {
$sparkle = ' sparkle';
} else {
@@ -198,13 +200,14 @@ class Item extends BaseObject {
// process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like');
- if(feature_enabled($conv->get_profile_owner(),'dislike'))
+ if (feature_enabled($conv->get_profile_owner(),'dislike')) {
$response_verbs[] = 'dislike';
- if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
+ }
+ if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno';
$response_verbs[] = 'attendmaybe';
- if($conv->is_writable()) {
+ if ($conv->is_writable()) {
$isevent = true;
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
}
@@ -213,8 +216,7 @@ class Item extends BaseObject {
$responses = get_responses($conv_responses,$response_verbs,$this,$item);
foreach ($response_verbs as $value=>$verbs) {
- $responses[$verbs][output] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : '');
-
+ $responses[$verbs]['output'] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : '');
}
/*
@@ -224,20 +226,21 @@ class Item extends BaseObject {
*/
$this->check_wall_to_wall();
- if($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url()))
+ if ($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url())) {
$osparkle = ' sparkle';
+ }
- if($this->is_toplevel()) {
- if($conv->get_profile_owner() == local_user()) {
+ if ($this->is_toplevel()) {
+ if ($conv->get_profile_owner() == local_user()) {
$isstarred = (($item['starred']) ? "starred" : "unstarred");
$star = array(
- 'do' => t("add star"),
- 'undo' => t("remove star"),
- 'toggle' => t("toggle star status"),
- 'classdo' => (($item['starred']) ? "hidden" : ""),
+ 'do' => t("add star"),
+ 'undo' => t("remove star"),
+ 'toggle' => t("toggle star status"),
+ 'classdo' => (($item['starred']) ? "hidden" : ""),
'classundo' => (($item['starred']) ? "" : "hidden"),
- 'starred' => t('starred'),
+ 'starred' => t('starred'),
);
$r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1",
intval($item['uid']),
@@ -245,19 +248,19 @@ class Item extends BaseObject {
);
if (dbm::is_result($r)) {
$ignore = array(
- 'do' => t("ignore thread"),
- 'undo' => t("unignore thread"),
- 'toggle' => t("toggle ignore status"),
- 'classdo' => (($r[0]['ignored']) ? "hidden" : ""),
+ 'do' => t("ignore thread"),
+ 'undo' => t("unignore thread"),
+ 'toggle' => t("toggle ignore status"),
+ 'classdo' => (($r[0]['ignored']) ? "hidden" : ""),
'classundo' => (($r[0]['ignored']) ? "" : "hidden"),
- 'ignored' => t('ignored'),
+ 'ignored' => t('ignored'),
);
}
$tagger = '';
if(feature_enabled($conv->get_profile_owner(),'commtag')) {
$tagger = array(
- 'add' => t("add tag"),
+ 'add' => t("add tag"),
'class' => "",
);
}
@@ -266,17 +269,19 @@ class Item extends BaseObject {
$indent = 'comment';
}
- if($conv->is_writable()) {
+ if ($conv->is_writable()) {
$buttons = array(
'like' => array( t("I like this \x28toggle\x29"), t("like")),
'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''),
);
- if ($shareable) $buttons['share'] = array( t('Share this'), t('share'));
+ if ($shareable) {
+ $buttons['share'] = array( t('Share this'), t('share'));
+ }
}
$comment = $this->get_comment_box($indent);
- if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0){
+ if (strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0){
$shiny = 'shiny';
}
@@ -298,8 +303,9 @@ class Item extends BaseObject {
foreach ($languages as $language) {
$langdata = explode(";", $language);
- if ($langstr != "")
+ if ($langstr != "") {
$langstr .= ", ";
+ }
//$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
$langstr .= round($langdata[1]*100, 1)."% ".$langdata[0];
@@ -311,20 +317,19 @@ class Item extends BaseObject {
list($categories, $folders) = get_cats_and_terms($item);
- if($a->theme['template_engine'] === 'internal') {
- $body_e = template_escape($body);
- $text_e = strip_tags(template_escape($body));
- $name_e = template_escape($profile_name);
- $title_e = template_escape($item['title']);
- $location_e = template_escape($location);
+ if ($a->theme['template_engine'] === 'internal') {
+ $body_e = template_escape($body);
+ $text_e = strip_tags(template_escape($body));
+ $name_e = template_escape($profile_name);
+ $title_e = template_escape($item['title']);
+ $location_e = template_escape($location);
$owner_name_e = template_escape($this->get_owner_name());
- }
- else {
- $body_e = $body;
- $text_e = strip_tags($body);
- $name_e = $profile_name;
- $title_e = $item['title'];
- $location_e = $location;
+ } else {
+ $body_e = $body;
+ $text_e = strip_tags($body);
+ $name_e = $profile_name;
+ $title_e = $item['title'];
+ $location_e = $location;
$owner_name_e = $this->get_owner_name();
}
@@ -334,89 +339,93 @@ class Item extends BaseObject {
$tagger = '';
}
- if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"]))
+ if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"])) {
unset($buttons["like"]);
+ }
- if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"]))
+ if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"])) {
unset($buttons["like"]);
+ }
// Diaspora isn't able to do likes on comments - but red does
if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment') AND
- !diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"]))
+ !diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"])) {
unset($buttons["like"]);
+ }
// Diaspora doesn't has multithreaded comments
- if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment'))
+ if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment')) {
unset($comment);
+ }
// Facebook can like comments - but it isn't programmed in the connector yet.
- if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"]))
+ if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"])) {
unset($buttons["like"]);
+ }
$tmp_item = array(
- 'template' => $this->get_template(),
-
- 'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
- 'tags' => $item['tags'],
- 'hashtags' => $item['hashtags'],
- 'mentions' => $item['mentions'],
- 'txt_cats' => t('Categories:'),
- 'txt_folders' => t('Filed under:'),
- 'has_cats' => ((count($categories)) ? 'true' : ''),
- 'has_folders' => ((count($folders)) ? 'true' : ''),
- 'categories' => $categories,
- 'folders' => $folders,
- 'body' => $body_e,
- 'text' => $text_e,
- 'id' => $this->get_id(),
- 'guid' => urlencode($item['guid']),
- 'isevent' => $isevent,
- 'attend' => $attend,
- 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
- 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), htmlentities($this->get_owner_name()), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
- 'to' => t('to'),
- 'via' => t('via'),
- 'wall' => t('Wall-to-Wall'),
- 'vwall' => t('via Wall-To-Wall:'),
- 'profile_url' => $profile_link,
+ 'template' => $this->get_template(),
+ 'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
+ 'tags' => $item['tags'],
+ 'hashtags' => $item['hashtags'],
+ 'mentions' => $item['mentions'],
+ 'txt_cats' => t('Categories:'),
+ 'txt_folders' => t('Filed under:'),
+ 'has_cats' => ((count($categories)) ? 'true' : ''),
+ 'has_folders' => ((count($folders)) ? 'true' : ''),
+ 'categories' => $categories,
+ 'folders' => $folders,
+ 'body' => $body_e,
+ 'text' => $text_e,
+ 'id' => $this->get_id(),
+ 'guid' => urlencode($item['guid']),
+ 'isevent' => $isevent,
+ 'attend' => $attend,
+ 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
+ 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), htmlentities($this->get_owner_name()), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
+ 'to' => t('to'),
+ 'via' => t('via'),
+ 'wall' => t('Wall-to-Wall'),
+ 'vwall' => t('via Wall-To-Wall:'),
+ 'profile_url' => $profile_link,
'item_photo_menu' => item_photo_menu($item),
- 'name' => $name_e,
- 'thumb' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)),
- 'osparkle' => $osparkle,
- 'sparkle' => $sparkle,
- 'title' => $title_e,
- 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'),
- 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
- 'app' => $item['app'],
- 'created' => relative_date($item['created']),
- 'lock' => $lock,
- 'location' => $location_e,
- 'indent' => $indent,
- 'shiny' => $shiny,
- 'owner_url' => $this->get_owner_url(),
- 'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)),
- 'owner_name' => htmlentities($owner_name_e),
- 'plink' => get_plink($item),
- 'edpost' => ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''),
- 'isstarred' => $isstarred,
- 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''),
- 'ignore' => ((feature_enabled($conv->get_profile_owner(),'ignore_posts')) ? $ignore : ''),
- 'tagger' => $tagger,
- 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''),
- 'drop' => $drop,
- 'vote' => $buttons,
- 'like' => $responses['like']['output'],
- 'dislike' => $responses['dislike']['output'],
- 'responses' => $responses,
- 'switchcomment' => t('Comment'),
- 'comment' => $comment,
- 'previewing' => ($conv->is_preview() ? ' preview ' : ''),
- 'wait' => t('Please wait'),
- 'thread_level' => $thread_level,
- 'postopts' => $langstr,
- 'edited' => $edited,
- 'network' => $item["item_network"],
- 'network_name' => network_to_name($item['item_network'], $profile_link),
+ 'name' => $name_e,
+ 'thumb' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)),
+ 'osparkle' => $osparkle,
+ 'sparkle' => $sparkle,
+ 'title' => $title_e,
+ 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'),
+ 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
+ 'app' => $item['app'],
+ 'created' => relative_date($item['created']),
+ 'lock' => $lock,
+ 'location' => $location_e,
+ 'indent' => $indent,
+ 'shiny' => $shiny,
+ 'owner_url' => $this->get_owner_url(),
+ 'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)),
+ 'owner_name' => htmlentities($owner_name_e),
+ 'plink' => get_plink($item),
+ 'edpost' => ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''),
+ 'isstarred' => $isstarred,
+ 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''),
+ 'ignore' => ((feature_enabled($conv->get_profile_owner(),'ignore_posts')) ? $ignore : ''),
+ 'tagger' => $tagger,
+ 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''),
+ 'drop' => $drop,
+ 'vote' => $buttons,
+ 'like' => $responses['like']['output'],
+ 'dislike' => $responses['dislike']['output'],
+ 'responses' => $responses,
+ 'switchcomment' => t('Comment'),
+ 'comment' => $comment,
+ 'previewing' => ($conv->is_preview() ? ' preview ' : ''),
+ 'wait' => t('Please wait'),
+ 'thread_level' => $thread_level,
+ 'postopts' => $langstr,
+ 'edited' => $edited,
+ 'network' => $item["item_network"],
+ 'network_name' => network_to_name($item['item_network'], $profile_link),
);
$arr = array('item' => $item, 'output' => $tmp_item);
@@ -427,39 +436,37 @@ class Item extends BaseObject {
$result['children'] = array();
$children = $this->get_children();
$nb_children = count($children);
- if($nb_children > 0) {
- foreach($children as $child) {
+ if ($nb_children > 0) {
+ foreach ($children as $child) {
$result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1);
}
// Collapse
- if(($nb_children > 2) || ($thread_level > 1)) {
+ if (($nb_children > 2) || ($thread_level > 1)) {
$result['children'][0]['comment_firstcollapsed'] = true;
$result['children'][0]['num_comments'] = sprintf( tt('%d comment','%d comments',$total_children),$total_children );
$result['children'][0]['hidden_comments_num'] = $total_children;
$result['children'][0]['hidden_comments_text'] = tt('comment', 'comments', $total_children);
$result['children'][0]['hide_text'] = t('show more');
- if($thread_level > 1) {
+ if ($thread_level > 1) {
$result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
- }
- else {
+ } else {
$result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
}
}
}
if ($this->is_toplevel()) {
- $result['total_comments_num'] = "$total_children";
- $result['total_comments_text'] = tt('comment', 'comments', $total_children);
+ $result['total_comments_num'] = "$total_children";
+ $result['total_comments_text'] = tt('comment', 'comments', $total_children);
}
$result['private'] = $item['private'];
$result['toplevel'] = ($this->is_toplevel() ? 'toplevel_item' : '');
- if($this->is_threaded()) {
+ if ($this->is_threaded()) {
$result['flatten'] = false;
$result['threaded'] = true;
- }
- else {
+ } else {
$result['flatten'] = true;
$result['threaded'] = false;
}
@@ -478,23 +485,21 @@ class Item extends BaseObject {
/**
* Add a child item
*/
- public function add_child($item) {
+ public function add_child(Item $item) {
$item_id = $item->get_id();
- if(!$item_id) {
+ if (!$item_id) {
logger('[ERROR] Item::add_child : Item has no ID!!', LOGGER_DEBUG);
return false;
- }
- if($this->get_child($item->get_id())) {
+ } elseif ($this->get_child($item->get_id())) {
logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG);
return false;
}
/*
* Only add what will be displayed
*/
- if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
+ if ($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
return false;
- }
- if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
+ } elseif (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
return false;
}
@@ -507,9 +512,10 @@ class Item extends BaseObject {
* Get a child by its ID
*/
public function get_child($id) {
- foreach($this->get_children() as $child) {
- if($child->get_id() == $id)
+ foreach ($this->get_children() as $child) {
+ if ($child->get_id() == $id) {
return $child;
+ }
}
return null;
}
@@ -546,8 +552,8 @@ class Item extends BaseObject {
*/
public function remove_child($item) {
$id = $item->get_id();
- foreach($this->get_children() as $key => $child) {
- if($child->get_id() == $id) {
+ foreach ($this->get_children() as $key => $child) {
+ if ($child->get_id() == $id) {
$child->remove_parent();
unset($this->children[$key]);
// Reindex the array, in order to make sure there won't be any trouble on loops using count()
@@ -575,8 +581,9 @@ class Item extends BaseObject {
$this->conversation = $conv;
// Set it on our children too
- foreach($this->get_children() as $child)
+ foreach ($this->get_children() as $child) {
$child->set_conversation($conv);
+ }
}
/**
@@ -603,7 +610,7 @@ class Item extends BaseObject {
* _ false on failure
*/
public function get_data_value($name) {
- if(!isset($this->data[$name])) {
+ if (!isset($this->data[$name])) {
// logger('[ERROR] Item::get_data_value : Item has no value name "'. $name .'".', LOGGER_DEBUG);
return false;
}
@@ -615,9 +622,7 @@ class Item extends BaseObject {
* Set template
*/
private function set_template($name) {
- $a = get_app();
-
- if(!x($this->available_templates, $name)) {
+ if (!x($this->available_templates, $name)) {
logger('[ERROR] Item::set_template : Template not available ("'. $name .'").', LOGGER_DEBUG);
return false;
}
@@ -645,13 +650,14 @@ class Item extends BaseObject {
private function is_writable() {
$conv = $this->get_conversation();
- if($conv) {
+ if ($conv) {
// This will allow us to comment on wall-to-wall items owned by our friends
// and community forums even if somebody else wrote the post.
// bug #517 - this fixes for conversation owner
- if($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user())
- return true;
+ if ($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user()) {
+ return true;
+ }
// this fixes for visitors
return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'profile'));
@@ -665,8 +671,8 @@ class Item extends BaseObject {
private function count_descendants() {
$children = $this->get_children();
$total = count($children);
- if($total > 0) {
- foreach($children as $child) {
+ if ($total > 0) {
+ foreach ($children as $child) {
$total += $child->count_descendants();
}
}
@@ -689,7 +695,7 @@ class Item extends BaseObject {
*/
private function get_comment_box($indent) {
$a = $this->get_app();
- if(!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) {
+ if (!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) {
return '';
}
@@ -697,48 +703,48 @@ class Item extends BaseObject {
$conv = $this->get_conversation();
$template = get_markup_template($this->get_comment_box_template());
$ww = '';
- if( ($conv->get_mode() === 'network') && $this->is_wall_to_wall() )
+ if ( ($conv->get_mode() === 'network') && $this->is_wall_to_wall() )
$ww = 'ww';
- if($conv->is_writable() && $this->is_writable()) {
+ if ($conv->is_writable() && $this->is_writable()) {
$qc = $qcomment = null;
/*
* Hmmm, code depending on the presence of a particular plugin?
* This should be better if done by a hook
*/
- if(in_array('qcomment',$a->plugins)) {
+ if (in_array('qcomment',$a->plugins)) {
$qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
$qcomment = (($qc) ? explode("\n",$qc) : null);
}
$comment_box = replace_macros($template,array(
'$return_path' => $a->query_string,
- '$threaded' => $this->is_threaded(),
-// '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
- '$jsreload' => '',
- '$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'),
- '$id' => $this->get_id(),
- '$parent' => $this->get_id(),
- '$qcomment' => $qcomment,
+ '$threaded' => $this->is_threaded(),
+// '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
+ '$jsreload' => '',
+ '$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'),
+ '$id' => $this->get_id(),
+ '$parent' => $this->get_id(),
+ '$qcomment' => $qcomment,
'$profile_uid' => $conv->get_profile_owner(),
- '$mylink' => $a->remove_baseurl($a->contact['url']),
- '$mytitle' => t('This is you'),
- '$myphoto' => $a->remove_baseurl($a->contact['thumb']),
- '$comment' => t('Comment'),
- '$submit' => t('Submit'),
- '$edbold' => t('Bold'),
- '$editalic' => t('Italic'),
- '$eduline' => t('Underline'),
- '$edquote' => t('Quote'),
- '$edcode' => t('Code'),
- '$edimg' => t('Image'),
- '$edurl' => t('Link'),
- '$edvideo' => t('Video'),
- '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''),
- '$indent' => $indent,
- '$sourceapp' => t($a->sourcename),
- '$ww' => (($conv->get_mode() === 'network') ? $ww : ''),
- '$rand_num' => random_digits(12)
+ '$mylink' => $a->remove_baseurl($a->contact['url']),
+ '$mytitle' => t('This is you'),
+ '$myphoto' => $a->remove_baseurl($a->contact['thumb']),
+ '$comment' => t('Comment'),
+ '$submit' => t('Submit'),
+ '$edbold' => t('Bold'),
+ '$editalic' => t('Italic'),
+ '$eduline' => t('Underline'),
+ '$edquote' => t('Quote'),
+ '$edcode' => t('Code'),
+ '$edimg' => t('Image'),
+ '$edurl' => t('Link'),
+ '$edvideo' => t('Video'),
+ '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''),
+ '$indent' => $indent,
+ '$sourceapp' => t($a->sourcename),
+ '$ww' => (($conv->get_mode() === 'network') ? $ww : ''),
+ '$rand_num' => random_digits(12)
));
}
@@ -768,14 +774,13 @@ class Item extends BaseObject {
$this->owner_photo = $a->page_contact['thumb'];
$this->owner_name = $a->page_contact['name'];
$this->wall_to_wall = true;
- }
- else if($this->get_data_value('owner-link')) {
+ } elseif($this->get_data_value('owner-link')) {
$owner_linkmatch = (($this->get_data_value('owner-link')) && link_compare($this->get_data_value('owner-link'),$this->get_data_value('author-link')));
$alias_linkmatch = (($this->get_data_value('alias')) && link_compare($this->get_data_value('alias'),$this->get_data_value('author-link')));
$owner_namematch = (($this->get_data_value('owner-name')) && $this->get_data_value('owner-name') == $this->get_data_value('author-name'));
- if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
+ if ((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
// The author url doesn't match the owner (typically the contact)
// and also doesn't match the contact alias.
@@ -791,18 +796,18 @@ class Item extends BaseObject {
$this->owner_name = $this->get_data_value('owner-name');
$this->wall_to_wall = true;
// If it is our contact, use a friendly redirect link
- if((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url')))
+ if ((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url')))
&& ($this->get_data_value('network') === NETWORK_DFRN)) {
$this->owner_url = $this->get_redirect_url();
- }
- else
+ } else {
$this->owner_url = zrl($this->get_data_value('owner-link'));
+ }
}
}
}
}
- if(!$this->wall_to_wall) {
+ if (!$this->wall_to_wall) {
$this->set_template('wall');
$this->owner_url = '';
$this->owner_photo = '';
@@ -830,8 +835,6 @@ class Item extends BaseObject {
return $this->visiting;
}
-
-
-
}
+/// @TODO These are discouraged and should be removed:
?>
From d82ed5d1b4a3af4d0a4782b809837e3b22d1211d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 22 Dec 2016 15:30:23 +0100
Subject: [PATCH 65/68] Continued with code convention: - added more curly
braces - added space betweent if/foreach and brace - added spaces for
beautification - converted some " to ' (mixed usage)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/Contact.php | 11 ++-
include/acl_selectors.php | 148 ++++++++++++++++++++------------------
mod/fbrowser.php | 31 ++++----
mod/ostatus_subscribe.php | 17 +++--
4 files changed, 111 insertions(+), 96 deletions(-)
diff --git a/include/Contact.php b/include/Contact.php
index 5cf40a9f0..b1f63cbdf 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -85,11 +85,12 @@ function contact_remove($id) {
function terminate_friendship($user,$self,$contact) {
+ /// @TODO Get rid of this, include/datetime.php should care about by itself
$a = get_app();
require_once('include/datetime.php');
- if($contact['network'] === NETWORK_OSTATUS) {
+ if ($contact['network'] === NETWORK_OSTATUS) {
require_once('include/ostatus.php');
@@ -99,16 +100,14 @@ function terminate_friendship($user,$self,$contact) {
$item['follow'] = $contact["url"];
$slap = ostatus::salmon($item, $user);
- if((x($contact,'notify')) && (strlen($contact['notify']))) {
+ if ((x($contact,'notify')) && (strlen($contact['notify']))) {
require_once('include/salmon.php');
slapper($user,$contact['notify'],$slap);
}
- }
- elseif($contact['network'] === NETWORK_DIASPORA) {
+ } elseif ($contact['network'] === NETWORK_DIASPORA) {
require_once('include/diaspora.php');
Diaspora::send_unshare($user,$contact);
- }
- elseif($contact['network'] === NETWORK_DFRN) {
+ } elseif ($contact['network'] === NETWORK_DFRN) {
require_once('include/dfrn.php');
dfrn::deliver($user,$contact,'placeholder', 1);
}
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index dc86ba034..a20775379 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -65,20 +65,24 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
$exclude = false;
$size = 4;
- if(is_array($options)) {
- if(x($options,'size'))
+ if (is_array($options)) {
+ if (x($options,'size'))
$size = $options['size'];
- if(x($options,'mutual_friends'))
+ if (x($options,'mutual_friends')) {
$mutual = true;
- if(x($options,'single'))
+ }
+ if (x($options,'single')) {
$single = true;
- if(x($options,'multiple'))
+ }
+ if (x($options,'multiple')) {
$single = false;
- if(x($options,'exclude'))
+ }
+ if (x($options,'exclude')) {
$exclude = $options['exclude'];
+ }
- if(x($options,'networks')) {
+ if (x($options,'networks')) {
switch($options['networks']) {
case 'DFRN_ONLY':
$networks = array(NETWORK_DFRN);
@@ -146,10 +150,11 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
if (dbm::is_result($r)) {
foreach ($r as $rr) {
- if((is_array($preselected)) && in_array($rr['id'], $preselected))
+ if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
$selected = " selected=\"selected\" ";
- else
+ } else {
$selected = '';
+ }
$trimmed = mb_substr($rr['name'],0,20);
@@ -231,8 +236,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
if ($privmail) {
$trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
- }
- else {
+ } else {
$trimmed = mb_substr($rr['name'],0,20);
}
@@ -260,16 +264,22 @@ function fixacl(&$item) {
function prune_deadguys($arr) {
- if(! $arr)
+ if (! $arr) {
return $arr;
+ }
+
$str = dbesc(implode(',',$arr));
+
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
+
if ($r) {
$ret = array();
- foreach($r as $rr)
+ foreach ($r as $rr) {
$ret[] = intval($rr['id']);
+ }
return $ret;
}
+
return array();
}
@@ -545,35 +555,33 @@ function acl_lookup(&$a, $out_type = 'json') {
dbesc(NETWORK_ZOT),
dbesc(NETWORK_DIASPORA)
);
- }
- elseif($type == 'a') {
+ } elseif ($type == 'a') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
WHERE `uid` = %d AND `pending` = 0
$sql_extra2
ORDER BY `name` ASC ",
intval(local_user())
);
- }
- elseif($type == 'x') {
+ } elseif ($type == 'x') {
// autocomplete for global contact search (e.g. navbar search)
$r = navbar_complete($a);
$contacts = array();
if ($r) {
- foreach($r as $g) {
+ foreach ($r as $g) {
$contacts[] = array(
- "photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
- "name" => $g['name'],
- "nick" => (x($g['addr']) ? $g['addr'] : $g['url']),
- "network" => $g['network'],
- "link" => $g['url'],
- "forum" => (x($g['community']) ? 1 : 0),
+ 'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
+ 'name' => $g['name'],
+ 'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
+ 'network' => $g['network'],
+ 'link' => $g['url'],
+ 'forum' => (x($g['community']) ? 1 : 0),
);
}
}
$o = array(
'start' => $start,
- 'count' => $count,
- 'items' => $contacts,
+ 'count' => $count,
+ 'items' => $contacts,
);
echo json_encode($o);
killme();
@@ -583,16 +591,16 @@ function acl_lookup(&$a, $out_type = 'json') {
if (dbm::is_result($r)) {
- foreach($r as $g){
+ foreach ($r as $g){
$contacts[] = array(
- "type" => "c",
- "photo" => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
- "name" => htmlentities($g['name']),
- "id" => intval($g['id']),
- "network" => $g['network'],
- "link" => $g['url'],
- "nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
- "forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
+ 'type' => 'c',
+ 'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
+ 'name' => htmlentities($g['name']),
+ 'id' => intval($g['id']),
+ 'network' => $g['network'],
+ 'link' => $g['url'],
+ 'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
+ 'forum' => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
);
}
}
@@ -618,7 +626,7 @@ function acl_lookup(&$a, $out_type = 'json') {
implode("','", $known_contacts)
);
if (dbm::is_result($r)){
- foreach($r as $row) {
+ foreach ($r as $row) {
// nickname..
$up = parse_url($row['author-link']);
$nick = explode("/",$up['path']);
@@ -626,14 +634,14 @@ function acl_lookup(&$a, $out_type = 'json') {
$nick .= "@".$up['host'];
// /nickname
$unknow_contacts[] = array(
- "type" => "c",
- "photo" => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
- "name" => htmlentities($row['author-name']),
- "id" => '',
- "network" => "unknown",
- "link" => $row['author-link'],
- "nick" => htmlentities($nick),
- "forum" => false
+ 'type' => 'c',
+ 'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
+ 'name' => htmlentities($row['author-name']),
+ 'id' => '',
+ 'network' => 'unknown',
+ 'link' => $row['author-link'],
+ 'nick' => htmlentities($nick),
+ 'forum' => false
);
}
}
@@ -643,34 +651,34 @@ function acl_lookup(&$a, $out_type = 'json') {
}
$results = array(
- "tot" => $tot,
- "start" => $start,
- "count" => $count,
- "groups" => $groups,
- "contacts" => $contacts,
- "items" => $items,
- "type" => $type,
- "search" => $search,
+ 'tot' => $tot,
+ 'start' => $start,
+ 'count' => $count,
+ 'groups' => $groups,
+ 'contacts' => $contacts,
+ 'items' => $items,
+ 'type' => $type,
+ 'search' => $search,
);
call_hooks('acl_lookup_end', $results);
if($out_type === 'html') {
$o = array(
- 'tot' => $results["tot"],
- 'start' => $results["start"],
- 'count' => $results["count"],
- 'groups' => $results["groups"],
- 'contacts' => $results["contacts"],
+ 'tot' => $results['tot'],
+ 'start' => $results['start'],
+ 'count' => $results['count'],
+ 'groups' => $results['groups'],
+ 'contacts' => $results['contacts'],
);
return $o;
}
$o = array(
- 'tot' => $results["tot"],
- 'start' => $results["start"],
- 'count' => $results["count"],
- 'items' => $results["items"],
+ 'tot' => $results['tot'],
+ 'start' => $results['start'],
+ 'count' => $results['count'],
+ 'items' => $results['items'],
);
echo json_encode($o);
@@ -687,7 +695,7 @@ function navbar_complete(&$a) {
// logger('navbar_complete');
- if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
@@ -698,28 +706,32 @@ function navbar_complete(&$a) {
$mode = $_REQUEST['smode'];
// don't search if search term has less than 2 characters
- if(! $search || mb_strlen($search) < 2)
+ if (! $search || mb_strlen($search) < 2) {
return array();
+ }
- if(substr($search,0,1) === '@')
+ if (substr($search,0,1) === '@') {
$search = substr($search,1);
+ }
- if($localsearch) {
+ if ($localsearch) {
$x = DirSearch::global_search_by_name($search, $mode);
return $x;
}
- if(! $localsearch) {
+ if (! $localsearch) {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
$x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
- if($x['success']) {
+ if ($x['success']) {
$t = 0;
$j = json_decode($x['body'],true);
- if($j && $j['results']) {
+ if ($j && $j['results']) {
return $j['results'];
}
}
}
+
+ /// @TODO Not needed here?
return;
}
diff --git a/mod/fbrowser.php b/mod/fbrowser.php
index 6af97368f..9c1d43cd8 100644
--- a/mod/fbrowser.php
+++ b/mod/fbrowser.php
@@ -94,19 +94,19 @@ function fbrowser_content($a){
$tpl = get_markup_template($template_file);
$o = replace_macros($tpl, array(
- '$type' => 'image',
- '$baseurl' => App::get_baseurl(),
- '$path' => $path,
- '$folders' => $albums,
- '$files' =>$files,
- '$cancel' => t('Cancel'),
+ '$type' => 'image',
+ '$baseurl' => App::get_baseurl(),
+ '$path' => $path,
+ '$folders' => $albums,
+ '$files' => $files,
+ '$cancel' => t('Cancel'),
'$nickname' => $a->user['nickname'],
));
break;
case "file":
- if ($a->argc==2){
+ if ($a->argc==2) {
$files = q("SELECT `id`, `filename`, `filetype` FROM `attach` WHERE `uid` = %d ",
intval(local_user())
);
@@ -116,10 +116,9 @@ function fbrowser_content($a){
list($m1,$m2) = explode("/",$rr['filetype']);
$filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
- if($a->theme['template_engine'] === 'internal') {
+ if ($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']);
- }
- else {
+ } else {
$filename_e = $rr['filename'];
}
@@ -130,12 +129,12 @@ function fbrowser_content($a){
$tpl = get_markup_template($template_file);
$o = replace_macros($tpl, array(
- '$type' => 'file',
- '$baseurl' => App::get_baseurl(),
- '$path' => array( array( "", t("Files")) ),
- '$folders' => false,
- '$files' =>$files,
- '$cancel' => t('Cancel'),
+ '$type' => 'file',
+ '$baseurl' => App::get_baseurl(),
+ '$path' => array( array( "", t("Files")) ),
+ '$folders' => false,
+ '$files' =>$files,
+ '$cancel' => t('Cancel'),
'$nickname' => $a->user['nickname'],
));
diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php
index 963f43693..04c8d7bde 100644
--- a/mod/ostatus_subscribe.php
+++ b/mod/ostatus_subscribe.php
@@ -21,21 +21,24 @@ function ostatus_subscribe_content(&$a) {
if (get_pconfig($uid, "ostatus", "legacy_friends") == "") {
- if ($_REQUEST["url"] == "")
+ if ($_REQUEST["url"] == "") {
return $o.t("No contact provided.");
+ }
$contact = probe_url($_REQUEST["url"]);
- if (!$contact)
+ if (!$contact) {
return $o.t("Couldn't fetch information for contact.");
+ }
$api = $contact["baseurl"]."/api/";
// Fetching friends
$data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]);
- if (!$data["success"])
+ if (!$data["success"]) {
return $o.t("Couldn't fetch friends for contact.");
+ }
set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]);
}
@@ -61,12 +64,14 @@ function ostatus_subscribe_content(&$a) {
$data = probe_url($url);
if ($data["network"] == NETWORK_OSTATUS) {
$result = new_contact($uid,$url,true);
- if ($result["success"])
+ if ($result["success"]) {
$o .= " - ".t("success");
- else
+ } else {
$o .= " - ".t("failed");
- } else
+ }
+ } else {
$o .= " - ".t("ignored");
+ }
$o .= "
";
From 2325d81048a4f4eeb90d08da6066cf939e15d3d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 22 Dec 2016 16:50:40 +0100
Subject: [PATCH 66/68] Code style changed: - added more curly braces - made
SQL keywords all-uppercase - added spaces between if/foreach and brace - //
Is for single-line comments *only*, please don't abuse it for multiple line
comments, use /* */ instead and a asterisk in front of every line.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/dbstructure.php | 91 ++++++++++++++++++++++++-----------------
1 file changed, 54 insertions(+), 37 deletions(-)
diff --git a/include/dbstructure.php b/include/dbstructure.php
index be1158eab..50c2856ab 100644
--- a/include/dbstructure.php
+++ b/include/dbstructure.php
@@ -26,7 +26,6 @@ function update_fail($update_id, $error_message){
}
// every admin could had different language
-
foreach ($adminlist as $admin) {
$lang = (($admin['language'])?$admin['language']:'en');
push_lang($lang);
@@ -83,8 +82,9 @@ function table_structure($table) {
if (dbm::is_result($indexes))
foreach ($indexes AS $index) {
- if ($index["Index_type"] == "FULLTEXT")
+ if ($index["Index_type"] == "FULLTEXT") {
continue;
+ }
if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
$indexdata[$index["Key_name"]] = array('UNIQUE');
@@ -95,26 +95,31 @@ function table_structure($table) {
// To avoid the need to add this to every index definition we just ignore it here.
// Exception are primary indexes
// Since there are some combindex primary indexes we use the limit of 180 here.
- if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY")))
+ if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) {
$column .= "(".$index["Sub_part"].")";
+ }
$indexdata[$index["Key_name"]][] = $column;
}
if (dbm::is_result($structures)) {
- foreach($structures AS $field) {
+ foreach ($structures AS $field) {
$fielddata[$field["Field"]]["type"] = $field["Type"];
- if ($field["Null"] == "NO")
+ if ($field["Null"] == "NO") {
$fielddata[$field["Field"]]["not null"] = true;
+ }
- if (isset($field["Default"]))
+ if (isset($field["Default"])) {
$fielddata[$field["Field"]]["default"] = $field["Default"];
+ }
- if ($field["Extra"] != "")
+ if ($field["Extra"] != "") {
$fielddata[$field["Field"]]["extra"] = $field["Extra"];
+ }
- if ($field["Key"] == "PRI")
+ if ($field["Key"] == "PRI") {
$fielddata[$field["Field"]]["primary"] = true;
+ }
}
}
return(array("fields"=>$fielddata, "indexes"=>$indexdata));
@@ -138,13 +143,15 @@ function print_structure($database, $charset) {
function update_structure($verbose, $action, $tables=null, $definition=null) {
global $a, $db;
- if ($action)
+ if ($action) {
set_config('system', 'maintenance', 1);
+ }
- if (isset($a->config["system"]["db_charset"]))
+ if (isset($a->config["system"]["db_charset"])) {
$charset = $a->config["system"]["db_charset"];
- else
+ } else {
$charset = "utf8";
+ }
$errors = false;
@@ -153,8 +160,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
// Get the current structure
$database = array();
- if (is_null($tables))
- $tables = q("show tables");
+ if (is_null($tables)) {
+ $tables = q("SHOW TABLES");
+ }
foreach ($tables AS $table) {
$table = current($table);
@@ -164,21 +172,24 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
}
// Get the definition
- if (is_null($definition))
+ if (is_null($definition)) {
$definition = db_definition($charset);
+ }
// Ensure index conversion to unique removes duplicates
$sql_config = "SET session old_alter_table=1;";
- if ($verbose)
+ if ($verbose) {
echo $sql_config."\n";
- if ($action)
- @$db->q($sql_config);
+ }
+ if ($action) {
+ $db->q($sql_config);
+ }
// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
!(strpos($db->server_info(), 'MariaDB') !== false)) {
$ignore = '';
- }else {
+ } else {
$ignore = ' IGNORE';
}
@@ -193,10 +204,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
}
$is_new_table = True;
} else {
- // Drop the index if it isn't present in the definition
- // or the definition differ from current status
- // and index name doesn't start with "local_"
- foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) {
+ /*
+ * Drop the index if it isn't present in the definition
+ * or the definition differ from current status
+ * and index name doesn't start with "local_"
+ */
+ foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
$current_index_definition = implode(",",$fieldnames);
if (isset($structure["indexes"][$indexname])) {
$new_index_definition = implode(",",$structure["indexes"][$indexname]);
@@ -205,39 +218,44 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
}
if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
$sql2=db_drop_index($indexname);
- if ($sql3 == "")
+ if ($sql3 == "") {
$sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2;
- else
+ } else {
$sql3 .= ", ".$sql2;
+ }
}
}
// Compare the field structure field by field
foreach ($structure["fields"] AS $fieldname => $parameters) {
if (!isset($database[$name]["fields"][$fieldname])) {
$sql2=db_add_table_field($fieldname, $parameters);
- if ($sql3 == "")
+ if ($sql3 == "") {
$sql3 = "ALTER TABLE `".$name."` ".$sql2;
- else
+ } else {
$sql3 .= ", ".$sql2;
+ }
} else {
// Compare the field definition
$current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
$new_field_definition = implode(",",$parameters);
if ($current_field_definition != $new_field_definition) {
$sql2=db_modify_table_field($fieldname, $parameters);
- if ($sql3 == "")
+ if ($sql3 == "") {
$sql3 = "ALTER TABLE `".$name."` ".$sql2;
- else
+ } else {
$sql3 .= ", ".$sql2;
+ }
}
}
}
}
- // Create the index if the index don't exists in database
- // or the definition differ from the current status.
- // Don't create keys if table is new
+ /*
+ * Create the index if the index don't exists in database
+ * or the definition differ from the current status.
+ * Don't create keys if table is new
+ */
if (!$is_new_table) {
foreach ($structure["indexes"] AS $indexname => $fieldnames) {
if (isset($database[$name]["indexes"][$indexname])) {
@@ -367,10 +385,11 @@ function db_create_index($indexname, $fieldnames, $method="ADD") {
if ($names != "")
$names .= ",";
- if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
+ if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
$names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
- else
+ } else {
$names .= "`".dbesc($fieldname)."`";
+ }
}
if ($indexname == "PRIMARY") {
@@ -383,8 +402,9 @@ function db_create_index($indexname, $fieldnames, $method="ADD") {
}
function db_index_suffix($charset, $reduce = 0) {
- if ($charset != "utf8mb4")
+ if ($charset != "utf8mb4") {
return "";
+ }
// On utf8mb4 indexes can only have a length of 191
$indexlength = 191 - $reduce;
@@ -1573,9 +1593,6 @@ function dbstructure_run(&$argv, &$argc) {
echo "dumpsql dump database schema\n";
return;
-
-
-
}
if (array_search(__file__,get_included_files())===0){
From 9c81b4948eeb22a51b28dbe67896b7e019809544 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 22 Dec 2016 16:58:50 +0100
Subject: [PATCH 67/68] Coding convention applied: - added curly braces - added
space between if/foreach and brace - avoided 2 return statements (true/false)
by replacing them with just one - added TODO for applying above to all
findings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
include/items.php | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/include/items.php b/include/items.php
index e91c7088a..10afc28c0 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1257,8 +1257,9 @@ function tag_deliver($uid,$item_id) {
$c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1",
intval($u[0]['uid'])
);
- if (! count($c))
+ if (! count($c)) {
return;
+ }
// also reset all the privacy bits to the forum default permissions
@@ -1266,8 +1267,8 @@ function tag_deliver($uid,$item_id) {
$forum_mode = (($prvgroup) ? 2 : 1);
- q("update item set wall = 1, origin = 1, forum_mode = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
- `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d",
+ q("UPDATE `item` SET `wall` = 1, `origin` = 1, `forum_mode` = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
+ `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `id` = %d",
intval($forum_mode),
dbesc($c[0]['name']),
dbesc($c[0]['url']),
@@ -1318,7 +1319,7 @@ function tgroup_check($uid,$item) {
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if ($cnt) {
- foreach($matches as $mtch) {
+ foreach ($matches as $mtch) {
if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
$mention = true;
logger('tgroup_check: mention found: ' . $mtch[2]);
@@ -1326,13 +1327,12 @@ function tgroup_check($uid,$item) {
}
}
- if (! $mention)
+ if (! $mention) {
return false;
+ }
- if ((! $community_page) && (! $prvgroup))
- return false;
-
- return true;
+ /// @TODO Combines both return statements into one
+ return (($community_page) || ($prvgroup));
}
/*
@@ -1344,15 +1344,16 @@ function tgroup_check($uid,$item) {
assumes the update has been seen before and should be ignored.
*/
function edited_timestamp_is_newer($existing, $update) {
- if (!x($existing,'edited') || !$existing['edited']) {
- return true;
- }
- if (!x($update,'edited') || !$update['edited']) {
- return false;
- }
- $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']);
- $update_edited = datetime_convert('UTC', 'UTC', $update['edited']);
- return (strcmp($existing_edited, $update_edited) < 0);
+ if (!x($existing,'edited') || !$existing['edited']) {
+ return true;
+ }
+ if (!x($update,'edited') || !$update['edited']) {
+ return false;
+ }
+
+ $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']);
+ $update_edited = datetime_convert('UTC', 'UTC', $update['edited']);
+ return (strcmp($existing_edited, $update_edited) < 0);
}
/**
From 31cd3fb33c088573a1b240a2b982c781197bab79 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?=
Date: Thu, 22 Dec 2016 17:12:34 +0100
Subject: [PATCH 68/68] Coding convention continued: - added curly braces -
added spaces between if/foreach and brace - made code block look nicer
(spaces added, tabs replaced by space) - added TODO
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Roland Häder
---
mod/common.php | 71 +++++++++++++++++++++++++++-----------------------
1 file changed, 39 insertions(+), 32 deletions(-)
diff --git a/mod/common.php b/mod/common.php
index 0be8f1d14..9657ac36d 100644
--- a/mod/common.php
+++ b/mod/common.php
@@ -19,23 +19,27 @@ function common_content(&$a) {
return;
}
- if($cmd !== 'loc' && $cmd != 'rem')
+ if ($cmd !== 'loc' && $cmd != 'rem') {
return;
+ }
- if(! $uid)
+ if (! $uid) {
return;
+ }
- if($cmd === 'loc' && $cid) {
+ if ($cmd === 'loc' && $cid) {
$c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($cid),
intval($uid)
);
+ /// @TODO Handle $c with dbm::is_result()
$a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
} else {
$c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
intval($uid)
);
+ /// @TODO Handle $c with dbm::is_result()
$vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
'$name' => htmlentities($c[0]['name']),
@@ -43,8 +47,9 @@ function common_content(&$a) {
'url' => 'contacts/' . $cid
));
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside')) {
$a->page['aside'] = '';
+ }
$a->page['aside'] .= $vcard_widget;
}
@@ -69,29 +74,29 @@ function common_content(&$a) {
}
}
-
-
- if($cid == 0 && $zcid == 0)
+ if ($cid == 0 && $zcid == 0) {
return;
+ }
-
- if($cid)
+ if ($cid) {
$t = count_common_friends($uid, $cid);
- else
+ } else {
$t = count_common_friends_zcid($uid, $zcid);
+ }
- if(count($t))
+ if (count($t)) {
$a->set_pager_total($t);
- else {
+ } else {
notice( t('No contacts in common.') . EOL);
return $o;
}
- if($cid)
+ if ($cid) {
$r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
- else
+ } else {
$r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
+ }
if (! dbm::is_result($r)) {
@@ -105,39 +110,41 @@ function common_content(&$a) {
//get further details of the contact
$contact_details = get_contact_details_by_url($rr['url'], $uid);
- // $rr[id] is needed to use contact_photo_menu()
- $rr[id] = $rr[cid];
+ // $rr['id'] is needed to use contact_photo_menu()
+ /// @TODO Adding '/" here avoids E_NOTICE on missing constants
+ $rr['id'] = $rr['cid'];
$photo_menu = '';
$photo_menu = contact_photo_menu($rr);
$entry = array(
- 'url' => $rr['url'],
- 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
- 'name' => $contact_details['name'],
- 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
- 'img_hover' => htmlentities($contact_details['name']),
- 'details' => $contact_details['location'],
- 'tags' => $contact_details['keywords'],
- 'about' => $contact_details['about'],
- 'account_type' => account_type($contact_details),
- 'network' => network_to_name($contact_details['network'], $contact_details['url']),
- 'photo_menu' => $photo_menu,
- 'id' => ++$id,
+ 'url' => $rr['url'],
+ 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
+ 'name' => $contact_details['name'],
+ 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
+ 'img_hover' => htmlentities($contact_details['name']),
+ 'details' => $contact_details['location'],
+ 'tags' => $contact_details['keywords'],
+ 'about' => $contact_details['about'],
+ 'account_type' => account_type($contact_details),
+ 'network' => network_to_name($contact_details['network'], $contact_details['url']),
+ 'photo_menu' => $photo_menu,
+ 'id' => ++$id,
);
$entries[] = $entry;
}
- if($cmd === 'loc' && $cid && $uid == local_user()) {
+ if ($cmd === 'loc' && $cid && $uid == local_user()) {
$tab_str = contacts_tab($a, $cid, 4);
- } else
+ } else {
$title = t('Common Friends');
+ }
$tpl = get_markup_template('viewcontact_template.tpl');
$o .= replace_macros($tpl,array(
- '$title' => $title,
- '$tab_str' => $tab_str,
+ '$title' => $title,
+ '$tab_str' => $tab_str,
'$contacts' => $entries,
'$paginate' => paginate($a),
));