1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 12:20:44 +02:00

Added basic support for CLI.

This commit is contained in:
CaMer0n
2008-01-21 03:54:10 +00:00
parent 02bc133676
commit 157bfd0ea0
2 changed files with 75 additions and 32 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/class2.php,v $
| $Revision: 1.44 $
| $Date: 2008-01-16 10:53:57 $
| $Revision: 1.45 $
| $Date: 2008-01-21 03:54:10 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -49,10 +49,12 @@ $oblev_before_start = ob_get_level();
//
// B: Remove all output buffering
//
while (@ob_end_clean()); // destroy all ouput buffering
ob_start(); // start our own.
$oblev_at_start = ob_get_level(); // preserve when destroying globals in step C
if(!$_E107['cli'])
{
while (@ob_end_clean()); // destroy all ouput buffering
ob_start(); // start our own.
$oblev_at_start = ob_get_level(); // preserve when destroying globals in step C
}
//
// C: Find out if register globals is enabled and destroy them if so
// (DO NOT use the value of any variables before this point! They could have been set by the user)
@@ -130,7 +132,7 @@ if(isset($retrieve_prefs) && is_array($retrieve_prefs)) {
define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? TRUE : FALSE));
// Define the domain name and subdomain name.
if(is_numeric(str_replace(".","",$_SERVER['HTTP_HOST']))){
if($_SERVER['HTTP_HOST'] && is_numeric(str_replace(".","",$_SERVER['HTTP_HOST']))){
$srvtmp = ""; // Host is an IP address.
}else{
$srvtmp = explode(".",$_SERVER['HTTP_HOST']);
@@ -1517,6 +1519,20 @@ class error_handler {
//
// This is initialized before the current debug level is known
//
global $_E107;
if($_E107['debug'])
{
$this->debug = true;
error_reporting(E_ALL);
return;
}
if($_E107['cli'])
{
error_reporting(E_ALL ^ E_NOTICE);
return;
}
if ((isset($_SERVER['QUERY_STRING']) && strpos($_SERVER['QUERY_STRING'], 'debug=') !== FALSE) || isset($_COOKIE['e107_debug_level'])) {
$this->debug = true;
error_reporting(E_ALL);

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
| $Revision: 1.15 $
| $Date: 2008-01-16 22:18:20 $
| $Author: e107steved $
| $Revision: 1.16 $
| $Date: 2008-01-21 03:54:10 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -56,12 +56,17 @@ class e107{
function set_paths(){
global $DOWNLOADS_DIRECTORY, $ADMIN_DIRECTORY, $IMAGES_DIRECTORY, $THEMES_DIRECTORY, $PLUGINS_DIRECTORY,
$FILES_DIRECTORY, $HANDLERS_DIRECTORY, $LANGUAGES_DIRECTORY, $HELP_DIRECTORY, $CACHE_DIRECTORY,
$NEWSIMAGES_DIRECTORY, $CUSTIMAGES_DIRECTORY, $UPLOADS_DIRECTORY;
$NEWSIMAGES_DIRECTORY, $CUSTIMAGES_DIRECTORY, $UPLOADS_DIRECTORY,$_E107;
$path = ""; $i = 0;
while (!file_exists("{$path}class2.php")) {
$path .= "../";
$i++;
if(!$_E107['cli'])
{
while (!file_exists("{$path}class2.php"))
{
$path .= "../";
$i++;
}
}
if($_SERVER['PHP_SELF'] == "") { $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME']; }
@@ -69,7 +74,8 @@ class e107{
$http_path = explode("/", $http_path);
$http_path = array_reverse($http_path);
$j = 0;
while ($j < $i) {
while ($j < $i)
{
unset($http_path[$j]);
$j++;
}
@@ -77,10 +83,15 @@ class e107{
$this->server_path = implode("/", $http_path)."/";
$this->server_path = $this->fix_windows_paths($this->server_path);
if ($this->server_path == "//") {
if ($this->server_path == "//")
{
$this->server_path = "/";
}
$this->relative_base_path = $path;
// Absolute file-path of directory containing class2.php
define("e_ROOT", realpath(dirname(__FILE__)."/../")."/");
$this->relative_base_path = (!$_E107['cli']) ? $path : e_ROOT;
$this->http_path = "http://{$_SERVER['HTTP_HOST']}{$this->server_path}";
$this->https_path = "https://{$_SERVER['HTTP_HOST']}{$this->server_path}";
$this->file_path = $path;
@@ -88,9 +99,8 @@ class e107{
if(!defined("e_HTTP") || !defined("e_ADMIN") )
{
define("e_HTTP", $this->server_path);
define("e_BASE", $this->relative_base_path);
define("e_BASE", $this->relative_base_path);
define("e_ROOT",$_SERVER['DOCUMENT_ROOT'].$this->server_path);
//
// HTTP relative paths
//
@@ -115,35 +125,48 @@ class e107{
if(isset($_SERVER['DOCUMENT_ROOT']))
{
define("e_DOCROOT", $_SERVER['DOCUMENT_ROOT']."/");
define("e_DOCROOT", $_SERVER['DOCUMENT_ROOT']."/");
}
else
{
define("e_DOCROOT", false);
define("e_DOCROOT", false);
}
define("e_DOCS_ABS", e_HTTP.$HELP_DIRECTORY);
if($CACHE_DIRECTORY) {
if($CACHE_DIRECTORY)
{
define("e_CACHE", e_BASE.$CACHE_DIRECTORY);
} else {
}
else
{
define("e_CACHE", e_BASE.$FILES_DIRECTORY."cache/");
}
if($NEWSIMAGES_DIRECTORY) {
if($NEWSIMAGES_DIRECTORY)
{
define("e_NEWSIMAGE", e_BASE.$NEWSIMAGES_DIRECTORY);
} else {
}
else
{
define("e_NEWSIMAGE", e_IMAGE."newspost_images/");
}
if($CUSTIMAGES_DIRECTORY) {
if($CUSTIMAGES_DIRECTORY)
{
define("e_CUSTIMAGE", e_BASE.$CUSTIMAGES_DIRECTORY);
} else {
}
else
{
define("e_CUSTIMAGE", e_IMAGE."custom/");
}
if ($DOWNLOADS_DIRECTORY{0} == "/") {
if ($DOWNLOADS_DIRECTORY{0} == "/")
{
define("e_DOWNLOAD", $DOWNLOADS_DIRECTORY);
} else {
}
else
{
define("e_DOWNLOAD", e_BASE.$DOWNLOADS_DIRECTORY);
}
@@ -152,15 +175,19 @@ class e107{
$UPLOADS_DIRECTORY = $FILES_DIRECTORY."public/";
}
if ($UPLOADS_DIRECTORY{0} == "/") {
if ($UPLOADS_DIRECTORY{0} == "/")
{
define("e_UPLOAD", $UPLOADS_DIRECTORY);
} else {
}
else
{
define("e_UPLOAD", e_BASE.$UPLOADS_DIRECTORY);
}
}
}
function fix_windows_paths($path) {
function fix_windows_paths($path)
{
$fixed_path = str_replace(array('\\\\', '\\'), array('/', '/'), $path);
$fixed_path = (substr($fixed_path, 1, 2) == ":/" ? substr($fixed_path, 2) : $fixed_path);
return $fixed_path;