replaced some tabs -> spaces + added curly braces #3254

Signed-off-by: Roland Haeder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-03-23 20:48:48 +01:00
parent f173322539
commit f5227c016d
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78

View file

@ -669,6 +669,7 @@ class App {
if (x($_SERVER,'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
$this->hostname .= ':' . $_SERVER['SERVER_PORT'];
}
/*
* Figure out if we are running at the top of a domain
* or in a sub-directory and adjust accordingly
@ -678,9 +679,11 @@ class App {
if (isset($path) && strlen($path) && ($path != $this->path))
$this->path = $path;
}
}
if ($hostname != "")
if ($hostname != "") {
$this->hostname = $hostname;
}
if (is_array($_SERVER["argv"]) && $_SERVER["argc"]>1 && substr(end($_SERVER["argv"]), 0, 4)=="http" ) {
$this->set_baseurl(array_pop($_SERVER["argv"]) );
@ -1090,6 +1093,7 @@ class App {
* @param string $name
*/
function register_template_engine($class, $name = '') {
/// @TODO Really === and not just == ?
if ($name === "") {
$v = get_class_vars( $class );
if (x($v,"name")) $name = $v['name'];
@ -1111,6 +1115,7 @@ class App {
* @return object Template Engine instance
*/
function template_engine($name = '') {
/// @TODO really type-check included?
if ($name !== "") {
$template_engine = $name;
} else {
@ -1276,27 +1281,26 @@ class App {
* @return bool Is it a known backend?
*/
function is_backend() {
static $backend = array(
"_well_known",
"api",
"dfrn_notify",
"fetch",
"hcard",
"hostxrd",
"nodeinfo",
"noscrape",
"p",
"poco",
"post",
"proxy",
"pubsub",
"pubsubhubbub",
"receive",
"rsd_xml",
"salmon",
"statistics_json",
"xrd",
);
$backend = array();
$backend[] = "_well_known";
$backend[] = "api";
$backend[] = "dfrn_notify";
$backend[] = "fetch";
$backend[] = "hcard";
$backend[] = "hostxrd";
$backend[] = "nodeinfo";
$backend[] = "noscrape";
$backend[] = "p";
$backend[] = "poco";
$backend[] = "post";
$backend[] = "proxy";
$backend[] = "pubsub";
$backend[] = "pubsubhubbub";
$backend[] = "receive";
$backend[] = "rsd_xml";
$backend[] = "salmon";
$backend[] = "statistics_json";
$backend[] = "xrd";
if (in_array($this->module, $backend)) {
return(true);
@ -1404,6 +1408,7 @@ class App {
} else {
proc_close(proc_open($cmdline." &",array(),$foo,dirname(__FILE__)));
}
}
/**
@ -1777,8 +1782,9 @@ function get_guid($size=16, $prefix = "") {
$prefix = hash("crc32", $a->get_hostname());
}
while (strlen($prefix) < ($size - 13))
while (strlen($prefix) < ($size - 13)) {
$prefix .= mt_rand();
}
if ($size >= 24) {
$prefix = substr($prefix, 0, $size - 22);
@ -2175,7 +2181,6 @@ function current_theme(){
}
/// @TODO No final return statement?
}
/**
@ -2258,8 +2263,9 @@ function is_site_admin() {
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
//if(local_user() && x($a->user,'email') && x($a->config,'admin_email') && ($a->user['email'] === $a->config['admin_email']))
if (local_user() && x($a->user,'email') && x($a->config,'admin_email') && in_array($a->user['email'], $adminlist))
if (local_user() && x($a->user,'email') && x($a->config,'admin_email') && in_array($a->user['email'], $adminlist)) {
return true;
}
return false;
}
@ -2275,6 +2281,7 @@ function build_querystring($params, $name=null) {
$ret = "";
foreach ($params as $key => $val) {
if (is_array($val)) {
/// @TODO maybe not compare against null, use is_null()
if ($name == null) {
$ret .= build_querystring($val, $key);
} else {
@ -2282,7 +2289,9 @@ function build_querystring($params, $name=null) {
}
} else {
$val = urlencode($val);
/// @TODO maybe not compare against null, use is_null()
if ($name != null) {
/// @TODO two string concated, can be merged to one
$ret .= $name . "[$key]" . "=$val&";
} else {
$ret .= "$key=$val&";
@ -2304,6 +2313,7 @@ function explode_querystring($query) {
$args = explode('&', substr($query, $arg_st));
foreach ($args as $k => $arg) {
/// @TODO really compare type-safe here?
if ($arg === '') {
unset($args[$k]);
}
@ -2332,7 +2342,9 @@ function curPageURL() {
if ($_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
@ -2344,6 +2356,7 @@ function curPageURL() {
function random_digits($digits) {
$rn = '';
for ($i = 0; $i < $digits; $i++) {
/// @TODO rand() is different to mt_rand() and maybe lesser "random"
$rn .= rand(0,9);
}
return $rn;
@ -2377,6 +2390,7 @@ function get_cachefile($file, $writemode = true) {
}
}
/// @TODO no need to put braces here
return($cachepath);
}
@ -2497,8 +2511,10 @@ function get_temppath() {
if (($temppath != "") AND App::directory_usable($temppath)) {
// To avoid any interferences with other systems we create our own directory
$new_temppath .= "/".$a->get_hostname();
if (!is_dir($new_temppath))
if (!is_dir($new_temppath)) {
/// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
mkdir($new_temppath);
}
if (App::directory_usable($new_temppath)) {
// The new path is usable, we are happy
@ -2519,6 +2535,7 @@ function get_temppath() {
function set_template_engine(App $a, $engine = 'internal') {
/// @note This function is no longer necessary, but keep it as a wrapper to the class method
/// to avoid breaking themes again unnecessarily
/// @TODO maybe output a warning here so the theme developer can see it? PHP won't show such warnings like Java does.
$a->set_template_engine($engine);
}
@ -2617,20 +2634,24 @@ function infinite_scroll_data($module) {
AND ($module == "network") AND ($_GET["mode"] != "minimal")) {
// get the page number
if (is_string($_GET["page"]))
if (is_string($_GET["page"])) {
$pageno = $_GET["page"];
else
} else {
$pageno = 1;
}
$reload_uri = "";
// try to get the uri from which we load the content
foreach ($_GET AS $param => $value)
if (($param != "page") AND ($param != "q"))
foreach ($_GET AS $param => $value) {
if (($param != "page") AND ($param != "q")) {
$reload_uri .= "&" . $param . "=" . urlencode($value);
}
}
if (($a->page_offset != "") AND !strstr($reload_uri, "&offset="))
if (($a->page_offset != "") AND !strstr($reload_uri, "&offset=")) {
$reload_uri .= "&offset=" . urlencode($a->page_offset);
}
$arr = array("pageno" => $pageno, "reload_uri" => $reload_uri);