merger from branch luminous (~r11576)

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@11580 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2012-10-04 05:04:23 +00:00
commit 51bb8d1985
91 changed files with 1157 additions and 703 deletions

View file

@ -235,16 +235,19 @@ class Context {
$oMemberModel = &getModel('member');
$oMemberController = &getController('member');
// if signed in, validate it.
if($oMemberModel->isLogged()) {
$oMemberController->setSessionInfo();
}
elseif($_COOKIE['xeak']) { // check auto sign-in
$oMemberController->doAutologin();
}
if($oMemberController && $oMemberModel)
{
// if signed in, validate it.
if($oMemberModel->isLogged()) {
$oMemberController->setSessionInfo();
}
elseif($_COOKIE['xeak']) { // check auto sign-in
$oMemberController->doAutologin();
}
$this->set('is_logged', $oMemberModel->isLogged() );
$this->set('logged_info', $oMemberModel->getLoggedInfo() );
$this->set('is_logged', $oMemberModel->isLogged() );
$this->set('logged_info', $oMemberModel->getLoggedInfo() );
}
}
// load common language file
@ -726,17 +729,49 @@ class Context {
$flag = true;
foreach($obj as $key=>$val) {
if(!$val) continue;
if($val && iconv($charset,$charset,$val)!=$val) $flag = false;
if(!is_array($val) && iconv($charset,$charset,$val)!=$val) $flag = false;
else if(is_array($val))
{
$userdata = array('charset1'=>$charset,'charset2'=>$charset,'useFlag'=>true);
Context::arrayConvWalkCallback($val,null,$userdata);
if($userdata['returnFlag'] === false) $flag = false;
}
}
if($flag) {
if($charset == 'UTF-8') return $obj;
foreach($obj as $key => $val) $obj->{$key} = iconv($charset,'UTF-8',$val);
foreach($obj as $key => $val)
{
if(!is_array($val)) $obj->{$key} = iconv($charset,'UTF-8',$val);
else Context::arrayConvWalkCallback($val,null,array($charset,'UTF-8'));
}
return $obj;
}
}
return $obj;
}
/**
* Convert array type variables into UTF-8
*
* @param mixed $val
* @param string $key
* @param mixed $userdata charset1 charset2 useFlag retrunFlag
* @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5
* @return object converted object
*/
function arrayConvWalkCallback(&$val, $key = null, &$userdata)
{
if (is_array($val)) array_walk($val,'Context::arrayConvWalkCallback',&$userdata);
else
{
if(!$userdata['useFlag']) $val = iconv($userdata['charset1'],$userdata['charset2'],$val);
else
{
if(iconv($charset,$charset,$val)!=$val) $userdata['returnFlag'] = (bool)false;
}
}
}
/**
* Convert strings into UTF-8
@ -810,6 +845,13 @@ class Context {
elseif($this->getRequestMethod()=='POST'&&isset($_POST[$key])) $set_to_vars = true;
else $set_to_vars = false;
if($set_to_vars)
{
$val = preg_replace('/<\?/i', '', $val);
$val = preg_replace('/<\%/i', '', $val);
$val = preg_replace('/<script\s+language\s*=\s*("|\')php("|\')\s*>/ism', '', $val);
}
$this->set($key, $val, $set_to_vars);
}
}
@ -1090,7 +1132,9 @@ class Context {
'act.mid' =>$is_feed?"$mid/$act":'',
'act.mid.vid'=>$is_feed?"$vid/$mid/$act":'',
'act.document_srl.key' =>($act=='trackback')?"$srl/$key/$act":'',
'act.document_srl.key.vid'=>($act=='trackback')?"$vid/$srl/$key/$act":''
'act.document_srl.key.mid'=>($act=='trackback')?"$mid/$srl/$key/$act":'',
'act.document_srl.key.vid'=>($act=='trackback')?"$vid/$srl/$key/$act":'',
'act.document_srl.key.mid.vid'=>($act=='trackback')?"$vid/$mid/$srl/$key/$act":''
);
$query = $target_map[$target];
@ -1102,7 +1146,7 @@ class Context {
if(is_array($val) && count($val)) {
foreach($val as $k => $v) $queries[] = $key.'['.$k.']='.urlencode($v);
} else {
$queries[] = $key.'='.urlencode($val);
$queries[] = $key.'='.@urlencode($val);
}
}
if(count($queries)) $query = 'index.php?'.implode('&', $queries);

View file

@ -407,6 +407,7 @@
*/
function executeQuery($query_id, $args = NULL, $arg_columns = NULL) {
static $cache_file = array();
if(!$query_id) return new Object(-1, 'msg_invalid_queryid');
if(!$this->db_type) return;
@ -414,7 +415,7 @@
$this->query_id = $query_id;
if(!isset($cache_file[$query_id])) {
if(!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id])) {
$id_args = explode('.', $query_id);
if(count($id_args) == 2) {
$target = 'modules';

View file

@ -455,7 +455,7 @@
if ($notnull) $query .= "not null ";
$this->_query ($query);
return $this->_query ($query);
}
/**

View file

@ -310,7 +310,7 @@
if($default) $query .= sprintf(" default '%s' ", $default);
if($notnull) $query .= " not null ";
$this->_query($query);
return $this->_query($query);
}
/**

View file

@ -256,7 +256,7 @@ class DBMysql extends DB {
if($default) $query .= sprintf(" default '%s' ", $default);
if($notnull) $query .= " not null ";
$this->_query($query);
return $this->_query($query);
}
/**

View file

@ -370,6 +370,32 @@ class FileHandler {
* @return string If success, the content of the target file. Otherwise: none
**/
function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array()) {
if(version_compare(PHP_VERSION, '5.0.0', '>='))
{
return include _XE_PATH_ . 'classes/file/getRemoteResourcePHP5.php';
}
else
{
return FileHandler::_getRemoteResource($url, $boyd, $timeout, $mehtod, $conent_type, $headers, $cookies, $post_data);
}
}
/**
* Return remote file's content via HTTP
*
* If the target is moved (when return code is 300~399), this function follows the location specified response header.
*
* @param string $url The address of the target file
* @param string $body HTTP request body
* @param int $timeout Connection timeout
* @param string $method GET/POST
* @param string $content_type Content type header of HTTP request
* @param string[] $headers Headers key vaule array.
* @param string[] $cookies Cookies key value array.
* @param string $post_data Request arguments array for POST method
* @return string If success, the content of the target file. Otherwise: none
**/
function _getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array()) {
requirePear();
require_once('HTTP/Request.php');

View file

@ -0,0 +1,9 @@
<?php
try
{
return self::_getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data);
}
catch(Exception $e)
{
return NULL;
}

View file

@ -99,7 +99,29 @@
$pathInfo = pathinfo($args[0]);
$file->fileName = $pathInfo['basename'];
$file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
$file->fileRealPath = FileHandler::getRealPath($pathInfo['dirname']);
$file->fileExtension = strtolower($pathInfo['extension']);
$file->fileNameNoExt = preg_replace("/\.{$file->fileExtension}$/", '', $file->fileName);
// Remove .min
$file->fileNameNoExt = preg_replace("/\.min$/", '', $file->fileNameNoExt);
$file->fileName = $file->keyName = "{$file->fileNameNoExt}.{$file->fileExtension}";
// if no debug mode load minified file
if(!__DEBUG__)
{
$tmp = "{$file->fileNameNoExt}.min.{$file->fileExtension}";
if(file_exists("{$file->fileRealPath}/{$tmp}"))
{
$file->fileName = $tmp;
$file->useMin = TRUE;
}
}
if(!$file->useMin && !file_exists("{$file->fileRealPath}/{$file->fileName}"))
{
$file->fileName = "{$file->fileNameNoExt}.min.{$file->fileExtension}";
}
if (strpos($file->filePath, '://') == false)
{
@ -121,7 +143,7 @@
if (!$file->media) $file->media = 'all';
$map = &$this->cssMap;
$mapIndex = &$this->cssMapIndex;
$key = $file->filePath . $file->fileName . "\t" . $file->targetIe . "\t" . $file->media;
$key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media;
$this->_arrangeCssIndex($pathInfo['dirname'], $file);
}
@ -138,11 +160,11 @@
$map = &$this->jsHeadMap;
$mapIndex = &$this->jsHeadMapIndex;
}
$key = $file->filePath . $file->fileName . "\t" . $file->targetIe;
$key = $file->filePath . $file->keyName . "\t" . $file->targetIe;
}
(is_null($file->index))?$file->index=0:$file->index=$file->index;
if (!isset($map[$file->index][$key]) || $mapIndex[$key] != $file->index)
if (!isset($map[$file->index][$key]) || $mapIndex[$key] > $file->index)
{
$this->unloadFile($args[0], $args[2], $args[1]);
$map[$file->index][$key] = $file;

View file

@ -373,6 +373,20 @@
{
$oModule = &$this->getModuleInstance($forward->module, $type, $kind);
}
if(!is_object($oModule)) {
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
$oMessageObject->setError(-1);
$oMessageObject->setMessage('msg_module_is_not_exists');
$oMessageObject->dispMessage();
if($this->httpStatusCode)
{
$oMessageObject->setHttpStatusCode($this->httpStatusCode);
}
return $oMessageObject;
}
$xml_info = $oModuleModel->getModuleActionXml($forward->module);
$oMemberModel = &getModel('member');
@ -698,6 +712,7 @@
if(__DEBUG__==3) $start_time = getMicroTime();
$parent_module = $module;
$kind = strtolower($kind);
$type = strtolower($type);
@ -714,10 +729,13 @@
// if there is no instance of the module in global variable, create a new one
if(!isset($GLOBALS['_loaded_module'][$module][$type][$kind]))
{
$parent_module = $module;
ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
$class_path = ModuleHandler::getModulePath($module);
if(!is_dir(FileHandler::getRealPath($class_path))) return NULL;
if($extend_module && (!is_readable($high_class_file) || !is_readable($class_file)))
{
$module = $parent_module;
ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
}
// Get base class name and load the file contains it
if(!class_exists($module)) {
@ -726,23 +744,6 @@
require_once($high_class_file);
}
// Get the object's name
$types = explode(' ', 'view controller model api wap mobile class');
if(!in_array($type, $types)) $type = $types[0];
if($type == 'class') {
$instance_name = '%s';
$class_file = '%s%s.%s.php';
} elseif($kind == 'admin' && array_search($type, $types) < 3) {
$instance_name = '%sAdmin%s';
$class_file = '%s%s.admin.%s.php';
} else{
$instance_name = '%s%s';
$class_file = '%s%s.%s.php';
}
$instance_name = sprintf($instance_name, $module, ucfirst($type));
$class_file = sprintf($class_file, $class_path, $module, $type);
$class_file = FileHandler::getRealPath($class_file);
// Get the name of the class file
if(!is_readable($class_file)) return NULL;
@ -779,6 +780,31 @@
return $GLOBALS['_loaded_module'][$module][$type][$kind];
}
function _getModuleFilePath($module, $type, $kind, &$classPath, &$highClassFile, &$classFile, &$instanceName)
{
$classPath = ModuleHandler::getModulePath($module);
$highClassFile = sprintf('%s%s%s.class.php', _XE_PATH_,$classPath, $module);
$highClassFile = FileHandler::getRealPath($highClassFile);
$types = explode(' ', 'view controller model api wap mobile class');
if(!in_array($type, $types)) $type = $types[0];
if($type == 'class') {
$instanceName = '%s';
$classFile = '%s%s.%s.php';
} elseif($kind == 'admin' && array_search($type, $types) < 3) {
$instanceName = '%sAdmin%s';
$classFile = '%s%s.admin.%s.php';
} else{
$instanceName = '%s%s';
$classFile = '%s%s.%s.php';
}
$instanceName = sprintf($instanceName, $module, ucfirst($type));
$classFile = sprintf($classFile, $classPath, $module, $type);
$classFile = FileHandler::getRealPath($classFile);
}
/**
* call a trigger
* @param string $trigger_name trigger's name to call

View file

@ -1,5 +1,5 @@
<?php
include "phphtmlparser/src/htmlparser.inc";
include _XE_PATH_ . 'classes/security/phphtmlparser/src/htmlparser.inc';
class EmbedFilter
{

View file

@ -164,20 +164,7 @@ class Argument {
*/
function _escapeStringValue($value) {
// Remove non-utf8 chars.
$regex = <<<'END'
/
(
(?:
[\x00-\x7F] # single-byte sequences 0xxxxxxx
|[\xC0-\xDF][\x80-\xBF] # double-byte sequences 110xxxxx 10xxxxxx
|[\xE0-\xEF][\x80-\xBF]{2} # triple-byte sequences 1110xxxx 10xxxxxx * 2
)+
)
|([\xF0-\xF7][\x80-\xBF]{3}) # quadruple-byte sequence 11110xxx 10xxxxxx * 3
|([\x80-\xBF]) # invalid byte in range 10000000 - 10111111
|([\xC0-\xFF]) # invalid byte in range 11000000 - 11111111
/x
END;
$regex = '@((?:[\x00-\x7F]|[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}){1,100})|([\xF0-\xF7][\x80-\xBF]{3})|([\x80-\xBF])|([\xC0-\xFF])@x';
$value = preg_replace_callback($regex, array($this, 'utf8Replacer'), $value);
$db = &DB::getInstance();