Procházet zdrojové kódy

Add basepath to App

tags/3.5.2
Hypolite Petovan před 3 roky
rodič
revize
569cd459ec
10 změnil soubory, kde provedl 48 přidání a 27 odebrání
  1. +3
    -2
      include/auth_ejabberd.php
  2. +1
    -1
      include/cli_startup.php
  3. +1
    -1
      include/dbstructure.php
  4. +2
    -2
      include/poller.php
  5. +1
    -1
      include/shadowupdate.php
  6. +1
    -1
      index.php
  7. +36
    -16
      src/App.php
  8. +1
    -1
      util/db_update.php
  9. +1
    -1
      util/maintenance.php
  10. +1
    -1
      util/typo.php

+ 3
- 2
include/auth_ejabberd.php Zobrazit soubor

@@ -49,8 +49,9 @@ require_once("boot.php");

global $a, $db;

if (is_null($a))
$a = new App;
if (is_null($a)) {
$a = new App(dirname(__DIR__));
}

if (is_null($db)) {
@include(".htconfig.php");


+ 1
- 1
include/cli_startup.php Zobrazit soubor

@@ -12,7 +12,7 @@ function cli_startup() {
global $a, $db;

if (is_null($a)) {
$a = new App;
$a = new App(dirname(__DIR__));
}

if (is_null($db)) {


+ 1
- 1
include/dbstructure.php Zobrazit soubor

@@ -1736,7 +1736,7 @@ function dbstructure_run(&$argv, &$argc) {
global $a, $db;

if (is_null($a)) {
$a = new App;
$a = new App(dirname(__DIR__));
}

if (is_null($db)) {


+ 2
- 2
include/poller.php Zobrazit soubor

@@ -19,8 +19,8 @@ require_once("boot.php");
function poller_run($argv, $argc){
global $a, $db;

if(is_null($a)) {
$a = new App;
if (is_null($a)) {
$a = new App(dirname(__DIR__));
}

if(is_null($db)) {


+ 1
- 1
include/shadowupdate.php Zobrazit soubor

@@ -10,7 +10,7 @@ function shadowupdate_run(&$argv, &$argc){
global $a, $db;

if (is_null($a)) {
$a = new App;
$a = new App(dirname(__DIR__));
}

if (is_null($db)) {


+ 1
- 1
index.php Zobrazit soubor

@@ -19,7 +19,7 @@ use Friendica\Core\Config;
require_once 'boot.php';
require_once 'object/BaseObject.php';

$a = new App;
$a = new App(__DIR__);
BaseObject::set_app($a);

// We assume that the index.php is called by a frontend process


+ 36
- 16
src/App.php Zobrazit soubor

@@ -40,6 +40,7 @@ class App {
public $module;
public $pager;
public $strings;
public $basepath;
public $path;
public $hooks;
public $timezone;
@@ -112,8 +113,10 @@ class App {
/**
* @brief App constructor.
*
* @param string $basepath Path to the app base folder
*/
function __construct() {
function __construct($basepath) {
global $default_timezone;
@@ -154,13 +157,6 @@ class App {
startup();
set_include_path(
get_include_path() . PATH_SEPARATOR
. 'include' . PATH_SEPARATOR
. 'library' . PATH_SEPARATOR
. 'library/langdet' . PATH_SEPARATOR
. '.');
$this->scheme = 'http';
if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) ||
@@ -195,6 +191,20 @@ class App {
$this->hostname = $hostname;
}
if (! static::directory_usable($basepath)) {
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);
if (is_array($_SERVER['argv']) && $_SERVER['argc'] > 1 && substr(end($_SERVER['argv']), 0, 4) == 'http') {
$this->set_baseurl(array_pop($_SERVER['argv']));
$_SERVER['argc'] --;
@@ -284,18 +294,28 @@ class App {
self::$a = $this;
}
/**
* @brief Returns the base filesystem path of the App
*
* It first checks for the internal variable, then for DOCUMENT_ROOT and
* finally for PWD
*
* @return string
*/
public static function get_basepath() {
$basepath = get_config('system', 'basepath');
if (isset($this)) {
$basepath = $this->basepath;
}
if ($basepath == '') {
$basepath = dirname(__FILE__);
if (! $basepath) {
$basepath = Config::get('system', 'basepath');
}
if ($basepath == '') {
if (! $basepath && x($_SERVER, 'DOCUMENT_ROOT')) {
$basepath = $_SERVER['DOCUMENT_ROOT'];
}
if ($basepath == '') {
if (! $basepath && x($_SERVER, 'PWD')) {
$basepath = $_SERVER['PWD'];
}
@@ -900,10 +920,10 @@ class App {
return;
}
if (get_config('system', 'proc_windows')) {
$resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, dirname(__FILE__));
if (Config::get('system', 'proc_windows')) {
$resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, $this->get_basepath());
} else {
$resource = proc_open($cmdline . ' &', array(), $foo, dirname(__FILE__));
$resource = proc_open($cmdline . ' &', array(), $foo, $this->get_basepath());
}
if (!is_resource($resource)) {
logger('We got no resource for command ' . $cmdline, LOGGER_DEBUG);


+ 1
- 1
util/db_update.php Zobrazit soubor

@@ -11,7 +11,7 @@ use Friendica\App;
*/
require_once("boot.php");

$a = new App;
$a = new App(dirname(__DIR__));
@include(".htconfig.php");

$lang = get_browser_language();


+ 1
- 1
util/maintenance.php Zobrazit soubor

@@ -5,7 +5,7 @@ use Friendica\Core\Config;

require_once("boot.php");

$a = new App;
$a = new App(dirname(__DIR__));
@include(".htconfig.php");

$lang = get_browser_language();


+ 1
- 1
util/typo.php Zobrazit soubor

@@ -12,7 +12,7 @@ ini_set('log_errors', '0');

include 'boot.php';

$a = new App();
$a = new App(dirname(__DIR__));

if (x($a->config, 'php_path')) {
$phpath = $a->config['php_path'];


Načítá se…
Zrušit
Uložit