mirror of
https://github.com/e107inc/e107.git
synced 2025-06-28 20:03:22 +02:00
Work on override class and multi-site support.
This commit is contained in:
@ -1013,6 +1013,61 @@ function update_706_to_800($type='')
|
||||
|
||||
//-- Media-manger import --------------------------------------------------
|
||||
|
||||
if(!is_dir(e_MEDIA))
|
||||
{
|
||||
mkdir(e_MEDIA,0755);
|
||||
}
|
||||
if(!is_dir(e_SYSTEM))
|
||||
{
|
||||
mkdir(e_SYSTEM,0755);
|
||||
}
|
||||
if(!is_dir(e_CACHE))
|
||||
{
|
||||
mkdir(e_CACHE,0755);
|
||||
}
|
||||
if(!is_dir(e_CACHE_CONTENT))
|
||||
{
|
||||
mkdir(e_CACHE_CONTENT,0755);
|
||||
}
|
||||
if(!is_dir(e_CACHE_IMAGE))
|
||||
{
|
||||
mkdir(e_CACHE_IMAGE,0755);
|
||||
}
|
||||
if(!is_dir(e_CACHE_DB))
|
||||
{
|
||||
mkdir(e_CACHE_DB,0755);
|
||||
}
|
||||
if(!is_dir(e_LOG))
|
||||
{
|
||||
mkdir(e_LOG,0755);
|
||||
}
|
||||
if(!is_dir(e_BACKUP))
|
||||
{
|
||||
mkdir(e_BACKUP,0755);
|
||||
}
|
||||
|
||||
|
||||
$root_media = str_replace(basename(e_MEDIA)."/","",e_MEDIA);
|
||||
$user_media_dirs = array("images","avatars","files","temp","videos","icons");
|
||||
|
||||
// check for old paths and rename.
|
||||
if(is_dir($root_media."images") || is_dir($root_media."temp"))
|
||||
{
|
||||
foreach($user_media_dirs as $md)
|
||||
{
|
||||
@rename($root_media.$md,e_MEDIA.$md);
|
||||
}
|
||||
}
|
||||
|
||||
// create sub-directories if they do not exist.
|
||||
if(!is_dir(e_MEDIA."images") || !is_dir(e_MEDIA."temp"))
|
||||
{
|
||||
foreach($user_media_dirs as $md)
|
||||
{
|
||||
mkdir(e_MEDIA.$md);
|
||||
}
|
||||
}
|
||||
|
||||
$med = e107::getMedia();
|
||||
|
||||
// Media Category Update
|
||||
|
@ -101,7 +101,7 @@ class _system_cron
|
||||
$sql = e107::getDb();
|
||||
$dbtable = $mySQLdefaultdb; // TODO - retrieve this in a better way. (without including e107_config)
|
||||
|
||||
$backupFile = e_SYSTEM."backups/".SITENAME."_".date("Y-m-d-H-i-s").".sql";
|
||||
$backupFile = e_BACKUP.SITENAME."_".date("Y-m-d-H-i-s").".sql";
|
||||
$result = mysql_list_tables($dbtable);
|
||||
|
||||
while ($tab = mysql_fetch_array($result, MYSQL_NUM))
|
||||
|
@ -45,6 +45,7 @@ class e107
|
||||
public $https_path;
|
||||
public $base_path;
|
||||
public $file_path;
|
||||
public $site_path;
|
||||
public $relative_base_path;
|
||||
public $_ip_cache;
|
||||
public $_host_name_cache;
|
||||
@ -311,12 +312,15 @@ class e107
|
||||
// Do some security checks/cleanup, prepare the environment
|
||||
$this->prepare_request();
|
||||
|
||||
// Set default folder (and override paths) if missing from e107_config.php
|
||||
$this->setDirs($e107_paths, $e107_config_override);
|
||||
|
||||
// mysql connection info
|
||||
$this->e107_config_mysql_info = $e107_config_mysql_info;
|
||||
|
||||
// unique folder for e_MEDIA - support for multiple websites from single-install. Must be set before setDirs()
|
||||
$this->site_path = substr(md5($e107_config_mysql_info['mySQLdefaultdb'].".".$e107_config_mysql_info['mySQLprefix']),0,10);
|
||||
|
||||
// Set default folder (and override paths) if missing from e107_config.php
|
||||
$this->setDirs($e107_paths, $e107_config_override);
|
||||
|
||||
// various constants - MAGIC_QUOTES_GPC, MPREFIX, ...
|
||||
$this->set_constants();
|
||||
|
||||
@ -386,6 +390,9 @@ class e107
|
||||
'WEB_DIRECTORY' => 'e107_web/',
|
||||
), (array) $override_root);
|
||||
|
||||
$ret['MEDIA_DIRECTORY'] .= $this->site_path."/"; // multisite support.
|
||||
$ret['SYSTEM_DIRECTORY'] .= $this->site_path."/"; // multisite support.
|
||||
|
||||
if($return_root) return $ret;
|
||||
|
||||
$ret['HELP_DIRECTORY'] = $ret['DOCS_DIRECTORY'].'help/';
|
||||
@ -398,6 +405,9 @@ class e107
|
||||
$ret['MEDIA_UPLOAD_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'temp/';
|
||||
|
||||
$ret['WEB_JS_DIRECTORY'] = $ret['WEB_DIRECTORY'].'js/';
|
||||
|
||||
|
||||
|
||||
$ret['WEB_CSS_DIRECTORY'] = $ret['WEB_DIRECTORY'].'css/';
|
||||
$ret['WEB_IMAGES_DIRECTORY'] = $ret['WEB_DIRECTORY'].'images/';
|
||||
$ret['WEB_PACKS_DIRECTORY'] = $ret['WEB_DIRECTORY'].'packages/';
|
||||
@ -411,6 +421,9 @@ class e107
|
||||
$ret['CACHE_DB_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'db/';
|
||||
|
||||
$ret['LOGS_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'logs/';
|
||||
$ret['BACKUP_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'backup/';
|
||||
|
||||
//TODO create directories which don't exist.
|
||||
|
||||
return $ret;
|
||||
}
|
||||
@ -543,7 +556,23 @@ class e107
|
||||
function getMySQLConfig($for)
|
||||
{
|
||||
$key = 'mySQL'.$for;
|
||||
return (isset($this->e107_config_mysql_info[$key]) ? $this->e107_config_mysql_info[$key] : '');
|
||||
$self = self::getInstance();
|
||||
return (isset($self->e107_config_mysql_info[$key]) ? $self->e107_config_mysql_info[$key] : '');
|
||||
|
||||
// return (isset($this->e107_config_mysql_info[$key]) ? $this->e107_config_mysql_info[$key] : '');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a unique path based on database used. ie. multi-site support from single install.
|
||||
*
|
||||
* @return string
|
||||
* @author
|
||||
*/
|
||||
function getSitePath()
|
||||
{
|
||||
$self = self::getInstance();
|
||||
return $self->site_path;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1178,6 +1207,19 @@ class e107
|
||||
return self::getSingleton('notify', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve override handler singleton object
|
||||
*
|
||||
* @return notify
|
||||
*/
|
||||
public static function getOverride()
|
||||
{
|
||||
return self::getSingleton('override', true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve Language handler singleton object
|
||||
*
|
||||
@ -2327,7 +2369,10 @@ class e107
|
||||
{
|
||||
return $this->e107_dirs[$dir.'_SERVER'];
|
||||
}
|
||||
return e_BASE.$this->e107_dirs[$dir.'_DIRECTORY'];
|
||||
$ret = e_BASE.$this->e107_dirs[$dir.'_DIRECTORY'];
|
||||
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2471,6 +2516,7 @@ class e107
|
||||
define('e_CACHE_DB', $this->get_override_rel('CACHE_DB'));
|
||||
|
||||
define('e_LOG', $this->get_override_rel('LOGS'));
|
||||
define('e_BACKUP', $this->get_override_rel('BACKUP'));
|
||||
|
||||
//
|
||||
// HTTP absolute paths
|
||||
@ -2503,6 +2549,9 @@ class e107
|
||||
define('e_PACK_ABS', $this->get_override_http('WEB_PACKS'));
|
||||
define('e_WEB_IMAGE_ABS', $this->get_override_http('WEB_IMAGES'));
|
||||
|
||||
define('e_JS', $this->get_override_http('WEB_JS')); // ABS Alias
|
||||
define('e_CSS', $this->get_override_http('WEB_CSS')); // ABS Alias
|
||||
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
@ -27,35 +27,105 @@ if (!defined('e107_INIT')) { exit; }
|
||||
* $result=call_user_func($over_func_name, params...);
|
||||
* }
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class override {
|
||||
var $functions = array();
|
||||
var $includes = array();
|
||||
|
||||
function override_function($override, $function, $include) {
|
||||
if ($include) {
|
||||
protected $functions = array();
|
||||
protected $includes = array();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Replace an existing function or class method
|
||||
* @param string|array $override - function name or class::method
|
||||
* @param string|array $function - new function name or class::method
|
||||
* @param $include (optional) - file to include from root dir.
|
||||
* @example e107::getOverride()->replace('secure_image::create_code', 'myclass::mymethod');
|
||||
*/
|
||||
public function replace($override,$function,$include) // Alias with class functionality.
|
||||
{
|
||||
if(is_array($override))
|
||||
{
|
||||
$arr = $override[0]."::".$override[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$arr = $override;
|
||||
}
|
||||
|
||||
$this->override_function($arr, $function, $include);
|
||||
}
|
||||
/**
|
||||
* check if an override exists
|
||||
* @param $override : function name or class object
|
||||
* @param $method : method name when 'class' is used for $override
|
||||
* @return mixed
|
||||
* @example if ($user_func = e107::getOverride()->check($this,'secure_image'))
|
||||
{
|
||||
return call_user_func($user_func);
|
||||
}
|
||||
*/
|
||||
public function check($override,$method='') // alias with check for class object
|
||||
{
|
||||
|
||||
if(vartrue($method))
|
||||
{
|
||||
$class = get_class($override);
|
||||
$override = $class."::".$method;
|
||||
}
|
||||
return $this->override_check($override);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function override_function($override, $function, $include)
|
||||
{
|
||||
if ($include)
|
||||
{
|
||||
$this->includes[$override] = $include;
|
||||
}
|
||||
else if (isset($this->includes[$override])) {
|
||||
else if (isset($this->includes[$override]))
|
||||
{
|
||||
unset($this->includes[$override]);
|
||||
}
|
||||
|
||||
$this->functions[$override] = $function;
|
||||
}
|
||||
|
||||
function override_check($override) {
|
||||
if (isset($this->includes[$override])) {
|
||||
if (file_exists($this->includes[$override])) {
|
||||
|
||||
function override_check($override)
|
||||
{
|
||||
if (isset($this->includes[$override]))
|
||||
{
|
||||
if (file_exists($this->includes[$override]))
|
||||
{
|
||||
include_once($this->includes[$override]);
|
||||
}
|
||||
if (function_exists($this->functions[$override])) {
|
||||
}
|
||||
|
||||
|
||||
$tmp = strpos($this->functions[$override],"::") ? explode("::",$this->functions[$override]) : $this->functions[$override];
|
||||
if(is_array($tmp) && class_exists($tmp[0]))
|
||||
{
|
||||
$cl = new $tmp[0];
|
||||
if(method_exists($cl,$tmp[1]))
|
||||
{
|
||||
return $this->functions[$override];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
if (function_exists($this->functions[$override]))
|
||||
{
|
||||
|
||||
return $this->functions[$override];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,11 @@ class secure_image
|
||||
|
||||
function secure_image()
|
||||
{
|
||||
if ($user_func = e107::getOverride()->check($this,'secure_image'))
|
||||
{
|
||||
return call_user_func($user_func);
|
||||
}
|
||||
|
||||
list($usec, $sec) = explode(" ", microtime());
|
||||
$this->random_number = str_replace(".", "", $sec.$usec);
|
||||
|
||||
@ -49,6 +54,10 @@ class secure_image
|
||||
|
||||
function create_code()
|
||||
{
|
||||
if ($user_func = e107::getOverride()->check($this,'create_code'))
|
||||
{
|
||||
return call_user_func($user_func);
|
||||
}
|
||||
|
||||
$pref = e107::getPref();
|
||||
$sql = e107::getDb();
|
||||
@ -68,6 +77,11 @@ class secure_image
|
||||
|
||||
function verify_code($rec_num, $checkstr)
|
||||
{
|
||||
if ($user_func = e107::getOverride()->check($this,'verify_code'))
|
||||
{
|
||||
return call_user_func($user_func,$rec_num,$checkstr);
|
||||
}
|
||||
|
||||
$sql = e107::getDb();
|
||||
$tp = e107::getParser();
|
||||
|
||||
@ -83,6 +97,11 @@ class secure_image
|
||||
|
||||
function r_image()
|
||||
{
|
||||
if ($user_func = e107::getOverride()->check($this,'r_image'))
|
||||
{
|
||||
return call_user_func($user_func);
|
||||
}
|
||||
|
||||
$code = $this->create_code();
|
||||
return "<img src='".e_HTTP.$this->HANDLERS_DIRECTORY."secure_img_render.php?{$code}' class='icon secure-image' alt='' />";
|
||||
}
|
||||
@ -94,6 +113,11 @@ class secure_image
|
||||
*/
|
||||
function render($qcode)
|
||||
{
|
||||
if ($user_func = e107::getOverride()->check($this,'render'))
|
||||
{
|
||||
return call_user_func($user_func,$qcode);
|
||||
}
|
||||
|
||||
if(!is_numeric($qcode)){ exit; }
|
||||
$recnum = preg_replace('#\D#',"",$qcode);
|
||||
|
||||
|
@ -101,6 +101,9 @@ class e_thumbpage
|
||||
$sql_info = array(); //compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix', 'mySQLcharset');
|
||||
//e107::getInstance()->initCore($e107_paths, $self, $sql_info, varset($e107_CONFIG, array()));
|
||||
$e107 = e107::getInstance();
|
||||
|
||||
$e107->site_path = substr(md5($mySQLdefaultdb.".".$mySQLprefix),0,10);
|
||||
|
||||
$e107->prepare_request();
|
||||
$e107->setDirs($e107_paths, varset($E107_CONFIG, array()));
|
||||
$e107->set_constants();
|
||||
@ -159,6 +162,8 @@ class e_thumbpage
|
||||
$this->_src_path = $path;
|
||||
return true;
|
||||
}
|
||||
|
||||
// echo "path=".$path."<br />";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user