mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-26 22:02:13 +09:00
Merge branch 'develop' into feature/pwhash
This commit is contained in:
commit
a837f1e00a
156 changed files with 10370 additions and 658 deletions
|
|
@ -219,7 +219,7 @@ class Context
|
|||
if($this->db_info->use_sitelock == 'Y')
|
||||
{
|
||||
if(is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist;
|
||||
|
||||
|
||||
if(!IpFilter::filter($whitelist))
|
||||
{
|
||||
$title = ($this->db_info->sitelock_title) ? $this->db_info->sitelock_title : 'Maintenance in progress...';
|
||||
|
|
@ -242,18 +242,9 @@ class Context
|
|||
}
|
||||
}
|
||||
|
||||
// check if using rewrite module
|
||||
$this->allow_rewrite = ($this->db_info->use_rewrite == 'Y' ? TRUE : FALSE);
|
||||
|
||||
// If XE is installed, get virtual site information
|
||||
if(self::isInstalled())
|
||||
{
|
||||
// If using rewrite module, initializes router
|
||||
if($this->allow_rewrite)
|
||||
{
|
||||
Router::proc();
|
||||
}
|
||||
|
||||
$oModuleModel = getModel('module');
|
||||
$site_module_info = $oModuleModel->getDefaultMid();
|
||||
|
||||
|
|
@ -372,6 +363,9 @@ class Context
|
|||
$this->lang = &$GLOBALS['lang'];
|
||||
$this->loadLang(_XE_PATH_ . 'common/lang/');
|
||||
|
||||
// check if using rewrite module
|
||||
$this->allow_rewrite = ($this->db_info->use_rewrite == 'Y' ? TRUE : FALSE);
|
||||
|
||||
// set locations for javascript use
|
||||
if($_SERVER['REQUEST_METHOD'] == 'GET')
|
||||
{
|
||||
|
|
@ -486,10 +480,8 @@ class Context
|
|||
$db_info->use_ssl = 'none';
|
||||
$this->set('_use_ssl', $db_info->use_ssl);
|
||||
|
||||
if($db_info->http_port)
|
||||
$self->set('_http_port', $db_info->http_port);
|
||||
if($db_info->https_port)
|
||||
$self->set('_https_port', $db_info->https_port);
|
||||
$self->set('_http_port', ($db_info->http_port) ? $db_info->http_port : NULL);
|
||||
$self->set('_https_port', ($db_info->https_port) ? $db_info->https_port : NULL);
|
||||
|
||||
if(!$db_info->sitelock_whitelist) {
|
||||
$db_info->sitelock_whitelist = '127.0.0.1';
|
||||
|
|
@ -1121,7 +1113,7 @@ class Context
|
|||
{
|
||||
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
|
||||
|
||||
$self->js_callback_func = isset($_GET['xe_js_callback']) ? $_GET['xe_js_callback'] : $_POST['xe_js_callback'];
|
||||
$self->js_callback_func = $self->getJSCallbackFunc();
|
||||
|
||||
($type && $self->request_method = $type) or
|
||||
(strpos($_SERVER['CONTENT_TYPE'], 'json') && $self->request_method = 'JSON') or
|
||||
|
|
@ -1252,19 +1244,75 @@ class Context
|
|||
$xml_obj = $oXml->parse();
|
||||
|
||||
$params = $xml_obj->methodcall->params;
|
||||
unset($params->node_name, $params->attrs);
|
||||
unset($params->node_name, $params->attrs, $params->body);
|
||||
|
||||
if(!count($params))
|
||||
if(!count(get_object_vars($params)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($params as $key => $obj)
|
||||
foreach($params as $key => $val)
|
||||
{
|
||||
$this->set($key, $this->_filterRequestVar($key, $obj->body, 0), TRUE);
|
||||
$this->set($key, $this->_filterXmlVars($key, $val), TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter xml variables
|
||||
*
|
||||
* @param string $key Variable key
|
||||
* @param object $val Variable value
|
||||
* @return mixed filtered value
|
||||
*/
|
||||
function _filterXmlVars($key, $val)
|
||||
{
|
||||
if(is_array($val))
|
||||
{
|
||||
$stack = array();
|
||||
foreach($val as $k => $v)
|
||||
{
|
||||
$stack[$k] = $this->_filterXmlVars($k, $v);
|
||||
}
|
||||
|
||||
return $stack;
|
||||
}
|
||||
|
||||
$body = $this->_filterRequestVar($key, trim($val->body ? $val->body : ''), 0);
|
||||
if($body)
|
||||
{
|
||||
return $body;
|
||||
}
|
||||
|
||||
unset($val->node_name, $val->attrs, $val->body);
|
||||
if(!count(get_object_vars($val)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$stack = new stdClass();
|
||||
foreach($val as $k => $v)
|
||||
{
|
||||
$output = $this->_filterXmlVars($k, $v);
|
||||
if(is_object($v) && $v->attrs->type == 'array')
|
||||
{
|
||||
$output = array($output);
|
||||
}
|
||||
if($k == 'value' && (is_array($v) || $v->attrs->type == 'array'))
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
$stack->{$k} = $output;
|
||||
}
|
||||
|
||||
if(!count(get_object_vars($stack)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return $stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter request variable
|
||||
*
|
||||
|
|
@ -1410,7 +1458,16 @@ class Context
|
|||
function getJSCallbackFunc()
|
||||
{
|
||||
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
|
||||
return $self->js_callback_func;
|
||||
$js_callback_func = isset($_GET['xe_js_callback']) ? $_GET['xe_js_callback'] : $_POST['xe_js_callback'];
|
||||
|
||||
if(!preg_match('/^[a-z0-9\.]+$/i', $js_callback_func))
|
||||
{
|
||||
unset($js_callback_func);
|
||||
unset($_GET['xe_js_callback']);
|
||||
unset($_POST['xe_js_callback']);
|
||||
}
|
||||
|
||||
return $js_callback_func;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1574,9 +1631,7 @@ class Context
|
|||
'act.document_srl.key.mid.vid' => ($act == 'trackback') ? "$vid/$mid/$srl/$key/$act" : ''
|
||||
);
|
||||
|
||||
Router::setMap($target_map);
|
||||
|
||||
$query = Router::makePrettyUrl($target);
|
||||
$query = $target_map[$target];
|
||||
}
|
||||
|
||||
if(!$query)
|
||||
|
|
@ -1612,7 +1667,7 @@ class Context
|
|||
}
|
||||
elseif($_use_ssl == 'optional')
|
||||
{
|
||||
$ssl_mode = ($get_vars['act'] && $self->isExistsSSLAction($get_vars['act'])) ? ENFORCE_SSL : RELEASE_SSL;
|
||||
$ssl_mode = (($self->get('module') === 'admin') || ($get_vars['module'] === 'admin') || (isset($get_vars['act']) && $self->isExistsSSLAction($get_vars['act']))) ? ENFORCE_SSL : RELEASE_SSL;
|
||||
$query = $self->getRequestUri($ssl_mode, $domain) . $query;
|
||||
// no SSL
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,8 +219,8 @@ class HTMLDisplayHandler
|
|||
|
||||
// set icon
|
||||
$oAdminModel = getAdminModel('admin');
|
||||
$favicon_url = $oAdminModel->getFaviconUrl();
|
||||
$mobicon_url = $oAdminModel->getMobileIconUrl();
|
||||
$favicon_url = $oAdminModel->getFaviconUrl(false);
|
||||
$mobicon_url = $oAdminModel->getMobileIconUrl(false);
|
||||
Context::set('favicon_url', $favicon_url);
|
||||
Context::set('mobicon_url', $mobicon_url);
|
||||
|
||||
|
|
@ -398,6 +398,7 @@ class HTMLDisplayHandler
|
|||
{
|
||||
$oContext->loadFile(array('./common/js/jquery-1.x.js', 'head', 'lt IE 9', -111000), true);
|
||||
$oContext->loadFile(array('./common/js/jquery.js', 'head', 'gte IE 9', -110000), true);
|
||||
$oContext->loadFile(array('./common/js/modernizr.js', 'head', '', -100000), true);
|
||||
$oContext->loadFile(array('./common/js/x.js', 'head', '', -100000), true);
|
||||
$oContext->loadFile(array('./common/js/common.js', 'head', '', -100000), true);
|
||||
$oContext->loadFile(array('./common/js/js_app.js', 'head', '', -100000), true);
|
||||
|
|
@ -451,8 +452,8 @@ class HTMLDisplayHandler
|
|||
// add common JS/CSS files
|
||||
if(__DEBUG__ || !__XE_VERSION_STABLE__)
|
||||
{
|
||||
$oContext->loadFile(array('./common/js/jquery-1.x.js', 'head', 'lt IE 9', -111000), true);
|
||||
$oContext->loadFile(array('./common/js/jquery.js', 'head', 'gte IE 9', -110000), true);
|
||||
$oContext->loadFile(array('./common/js/jquery.js', 'head', '', -110000), true);
|
||||
$oContext->loadFile(array('./common/js/modernizr.js', 'head', '', -100000), true);
|
||||
$oContext->loadFile(array('./common/js/x.js', 'head', '', -100000), true);
|
||||
$oContext->loadFile(array('./common/js/common.js', 'head', '', -100000), true);
|
||||
$oContext->loadFile(array('./common/js/js_app.js', 'head', '', -100000), true);
|
||||
|
|
@ -463,8 +464,7 @@ class HTMLDisplayHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
$oContext->loadFile(array('./common/js/jquery-1.x.min.js', 'head', 'lt IE 9', -111000), true);
|
||||
$oContext->loadFile(array('./common/js/jquery.min.js', 'head', 'gte IE 9', -110000), true);
|
||||
$oContext->loadFile(array('./common/js/jquery.min.js', 'head', '', -110000), true);
|
||||
$oContext->loadFile(array('./common/js/x.min.js', 'head', '', -100000), true);
|
||||
$oContext->loadFile(array('./common/js/xe.min.js', 'head', '', -100000), true);
|
||||
$oContext->loadFile(array('./common/css/xe.min.css', '', '', -1000000), true);
|
||||
|
|
|
|||
|
|
@ -1,253 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file Router.class.php
|
||||
* @brief Parses URIs and determines routing
|
||||
* @author FunnyXE (admin@funnyxe.com)
|
||||
*/
|
||||
class Router
|
||||
{
|
||||
/**
|
||||
* URI Segments
|
||||
* @var array
|
||||
*/
|
||||
private static $segments = array();
|
||||
|
||||
/**
|
||||
* Routes
|
||||
* @var array
|
||||
*/
|
||||
private static $routes = array(
|
||||
// rss , blogAPI
|
||||
'(rss|atom)' => array('module' => 'rss', 'act' => '$1', '[L]' => TRUE),
|
||||
'([a-zA-Z0-9_]+)/(rss|atom|api)' => array('mid' => '$1', 'act' => '$2', '[L]' => TRUE),
|
||||
'([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/(rss|atom|api)' => array('vid' => '$1', 'mid' => '$2', 'act' => '$3', '[L]' => TRUE),
|
||||
// trackback
|
||||
'([0-9]+)/(.+)/trackback' => array('document_srl' => '$1', 'key' => '$2', 'act' => 'trackback', '[L]' => TRUE),
|
||||
'([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback' => array('mid' => '$1', 'document_srl' => '$2', 'key' => '$3', 'act' => 'trackback', '[L]' => TRUE),
|
||||
'([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback' => array('vid' => '$1', 'mid' => '$2', 'document_srl' => '$3' , 'key' => '$4', 'act' => 'trackback', '[L]' => TRUE),
|
||||
// document_srl
|
||||
'([0-9]+)' => array('document_srl' => '$1', '[L]' => TRUE),
|
||||
// mid
|
||||
'([a-zA-Z0-9_]+)/?' => array('mid' => '$1', '[L]' => TRUE),
|
||||
// mid + document_srl
|
||||
'([a-zA-Z0-9_]+)/([0-9]+)' => array('mid' => '$1', 'document_srl' => '$2', '[L]' => TRUE),
|
||||
// vid + mid
|
||||
'([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/' => array('vid' => '$1', 'mid' => '$2', '[L]' => TRUE),
|
||||
// vid + mid + document_srl
|
||||
'([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([0-9]+)?' => array('vid' => '$1', 'mid' => '$2', 'document_srl' => '$3', '[L]' => TRUE),
|
||||
// mid + entry title
|
||||
'([a-zA-Z0-9_]+)/entry/(.+)' => array('mid' => '$1', 'entry' => '$2', '[L]' => TRUE),
|
||||
// vid + mid + entry title
|
||||
'([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/entry/(.+)' => array('vid' => '$1', 'mid' => '$2', 'entry' => '$3', '[L]' => TRUE),
|
||||
// shop / vid / [category|product] / identifier
|
||||
'([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([a-zA-Z0-9_\.-]+)' => array('act' => 'route', 'vid' => '$1', 'type' => '$2', 'identifier'=> '$3', '[L]' => TRUE)
|
||||
);
|
||||
|
||||
/**
|
||||
* Rewrite map
|
||||
* @var array
|
||||
*/
|
||||
private static $rewrite_map = array();
|
||||
|
||||
/**
|
||||
* @brief Applys routes.
|
||||
* @see This function should be called only once
|
||||
* @return void
|
||||
*/
|
||||
public static function proc()
|
||||
{
|
||||
$uri = $_SERVER['REQUEST_URI'];
|
||||
|
||||
if (stripos($uri, $_SERVER['SCRIPT_NAME']) === 0)
|
||||
{
|
||||
$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
|
||||
}
|
||||
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
|
||||
{
|
||||
$uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
|
||||
}
|
||||
|
||||
if ($uri == '/' || empty($uri))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get relative path from request uri
|
||||
$path = parse_url($uri, PHP_URL_PATH);
|
||||
|
||||
// Do some final cleaning of the URI and return it
|
||||
$path = str_replace(array('//', '../'), '/', trim($path, '/'));
|
||||
|
||||
if(strlen($path) > 0)
|
||||
{
|
||||
self::$segments = explode('/', $path);
|
||||
}
|
||||
|
||||
if(isset(self::$routes[$path]))
|
||||
{
|
||||
foreach(self::$routes[$path] as $key => $val)
|
||||
{
|
||||
if(strlen($val) > 0)
|
||||
{
|
||||
if(substr_compare($val, '$', 0, 1) == 0)
|
||||
{
|
||||
$segment_index = (int) substr($val, 1) - 1;
|
||||
if($segment_index < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Context::set($key, self::$segments[$segment_index], TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set($key, $val, TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set($key, '', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$break = FALSE;
|
||||
|
||||
// Apply routes
|
||||
foreach(self::$routes as $regex => $query)
|
||||
{
|
||||
// Stop the routing proccess
|
||||
if($break)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(preg_match('#^' . $regex . '$#', $path, $matches))
|
||||
{
|
||||
foreach($query as $key => $val)
|
||||
{
|
||||
// If [L] keyword is defined
|
||||
if($key == '[L]')
|
||||
{
|
||||
// Stop the routing process and don't apply any more rules
|
||||
$break = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(strlen($val) > 0)
|
||||
{
|
||||
if(substr($val, 0, 1) == '$')
|
||||
{
|
||||
$segment_index = (int) substr($val, 1) - 1;
|
||||
if($segment_index < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Context::set($key, self::$segments[$segment_index], TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set($key, $val, TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set($key, '', TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add a rewrite map(s)
|
||||
* @param array $map
|
||||
* @return void
|
||||
*/
|
||||
public static function setMap($map)
|
||||
{
|
||||
self::$rewrite_map = array_merge(self::$rewrite_map, $map);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add a route
|
||||
* @param string $target
|
||||
* @param array $query
|
||||
* @return void
|
||||
*/
|
||||
public static function add($target, $query)
|
||||
{
|
||||
self::$routes[$target] = $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add multiple routes
|
||||
* @param array $routes
|
||||
* @return void
|
||||
*/
|
||||
public function adds($routes)
|
||||
{
|
||||
self::$routes = array_merge(self::$routes, $routes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get segment from request uri
|
||||
* @param int $index
|
||||
* @return string
|
||||
*/
|
||||
public static function getSegment($index)
|
||||
{
|
||||
return self::$segments[$index - 1];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get segment from request uri
|
||||
* @param int $index
|
||||
* @return string
|
||||
*/
|
||||
public static function getSegments()
|
||||
{
|
||||
return self::$segments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get route info
|
||||
* @param string $regex
|
||||
* @return array
|
||||
*/
|
||||
public static function getRoute($regex)
|
||||
{
|
||||
return self::$routes[$regex];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get routes list
|
||||
* @return array
|
||||
*/
|
||||
public static function getRoutes()
|
||||
{
|
||||
return self::$routes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get routes list
|
||||
* @param string $regex
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isExistsRoute($regex)
|
||||
{
|
||||
return isset(self::$routes[$regex]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Makes shortten url
|
||||
* @param string $regex
|
||||
* @return string
|
||||
*/
|
||||
public static function makePrettyUrl($regex)
|
||||
{
|
||||
return self::$rewrite_map[$regex];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue