namespace Friendica;
+use Friendica\Core\System;
+use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
+use Friendica\Database\DBM;
-use Cache;
use dba;
-use dbm;
use Detection\MobileDetect;
$hostname = '';
- if (file_exists('.htpreconfig.php')) {
- include '.htpreconfig.php';
+ if (! static::directory_usable($basepath, false)) {
+ throw new Exception('Basepath ' . $basepath . ' isn\'t usable.');
+ }
+
+ $this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR);
+
+ if (file_exists($this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php')) {
+ include $this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php';
}
$this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
$this->hostname = $hostname;
}
- if (! static::directory_usable($basepath, false)) {
- throw new Exception('Basepath ' . $basepath . ' isn\'t usable.');
- }
-
- $this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR);
-
set_include_path(
get_include_path() . PATH_SEPARATOR
. $this->basepath . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR
. $this->basepath . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR
- . $this->basepath . DIRECTORY_SEPARATOR . 'library/langdet' . PATH_SEPARATOR
. $this->basepath);
// Register template engines
$dc = get_declared_classes();
foreach ($dc as $k) {
- if (in_array('ITemplateEngine', class_implements($k))) {
+ if (in_array('Friendica\Render\ITemplateEngine', class_implements($k))) {
$this->register_template_engine($k);
}
}
* @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) {
$this->path = trim($parsed['path'], '\\/');
}
- if (file_exists('.htpreconfig.php')) {
- include '.htpreconfig.php';
+ if (file_exists($this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php')) {
+ include $this->basepath.DIRECTORY_SEPARATOR.'.htpreconfig.php';
}
if (Config::get('config', 'hostname') != '') {
$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?'),
}
$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'];
}
*/
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());
$this->performance[$value] += (float) $duration;
$this->performance['marktime'] += (float) $duration;
- $callstack = $this->callstack();
+ $callstack = System::callstack();
if (!isset($this->callstack[$value][$callstack])) {
// Prevent ugly E_NOTICE
dba::transaction();
$r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));
- if (!dbm::is_result($r)) {
+ if (!DBM::is_result($r)) {
dba::insert('process', array('pid' => getmypid(), 'command' => $command, 'created' => datetime_convert()));
}
dba::commit();
dba::transaction();
$r = q('SELECT `pid` FROM `process`');
- if (dbm::is_result($r)) {
+ if (DBM::is_result($r)) {
foreach ($r AS $process) {
if (!posix_kill($process['pid'], 0)) {
- q('DELETE FROM `process` WHERE `pid` = %d', intval($process['pid']));
+ dba::delete('process', array('pid' => $process['pid']));
}
}
}
* @brief Remove the active process from the "process" table
*/
function end_process() {
- q('DELETE FROM `process` WHERE `pid` = %d', intval(getmypid()));
- }
-
- /**
- * @brief Returns a string with a callstack. Can be used for logging.
- *
- * @return string
- */
- function callstack($depth = 4) {
- $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $depth + 2);
-
- // We remove the first two items from the list since they contain data that we don't need.
- array_shift($trace);
- array_shift($trace);
-
- $callstack = array();
- foreach ($trace AS $func) {
- $callstack[] = $func['function'];
- }
-
- return implode(', ', $callstack);
+ dba::delete('process', array('pid' => getmypid()));
}
function get_useragent() {
}
}
- $processlist = dbm::processlist();
+ $processlist = DBM::processlist();
if ($processlist['list'] != '') {
logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG);