X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FApp.php;h=a5c6f34227e7216713301712736912d6bb89c691;hb=5adfeb0bd5fed2f793332056c03bb7c043d5fc69;hp=f6b568ae8ac2c59b5c3e532ef81f8eacce318740;hpb=9c0d2c31e87a73f157b360c518eb059e9a2507de;p=friendica.git diff --git a/src/App.php b/src/App.php index f6b568ae8a..a5c6f34227 100644 --- a/src/App.php +++ b/src/App.php @@ -6,6 +6,7 @@ use Friendica\Core\Config; use Friendica\Core\PConfig; use Cache; +use dba; use dbm; use Detection\MobileDetect; @@ -100,6 +101,7 @@ class App { */ public $template_engine_instance = array(); public $process_id; + public $queue; private $ldelim = array( 'internal' => '', 'smarty3' => '{{' @@ -326,7 +328,27 @@ class App { $basepath = $_SERVER['PWD']; } - return $basepath; + return self::realpath($basepath); + } + + /** + * @brief Returns a normalized file path + * + * This is a wrapper for the "realpath" function. + * That function cannot detect the real path when some folders aren't readable. + * Since this could happen with some hosters we need to handle this. + * + * @param string $path The path that is about to be normalized + * @return string normalized path - when possible + */ + public static function realpath($path) { + $normalized = realpath($path); + + if (!is_bool($normalized)) { + return $normalized; + } else { + return $path; + } } function get_scheme() { @@ -348,11 +370,6 @@ class App { * @return string Friendica server base URL */ function get_baseurl($ssl = false) { - // Is the function called statically? - if (!(isset($this) && get_class($this) == __CLASS__)) { - return self::$a->get_baseurl($ssl); - } - $scheme = $this->scheme; if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) { @@ -499,7 +516,7 @@ class App { $tpl = get_markup_template('head.tpl'); $this->page['htmlhead'] = replace_macros($tpl, array( - '$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!! + '$baseurl' => $this->get_baseurl(), '$local_user' => local_user(), '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION, '$delitem' => t('Delete this item?'), @@ -519,7 +536,7 @@ class App { } $tpl = get_markup_template('end.tpl'); $this->page['end'] = replace_macros($tpl, array( - '$baseurl' => $this->get_baseurl() // FIXME for z_path!!!! + '$baseurl' => $this->get_baseurl() )) . $this->page['end']; } @@ -560,11 +577,6 @@ class App { */ function remove_baseurl($orig_url) { - // Is the function called statically? - if (!(isset($this) && get_class($this) == __CLASS__)) { - return self::$a->remove_baseurl($orig_url); - } - // Remove the hostname from the url if it is an internal link $nurl = normalise_link($orig_url); $base = normalise_link($this->get_baseurl()); @@ -691,20 +703,20 @@ class App { $this->remove_inactive_processes(); - q('START TRANSACTION'); + dba::transaction(); $r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid())); if (!dbm::is_result($r)) { - q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')", intval(getmypid()), dbesc($command), dbesc(datetime_convert())); + dba::insert('process', array('pid' => getmypid(), 'command' => $command, 'created' => datetime_convert())); } - q('COMMIT'); + dba::commit(); } /** * @brief Remove inactive processes */ function remove_inactive_processes() { - q('START TRANSACTION'); + dba::transaction(); $r = q('SELECT `pid` FROM `process`'); if (dbm::is_result($r)) { @@ -714,7 +726,7 @@ class App { } } } - q('COMMIT'); + dba::commit(); } /** @@ -738,7 +750,11 @@ class App { $callstack = array(); foreach ($trace AS $func) { - $callstack[] = $func['function']; + if (!empty($func['class'])) { + $callstack[] = $func['class'].'::'.$func['function']; + } else { + $callstack[] = $func['function']; + } } return implode(', ', $callstack);