Merge pull request #13 from xetown/develop

XETOWN cms develop 12.30.15
This commit is contained in:
MinSoo Kim 2015-12-30 22:37:36 +09:00
commit 2cd07067de
265 changed files with 4412 additions and 1691 deletions

View file

@ -27,4 +27,5 @@ script:
- if [ $(phpenv version-name) != "5.3" ]; then ./vendor/bin/codecept run -d --fail-fast --env travis; fi
notifications:
slack:
secure: 0HhwktIb65zfge56E4yMfYj0Xj4GeYIaxvh/Obb13BK1/C8RdWBy6u213N5MQ2UHsxYk8wXXzynaCh4psegi2iPy9dbKmkdAdEQMzYoKE2xYVSqZveeVQm0sqFVXAlzggpgs/j5vtvKYjRkQKtTrz0C+p0uJ0bkLcyWGezWTpGc=
secure: jpoMjtkveVuPZM4JXJETAPv8QUCtTbI/ZTixdS9HUgxSb9tD2DkoekMaRzXYnXA82Les/gGxTC0fQFcFrls6Ypkbvp1udBPggmAdLiBHubBIz+yd1BGIf/l4I6MY1QmGe1Lx4xlnVlEgLnKXHn+W+ENep4/MzpCEaR9Vw8wfGqY=
secure: "gPv4qFmGcXimNlI/OeVk5n4VtRCWbAe7VUtw7Inb3A/ZZaVDo11gtMNkwo/JVKSnXqFkaCQYebcNpj2D9Rb2ZCwgjMSX6wxvpA4/8OLOZpbWqFW6Hz2RKNggubXlnalXkIwFcsvj70rKctbcJFk2C1G9rVvYWdVGD9X4/ozQtAc="

View file

@ -1,57 +1,9 @@
XpressEngine
XpressEngine With XETOWN
============
develop 브랜치에서 쓸만한 PR Merge!
[![Build Status](https://travis-ci.org/xpressengine/xe-core.svg?branch=master)](https://travis-ci.org/xpressengine/xe-core)
[![License](http://img.shields.io/badge/license-GNU%20LGPL-brightgreen.svg)](http://www.gnu.org/licenses/gpl.html)
[![Latest release](http://img.shields.io/github/release/xpressengine/xe-core.svg)](https://github.com/xpressengine/xe-core/releases)
xe core 새버전이 나오면 master 브랜치에서 Merge후 develop 브랜치와 최종 Merge!
XpressEngine(XE)은 누구나 쉽고 편하고 자유롭게 콘텐츠를 발행을 할 수 있도록 하기 위한 CMS(Content Management System)입니다.
오픈소스 라이선스로 누구나 사용 또는 개작할 수 있으며, 개방형 프로젝트로서 누구나 개발에 참여할 수 있습니다.
develop 브랜치에서 커밋 가능. (소스수정)
### 확장형 구조
XE 코어는 모듈, 애드온, 에디터 컴포넌트, 위젯, 레이아웃의 구조를 기반으로 결과물을 생성합니다.
이렇게 각각의 기능과 디자인이 구조적으로 연결되는 모듈형 구조는 개발 및 유지보수를 쉽게 하도록 도와주며 관리자는 손쉽게 설정과 디자인을 변경할 수 있습니다.
레이아웃, 모듈 스킨 그리고 위젯의 스타일과 스킨을 활용하면 여러분만의 개성을 가진 웹 사이트를 만들 수 있습니다. XE와 함께 더 다채롭고 개성있는 웹사이트를 만들어보세요!
### 오픈 소스 소프트웨어! 열린 프로젝트! (코드 공헌 가이드)
많은 분들께서 개발, 디자인, 마크업 등의 전문 분야는 물론 다국어 번역, 문제점 보고 등 기능 개선 및 문제 해결을 위해 많은 노력을 해주시고 계십니다.
참여를 원하시는 분들은 버그 신고/제안 혹은 Pull Request 전에 [CONTRIBUTING.md](./CONTRIBUTING.md) 문서를 먼저 읽어주시기 바랍니다.
XpressEngine은 여러분들의 개발 참여를 기다립니다.
## Server Requirements
* PHP version 5.3.0 or greater (But recommend PHP >= 5.5.0)
* MYSQL version 4.1 or greater (But recommend MYSQL >= 5.x) , MS-SQL, CUBRID
* XML Library
* GD Library
* ICONV
* session.auto_start = Off (php.ini)
## Maintainers
@akasima @bnu @jhyeon1010 @khongchi @findstar @ngleader
## Contributors
http://www.xpressengine.com/contributors
## Support
* Official site (Korean) : http://www.xpressengine.com/
## License
Copyright 2014 NAVER Corp. <http://www.navercorp.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
참여하실 분들은 conory(conorycom@gmail.com) 에게 알려주시면 Collaborators 으로 등록해드리겠습니다.

View file

@ -10,7 +10,7 @@ if(!defined('__XE__'))
* @brief admin log
*/
$logged_info = Context::get('logged_info');
if($logged_info && $logged_info->is_admin == 'Y' && stripos(Context::get('act'), 'admin') !== false && $called_position == 'before_module_proc')
if(Context::get('is_logged') && $logged_info->is_admin == 'Y' && stripos(Context::get('act'), 'admin') !== false && $called_position == 'before_module_proc')
{
$oAdminloggingController = getController('adminlogging');
$oAdminloggingController->insertLog($this->module, $this->act);

View file

@ -14,12 +14,13 @@ if(!defined('__XE__'))
* - When caliing MemberModel::getMemberMenu, feature to add a friend is added
*/
// Stop if non-logged-in user is
$logged_info = Context::get('logged_info');
if(!$logged_info|| isCrawler())
if(!Context::get('is_logged') || isCrawler())
{
return;
}
$logged_info = Context::get('logged_info');
/**
* Message/Friend munus are added on the pop-up window and member profile. Check if a new message is received
* */

View file

@ -21,8 +21,14 @@ function memberTransImageName($matches)
$oMemberModel = getModel('member');
$nick_name = $matches[5];
// Initialize global variable for cache
if(!isset($GLOBALS['_transImageNameList'][$member_srl]))
{
$GLOBALS['_transImageNameList'][$member_srl] = new stdClass();
}
$_tmp = &$GLOBALS['_transImageNameList'][$member_srl];
// If pre-defined data in the global variablesm return it
// If pre-defined data in the global variables, return it
if(!$_tmp->cached)
{
$_tmp->cached = true;
@ -31,7 +37,8 @@ function memberTransImageName($matches)
if(file_exists(_XE_PATH_ . $image_name_file))
{
$_tmp->image_name_file = $image_name_file;
$_tmp->image_name_file = $image_name_file . '?' . date('YmdHis', filemtime(_XE_PATH_ . $image_name_file));
$image_name_file = $_tmp->image_name_file;
}
else
{
@ -40,7 +47,8 @@ function memberTransImageName($matches)
if(file_exists(_XE_PATH_ . $image_mark_file))
{
$_tmp->image_mark_file = $image_mark_file;
$_tmp->image_mark_file = $image_mark_file . '?' . date('YmdHis', filemtime(_XE_PATH_ . $image_mark_file));
$image_mark_file = $_tmp->image_mark_file;
}
else
{

View file

@ -8,9 +8,9 @@ class wap extends mobileXE {
/**
* @brief constructor
**/
function wap()
function __construct()
{
parent::mobileXE();
parent::__construct();
}
/**

View file

@ -9,9 +9,9 @@ class wap extends mobileXE
/**
* @brief constructor
**/
function wap()
function __construct()
{
parent::mobileXE();
parent::__construct();
}
/**

View file

@ -76,7 +76,7 @@ class mobileXE
/**
* @brief constructor
*/
function mobileXE()
function __construct()
{
// Check navigation mode
if(Context::get('nm'))

View file

@ -8,9 +8,9 @@ class wap extends mobileXE
/**
* @brief constructor
*/
function wap()
function __construct()
{
parent::mobileXE();
parent::__construct();
}
/**

View file

@ -7,15 +7,17 @@
function pointLevelIconTrans($matches)
{
$member_srl = $matches[3];
if($member_srl < 1)
// If anonymous or not member_srl go to Hide Point Icon
if($member_srl < 1||!$member_srl)
{
return $matches[0];
}
$orig_text = preg_replace('/' . preg_quote($matches[5], '/') . '<\/' . $matches[6] . '>$/', '', $matches[0]);
// Check Group Image Mark
$oMemberModel = getModel('member');
// Check Group Image Mark
if($oMemberModel->getGroupImageMark($member_srl))
{
return $orig_text . $matches[5] . '</' . $matches[6] . '>';

View file

@ -30,7 +30,7 @@ class CacheApc extends CacheBase
*
* @return void
*/
function CacheApc()
function __construct()
{
}

View file

@ -6,7 +6,7 @@
*
* Filedisk Cache Handler
*
* @author NAVER (developers@xpressengine.com)
* @author NAVER (developers@xpressengine.com)
*/
class CacheFile extends CacheBase
{
@ -35,7 +35,7 @@ class CacheFile extends CacheBase
*
* @return void
*/
function CacheFile()
function __construct()
{
$this->cache_dir = _XE_PATH_ . $this->cache_dir;
FileHandler::makeDir($this->cache_dir);
@ -78,31 +78,32 @@ class CacheFile extends CacheBase
$content[] = 'if(!defined(\'__XE__\')) { exit(); }';
$content[] = 'return \'' . addslashes(serialize($obj)) . '\';';
FileHandler::writeFile($cache_file, implode(PHP_EOL, $content));
if(function_exists('opcache_invalidate'))
{
@opcache_invalidate($cache_file, true);
}
if(function_exists('opcache_invalidate'))
{
@opcache_invalidate($cache_file, true);
}
}
/**
* Return whether cache is valid or invalid
*
* @param string $key Cache key
* @param int $modified_time Not used
* @param int $modified_time Unix time of data modified.
* If stored time is older then modified time, return false.
* @return bool Return true on valid or false on invalid.
*/
function isValid($key, $modified_time = 0)
{
$cache_file = $this->getCacheFileName($key);
if(file_exists($cache_file))
{
if($modified_time > 0 && filemtime($cache_file) < $modified_timed)
{
FileHandler::removeFile($cache_file);
return false;
}
if($modified_time > 0 && filemtime($cache_file) < $modified_time)
{
FileHandler::removeFile($cache_file);
return false;
}
return true;
}
@ -113,24 +114,25 @@ class CacheFile extends CacheBase
* Fetch a stored variable from the cache
*
* @param string $key The $key used to store the value.
* @param int $modified_time Not used
* @param int $modified_time Unix time of data modified.
* If stored time is older then modified time, return false.
* @return false|mixed Return false on failure. Return the string associated with the $key on success.
*/
function get($key, $modified_time = 0)
{
if(!$cache_file = FileHandler::exists($this->getCacheFileName($key)))
{
return false;
}
if($modified_time > 0 && filemtime($cache_file) < $modified_timed)
if(!$cache_file = FileHandler::exists($this->getCacheFileName($key)))
{
FileHandler::removeFile($cache_file);
return false;
}
$content = include($cache_file);
if($modified_time > 0 && filemtime($cache_file) < $modified_time)
{
FileHandler::removeFile($cache_file);
return false;
}
$content = include($cache_file);
return unserialize(stripslashes($content));
}
@ -143,10 +145,10 @@ class CacheFile extends CacheBase
function _delete($_key)
{
$cache_file = $this->getCacheFileName($_key);
if(function_exists('opcache_invalidate'))
{
@opcache_invalidate($cache_file, true);
}
if(function_exists('opcache_invalidate'))
{
@opcache_invalidate($cache_file, true);
}
FileHandler::removeFile($cache_file);
}
@ -169,6 +171,7 @@ class CacheFile extends CacheBase
function truncate()
{
FileHandler::removeFilesInDir($this->cache_dir);
return true;
}
}

View file

@ -49,7 +49,7 @@ class CacheHandler extends Handler
* @param boolean $always_use_file If set true, use a file cache always
* @return CacheHandler
*/
function CacheHandler($target, $info = null, $always_use_file = false)
function __construct($target, $info = null, $always_use_file = false)
{
if(!$info)
{
@ -69,6 +69,11 @@ class CacheHandler extends Handler
$type = 'memcache';
$url = $info->use_object_cache;
}
else if(substr($info->use_object_cache, 0, 5) == 'redis')
{
$type = 'redis';
$url = $info->use_object_cache;
}
else if($info->use_object_cache == 'wincache')
{
$type = 'wincache';
@ -93,6 +98,11 @@ class CacheHandler extends Handler
$type = 'memcache';
$url = $info->use_template_cache;
}
else if(substr($info->use_template_cache, 0, 5) == 'redis')
{
$type = 'redis';
$url = $info->use_template_cache;
}
else if($info->use_template_cache == 'wincache')
{
$type = 'wincache';

View file

@ -13,6 +13,7 @@ class CacheMemcache extends CacheBase
* @var Memcahe
*/
var $Memcache;
var $SelectedExtension;
/**
* Get instance of CacheMemcache
@ -36,11 +37,24 @@ class CacheMemcache extends CacheBase
* @param string $url url of memcache
* @return void
*/
function CacheMemcache($url)
function __construct($url)
{
//$config['url'] = array('memcache://localhost:11211');
$config['url'] = is_array($url) ? $url : array($url);
$this->Memcache = new Memcache;
if(class_exists('Memcached'))
{
$this->Memcache = new Memcached;
$this->SelectedExtension = 'Memcached';
}
elseif(class_exists('Memcache'))
{
$this->Memcache = new Memcache;
$this->SelectedExtension = 'Memcache';
}
else
{
return false;
}
foreach($config['url'] as $url)
{
@ -58,19 +72,21 @@ class CacheMemcache extends CacheBase
{
if(isset($GLOBALS['XE_MEMCACHE_SUPPORT']))
{
return true;
return $GLOBALS['XE_MEMCACHE_SUPPORT'];
}
if($this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1))
if($this->SelectedExtension === 'Memcached')
{
$GLOBALS['XE_MEMCACHE_SUPPORT'] = true;
return $GLOBALS['XE_MEMCACHE_SUPPORT'] = $this->Memcache->set('xe', 'xe', 1);
}
elseif($this->SelectedExtension === 'Memcache')
{
return $GLOBALS['XE_MEMCACHE_SUPPORT'] = $this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1);
}
else
{
$GLOBALS['XE_MEMCACHE_SUPPORT'] = false;
return $GLOBALS['XE_MEMCACHE_SUPPORT'] = false;
}
return $GLOBALS['XE_MEMCACHE_SUPPORT'];
}
/**
@ -108,7 +124,14 @@ class CacheMemcache extends CacheBase
$valid_time = $this->valid_time;
}
return $this->Memcache->set($this->getKey($key), array($_SERVER['REQUEST_TIME'], $buff), MEMCACHE_COMPRESSED, $valid_time);
if($this->SelectedExtension === 'Memcached')
{
return $this->Memcache->set($this->getKey($key), array($_SERVER['REQUEST_TIME'], $buff), $valid_time);
}
else
{
return $this->Memcache->set($this->getKey($key), array($_SERVER['REQUEST_TIME'], $buff), MEMCACHE_COMPRESSED, $valid_time);
}
}
/**

248
classes/cache/CacheRedis.class.php vendored Normal file
View file

@ -0,0 +1,248 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* Cache class for Redis
*
* @author NAVER (developer@xpressengine.com)
*/
class CacheRedis extends CacheBase
{
/**
* instance of Redis
* @var redis
*/
var $redis;
var $status;
/**
* Get instance of CacheRedis
*
* @param string $url url of Redis
* @return CacheRedis instance of CacheRedis
*/
function getInstance($url)
{
if(!$GLOBALS['__CacheRedis__'])
{
$GLOBALS['__CacheRedis__'] = new CacheRedis($url);
}
return $GLOBALS['__CacheRedis__'];
}
/**
* Construct
*
* Do not use this directly. You can use getInstance() instead.
* @param string $url url of Redis
* @return void
*/
function CacheRedis($url)
{
//$config['url'] = 'redis://localhost:6379/1';
$config['url'] = is_array($url) ? reset($url) : $url;
if(!class_exists('Redis'))
{
return $this->status = false;
}
try
{
$this->redis = new Redis;
$info = parse_url($url);
$this->redis->connect($info['host'], $info['port'], 0.15);
if(isset($info['user']) || isset($info['pass']))
{
$this->redis->auth(isset($info['user']) ? $info['user'] : $info['pass']);
}
if(isset($info['path']) && $dbnum = intval(substr($info['path'], 1)))
{
$this->redis->select($dbnum);
}
return $this->status = true;
}
catch(RedisException $e)
{
return $this->status = false;
}
}
/**
* Return whether support or not support cache
*
* @return bool Return true on support or false on not support
*/
function isSupport()
{
if($this->status !== null)
{
return $this->status;
}
try
{
return $this->redis->setex('xe', 1, 'xe');
}
catch(RedisException $e)
{
return $this->status = false;
}
}
/**
* Get unique key of given key by path of XE
*
* @param string $key Cache key
* @return string Return unique key
*/
function getKey($key)
{
static $prefix = null;
if($prefix === null)
{
$prefix = substr(sha1(_XE_PATH_), 0, 12) . ':';
}
return $prefix . $key;
}
/**
* Store data at the server
*
* CacheRedis::put() stores an item $buff with $key on the Redis server.
* Parameter $valid_time is expiration time in seconds. If it's 0, the item never expires
* (but Redis server doesn't guarantee this item to be stored all the time, it could be delete from the cache to make place for other items).
*
* Remember that resource variables (i.e. file and connection descriptors) cannot be stored in the cache,
* because they can not be adequately represented in serialized state.
*
* @param string $key The key that will be associated with the item.
* @param mixed $buff The variable to store. Strings and integers are stored as is, other types are stored serialized.
* @param int $valid_time Expiration time of the item.
* You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).
* If it's equal to zero, use the default valid time CacheRedis::valid_time.
* @return bool Returns true on success or false on failure.
*/
function put($key, $buff, $valid_time = 0)
{
if($valid_time > 60 * 60 * 24 * 30)
{
$valid_time = $valid_time - time();
}
if($valid_time <= 0)
{
$valid_time = $this->valid_time;
}
try
{
return $this->redis->setex($this->getKey($key), $valid_time, serialize(array($_SERVER['REQUEST_TIME'], $buff)));
}
catch(RedisException $e)
{
return $this->status = false;
}
}
/**
* Return whether cache is valid or invalid
*
* @param string $key Cache key
* @param int $modified_time Unix time of data modified.
* If stored time is older then modified time, the data is invalid.
* @return bool Return true on valid or false on invalid.
*/
function isValid($key, $modified_time = 0)
{
$_key = $this->getKey($key);
$obj = $this->redis->get($_key);
$obj = $obj ? unserialize($obj) : false;
if(!$obj || !is_array($obj))
{
return false;
}
unset($obj[1]);
if($modified_time > 0 && $modified_time > $obj[0])
{
$this->redis->del($_key);
return false;
}
return true;
}
/**
* Retrieve item from the server
*
* CacheRedis::get() returns previously stored data if an item with such $key exists on the server at this moment.
*
* @param string $key The key to fetch
* @param int $modified_time Unix time of data modified.
* If stored time is older then modified time, return false.
* @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
*/
function get($key, $modified_time = 0)
{
$_key = $this->getKey($key);
$obj = $this->redis->get($_key);
$obj = $obj ? unserialize($obj) : false;
if(!$obj || !is_array($obj))
{
return false;
}
if($modified_time > 0 && $modified_time > $obj[0])
{
$this->redis->del($_key);
return false;
}
return $obj[1];
}
/**
* Delete item from the server
*
* CacheRedis::delete() deletes an item with tey $key.
*
* @param string $key The key associated with the item to delete.
* @return void
*/
function delete($key)
{
$_key = $this->getKey($key);
try
{
$this->redis->del($_key);
}
catch(RedisException $e)
{
return $this->status = false;
}
}
/**
* Flush all existing items at the server
*
* CacheRedis::truncate() immediately invalidates all existing items.
* If using multiple databases, items in other databases are not affected.
*
* @return bool Returns true on success or false on failure.
*/
function truncate()
{
try
{
return $this->redis->flushDB();
}
catch(RedisException $e)
{
return $this->status = false;
}
}
}
/* End of file CacheRedis.class.php */
/* Location: ./classes/cache/CacheRedis.class.php */

View file

@ -32,7 +32,7 @@ class CacheWincache extends CacheBase
*
* @return void
*/
function CacheWincache()
function __construct()
{
}

View file

@ -159,7 +159,7 @@ class Context
*
* @return object Instance
*/
function &getInstance()
public static function &getInstance()
{
static $theInstance = null;
if(!$theInstance)
@ -175,7 +175,7 @@ class Context
*
* @return void
*/
function Context()
public function __construct()
{
$this->oFrontEndFileHandler = new FrontEndFileHandler();
$this->get_vars = new stdClass();
@ -198,10 +198,18 @@ class Context
* @see This function should be called only once
* @return void
*/
function init()
public function init()
{
if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === true) {
if(simplexml_load_string(file_get_contents("php://input")) !== false) $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
// fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above
if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE)
{
$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
// If content is not XML JSON, unset
if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE)
{
unset($GLOBALS['HTTP_RAW_POST_DATA']);
}
}
// set context variables in $GLOBALS (to use in display handler)
@ -333,8 +341,29 @@ class Context
);
}
if($sess = $_POST[session_name()]) session_id($sess);
session_start();
// start session if it was previously started
$session_name = session_name();
$session_id = NULL;
if($session_id = $_POST[$session_name])
{
session_id($session_id);
}
else
{
$session_id = $_COOKIE[$session_name];
}
if($session_id !== NULL || $this->db_info->cache_friendly != 'Y')
{
$this->setCacheControl(0, false);
session_start();
}
else
{
$this->setCacheControl(-1, true);
register_shutdown_function(array($this, 'checkSessionStatus'));
$_SESSION = array();
}
// set authentication information in Context and session
if(self::isInstalled())
@ -359,7 +388,10 @@ class Context
}
$this->set('is_logged', $oMemberModel->isLogged());
$this->set('logged_info', $oMemberModel->getLoggedInfo());
if($oMemberModel->isLogged())
{
$this->set('logged_info', $oMemberModel->getLoggedInfo());
}
}
}
@ -420,22 +452,78 @@ class Context
}
}
/**
* Get the session status
*
* @return bool
*/
public static function getSessionStatus()
{
return (session_id() !== '');
}
/**
* Start the session if $_SESSION was touched
*
* @return void
*/
public static function checkSessionStatus($force_start = false)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
if($self->getSessionStatus())
{
return;
}
if($force_start || (count($_SESSION) && !headers_sent()))
{
$tempSession = $_SESSION;
unset($_SESSION);
session_start();
$_SESSION = $tempSession;
}
}
/**
* Finalize using resources, such as DB connection
*
* @return void
*/
function close()
public static function close()
{
session_write_close();
}
/**
* set Cache-Control header
*
* @return void
*/
public static function setCacheControl($ttl = 0, $public = true)
{
if($ttl == 0)
{
header('Cache-Control: ' . ($public ? 'public, ' : 'private, ') . 'must-revalidate, post-check=0, pre-check=0, no-store, no-cache');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
}
elseif($ttl == -1)
{
header('Cache-Control: ' . ($public ? 'public, ' : 'private, ') . 'must-revalidate, post-check=0, pre-check=0');
}
else
{
header('Cache-Control: ' . ($public ? 'public, ' : 'private, ') . 'must-revalidate, max-age=' . (int)$ttl);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (int)$ttl) . ' GMT');
}
}
/**
* Load the database information
*
* @return void
*/
function loadDBInfo()
public static function loadDBInfo()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -498,7 +586,7 @@ class Context
$db_info->use_db_session = 'N';
if(!$db_info->use_ssl)
$db_info->use_ssl = 'none';
$this->set('_use_ssl', $db_info->use_ssl);
$self->set('_use_ssl', $db_info->use_ssl);
$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);
@ -519,7 +607,7 @@ class Context
*
* @return string DB's db_type
*/
function getDBType()
public static function getDBType()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->db_info->master_db["db_type"];
@ -531,7 +619,7 @@ class Context
* @param object $db_info DB information
* @return void
*/
function setDBInfo($db_info)
public static function setDBInfo($db_info)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->db_info = $db_info;
@ -542,7 +630,7 @@ class Context
*
* @return object DB information
*/
function getDBInfo()
public static function getDBInfo()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->db_info;
@ -553,7 +641,7 @@ class Context
*
* @return object SSL status (Optional - none|always|optional)
*/
function getSslStatus()
public static function getSslStatus()
{
$dbInfo = self::getDBInfo();
return $dbInfo->use_ssl;
@ -564,7 +652,7 @@ class Context
*
* @return string Default URL
*/
function getDefaultUrl()
public static function getDefaultUrl()
{
$db_info = self::getDBInfo();
return $db_info->default_url;
@ -575,7 +663,7 @@ class Context
*
* @return array Supported languages
*/
function loadLangSupported()
public static function loadLangSupported()
{
static $lang_supported = null;
if(!$lang_supported)
@ -596,7 +684,7 @@ class Context
*
* @return array Selected languages
*/
function loadLangSelected()
public static function loadLangSelected()
{
static $lang_selected = null;
if(!$lang_selected)
@ -634,7 +722,7 @@ class Context
*
* @return bool True : Module handling is necessary in the control path of current request , False : Otherwise
*/
function checkSSO()
public function checkSSO()
{
// pass if it's not GET request or XE is not yet installed
if($this->db_info->use_sso != 'Y' || isCrawler())
@ -659,41 +747,68 @@ class Context
$default_url .= '/';
}
// for sites recieving SSO valdiation
if($default_url == self::getRequestUri())
{
if(self::get('default_url'))
{
$url = base64_decode(self::get('default_url'));
$url_info = parse_url($url);
$url_info['query'].= ($url_info['query'] ? '&' : '') . 'SSOID=' . session_id();
$redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':' . $url_info['port'] : '', $url_info['path'], $url_info['query']);
header('location:' . $redirect_url);
return FALSE;
}
// for sites requesting SSO validation
}
else
{
// result handling : set session_name()
if($session_name = self::get('SSOID'))
{
setcookie(session_name(), $session_name);
// Get current site information (only the base URL, not the full URL)
$current_site = self::getRequestUri();
$url = preg_replace('/([\?\&])$/', '', str_replace('SSOID=' . $session_name, '', self::getRequestUrl()));
header('location:' . $url);
return FALSE;
// send SSO request
}
else if(!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri()))
{
setcookie('sso', md5(self::getRequestUri()), 0, '/');
$url = sprintf("%s?default_url=%s", $default_url, base64_encode(self::getRequestUrl()));
header('location:' . $url);
return FALSE;
}
// Step 1: if the current site is not the default site, send SSO validation request to the default site
if($default_url !== $current_site && !self::get('SSOID') && $_COOKIE['sso'] !== md5($current_site))
{
// Set sso cookie to prevent multiple simultaneous SSO validation requests
setcookie('sso', md5($current_site), 0, '/');
// Redirect to the default site
$redirect_url = sprintf('%s?return_url=%s', $default_url, urlencode(base64_encode($current_site)));
header('Location:' . $redirect_url);
return FALSE;
}
// Step 2: receive and process SSO validation request at the default site
if($default_url === $current_site && self::get('return_url'))
{
// Get the URL of the origin site
$url = base64_decode(self::get('return_url'));
$url_info = parse_url($url);
// Check that the origin site is a valid site in this XE installation (to prevent open redirect vuln)
if(!getModel('module')->getSiteInfoByDomain(rtrim($url, '/'))->site_srl)
{
htmlHeader();
echo self::getLang("msg_invalid_request");
htmlFooter();
return FALSE;
}
// Redirect back to the origin site
$url_info['query'] .= ($url_info['query'] ? '&' : '') . 'SSOID=' . session_id();
$redirect_url = sprintf('%s://%s%s%s%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? (':' . $url_info['port']) : '', $url_info['path'], ($url_info['query'] ? ('?' . $url_info['query']) : ''));
header('Location:' . $redirect_url);
return FALSE;
}
// Step 3: back at the origin site, set session ID to be the same as the default site
if($default_url !== $current_site && self::get('SSOID'))
{
// Check that the session ID was given by the default site (to prevent session fixation CSRF)
if(isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $default_url) !== 0)
{
htmlHeader();
echo self::getLang("msg_invalid_request");
htmlFooter();
return FALSE;
}
// Set session ID
setcookie(session_name(), self::get('SSOID'));
// Finally, redirect to the originally requested URL
$url_info = parse_url(self::getRequestUrl());
$url_info['query'] = preg_replace('/(^|\b)SSOID=([^&?]+)/', '', $url_info['query']);
$redirect_url = sprintf('%s://%s%s%s%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? (':' . $url_info['port']) : '', $url_info['path'], ($url_info['query'] ? ('?' . $url_info['query']) : ''));
header('Location:' . $redirect_url);
return FALSE;
}
// If none of the conditions above apply, proceed normally
return TRUE;
}
@ -702,7 +817,7 @@ class Context
*
* @return bool True: FTP information is registered, False: otherwise
*/
function isFTPRegisted()
public static function isFTPRegisted()
{
return file_exists(self::getFTPConfigFile());
}
@ -712,7 +827,7 @@ class Context
*
* @return object FTP information
*/
function getFTPInfo()
public static function getFTPInfo()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -732,7 +847,7 @@ class Context
* @param string $site_title Browser title to be added
* @return void
*/
function addBrowserTitle($site_title)
public static function addBrowserTitle($site_title)
{
if(!$site_title)
{
@ -756,7 +871,7 @@ class Context
* @param string $site_title Browser title to be set
* @return void
*/
function setBrowserTitle($site_title)
public static function setBrowserTitle($site_title)
{
if(!$site_title)
{
@ -771,7 +886,7 @@ class Context
*
* @return string Browser title(htmlspecialchars applied)
*/
function getBrowserTitle()
public static function getBrowserTitle()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -785,7 +900,7 @@ class Context
* Return layout's title
* @return string layout's title
*/
public function getSiteTitle()
public static function getSiteTitle()
{
$oModuleModel = getModel('module');
$moduleConfig = $oModuleModel->getModuleConfig('module');
@ -801,7 +916,7 @@ class Context
* Get browser title
* @deprecated
*/
function _getBrowserTitle()
public function _getBrowserTitle()
{
return $this->getBrowserTitle();
}
@ -812,7 +927,7 @@ class Context
* @param string $path Path of the language file
* @return void
*/
function loadLang($path)
public static function loadLang($path)
{
global $lang;
@ -857,7 +972,7 @@ class Context
* @param string Path of the language file
* @return void
*/
function _evalxmlLang($path)
public function _evalxmlLang($path)
{
global $lang;
@ -891,7 +1006,7 @@ class Context
* @param string $path Path of the language file
* @return string file name
*/
function _loadXmlLang($path)
public function _loadXmlLang($path)
{
if(!$path) return;
@ -905,7 +1020,7 @@ class Context
* @param string $path Path of the language file
* @return string file name
*/
function _loadPhpLang($path)
public function _loadPhpLang($path)
{
if(!$path) return;
@ -935,14 +1050,17 @@ class Context
* @param string $lang_type Language type.
* @return void
*/
function setLangType($lang_type = 'ko')
public static function setLangType($lang_type = 'ko')
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->lang_type = $lang_type;
$self->set('lang_type', $lang_type);
$_SESSION['lang_type'] = $lang_type;
if($self->getSessionStatus())
{
$_SESSION['lang_type'] = $lang_type;
}
}
/**
@ -950,7 +1068,7 @@ class Context
*
* @return string Language type
*/
function getLangType()
public static function getLangType()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->lang_type;
@ -962,7 +1080,7 @@ class Context
* @param string $code Language variable name
* @return string If string for the code exists returns it, otherwise returns original code
*/
function getLang($code)
public static function getLang($code)
{
if(!$code)
{
@ -982,7 +1100,7 @@ class Context
* @param string $val `$code`s value
* @return void
*/
function setLang($code, $val)
public static function setLang($code, $val)
{
if(!isset($GLOBALS['lang']))
{
@ -997,7 +1115,7 @@ class Context
* @param object $source_obj Conatins strings to convert
* @return object converted object
*/
function convertEncoding($source_obj)
public static function convertEncoding($source_obj)
{
$charset_list = array(
'UTF-8', 'EUC-KR', 'CP949', 'ISO8859-1', 'EUC-JP', 'SHIFT_JIS', 'CP932',
@ -1038,7 +1156,7 @@ class Context
* @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5
* @return void
*/
function checkConvertFlag(&$val, $key = null, $charset = null)
public static function checkConvertFlag(&$val, $key = null, $charset = null)
{
static $flag = TRUE;
if($charset)
@ -1065,7 +1183,7 @@ class Context
* @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5
* @return object converted object
*/
function doConvertEncoding(&$val, $key = null, $charset)
public static function doConvertEncoding(&$val, $key = null, $charset)
{
if (is_array($val))
{
@ -1080,7 +1198,7 @@ class Context
* @param string $str String to convert
* @return string converted string
*/
function convertEncodingStr($str)
public static function convertEncodingStr($str)
{
if(!$str) return null;
$obj = new stdClass();
@ -1107,7 +1225,7 @@ class Context
* @param string $method Response method. [HTML|XMLRPC|JSON]
* @return void
*/
function setResponseMethod($method = 'HTML')
public static function setResponseMethod($method = 'HTML')
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -1120,7 +1238,7 @@ class Context
*
* @return string Response method. If it's not set, returns request method.
*/
function getResponseMethod()
public static function getResponseMethod()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -1141,7 +1259,7 @@ class Context
* @param string $type Request method. (Optional - GET|POST|XMLRPC|JSON)
* @return void
*/
function setRequestMethod($type = '')
public static function setRequestMethod($type = '')
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -1159,7 +1277,7 @@ class Context
*
* @return void
*/
function _checkGlobalVars()
public function _checkGlobalVars()
{
$this->_recursiveCheckVar($_SERVER['HTTP_HOST']);
@ -1171,11 +1289,11 @@ class Context
}
/**
* handle request areguments for GET/POST
* handle request arguments for GET/POST
*
* @return void
*/
function _setRequestArgument()
public function _setRequestArgument()
{
if(!count($_REQUEST))
{
@ -1218,7 +1336,7 @@ class Context
}
}
function _recursiveCheckVar($val)
public function _recursiveCheckVar($val)
{
if(is_string($val))
{
@ -1245,7 +1363,7 @@ class Context
*
* @return void
*/
function _setJSONRequestArgument()
public function _setJSONRequestArgument()
{
if($this->getRequestMethod() != 'JSON')
{
@ -1266,7 +1384,7 @@ class Context
*
* @return void
*/
function _setXmlRpcArgument()
public function _setXmlRpcArgument()
{
if($this->getRequestMethod() != 'XMLRPC')
{
@ -1357,7 +1475,7 @@ class Context
* @param string $do_stripslashes Whether to strip slashes
* @return mixed filtered value. Type are string or array
*/
function _filterRequestVar($key, $val, $do_stripslashes = 1)
public function _filterRequestVar($key, $val, $do_stripslashes = 1)
{
if(!($isArray = is_array($val)))
{
@ -1404,7 +1522,7 @@ class Context
*
* @return bool True: exists, False: otherwise
*/
function isUploaded()
public static function isUploaded()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->is_uploaded;
@ -1415,7 +1533,7 @@ class Context
*
* @return void
*/
function _setUploadedArgument()
public function _setUploadedArgument()
{
if($_SERVER['REQUEST_METHOD'] != 'POST' || !$_FILES || (stripos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') === FALSE && stripos($_SERVER['HTTP_CONTENT_TYPE'], 'multipart/form-data') === FALSE))
{
@ -1458,7 +1576,7 @@ class Context
* Return request method
* @return string Request method type. (Optional - GET|POST|XMLRPC|JSON)
*/
function getRequestMethod()
public static function getRequestMethod()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->request_method;
@ -1468,7 +1586,7 @@ class Context
* Return request URL
* @return string request URL
*/
function getRequestUrl()
public static function getRequestUrl()
{
static $url = null;
if(is_null($url))
@ -1490,7 +1608,7 @@ class Context
* Return js callback func.
* @return string callback func.
*/
function getJSCallbackFunc()
public static function getJSCallbackFunc()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$js_callback_func = isset($_GET['xe_js_callback']) ? $_GET['xe_js_callback'] : $_POST['xe_js_callback'];
@ -1515,7 +1633,7 @@ class Context
* @param bool $autoEncode If TRUE, url encode automatically, detailed. Use this option, $encode value should be TRUE
* @return string URL
*/
function getUrl($num_args = 0, $args_list = array(), $domain = null, $encode = TRUE, $autoEncode = FALSE)
public static function getUrl($num_args = 0, $args_list = array(), $domain = null, $encode = TRUE, $autoEncode = FALSE)
{
static $site_module_info = null;
static $current_info = null;
@ -1757,7 +1875,7 @@ class Context
* @param string $domain Domain
* @retrun string converted URL
*/
function getRequestUri($ssl_mode = FOLLOW_REQUEST_SSL, $domain = null)
public static function getRequestUri($ssl_mode = FOLLOW_REQUEST_SSL, $domain = null)
{
static $url = array();
@ -1856,7 +1974,7 @@ class Context
* @param mixed $set_to_get_vars If not FALSE, Set to get vars.
* @return void
*/
function set($key, $val, $set_to_get_vars = 0)
public static function set($key, $val, $set_to_get_vars = 0)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->context->{$key} = $val;
@ -1881,7 +1999,7 @@ class Context
* @param string $key Key
* @return string Key
*/
function get($key)
public static function get($key)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -1897,7 +2015,7 @@ class Context
*
* @return object
*/
function gets()
public static function gets()
{
$num_args = func_num_args();
if($num_args < 1)
@ -1920,7 +2038,7 @@ class Context
*
* @return object All data
*/
function getAll()
public static function getAll()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->context;
@ -1931,7 +2049,7 @@ class Context
*
* @return Object Request variables.
*/
function getRequestVars()
public static function getRequestVars()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
if($self->get_vars)
@ -1947,7 +2065,7 @@ class Context
* @param string $action act name
* @return void
*/
function addSSLAction($action)
public static function addSSLAction($action)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -1971,7 +2089,7 @@ class Context
* @param string $action act name
* @return void
*/
function addSSLActions($action_array)
public static function addSSLActions($action_array)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -1999,7 +2117,7 @@ class Context
* @param string $action act name
* @return void
*/
function subtractSSLAction($action)
public static function subtractSSLAction($action)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -2017,7 +2135,7 @@ class Context
*
* @return string acts in array
*/
function getSSLActions()
public static function getSSLActions()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
if($self->getSslStatus() == 'optional')
@ -2032,7 +2150,7 @@ class Context
* @param string $action act name
* @return bool If SSL exists, return TRUE.
*/
function isExistsSSLAction($action)
public static function isExistsSSLAction($action)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return isset($self->ssl_actions[$action]);
@ -2045,7 +2163,7 @@ class Context
* @param string $file file path
* @return string normalized file path
*/
function normalizeFilePath($file)
public static function normalizeFilePath($file)
{
if($file{0} != '/' && $file{0} != '.' && strpos($file, '://') === FALSE)
{
@ -2067,7 +2185,7 @@ class Context
* @param string $file file path
* @return string Converted file path
*/
function getAbsFileUrl($file)
public static function getAbsFileUrl($file)
{
$file = self::normalizeFilePath($file);
if(strpos($file, './') === 0)
@ -2098,7 +2216,7 @@ class Context
* $args[3]: index
*
*/
function loadFile($args)
public static function loadFile($args)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -2113,7 +2231,7 @@ class Context
* @param string $media Media query
* @return void
*/
function unloadFile($file, $targetIe = '', $media = 'all')
public static function unloadFile($file, $targetIe = '', $media = 'all')
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->oFrontEndFileHandler->unloadFile($file, $targetIe, $media);
@ -2125,7 +2243,7 @@ class Context
* @param string $type Unload target (optional - all|css|js)
* @return void
*/
function unloadAllFiles($type = 'all')
public static function unloadAllFiles($type = 'all')
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->oFrontEndFileHandler->unloadAllFiles($type);
@ -2144,7 +2262,7 @@ class Context
* @param string $autoPath If path not readed, set the path automatically.
* @return void
*/
function addJsFile($file, $optimized = FALSE, $targetie = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null)
public static function addJsFile($file, $optimized = FALSE, $targetie = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null)
{
if($isRuleset)
{
@ -2174,7 +2292,7 @@ class Context
* @param string $targetie target IE
* @return void
*/
function unloadJsFile($file, $optimized = FALSE, $targetie = '')
public static function unloadJsFile($file, $optimized = FALSE, $targetie = '')
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->oFrontEndFileHandler->unloadFile($file, $targetie);
@ -2185,7 +2303,7 @@ class Context
*
* @return void
*/
function unloadAllJsFiles()
public static function unloadAllJsFiles()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->oFrontEndFileHandler->unloadAllFiles('js');
@ -2198,7 +2316,7 @@ class Context
* @param string $filename File name
* @return void
*/
function addJsFilter($path, $filename)
public static function addJsFilter($path, $filename)
{
$oXmlFilter = new XmlJSFilter($path, $filename);
$oXmlFilter->compile();
@ -2211,7 +2329,7 @@ class Context
* @param array $files File list
* @return array File list
*/
function _getUniqueFileList($files)
public static function _getUniqueFileList($files)
{
ksort($files);
$files = array_values($files);
@ -2234,7 +2352,7 @@ class Context
* @param string $type Added position. (head:<head>..</head>, body:<body>..</body>)
* @return array Returns javascript file list. Array contains file, targetie.
*/
function getJsFile($type = 'head')
public static function getJsFile($type = 'head')
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->oFrontEndFileHandler->getJsFileList($type);
@ -2252,7 +2370,7 @@ class Context
* @return void
*
*/
function addCSSFile($file, $optimized = FALSE, $media = 'all', $targetie = '', $index = 0)
public static function addCSSFile($file, $optimized = FALSE, $media = 'all', $targetie = '', $index = 0)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->oFrontEndFileHandler->loadFile(array($file, $media, $targetie, $index));
@ -2268,7 +2386,7 @@ class Context
* @param string $targetie target IE
* @return void
*/
function unloadCSSFile($file, $optimized = FALSE, $media = 'all', $targetie = '')
public static function unloadCSSFile($file, $optimized = FALSE, $media = 'all', $targetie = '')
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->oFrontEndFileHandler->unloadFile($file, $targetie, $media);
@ -2279,7 +2397,7 @@ class Context
*
* @return void
*/
function unloadAllCSSFiles()
public static function unloadAllCSSFiles()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->oFrontEndFileHandler->unloadAllFiles('css');
@ -2290,7 +2408,7 @@ class Context
*
* @return array Returns css file list. Array contains file, media, targetie.
*/
function getCSSFile()
public static function getCSSFile()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->oFrontEndFileHandler->getCssFileList();
@ -2301,7 +2419,7 @@ class Context
* @param string $pluginName
* @return stdClass
*/
function getJavascriptPluginInfo($pluginName)
public static function getJavascriptPluginInfo($pluginName)
{
if($plugin_name == 'ui.datepicker')
{
@ -2356,7 +2474,7 @@ class Context
* @param string $plugin_name plugin name
* @return void
*/
function loadJavascriptPlugin($plugin_name)
public static function loadJavascriptPlugin($plugin_name)
{
static $loaded_plugins = array();
@ -2414,13 +2532,13 @@ class Context
* @param string $header add html code before </head>.
* @return void
*/
function addHtmlHeader($header)
public static function addHtmlHeader($header)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->html_header .= "\n" . $header;
}
function clearHtmlHeader()
public static function clearHtmlHeader()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->html_header = '';
@ -2431,7 +2549,7 @@ class Context
*
* @return string Added html code before </head>
*/
function getHtmlHeader()
public static function getHtmlHeader()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->html_header;
@ -2442,7 +2560,7 @@ class Context
*
* @param string $class_name class name
*/
function addBodyClass($class_name)
public static function addBodyClass($class_name)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->body_class[] = $class_name;
@ -2453,7 +2571,7 @@ class Context
*
* @return string Return class to html body
*/
function getBodyClass()
public static function getBodyClass()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->body_class = array_unique($self->body_class);
@ -2466,7 +2584,7 @@ class Context
*
* @param string $header Add html code after <body>
*/
function addBodyHeader($header)
public static function addBodyHeader($header)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->body_header .= "\n" . $header;
@ -2477,7 +2595,7 @@ class Context
*
* @return string Added html code after <body>
*/
function getBodyHeader()
public static function getBodyHeader()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->body_header;
@ -2488,7 +2606,7 @@ class Context
*
* @param string $footer Add html code before </body>
*/
function addHtmlFooter($footer)
public static function addHtmlFooter($footer)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->html_footer .= ($self->Htmlfooter ? "\n" : '') . $footer;
@ -2499,7 +2617,7 @@ class Context
*
* @return string Added html code before </body>
*/
function getHtmlFooter()
public static function getHtmlFooter()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
return $self->html_footer;
@ -2510,7 +2628,7 @@ class Context
*
* @retrun string The path of the config file that contains database settings
*/
function getConfigFile()
public static function getConfigFile()
{
return _XE_PATH_ . 'files/config/db.config.php';
}
@ -2520,7 +2638,7 @@ class Context
*
* @return string The path of the config file that contains FTP settings
*/
function getFTPConfigFile()
public static function getFTPConfigFile()
{
return _XE_PATH_ . 'files/config/ftp.config.php';
}
@ -2530,7 +2648,7 @@ class Context
*
* @return bool True if the config file exists, otherwise FALSE.
*/
function isInstalled()
public static function isInstalled()
{
return FileHandler::hasContent(self::getConfigFile());
}
@ -2541,7 +2659,7 @@ class Context
* @param string Transforms codes
* @return string Transforms codes
*/
function transContent($content)
public static function transContent($content)
{
return $content;
}
@ -2551,7 +2669,7 @@ class Context
*
* @return bool True if it is allowed to use rewrite mod, otherwise FALSE
*/
function isAllowRewrite()
public static function isAllowRewrite()
{
$oContext = self::getInstance();
return $oContext->allow_rewrite;
@ -2563,7 +2681,7 @@ class Context
* @param string $path URL path
* @return string Converted path
*/
function pathToUrl($path)
public static function pathToUrl($path)
{
$xe = _XE_PATH_;
$path = strtr($path, "\\", "/");
@ -2618,7 +2736,7 @@ class Context
* Get meta tag
* @return array The list of meta tags
*/
function getMetaTag()
public static function getMetaTag()
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
@ -2645,7 +2763,7 @@ class Context
* @param mixed $is_http_equiv value of http_equiv
* @return void
*/
function addMetaTag($name, $content, $is_http_equiv = FALSE)
public static function addMetaTag($name, $content, $is_http_equiv = FALSE)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$self->meta_tags[$name . "\t" . ($is_http_equiv ? '1' : '0')] = $content;

View file

@ -1,11 +1,6 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
if(!defined('__XE_LOADED_DB_CLASS__'))
{
define('__XE_LOADED_DB_CLASS__', 1);
}
/**
* - DB parent class
* - usage of db in XE is via xml
@ -190,7 +185,7 @@ class DB
* constructor
* @return void
*/
function DB()
function __construct()
{
$this->count_cache_path = _XE_PATH_ . $this->count_cache_path;
$this->cache_file = _XE_PATH_ . $this->cache_file;
@ -215,16 +210,18 @@ class DB
*/
function getEnableList()
{
if(!$this->supported_list)
is_a($this, 'DB') ? $self = $this : $self = self::getInstance();
if(!$self->supported_list)
{
$oDB = new DB();
$this->supported_list = $oDB->_getSupportedList();
$self->supported_list = $oDB->_getSupportedList();
}
$enableList = array();
if(is_array($this->supported_list))
if(is_array($self->supported_list))
{
foreach($this->supported_list AS $key => $value)
foreach($self->supported_list AS $key => $value)
{
if($value->enable)
{
@ -242,16 +239,18 @@ class DB
*/
function getDisableList()
{
if(!$this->supported_list)
is_a($this, 'DB') ? $self = $this : $self = self::getInstance();
if(!$self->supported_list)
{
$oDB = new DB();
$this->supported_list = $oDB->_getSupportedList();
$self->supported_list = $oDB->_getSupportedList();
}
$disableList = array();
if(is_array($this->supported_list))
if(is_array($self->supported_list))
{
foreach($this->supported_list AS $key => $value)
foreach($self->supported_list AS $key => $value)
{
if(!$value->enable)
{
@ -1090,7 +1089,7 @@ class DB
* this method is protected
* @return boolean
*/
function _begin()
function _begin($transactionLevel = 0)
{
return TRUE;
}
@ -1118,7 +1117,7 @@ class DB
* this method is protected
* @return boolean
*/
function _rollback()
function _rollback($transactionLevel = 0)
{
return TRUE;
}

View file

@ -49,7 +49,7 @@ class DBCubrid extends DB
* constructor
* @return void
*/
function DBCubrid()
function __construct()
{
$this->_setDBInfo();
$this->_connect();
@ -144,7 +144,7 @@ class DBCubrid extends DB
* this method is private
* @return boolean
*/
function _begin($transactionLevel)
function _begin($transactionLevel = 0)
{
if(__CUBRID_VERSION__ >= '8.4.0')
{
@ -167,7 +167,7 @@ class DBCubrid extends DB
* this method is private
* @return boolean
*/
function _rollback($transactionLevel)
function _rollback($transactionLevel = 0)
{
$connection = $this->_getConnection('master');
@ -539,6 +539,68 @@ class DBCubrid extends DB
$this->_query($query);
}
/**
* Modify a column (only supported in CUBRID 8.4 and above, otherwise returns false)
* @param string $table_name table name
* @param string $column_name column name
* @param string $type column type, default value is 'number'
* @param int $size column size
* @param string|int $default default value
* @param boolean $notnull not null status, default value is false
* @return bool
*/
function modifyColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = FALSE)
{
if(!version_compare(__CUBRID_VERSION__, '8.4.0', '>='))
{
return false;
}
$type = strtoupper($this->column_type[$type]);
if($type == 'INTEGER')
{
$size = '';
}
$query = sprintf("alter class \"%s%s\" modify \"%s\" ", $this->prefix, $table_name, $column_name);
if($type == 'char' || $type == 'varchar')
{
if($size)
{
$size = $size * 3;
}
}
if($size)
{
$query .= sprintf("%s(%s) ", $type, $size);
}
else
{
$query .= sprintf("%s ", $type);
}
if($default)
{
if($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT')
{
$query .= sprintf("default %d ", $default);
}
else
{
$query .= sprintf("default '%s' ", $default);
}
}
if($notnull)
{
$query .= "not null ";
}
return $this->_query($query) ? true : false;
}
/**
* Check column exist status of the table
* @param string $table_name table name
@ -567,6 +629,62 @@ class DBCubrid extends DB
return $output;
}
/**
* Get information about a column
* @param string $table_name table name
* @param string $column_name column name
* @return object
*/
function getColumnInfo($table_name, $column_name)
{
$query = sprintf("select * from \"db_attribute\" where " . "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name);
$result = $this->_query($query);
if($this->isError())
{
return;
}
$output = $this->_fetch($result);
if($output)
{
$dbtype = strtolower($output->data_type);
if($dbtype === 'string') $dbtype = 'character varying';
$size = ($output->prec > 0) ? $output->prec : null;
if($xetype = array_search("$dbtype($size)", $this->column_type))
{
$dbtype = "$dbtype($size)";
$size = null;
}
elseif($size !== null)
{
if($xetype = array_search($dbtype, $this->column_type))
{
if($size % 3 == 0) $size = intval($size / 3);
}
else
{
$xetype = $dbtype;
}
}
else
{
$xetype = $dbtype;
$size = null;
}
return (object)array(
'name' => $output->attr_name,
'dbtype' => $dbtype,
'xetype' => $xetype,
'size' => $size,
'default_value' => $output->default_value,
'notnull' => !$output->is_nullable,
);
}
else
{
return false;
}
}
/**
* Add an index to the table
* $target_columns = array(col1, col2)

View file

@ -42,7 +42,7 @@ class DBMssql extends DB
* Constructor
* @return void
*/
function DBMssql()
function __construct()
{
$this->_setDBInfo();
$this->_connect();
@ -113,7 +113,7 @@ class DBMssql extends DB
* this method is private
* @return boolean
*/
function _begin($transactionLevel)
function _begin($transactionLevel = 0)
{
$connection = $this->_getConnection('master');
@ -136,7 +136,7 @@ class DBMssql extends DB
* this method is private
* @return boolean
*/
function _rollback($transactionLevel)
function _rollback($transactionLevel = 0)
{
$connection = $this->_getConnection('master');
@ -389,7 +389,7 @@ class DBMssql extends DB
$size = '';
}
$query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name);
$query = sprintf("alter table %s%s add \"%s\" ", $this->prefix, $table_name, $column_name);
if($size)
{
$query .= sprintf(" %s(%s) ", $type, $size);
@ -423,10 +423,50 @@ class DBMssql extends DB
{
return;
}
$query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name);
$query = sprintf("alter table %s%s drop column \"%s\" ", $this->prefix, $table_name, $column_name);
$this->_query($query);
}
/**
* Modify a column
* @param string $table_name table name
* @param string $column_name column name
* @param string $type column type, default value is 'number'
* @param int $size column size
* @param string|int $default default value
* @param boolean $notnull not null status, default value is false
* @return bool
*/
function modifyColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = false)
{
$type = $this->column_type[$type];
if(strtoupper($type) == 'INTEGER')
{
$size = '';
}
$query = sprintf("alter table %s%s alter column %s ", $this->prefix, $table_name, $column_name);
if($size)
{
$query .= sprintf(" %s(%s) ", $type, $size);
}
else
{
$query .= sprintf(" %s ", $type);
}
if($default)
{
$query .= sprintf(" default '%s' ", $default);
}
if($notnull)
{
$query .= " not null ";
}
return $this->_query($query) ? true : false;
}
/**
* Check column exist status of the table
* @param string $table_name table name
@ -448,7 +488,67 @@ class DBMssql extends DB
}
return true;
}
/**
* Get information about a column
* @param string $table_name table name
* @param string $column_name column name
* @return object
*/
function getColumnInfo($table_name, $column_name)
{
$query = sprintf("select syscolumns.name as name, systypes.name as type_name, syscolumns.length as length, " .
"syscolumns.isnullable as isnullable, syscomments.text as default_value from syscolumns " .
"inner join sysobjects on sysobjects.id = syscolumns.id " .
"inner join systypes on systypes.xtype = syscolumns.xtype " .
"left join syscomments on syscolumns.cdefault = syscomments.id " .
"where sysobjects.name = '%s%s' and syscolumns.name = '%s'", $this->prefix, $table_name, $column_name);
$result = $this->_query($query);
if($this->isError())
{
return;
}
$output = $this->_fetch($result);
if($output)
{
$dbtype = $output->type_name;
$size = ($output->length > 0) ? $output->length : null;
if($xetype = array_search("$dbtype($size)", $this->column_type))
{
$dbtype = "$dbtype($size)";
$size = null;
}
elseif($size !== null)
{
if($xetype = array_search($dbtype, $this->column_type))
{
// no-op
}
else
{
$xetype = $dbtype;
}
}
else
{
$xetype = $dbtype;
$size = null;
}
return (object)array(
'name' => $output->name,
'dbtype' => $dbtype,
'xetype' => $xetype,
'size' => $size,
'default_value' => $output->default_value,
'notnull' => !$output->isnullable,
);
}
else
{
return false;
}
}
/**
* Add an index to the table
* $target_columns = array(col1, col2)

View file

@ -43,7 +43,7 @@ class DBMysql extends DB
* Constructor
* @return void
*/
function DBMysql()
function __construct()
{
$this->_setDBInfo();
$this->_connect();
@ -147,7 +147,7 @@ class DBMysql extends DB
* this method is private
* @return boolean
*/
function _begin()
function _begin($transactionLevel = 0)
{
return true;
}
@ -157,7 +157,7 @@ class DBMysql extends DB
* this method is private
* @return boolean
*/
function _rollback()
function _rollback($transactionLevel = 0)
{
return true;
}
@ -340,6 +340,45 @@ class DBMysql extends DB
$this->_query($query);
}
/**
* Modify a column
* @param string $table_name table name
* @param string $column_name column name
* @param string $type column type, default value is 'number'
* @param int $size column size
* @param string|int $default default value
* @param boolean $notnull not null status, default value is false
* @return bool
*/
function modifyColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = false)
{
$type = $this->column_type[$type];
if(strtoupper($type) == 'INTEGER')
{
$size = '';
}
$query = sprintf("alter table `%s%s` modify `%s` ", $this->prefix, $table_name, $column_name);
if($size)
{
$query .= sprintf(" %s(%s) ", $type, $size);
}
else
{
$query .= sprintf(" %s ", $type);
}
if($default)
{
$query .= sprintf(" default '%s' ", $default);
}
if($notnull)
{
$query .= " not null ";
}
return $this->_query($query) ? true : false;
}
/**
* Check column exist status of the table
* @param string $table_name table name
@ -370,6 +409,61 @@ class DBMysql extends DB
return false;
}
/**
* Get information about a column
* @param string $table_name table name
* @param string $column_name column name
* @return object
*/
function getColumnInfo($table_name, $column_name)
{
$query = sprintf("show fields from `%s%s` where `Field` = '%s'", $this->prefix, $table_name, $column_name);
$result = $this->_query($query);
if($this->isError())
{
return;
}
$output = $this->_fetch($result);
if($output)
{
$dbtype = $output->{'Type'};
if($xetype = array_search($dbtype, $this->column_type))
{
$size = null;
}
elseif(strpos($dbtype, '(') !== false)
{
list($dbtype, $size) = explode('(', $dbtype, 2);
$size = intval(rtrim($size, ')'));
if($xetype = array_search($dbtype, $this->column_type))
{
// no-op
}
else
{
$xetype = $dbtype;
}
}
else
{
$xetype = $dbtype;
$size = null;
}
return (object)array(
'name' => $output->{'Field'},
'dbtype' => $dbtype,
'xetype' => $xetype,
'size' => $size,
'default_value' => $output->{'Default'},
'notnull' => strncmp($output->{'Null'}, 'NO', 2) == 0 ? true : false,
);
}
else
{
return false;
}
}
/**
* Add an index to the table
* $target_columns = array(col1, col2)

View file

@ -20,7 +20,7 @@ class DBMysql_innodb extends DBMysql
* Constructor
* @return void
*/
function DBMysql_innodb()
function __construct()
{
$this->_setDBInfo();
$this->_connect();
@ -51,7 +51,7 @@ class DBMysql_innodb extends DBMysql
* this method is private
* @return boolean
*/
function _begin($transactionLevel)
function _begin($transactionLevel = 0)
{
$connection = $this->_getConnection('master');
@ -71,7 +71,7 @@ class DBMysql_innodb extends DBMysql
* this method is private
* @return boolean
*/
function _rollback($transactionLevel)
function _rollback($transactionLevel = 0)
{
$connection = $this->_getConnection('master');

View file

@ -20,7 +20,7 @@ class DBMysqli extends DBMysql
* Constructor
* @return void
*/
function DBMysqli()
function __construct()
{
$this->_setDBInfo();
$this->_connect();

View file

@ -20,7 +20,7 @@ class DBMysqli_innodb extends DBMysql
* Constructor
* @return void
*/
function DBMysqli_innodb()
function __construct()
{
$this->_setDBInfo();
$this->_connect();
@ -85,7 +85,7 @@ class DBMysqli_innodb extends DBMysql
* this method is private
* @return boolean
*/
function _begin($transactionLevel)
function _begin($transactionLevel = 0)
{
$connection = $this->_getConnection('master');
@ -105,7 +105,7 @@ class DBMysqli_innodb extends DBMysql
* this method is private
* @return boolean
*/
function _rollback($transactionLevel)
function _rollback($transactionLevel = 0)
{
$connection = $this->_getConnection('master');

View file

@ -94,7 +94,7 @@ class Query extends Object
* @param string $priority
* @return void
*/
function Query($queryID = NULL
function __construct($queryID = NULL
, $action = NULL
, $columns = NULL
, $tables = NULL

View file

@ -33,7 +33,7 @@ class Subquery extends Query
* @param string $join_type
* @return void
*/
function Subquery($alias, $columns, $tables, $conditions, $groups, $orderby, $limit, $join_type = null)
function __construct($alias, $columns, $tables, $conditions, $groups, $orderby, $limit, $join_type = null)
{
$this->alias = $alias;

View file

@ -41,7 +41,7 @@ class Condition
* @param string $pipe
* @return void
*/
function Condition($column_name, $argument, $operation, $pipe)
function __construct($column_name, $argument, $operation, $pipe)
{
$this->column_name = $column_name;
$this->argument = $argument;

View file

@ -29,7 +29,7 @@ class ConditionGroup
* @param string $pipe
* @return void
*/
function ConditionGroup($conditions, $pipe = "")
function __construct($conditions, $pipe = "")
{
$this->conditions = array();
foreach($conditions as $condition)

View file

@ -17,9 +17,9 @@ class ConditionSubquery extends Condition
* @param string $pipe
* @return void
*/
function ConditionSubquery($column_name, $argument, $operation, $pipe = "")
function __construct($column_name, $argument, $operation, $pipe = "")
{
parent::Condition($column_name, $argument, $operation, $pipe);
parent::__construct($column_name, $argument, $operation, $pipe);
$this->_value = $this->argument->toString();
}

View file

@ -17,14 +17,14 @@ class ConditionWithArgument extends Condition
* @param string $pipe
* @return void
*/
function ConditionWithArgument($column_name, $argument, $operation, $pipe = "")
function __construct($column_name, $argument, $operation, $pipe = "")
{
if($argument === null)
{
$this->_show = false;
return;
}
parent::Condition($column_name, $argument, $operation, $pipe);
parent::__construct($column_name, $argument, $operation, $pipe);
$this->_value = $argument->getValue();
}

View file

@ -17,9 +17,9 @@ class ConditionWithoutArgument extends Condition
* @param string $pipe
* @return void
*/
function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = "")
function __construct($column_name, $argument, $operation, $pipe = "")
{
parent::Condition($column_name, $argument, $operation, $pipe);
parent::__construct($column_name, $argument, $operation, $pipe);
$tmpArray = array('in' => 1, 'notin' => 1, 'not_in' => 1);
if(isset($tmpArray[$operation]))
{

View file

@ -23,9 +23,9 @@ class ClickCountExpression extends SelectExpression
* @param bool $click_count
* @return void
*/
function ClickCountExpression($column_name, $alias = NULL, $click_count = false)
function __construct($column_name, $alias = NULL, $click_count = false)
{
parent::SelectExpression($column_name, $alias);
parent::__construct($column_name, $alias);
if(!is_bool($click_count))
{

View file

@ -24,9 +24,9 @@ class DeleteExpression extends Expression
* @param mixed $value
* @return void
*/
function DeleteExpression($column_name, $value)
function __construct($column_name, $value)
{
parent::Expression($column_name);
parent::__construct($column_name);
$this->value = $value;
}

View file

@ -27,7 +27,7 @@ class Expression
* @param string $column_name
* @return void
*/
function Expression($column_name)
function __construct($column_name)
{
$this->column_name = $column_name;
}

View file

@ -23,9 +23,9 @@ class InsertExpression extends Expression
* @param object $argument
* @return void
*/
function InsertExpression($column_name, $argument)
function __construct($column_name, $argument)
{
parent::Expression($column_name);
parent::__construct($column_name);
$this->argument = $argument;
}

View file

@ -30,9 +30,9 @@ class SelectExpression extends Expression
* @param string $alias
* @return void
*/
function SelectExpression($column_name, $alias = NULL)
function __construct($column_name, $alias = NULL)
{
parent::Expression($column_name);
parent::__construct($column_name);
$this->column_alias = $alias;
}

View file

@ -16,9 +16,9 @@ class StarExpression extends SelectExpression
* constructor, set the column to asterisk
* @return void
*/
function StarExpression()
function __construct()
{
parent::SelectExpression("*");
parent::__construct("*");
}
function getArgument()

View file

@ -23,9 +23,9 @@ class UpdateExpression extends Expression
* @param object $argument
* @return void
*/
function UpdateExpression($column_name, $argument)
function __construct($column_name, $argument)
{
parent::Expression($column_name);
parent::__construct($column_name);
$this->argument = $argument;
}

View file

@ -23,9 +23,9 @@ class UpdateExpressionWithoutArgument extends UpdateExpression
* @param object $argument
* @return void
*/
function UpdateExpressionWithoutArgument($column_name, $argument)
function __construct($column_name, $argument)
{
parent::Expression($column_name);
parent::__construct($column_name, $argument);
$this->argument = $argument;
}

View file

@ -40,7 +40,7 @@ class Limit
* @param int $page_count
* @return void
*/
function Limit($list_count, $page = NULL, $page_count = NULL)
function __construct($list_count, $page = NULL, $page_count = NULL)
{
$this->list_count = $list_count;
if($page)

View file

@ -27,7 +27,7 @@ class OrderByColumn
* @param string $sort_order
* @return void
*/
function OrderByColumn($column_name, $sort_order)
function __construct($column_name, $sort_order)
{
$this->column_name = $column_name;
$this->sort_order = $sort_order;

View file

@ -34,9 +34,9 @@ class CubridTableWithHint extends Table
* @param array $index_hints_list
* @return void
*/
function CubridTableWithHint($name, $alias = NULL, $index_hints_list)
function __construct($name, $alias = NULL, $index_hints_list)
{
parent::Table($name, $alias);
parent::__construct($name, $alias);
$this->index_hints_list = $index_hints_list;
}

View file

@ -27,7 +27,7 @@ class IndexHint
* @param string $index_hint_type
* @return void
*/
function IndexHint($index_name, $index_hint_type)
function __construct($index_name, $index_hint_type)
{
$this->index_name = $index_name;
$this->index_hint_type = $index_hint_type;

View file

@ -32,9 +32,9 @@ class JoinTable extends Table
* @param array $conditions
* @return void
*/
function JoinTable($name, $alias, $join_type, $conditions)
function __construct($name, $alias, $join_type, $conditions)
{
parent::Table($name, $alias);
parent::__construct($name, $alias);
$this->join_type = $join_type;
$this->conditions = $conditions;
}

View file

@ -34,9 +34,9 @@ class MssqlTableWithHint extends Table
* @param string $index_hints_list
* @return void
*/
function MssqlTableWithHint($name, $alias = NULL, $index_hints_list)
function __construct($name, $alias = NULL, $index_hints_list)
{
parent::Table($name, $alias);
parent::__construct($name, $alias);
$this->index_hints_list = $index_hints_list;
}

View file

@ -34,9 +34,9 @@ class MysqlTableWithHint extends Table
* @param string $index_hints_list
* @return void
*/
function MysqlTableWithHint($name, $alias = NULL, $index_hints_list)
function __construct($name, $alias = NULL, $index_hints_list)
{
parent::Table($name, $alias);
parent::__construct($name, $alias);
$this->index_hints_list = $index_hints_list;
}

View file

@ -27,7 +27,7 @@ class Table
* @param string $alias
* @return void
*/
function Table($name, $alias = NULL)
function __construct($name, $alias = NULL)
{
$this->name = $name;
$this->alias = $alias;

View file

@ -28,7 +28,6 @@ class DisplayHandler extends Handler
if(
(defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1) &&
strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE &&
function_exists('ob_gzhandler') &&
extension_loaded('zlib') &&
$oModule->gzhandler_enable
)
@ -78,6 +77,9 @@ class DisplayHandler extends Handler
$handler->prepareToPrint($output);
}
// Start the session if $_SESSION was touched
Context::getInstance()->checkSessionStatus();
// header output
$httpStatusCode = $oModule->getHttpStatusCode();
@ -112,17 +114,15 @@ class DisplayHandler extends Handler
$this->gz_enabled = FALSE;
}
// results directly output
// enable gzip using zlib extension
if($this->gz_enabled)
{
header("Content-Encoding: gzip");
print ob_gzhandler($output, 5);
}
else
{
print $output;
ini_set('zlib.output_compression', true);
}
// results directly output
print $output;
// call a trigger after display
ModuleHandler::triggerCall('display', 'after', $output);
@ -321,11 +321,6 @@ class DisplayHandler extends Handler
function _printXMLHeader()
{
header("Content-Type: text/xml; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**
@ -335,11 +330,6 @@ class DisplayHandler extends Handler
function _printHTMLHeader()
{
header("Content-Type: text/html; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**
@ -349,11 +339,6 @@ class DisplayHandler extends Handler
function _printJSONHeader()
{
header("Content-Type: text/html; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**

View file

@ -38,7 +38,7 @@ class ExtraVar
* @param int $module_srl Sequence of module
* @return void
*/
function ExtraVar($module_srl)
function __construct($module_srl)
{
$this->module_srl = $module_srl;
}
@ -157,7 +157,7 @@ class ExtraItem
* @param string $eid Unique id of extra variable in module
* @return void
*/
function ExtraItem($module_srl, $idx, $name, $type = 'text', $default = null, $desc = '', $is_required = 'N', $search = 'N', $value = null, $eid = '')
function __construct($module_srl, $idx, $name, $type = 'text', $default = null, $desc = '', $is_required = 'N', $search = 'N', $value = null, $eid = '')
{
if(!$idx)
{
@ -292,11 +292,11 @@ class ExtraItem
/**
* Returns a value for HTML
*
* @return string Returns a value expressed in HTML.
* @return string Returns filtered value
*/
function getValue()
{
return $this->_getTypeValue($this->type, $this->value);
return removeHackTag($this->value);
}
/**

View file

@ -15,7 +15,7 @@ class FileHandler
* @param string $source path to change into absolute path
* @return string Absolute path
*/
function getRealPath($source)
public static function getRealPath($source)
{
if(strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0)
{
@ -36,7 +36,7 @@ class FileHandler
* @param string $type If set as 'force'. Even if the file exists in target, the file is copied.
* @return void
*/
function copyDir($source_dir, $target_dir, $filter = null, $type = null)
public static function copyDir($source_dir, $target_dir, $filter = null, $type = null)
{
$source_dir = self::getRealPath($source_dir);
$target_dir = self::getRealPath($target_dir);
@ -101,7 +101,7 @@ class FileHandler
* @param string $force Y: overwrite
* @return void
*/
function copyFile($source, $target, $force = 'Y')
public static function copyFile($source, $target, $force = 'Y')
{
setlocale(LC_CTYPE, 'en_US.UTF8', 'ko_KR.UTF8');
$source = self::getRealPath($source);
@ -124,7 +124,7 @@ class FileHandler
* @param string $filename Path of target file
* @return string The content of the file. If target file does not exist, this function returns nothing.
*/
function readFile($filename)
public static function readFile($filename)
{
if(($filename = self::exists($filename)) === FALSE || filesize($filename) < 1)
{
@ -142,7 +142,7 @@ class FileHandler
* @param string $mode a(append) / w(write)
* @return void
*/
function writeFile($filename, $buff, $mode = "w")
public static function writeFile($filename, $buff, $mode = "w")
{
$filename = self::getRealPath($filename);
$pathinfo = pathinfo($filename);
@ -164,7 +164,7 @@ class FileHandler
* @param string $filename path of target file
* @return bool Returns TRUE on success or FALSE on failure.
*/
function removeFile($filename)
public static function removeFile($filename)
{
return (($filename = self::exists($filename)) !== FALSE) && @unlink($filename);
}
@ -178,7 +178,7 @@ class FileHandler
* @param string $target Path of target file
* @return bool Returns TRUE on success or FALSE on failure.
*/
function rename($source, $target)
public static function rename($source, $target)
{
return @rename(self::getRealPath($source), self::getRealPath($target));
}
@ -190,7 +190,7 @@ class FileHandler
* @param string $target Path of target file
* @return bool Returns TRUE on success or FALSE on failure.
*/
function moveFile($source, $target)
public static function moveFile($source, $target)
{
if(($source = self::exists($source)) !== FALSE)
{
@ -209,7 +209,7 @@ class FileHandler
* @param string $target_dir Path of target directory
* @return void
*/
function moveDir($source_dir, $target_dir)
public static function moveDir($source_dir, $target_dir)
{
self::rename($source_dir, $target_dir);
}
@ -225,7 +225,7 @@ class FileHandler
* @param bool $concat_prefix If TRUE, return file name as absolute path
* @return string[] Array of the filenames in the path
*/
function readDir($path, $filter = '', $to_lower = FALSE, $concat_prefix = FALSE)
public static function readDir($path, $filter = '', $to_lower = FALSE, $concat_prefix = FALSE)
{
$path = self::getRealPath($path);
$output = array();
@ -277,7 +277,7 @@ class FileHandler
* @param string $path_string Path of target directory
* @return bool TRUE if success. It might return nothing when ftp is used and connection to the ftp address failed.
*/
function makeDir($path_string)
public static function makeDir($path_string)
{
if(self::exists($path_string) !== FALSE)
{
@ -358,7 +358,7 @@ class FileHandler
* @param string $path Path of the target directory
* @return void
*/
function removeDir($path)
public static function removeDir($path)
{
if(($path = self::isDir($path)) === FALSE)
{
@ -399,7 +399,7 @@ class FileHandler
* @param string $path Path of the target directory
* @return void
*/
function removeBlankDir($path)
public static function removeBlankDir($path)
{
if(($path = self::isDir($path)) === FALSE)
{
@ -433,7 +433,7 @@ class FileHandler
* @param string $path Path of the target directory
* @return void
*/
function removeFilesInDir($path)
public static function removeFilesInDir($path)
{
if(($path = self::getRealPath($path)) === FALSE)
{
@ -475,7 +475,7 @@ class FileHandler
* @param int $size Number of the size
* @return string File size string
*/
function filesize($size)
public static function filesize($size)
{
if(!$size)
{
@ -515,12 +515,12 @@ class FileHandler
* @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(), $request_config = array())
public static function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
{
try
{
requirePear();
require_once('HTTP/Request.php');
if(!class_exists('HTTP_Request')) require_once('HTTP/Request.php');
$parsed_url = parse_url(__PROXY_SERVER__);
if($parsed_url["host"])
@ -621,7 +621,7 @@ class FileHandler
* @param string[] $headers Headers key value array.
* @return bool TRUE: success, FALSE: failed
*/
function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
public static function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
{
if(!($body = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers,$cookies,$post_data,$request_config)))
{
@ -639,7 +639,7 @@ class FileHandler
* @param $val Size in string (ex., 10, 10K, 10M, 10G )
* @return int converted size
*/
function returnBytes($val)
public static function returnBytes($val)
{
$unit = strtoupper(substr($val, -1));
$val = (float)$val;
@ -660,7 +660,7 @@ class FileHandler
* @param array $imageInfo Image info retrieved by getimagesize function
* @return bool TRUE: it's ok, FALSE: otherwise
*/
function checkMemoryLoadImage(&$imageInfo)
public static function checkMemoryLoadImage(&$imageInfo)
{
$K64 = 65536;
$TWEAKFACTOR = 2.0;
@ -689,7 +689,7 @@ class FileHandler
* @param string $thumbnail_type Thumbnail type(crop, ratio)
* @return bool TRUE: success, FALSE: failed
*/
function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop')
public static function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop')
{
// check params
if (($source_file = self::exists($source_file)) === FALSE)
@ -892,7 +892,7 @@ class FileHandler
* @param string $filename Path of the ini file
* @return array ini array (if the target file does not exist, it returns FALSE)
*/
function readIniFile($filename)
public static function readIniFile($filename)
{
if(($filename = self::exists($filename)) === FALSE)
{
@ -923,7 +923,7 @@ class FileHandler
* @param array $arr Array
* @return bool if array contains nothing it returns FALSE, otherwise TRUE
*/
function writeIniFile($filename, $arr)
public static function writeIniFile($filename, $arr)
{
if(!is_array($arr) || count($arr) == 0)
{
@ -939,7 +939,7 @@ class FileHandler
* @param array $arr Array
* @return string
*/
function _makeIniBuff($arr)
public static function _makeIniBuff($arr)
{
$return = array();
foreach($arr as $key => $val)
@ -976,7 +976,7 @@ class FileHandler
* @param string $mode File mode for fopen
* @return FileObject File object
*/
function openFile($filename, $mode)
public static function openFile($filename, $mode)
{
$pathinfo = pathinfo($filename);
self::makeDir($pathinfo['dirname']);
@ -991,7 +991,7 @@ class FileHandler
* @param string $filename Target file name
* @return bool Returns TRUE if the file exists and contains something.
*/
function hasContent($filename)
public static function hasContent($filename)
{
return (is_readable($filename) && (filesize($filename) > 0));
}
@ -1002,7 +1002,7 @@ class FileHandler
* @param string $filename Target file name
* @return bool Returns FALSE if the file does not exists, or Returns full path file(string).
*/
function exists($filename)
public static function exists($filename)
{
$filename = self::getRealPath($filename);
return file_exists($filename) ? $filename : FALSE;
@ -1014,7 +1014,7 @@ class FileHandler
* @param string $dir Target dir path
* @return bool Returns FALSE if the dir is not dir, or Returns full path of dir(string).
*/
function isDir($path)
public static function isDir($path)
{
$path = self::getRealPath($path);
return is_dir($path) ? $path : FALSE;
@ -1026,7 +1026,7 @@ class FileHandler
* @param string $path Target dir path
* @return bool
*/
function isWritableDir($path)
public static function isWritableDir($path)
{
$path = self::getRealPath($path);
if(is_dir($path)==FALSE)

View file

@ -34,7 +34,7 @@ class FileObject extends Object
* @param string $mode File open mode
* @return void
*/
function FileObject($path, $mode)
function __construct($path, $mode)
{
if($path != NULL)
{

View file

@ -41,7 +41,7 @@ class XEHttpRequest
* constructor
* @return void
*/
function XEHttpRequest($host, $port, $scheme='')
function __construct($host, $port, $scheme='')
{
$this->m_host = $host;
$this->m_port = $port;

View file

@ -130,7 +130,7 @@ class Mail extends PHPMailer
*
* @return void
*/
function Mail()
function __construct()
{
}

View file

@ -123,13 +123,13 @@ class Mobile
setcookie("mobile", 'true', 0, $xe_web_path);
}
}
elseif($_COOKIE['mobile'] != 'false')
elseif(isset($_COOKIE['mobile']) && $_COOKIE['mobile'] != 'false')
{
$_COOKIE['mobile'] = 'false';
setcookie("mobile", 'false', 0, $xe_web_path);
}
if($_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT']))
if(isset($_COOKIE['mobile']) && $_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT']))
{
setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path);
}
@ -238,4 +238,3 @@ class Mobile
return ($db_info->use_mobile_view === 'Y');
}
}
?>

View file

@ -32,7 +32,7 @@ class ModuleHandler extends Handler
* @return void
* */
function ModuleHandler($module = '', $act = '', $mid = '', $document_srl = '', $module_srl = '')
function __construct($module = '', $act = '', $mid = '', $document_srl = '', $module_srl = '')
{
// If XE has not installed yet, set module as install
if(!Context::isInstalled())
@ -116,7 +116,6 @@ class ModuleHandler extends Handler
* */
function init()
{
$oModuleModel = getModel('module');
$site_module_info = Context::get('site_module_info');
@ -317,13 +316,13 @@ class ModuleHandler extends Handler
function procModule()
{
$oModuleModel = getModel('module');
$display_mode = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
// If error occurred while preparation, return a message instance
if($this->error)
{
$this->_setInputErrorToContext();
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
@ -359,8 +358,7 @@ class ModuleHandler extends Handler
$this->httpStatusCode = '404';
$this->_setInputErrorToContext();
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
@ -397,7 +395,7 @@ class ModuleHandler extends Handler
if(!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList))
{
$this->error = "msg_invalid_request";
$oMessageObject = ModuleHandler::getModuleInstance('message', 'view');
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
@ -410,13 +408,24 @@ class ModuleHandler extends Handler
Mobile::setMobile(FALSE);
}
// Admin ip
$logged_info = Context::get('logged_info');
// check CSRF for POST actions
if(Context::getRequestMethod() === 'POST' && Context::isInstalled() && $this->act !== 'procFileUpload' && !checkCSRF()) {
$this->error = 'msg_invalid_request';
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
return $oMessageObject;
}
// Admin ip
if($kind == 'admin' && $_SESSION['denied_admin'] == 'Y')
{
$this->_setInputErrorToContext();
$this->error = "msg_not_permitted_act";
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
@ -446,8 +455,7 @@ class ModuleHandler extends Handler
if(!is_object($oModule))
{
$this->_setInputErrorToContext();
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
@ -466,7 +474,7 @@ class ModuleHandler extends Handler
{
$this->_setInputErrorToContext();
$this->error = 'msg_invalid_request';
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
@ -495,7 +503,7 @@ class ModuleHandler extends Handler
else
{
$this->error = 'msg_invalid_request';
$oMessageObject = ModuleHandler::getModuleInstance('message', 'view');
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
@ -517,6 +525,34 @@ class ModuleHandler extends Handler
$tpl_path = $oModule->getTemplatePath();
$orig_module = $oModule;
$xml_info = $oModuleModel->getModuleActionXml($forward->module);
// SECISSUE also check foward act method
// check REQUEST_METHOD in controller
if($type == 'controller')
{
$allowedMethod = $xml_info->action->{$forward->act}->method;
if(!$allowedMethod)
{
$allowedMethodList[0] = 'POST';
}
else
{
$allowedMethodList = explode('|', strtoupper($allowedMethod));
}
if(!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList))
{
$this->error = "msg_invalid_request";
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
return $oMessageObject;
}
}
if($type == "view" && Mobile::isFromMobilePhone())
{
$orig_type = "view";
@ -537,9 +573,8 @@ class ModuleHandler extends Handler
if(!is_object($oModule))
{
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$this->_setInputErrorToContext();
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage('msg_module_is_not_exists');
$oMessageObject->dispMessage();
@ -550,8 +585,6 @@ class ModuleHandler extends Handler
return $oMessageObject;
}
$xml_info = $oModuleModel->getModuleActionXml($forward->module);
if($this->module == "admin" && $type == "view")
{
if($logged_info->is_admin == 'Y')
@ -569,7 +602,7 @@ class ModuleHandler extends Handler
$this->_setInputErrorToContext();
$this->error = 'msg_is_not_administrator';
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
@ -583,7 +616,7 @@ class ModuleHandler extends Handler
{
$this->_setInputErrorToContext();
$this->error = 'msg_is_not_manager';
$oMessageObject = ModuleHandler::getModuleInstance('message', 'view');
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
@ -595,7 +628,7 @@ class ModuleHandler extends Handler
{
$this->_setInputErrorToContext();
$this->error = 'msg_is_not_administrator';
$oMessageObject = ModuleHandler::getModuleInstance('message', 'view');
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
@ -722,15 +755,23 @@ class ModuleHandler extends Handler
}
$_SESSION['XE_VALIDATOR_ERROR'] = $error;
$_SESSION['XE_VALIDATOR_ID'] = Context::get('xe_validator_id');
if($error != 0)
{
$_SESSION['XE_VALIDATOR_ERROR'] = $error;
}
if($validator_id = Context::get('xe_validator_id'))
{
$_SESSION['XE_VALIDATOR_ID'] = $validator_id;
}
if($message != 'success')
{
$_SESSION['XE_VALIDATOR_MESSAGE'] = $message;
}
$_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType;
if(Context::get('xeVirtualRequestMethod') != 'xml')
if($messageType != 'info')
{
$_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType;
}
if(Context::get('xeVirtualRequestMethod') != 'xml' && $redirectUrl)
{
$_SESSION['XE_VALIDATOR_RETURN_URL'] = $redirectUrl;
}
@ -780,12 +821,12 @@ class ModuleHandler extends Handler
* */
function _clearErrorSession()
{
$_SESSION['XE_VALIDATOR_ERROR'] = '';
$_SESSION['XE_VALIDATOR_MESSAGE'] = '';
$_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = '';
$_SESSION['XE_VALIDATOR_RETURN_URL'] = '';
$_SESSION['XE_VALIDATOR_ID'] = '';
$_SESSION['INPUT_ERROR'] = '';
unset($_SESSION['XE_VALIDATOR_ERROR']);
unset($_SESSION['XE_VALIDATOR_MESSAGE']);
unset($_SESSION['XE_VALIDATOR_MESSAGE_TYPE']);
unset($_SESSION['XE_VALIDATOR_RETURN_URL']);
unset($_SESSION['XE_VALIDATOR_ID']);
unset($_SESSION['INPUT_ERROR']);
}
/**
@ -839,6 +880,7 @@ class ModuleHandler extends Handler
$display_handler = new DisplayHandler();
$display_handler->_debugOutput();
Context::getInstance()->checkSessionStatus();
header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
return;
}

View file

@ -86,7 +86,7 @@ class ModuleObject extends Object
* @param string $type type of message (error, info, update)
* @return void
* */
function setMessage($message, $type = NULL)
function setMessage($message = 'success', $type = NULL)
{
parent::setMessage($message);
$this->setMessageType($type);
@ -370,7 +370,7 @@ class ModuleObject extends Object
* set the directory path of the layout directory
* @return string
* */
function getLayoutPath()
function getLayoutPath($layout_name = "", $layout_type = "P")
{
return $this->layout_path;
}
@ -472,12 +472,12 @@ class ModuleObject extends Object
return FALSE;
}
}
// execute api methos of the module if view action is and result is XMLRPC or JSON
if($this->module_info->module_type == 'view')
// execute api methods of the module if view action is and result is XMLRPC or JSON
if($this->module_info->module_type == 'view' || $this->module_info->module_type == 'mobile')
{
if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON')
{
$oAPI = getAPI($this->module_info->module, 'api');
$oAPI = getAPI($this->module_info->module);
if(method_exists($oAPI, $this->act))
{
$oAPI->{$this->act}($this);

View file

@ -40,7 +40,7 @@ class Object
* @param string $message Error message
* @return void
*/
function Object($error = 0, $message = 'success')
function __construct($error = 0, $message = 'success')
{
$this->setError($error);
$this->setMessage($message);
@ -94,7 +94,7 @@ class Object
* @param string $message Error message
* @return bool Alaways returns true.
*/
function setMessage($message = 'success')
function setMessage($message = 'success', $type = NULL)
{
if($str = Context::getLang($message))
{

View file

@ -30,7 +30,7 @@ class PageHandler extends Handler
* @return void
*/
function PageHandler($total_count, $total_page, $cur_page, $page_count = 10)
function __construct($total_count, $total_page, $cur_page, $page_count = 10)
{
$this->total_count = $total_count;
$this->total_page = $total_page;

View file

@ -0,0 +1,357 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* This class makes encryption and digital signing easy to use in XE.
*
* The encryption methods use AES-128, and is fully compatible with
* https://github.com/defuse/php-encryption
* except that it uses base64-encoded keys and ciphertexts.
*
* The digital signature methods is based on the same SHA-256 based
* key derivation function used by the encryption methods.
*
* A key is automatically generated and saved to the files/config directory
* when first invoked. The same key will be used for all subsequent
* method calls that do not specify a different key.
* The key must be a binary string exactly 16 bytes long.
*
* @file Crypto.class.php
* @author Kijin Sung (kijin@kijinsung.com)
* @package /classes/security
* @version 1.0
*/
class Crypto
{
/**
* @brief Default configuration
*/
const ENCRYPTION_ALGO = 'aes-128';
const ENCRYPTION_MODE = 'cbc';
const ENCRYPTION_BLOCK_SIZE = 16;
const ENCRYPTION_KEY_SIZE = 16;
const ENCRYPTION_KEY_INFO = 'DefusePHP|KeyForEncryption';
const ENCRYPTION_MAC_ALGO = 'sha256';
const ENCRYPTION_MAC_SIZE = 32;
const ENCRYPTION_MAC_INFO = 'DefusePHP|KeyForAuthentication';
const SIGNATURE_ALGO = 'sha256';
const SIGNATURE_SIZE = '32';
/**
* @brief The default key
*/
protected static $_default_key = null;
/**
* @brief The currently selected extension
*/
protected static $_extension = null;
/**
* @brief If this is true, encryption and signature are only valid in current session
*/
protected $_current_session_only = false;
/**
* @brief Constructor
*/
public function __construct()
{
if(function_exists('openssl_encrypt'))
{
self::$_extension = 'openssl';
}
elseif(function_exists('mcrypt_encrypt'))
{
self::$_extension = 'mcrypt';
}
else
{
throw new Exception('Crypto class requires openssl or mcrypt extension.');
}
}
/**
* @brief Check if cryptography is supported on this server
* @return bool
*/
public static function isSupported()
{
return (function_exists('openssl_encrypt') || function_exists('mcrypt_encrypt'));
}
/**
* @brief Make encryption and signature only valid in current session
* @return void
*/
public function currentSessionOnly()
{
$this->_current_session_only = true;
}
/**
* @brief Encrypt a string
* @param string $plaintext The string to encrypt
* @param string $key Optional key. If empty, default key will be used.
* @return string
*/
public function encrypt($plaintext, $key = null)
{
if($key === null || $key === '')
{
$key = $this->_getSessionKey();
}
// Generate subkey for encryption
$enc_key = self::_defuseCompatibleHKDF($key, self::ENCRYPTION_KEY_INFO);
// Generate IV
$iv = self::_createIV();
// Encrypt the plaintext
if(self::$_extension === 'openssl')
{
$openssl_method = self::ENCRYPTION_ALGO . '-' . self::ENCRYPTION_MODE;
$ciphertext = openssl_encrypt($plaintext, $openssl_method, $enc_key, OPENSSL_RAW_DATA, $iv);
}
else
{
$mcrypt_method = str_replace('aes', 'rijndael', self::ENCRYPTION_ALGO);
$plaintext = self::_applyPKCS7Padding($plaintext, self::ENCRYPTION_BLOCK_SIZE);
$ciphertext = mcrypt_encrypt($mcrypt_method, $enc_key, $plaintext, self::ENCRYPTION_MODE, $iv);
}
// Generate MAC
$mac_key = self::_defuseCompatibleHKDF($key, self::ENCRYPTION_MAC_INFO);
$mac = hash_hmac(self::ENCRYPTION_MAC_ALGO, ($iv . $ciphertext), $mac_key, true);
// Return the MAC, IV, and ciphertext as a base64 encoded string
return base64_encode($mac . $iv . $ciphertext);
}
/**
* @brief Decrypt a string
* @param string $ciphertext The string to decrypt
* @param string $key Optional key. If empty, default key will be used.
* @return string
*/
public function decrypt($ciphertext, $key = null)
{
if($key === null || $key === '')
{
$key = $this->_getSessionKey();
}
// Base64 decode the ciphertext and check the length
$ciphertext = @base64_decode($ciphertext);
if(strlen($ciphertext) < (self::ENCRYPTION_MAC_SIZE + (self::ENCRYPTION_BLOCK_SIZE * 2)))
{
return false;
}
// Extract MAC and IV from the remainder of the ciphertext
$mac = substr($ciphertext, 0, self::ENCRYPTION_MAC_SIZE);
$iv = substr($ciphertext, self::ENCRYPTION_MAC_SIZE, self::ENCRYPTION_BLOCK_SIZE);
$ciphertext = substr($ciphertext, self::ENCRYPTION_MAC_SIZE + self::ENCRYPTION_BLOCK_SIZE);
// Validate MAC
$mac_key = self::_defuseCompatibleHKDF($key, self::ENCRYPTION_MAC_INFO);
$mac_compare = hash_hmac(self::ENCRYPTION_MAC_ALGO, ($iv . $ciphertext), $mac_key, true);
$oPassword = new Password();
if(!$oPassword->strcmpConstantTime($mac, $mac_compare))
{
return false;
}
// Generate subkey for encryption
$enc_key = self::_defuseCompatibleHKDF($key, self::ENCRYPTION_KEY_INFO);
// Decrypt the ciphertext
if (self::$_extension === 'openssl')
{
$openssl_method = self::ENCRYPTION_ALGO . '-' . self::ENCRYPTION_MODE;
$plaintext = openssl_decrypt($ciphertext, $openssl_method, $enc_key, OPENSSL_RAW_DATA, $iv);
}
else
{
$mcrypt_method = str_replace('aes', 'rijndael', self::ENCRYPTION_ALGO);
$plaintext = @mcrypt_decrypt($mcrypt_method, $enc_key, $ciphertext, self::ENCRYPTION_MODE, $iv);
if($plaintext === false)
{
return false;
}
$plaintext = self::_stripPKCS7Padding($plaintext, self::ENCRYPTION_BLOCK_SIZE);
if($plaintext === false)
{
return false;
}
}
// Return the plaintext
return $plaintext;
}
/**
* @brief Create a digital signature of a string
* @param string $plaintext The string to sign
* @param string $key Optional key. If empty, default key will be used.
* @return string
*/
public function createSignature($plaintext, $key = null)
{
if($key === null || $key === '')
{
$key = $this->_getSessionKey();
}
// Generate a signature using HMAC
return bin2hex(self::_defuseCompatibleHKDF($plaintext, $key));
}
/**
* @brief Verify a digital signature
* @param string $signature The signature to verify
* @param string $plaintext The string to verify
* @param string $key Optional key. If empty, default key will be used.
* @return bool
*/
public function verifySignature($signature, $plaintext, $key = null)
{
if($key === null || $key === '')
{
$key = $this->_getSessionKey();
}
// Verify the signature using HMAC
$oPassword = new Password();
$compare = bin2hex(self::_defuseCompatibleHKDF($plaintext, $key));
return $oPassword->strcmpConstantTime($signature, $compare);
}
/**
* @brief Get the default key applicable to this instance
* @return string
*/
protected function _getSessionKey()
{
if($this->_current_session_only)
{
if(!isset($_SESSION['XE_CRYPTO_SESSKEY']))
{
$_SESSION['XE_CRYPTO_SESSKEY'] = self::_createSecureKey();
}
$session_key = base64_decode($_SESSION['XE_CRYPTO_SESSKEY']);
return strval(self::_getDefaultKey()) ^ strval($session_key);
}
else
{
return strval(self::_getDefaultKey());
}
}
/**
* @brief Get the default key
* @return string
*/
protected static function _getDefaultKey()
{
if(self::$_default_key !== null)
{
return base64_decode(self::$_default_key);
}
else
{
$file_name = _XE_PATH_ . 'files/config/crypto.config.php';
if(file_exists($file_name) && is_readable($file_name))
{
$key = (include $file_name);
}
if(!isset($key) || !is_string($key))
{
$key = self::_createSecureKey();
self::_setDefaultKey($key);
}
return base64_decode(self::$_default_key = $key);
}
}
/**
* @brief Set the default key
* @param string $key The default key
* @return void
*/
protected static function _setDefaultKey($key)
{
self::$_default_key = $key = trim($key);
$file_name = _XE_PATH_ . 'files/config/crypto.config.php';
$file_content = '<?php return ' . var_export($key, true) . ';' . PHP_EOL;
FileHandler::writeFile($file_name, $file_content);
}
/**
* @brief Create a secure key
* @return string
*/
protected static function _createSecureKey()
{
$oPassword = new Password();
return base64_encode($oPassword->createSecureSalt(ENCRYPTION_KEY_SIZE, 'binary'));
}
/**
* @brief Create an IV
* @return string
*/
protected static function _createIV()
{
$oPassword = new Password();
return $oPassword->createSecureSalt(self::ENCRYPTION_BLOCK_SIZE, 'binary');
}
/**
* @brief Apply PKCS#7 padding to a string
* @param string $str The string
* @param int $block_size The block size
* @return string
*/
protected static function _applyPKCS7Padding($str, $block_size)
{
$padding_size = $block_size - (strlen($str) % $block_size);
if ($padding_size === 0) $padding_size = $block_size;
return $str . str_repeat(chr($padding_size), $padding_size);
}
/**
* @brief Remove PKCS#7 padding from a string
* @param string $str The string
* @param int $block_size The block size
* @return string
*/
protected static function _stripPKCS7Padding($str, $block_size)
{
if (strlen($str) % $block_size !== 0) return false;
$padding_size = ord(substr($str, -1));
if ($padding_size < 1 || $padding_size > $block_size) return false;
if (substr($str, (-1 * $padding_size)) !== str_repeat(chr($padding_size), $padding_size)) return false;
return substr($str, 0, strlen($str) - $padding_size);
}
/**
* @brief HKDF function compatible with defuse/php-encryption
* @return string
*/
protected static function _defuseCompatibleHKDF($key, $info)
{
$salt = str_repeat("\x00", self::ENCRYPTION_MAC_SIZE);
$prk = hash_hmac(self::ENCRYPTION_MAC_ALGO, $key, $salt, true);
$t = $last_block = '';
for ($block_index = 1; strlen($t) < self::ENCRYPTION_KEY_SIZE; $block_index++)
{
$t .= $last_block = hash_hmac(self::ENCRYPTION_MAC_ALGO, ($last_block . $info . chr($block_index)), $prk, true);
}
return substr($t, 0, self::ENCRYPTION_KEY_SIZE);
}
}
/* End of file : Crypto.class.php */
/* Location: ./classes/security/Crypto.class.php */

View file

@ -260,7 +260,7 @@ class EmbedFilter
* @constructor
* @return void
*/
function EmbedFilter()
function __construct()
{
$this->_makeWhiteDomainList();

View file

@ -12,6 +12,24 @@
*/
class Password
{
/**
* @brief Custom algorithms are stored here
* @var array
*/
protected static $_custom = array();
/**
* @brief Register a custom algorithm for password checking
* @param string $name The name of the algorithm
* @param string $regexp The regular expression to detect the algorithm
* @param callable $callback The function to call to regenerate the hash
* @return void
*/
public static function registerCustomAlgorithm($name, $regexp, $callback)
{
self::$_custom[$name] = array('regexp' => $regexp, 'callback' => $callback);
}
/**
* @brief Return the list of hashing algorithms supported by this server
* @return array
@ -162,6 +180,16 @@ class Password
return $this->strcmpConstantTime($hash_to_compare, $hash);
default:
if($algorithm && isset(self::$_custom[$algorithm]))
{
$hash_callback = self::$_custom[$algorithm]['callback'];
$hash_to_compare = $hash_callback($password, $hash);
return $this->strcmpConstantTime($hash_to_compare, $hash);
}
if(in_array($algorithm, hash_algos()))
{
return $this->strcmpConstantTime(hash($algorithm, $password), $hash);
}
return false;
}
}
@ -173,6 +201,14 @@ class Password
*/
function checkAlgorithm($hash)
{
foreach(self::$_custom as $name => $definition)
{
if(preg_match($definition['regexp'], $hash))
{
return $name;
}
}
if(preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches))
{
return 'bcrypt';
@ -185,6 +221,22 @@ class Password
{
return 'md5';
}
elseif(strlen($hash) === 40 && ctype_xdigit($hash))
{
return 'sha1';
}
elseif(strlen($hash) === 64 && ctype_xdigit($hash))
{
return 'sha256';
}
elseif(strlen($hash) === 96 && ctype_xdigit($hash))
{
return 'sha384';
}
elseif(strlen($hash) === 128 && ctype_xdigit($hash))
{
return 'sha512';
}
elseif(strlen($hash) === 16 && ctype_xdigit($hash))
{
return 'mysql_old_password';
@ -246,8 +298,13 @@ class Password
$entropy_capped_bytes = min(32, $entropy_required_bytes);
// Find and use the most secure way to generate a random string
$entropy = false;
$is_windows = (defined('PHP_OS') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
if(function_exists('openssl_random_pseudo_bytes') && (!$is_windows || version_compare(PHP_VERSION, '5.4', '>=')))
if(function_exists('random_bytes')) // PHP 7
{
$entropy = random_bytes($entropy_capped_bytes);
}
elseif(function_exists('openssl_random_pseudo_bytes') && (!$is_windows || version_compare(PHP_VERSION, '5.4', '>=')))
{
$entropy = openssl_random_pseudo_bytes($entropy_capped_bytes);
}
@ -262,10 +319,16 @@ class Password
elseif(!$is_windows && @is_readable('/dev/urandom'))
{
$fp = fopen('/dev/urandom', 'rb');
if (function_exists('stream_set_read_buffer')) // This function does not exist in HHVM
{
stream_set_read_buffer($fp, 0); // Prevent reading several KB of unnecessary data from urandom
}
$entropy = fread($fp, $entropy_capped_bytes);
fclose($fp);
}
else
// Use built-in source of entropy if an error occurs while using other functions
if($entropy === false || strlen($entropy) < $entropy_capped_bytes)
{
$entropy = '';
for($i = 0; $i < $entropy_capped_bytes; $i += 2)

View file

@ -9,7 +9,7 @@ class Purifier
private $_config;
private $_def;
public function Purifier()
public function __construct()
{
$this->_checkCacheDir();
@ -93,11 +93,17 @@ class Purifier
{
foreach($m2[1] as $value2)
{
//SECISSUE check style attr
if($value2 == 'style')
{
continue;
}
$attributeList[] = $value2;
}
}
}
}
return array_unique($attributeList);
}
@ -121,6 +127,11 @@ class Purifier
{
foreach($m2[1] as $value2)
{
//SECISSUE check style attr
if($value2 == 'style')
{
continue;
}
$attributeList[] = $value2;
}
}

View file

@ -22,7 +22,7 @@ class Security
* @param mixed $var Target context
* @return void
*/
function Security($var = NULL)
function __construct($var = NULL)
{
$this->_targetVar = $var;
}

View file

@ -19,6 +19,7 @@ class TemplateHandler
private $xe_path = NULL; ///< XpressEngine base path
private $web_path = NULL; ///< tpl file web path
private $compiled_file = NULL; ///< tpl file web path
private $config = NULL;
private $skipTags = NULL;
private $handler_mtime = 0;
static private $rootTpl = NULL;
@ -31,6 +32,7 @@ class TemplateHandler
{
$this->xe_path = rtrim(preg_replace('/([^\.^\/]+)\.php$/i', '', $_SERVER['SCRIPT_NAME']), '/');
$this->compiled_path = _XE_PATH_ . $this->compiled_path;
$this->config = new stdClass();
}
/**
@ -232,6 +234,13 @@ class TemplateHandler
$this->skipTags = array('marquee');
}
// reset config for this buffer (this step is necessary because we use a singleton for every template)
$previous_config = clone $this->config;
$this->config = new stdClass();
// detect existence of autoescape config
$this->config->autoescape = (strpos($buff, ' autoescape="') === FALSE) ? NULL : 'off';
// replace comments
$buff = preg_replace('@<!--//.*?-->@s', '', $buff);
@ -242,7 +251,7 @@ class TemplateHandler
$buff = $this->_parseInline($buff);
// include, unload/load, import
$buff = preg_replace_callback('/{(@[\s\S]+?|(?=\$\w+|_{1,2}[A-Z]+|[!\(+-]|\w+(?:\(|::)|\d+|[\'"].*?[\'"]).+?)}|<(!--[#%])?(include|import|(un)?load(?(4)|(?:_js_plugin)?))(?(2)\(["\']([^"\']+)["\'])(.*?)(?(2)\)--|\/)>|<!--(@[a-z@]*)([\s\S]*?)-->(\s*)/', array($this, '_parseResource'), $buff);
$buff = preg_replace_callback('/{(@[\s\S]+?|(?=\$\w+|_{1,2}[A-Z]+|[!\(+-]|\w+(?:\(|::)|\d+|[\'"].*?[\'"]).+?)}|<(!--[#%])?(include|import|(un)?load(?(4)|(?:_js_plugin)?)|config)(?(2)\(["\']([^"\']+)["\'])(.*?)(?(2)\)--|\/)>|<!--(@[a-z@]*)([\s\S]*?)-->(\s*)/', array($this, '_parseResource'), $buff);
// remove block which is a virtual tag
$buff = preg_replace('@</?block\s*>@is', '', $buff);
@ -260,6 +269,9 @@ class TemplateHandler
// remove php script reopening
$buff = preg_replace(array('/(\n|\r\n)+/', '/(;)?( )*\?\>\<\?php([\n\t ]+)?/'), array("\n", ";\n"), $buff);
// restore config to previous value
$this->config = $previous_config;
return $buff;
}
@ -509,7 +521,10 @@ class TemplateHandler
{
$expr_m[2] .= '=>' . trim($expr_m[3]);
}
$nodes[$idx - 1] .= "<?php if({$expr_m[1]}&&count({$expr_m[1]}))foreach({$expr_m[1]} as {$expr_m[2]}){ ?>";
$nodes[$idx - 1] .= sprintf(
'<?php $t%3$s=%1$s;if($t%3$s&&count($t%3$s))foreach($t%3$s as %2$s){ ?>'
,$expr_m[1], $expr_m[2], md5( $buff . strval($idx-1) )
);
}
elseif($expr_m[4])
{
@ -587,14 +602,35 @@ class TemplateHandler
{
return $m[0];
}
$echo = 'echo ';
if($m[1]{0} == '@')
{
$echo = '';
$m[1] = substr($m[1], 1);
$m[1] = $this->_replaceVar(substr($m[1], 1));
return "<?php {$m[1]} ?>";
}
else
{
$escape_option = $this->config->autoescape !== null ? 'auto' : 'noescape';
if(preg_match('@^(.+)\\|((?:no)?escape)$@', $m[1], $mm))
{
$m[1] = $mm[1];
$escape_option = $mm[2];
}
elseif($m[1] === '$content' && preg_match('@/layouts/.+/layout\.html$@', $this->file))
{
$escape_option = 'noescape';
}
$m[1] = $this->_replaceVar($m[1]);
switch($escape_option)
{
case 'auto':
return "<?php echo (\$this->config->autoescape === 'on' ? htmlspecialchars({$m[1]}, ENT_COMPAT, 'UTF-8', false) : {$m[1]}) ?>";
case 'escape':
return "<?php echo htmlspecialchars({$m[1]}, ENT_COMPAT, 'UTF-8', true) ?>";
case 'noescape':
return "<?php echo {$m[1]} ?>";
}
}
return '<?php ' . $echo . $this->_replaceVar($m[1]) . ' ?>';
}
if($m[3])
@ -727,6 +763,17 @@ class TemplateHandler
}
return $result;
// <config ...>
case 'config':
$result = '';
if(preg_match_all('@ (\w+)="([^"]+)"@', $m[6], $config_matches, PREG_SET_ORDER))
{
foreach($config_matches as $config_match)
{
$result .= "\$this->config->{$config_match[1]} = '" . trim(strtolower($config_match[2])) . "';";
}
}
return "<?php {$result} ?>";
}
}

View file

@ -79,7 +79,7 @@ class XmlJsFilter extends XmlParser
* @return void
*/
function XmlJsFilter($path, $xml_file)
function __construct($path, $xml_file)
{
if(substr($path, -1) !== '/')
{

View file

@ -53,7 +53,7 @@ class XmlLangParser extends XmlParser
* @param string $lang_type
* @return void
*/
function XmlLangParser($xml_file, $lang_type)
function __construct($xml_file, $lang_type)
{
$this->lang_type = $lang_type;
$this->xml_file = $xml_file;

View file

@ -24,7 +24,7 @@ class XmlQueryParser extends XmlParser
* constructor
* @return void
*/
function XmlQueryParser()
function __construct()
{
}

View file

@ -60,7 +60,7 @@ class DBParser
*
* @return void
*/
function DBParser($escape_char_left, $escape_char_right = "", $table_prefix = "xe_")
function __construct($escape_char_left, $escape_char_right = "", $table_prefix = "xe_")
{
$this->escape_char_left = $escape_char_left;
if($escape_char_right !== "")

View file

@ -30,7 +30,7 @@ class QueryParser
* @param bool $isSubQuery
* @return void
*/
function QueryParser($query = NULL, $isSubQuery = FALSE)
function __construct($query = NULL, $isSubQuery = FALSE)
{
if($query)
{

View file

@ -64,7 +64,7 @@ class Argument
* @return void
*/
function Argument($name, $value)
function __construct($name, $value)
{
$this->value = $value;
$this->name = $name;

View file

@ -23,7 +23,7 @@ class ConditionArgument extends Argument
* @param string $operation
* @return void
*/
function ConditionArgument($name, $value, $operation)
function __construct($name, $value, $operation)
{
$operationList = array('in' => 1, 'notin' => 1, 'not_in' => 1, 'between' => 1);
if(isset($value) && isset($operationList[$operation]) && !is_array($value) && $value != '')
@ -32,7 +32,7 @@ class ConditionArgument extends Argument
$value = str_replace('\'', '', $value);
$value = explode(',', $value);
}
parent::Argument($name, $value);
parent::__construct($name, $value);
$this->operation = $operation;
}

View file

@ -58,7 +58,7 @@ class DefaultValue
* @param mixed $value value
* @return void
*/
function DefaultValue($column_name, $value)
function __construct($column_name, $value)
{
$dbParser = DB::getParser();
$this->column_name = $dbParser->parseColumnName($column_name);

View file

@ -58,7 +58,7 @@ class QueryArgument
* @param bool $ignore_value
* @return void
*/
function QueryArgument($tag, $ignore_value = FALSE)
function __construct($tag, $ignore_value = FALSE)
{
static $number_of_arguments = 0;

View file

@ -59,7 +59,7 @@ class QueryArgumentValidator
* @param QueryArgument $argument
* @return void
*/
function QueryArgumentValidator($tag, $argument)
function __construct($tag, $argument)
{
$this->argument = $argument;
$this->argument_name = $this->argument->getArgumentName();

View file

@ -25,7 +25,7 @@ class ColumnTag
* @param string $name
* @return void
*/
function ColumnTag($name)
function __construct($name)
{
$this->name = $name;
}

View file

@ -25,9 +25,9 @@ class InsertColumnTag extends ColumnTag
*
* @return void
*/
function InsertColumnTag($column)
function __construct($column)
{
parent::ColumnTag($column->attrs->name);
parent::__construct($column->attrs->name);
$dbParser = DB::getParser();
$this->name = $dbParser->parseColumnName($this->name);
$this->argument = new QueryArgument($column);

View file

@ -17,9 +17,9 @@ class InsertColumnTagWithoutArgument extends ColumnTag
* @param object $column
* @return void
*/
function InsertColumnTagWithoutArgument($column)
function __construct($column)
{
parent::ColumnTag($column->attrs->name);
parent::__construct($column->attrs->name);
$dbParser = DB::getParser();
$this->name = $dbParser->parseColumnName($this->name);
}

View file

@ -24,7 +24,7 @@ class InsertColumnsTag
* @param array|string $xml_columns
* @return void
*/
function InsertColumnsTag($xml_columns)
function __construct($xml_columns)
{
$this->columns = array();

View file

@ -31,16 +31,16 @@ class SelectColumnTag extends ColumnTag
* @param string|object $column
* @return void
*/
function SelectColumnTag($column)
function __construct($column)
{
if($column == "*" || $column->attrs->name == '*')
{
parent::ColumnTag(NULL);
parent::__construct(NULL);
$this->name = "*";
}
else
{
parent::ColumnTag($column->attrs->name);
parent::__construct($column->attrs->name);
$dbParser = DB::getParser();
$this->name = $dbParser->parseExpression($this->name);

View file

@ -25,7 +25,7 @@ class SelectColumnsTag
* @internal param \Xml_Node_ $xml_columns
* @return void
*/
function SelectColumnsTag($xml_columns_tag)
function __construct($xml_columns_tag)
{
if(!$xml_columns_tag)
{

View file

@ -31,9 +31,9 @@ class UpdateColumnTag extends ColumnTag
* @param object $column
* @return void
*/
function UpdateColumnTag($column)
function __construct($column)
{
parent::ColumnTag($column->attrs->name);
parent::__construct($column->attrs->name);
$dbParser = DB::getParser();
$this->name = $dbParser->parseColumnName($this->name);

View file

@ -24,7 +24,7 @@ class UpdateColumnsTag
* @param array|object $xml_columns
* @return void
*/
function UpdateColumnsTag($xml_columns)
function __construct($xml_columns)
{
$this->columns = array();

View file

@ -29,7 +29,7 @@ class ConditionGroupTag
* @param string $pipe
* @return void
*/
function ConditionGroupTag($conditions, $pipe = "")
function __construct($conditions, $pipe = "")
{
$this->pipe = $pipe;

View file

@ -59,7 +59,7 @@ class ConditionTag
* @param object $condition
* @return void
*/
function ConditionTag($condition)
function __construct($condition)
{
$this->operation = $condition->attrs->operation;
$this->pipe = $condition->attrs->pipe;

View file

@ -22,7 +22,7 @@ class ConditionsTag
* @param object $xml_conditions
* @return void
*/
function ConditionsTag($xml_conditions)
function __construct($xml_conditions)
{
$this->condition_groups = array();
if(!$xml_conditions)

View file

@ -16,9 +16,9 @@ class JoinConditionsTag extends ConditionsTag
* @param object $xml_conditions
* @return void
*/
function JoinConditionsTag($xml_conditions)
function __construct($xml_conditions)
{
parent::ConditionsTag($xml_conditions);
parent::__construct($xml_conditions);
$this->condition_groups[0]->conditions[0]->setPipe("");
}

View file

@ -22,7 +22,7 @@ class GroupsTag
* @param array|string $xml_groups
* @return void
*/
function GroupsTag($xml_groups)
function __construct($xml_groups)
{
$this->groups = array();

View file

@ -46,7 +46,7 @@ class IndexTag
* @param object $index
* @return void
*/
function IndexTag($index)
function __construct($index)
{
$this->argument_name = $index->attrs->var;

View file

@ -40,7 +40,7 @@ class LimitTag
* @param object $index
* @return void
*/
function LimitTag($index)
function __construct($index)
{
if($index->page && $index->page->attrs && $index->page_count && $index->page_count->attrs)
{

View file

@ -46,7 +46,7 @@ class NavigationTag
* @param object $xml_navigation
* @return void
*/
function NavigationTag($xml_navigation)
function __construct($xml_navigation)
{
$this->order = array();
if($xml_navigation)

View file

@ -119,7 +119,7 @@ class QueryTag
* @param bool $isSubQuery
* @return void
*/
function QueryTag($query, $isSubQuery = FALSE)
function __construct($query, $isSubQuery = FALSE)
{
$this->action = $query->attrs->action;
$this->query_id = $query->attrs->id;

View file

@ -25,9 +25,9 @@ class HintTableTag extends TableTag
* @param array $index
* @return void
*/
function HintTableTag($table, $index)
function __construct($table, $index)
{
parent::TableTag($table);
parent::__construct($table);
$this->index = $index;
}

View file

@ -66,7 +66,7 @@ class TableTag
* @param object $table XML <table> tag
* @return void
*/
function TableTag($table)
function __construct($table)
{
$dbParser = DB::getParser();

View file

@ -33,7 +33,7 @@ class TablesTag
* @param object $xml_index_hints_tag
* @return void
*/
function TablesTag($xml_tables_tag, $xml_index_hints_tag = NULL)
function __construct($xml_tables_tag, $xml_index_hints_tag = NULL)
{
$this->tables = array();

View file

@ -2,9 +2,9 @@
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
*/
(function(a){CKEDITOR.config.jqueryOverrideVal="undefined"==typeof CKEDITOR.config.jqueryOverrideVal?!0:CKEDITOR.config.jqueryOverrideVal;"undefined"!=typeof a&&(a.extend(a.fn,{ckeditorGet:function(){var a=this.eq(0).data("ckeditorInstance");if(!a)throw"CKEditor is not initialized yet, use ckeditor() with a callback.";return a},ckeditor:function(g,d){if(!CKEDITOR.env.isCompatible)throw Error("The environment is incompatible.");if(!a.isFunction(g))var k=d,d=g,g=k;var i=[],d=d||{};this.each(function(){var b=
a(this),c=b.data("ckeditorInstance"),f=b.data("_ckeditorInstanceLock"),h=this,j=new a.Deferred;i.push(j.promise());if(c&&!f)g&&g.apply(c,[this]),j.resolve();else if(f)c.once("instanceReady",function(){setTimeout(function(){c.element?(c.element.$==h&&g&&g.apply(c,[h]),j.resolve()):setTimeout(arguments.callee,100)},0)},null,null,9999);else{if(d.autoUpdateElement||"undefined"==typeof d.autoUpdateElement&&CKEDITOR.config.autoUpdateElement)d.autoUpdateElementJquery=!0;d.autoUpdateElement=!1;b.data("_ckeditorInstanceLock",
!0);c=a(this).is("textarea")?CKEDITOR.replace(h,d):CKEDITOR.inline(h,d);b.data("ckeditorInstance",c);c.on("instanceReady",function(d){var e=d.editor;setTimeout(function(){if(e.element){d.removeListener();e.on("dataReady",function(){b.trigger("dataReady.ckeditor",[e])});e.on("setData",function(a){b.trigger("setData.ckeditor",[e,a.data])});e.on("getData",function(a){b.trigger("getData.ckeditor",[e,a.data])},999);e.on("destroy",function(){b.trigger("destroy.ckeditor",[e])});e.on("save",function(){a(h.form).submit();
return!1},null,null,20);if(e.config.autoUpdateElementJquery&&b.is("textarea")&&a(h.form).length){var c=function(){b.ckeditor(function(){e.updateElement()})};a(h.form).submit(c);a(h.form).bind("form-pre-serialize",c);b.bind("destroy.ckeditor",function(){a(h.form).unbind("submit",c);a(h.form).unbind("form-pre-serialize",c)})}e.on("destroy",function(){b.removeData("ckeditorInstance")});b.removeData("_ckeditorInstanceLock");b.trigger("instanceReady.ckeditor",[e]);g&&g.apply(e,[h]);j.resolve()}else setTimeout(arguments.callee,
100)},0)},null,null,9999)}});var f=new a.Deferred;this.promise=f.promise();a.when.apply(this,i).then(function(){f.resolve()});this.editor=this.eq(0).data("ckeditorInstance");return this}}),CKEDITOR.config.jqueryOverrideVal&&(a.fn.val=CKEDITOR.tools.override(a.fn.val,function(g){return function(d){if(arguments.length){var k=this,i=[],f=this.each(function(){var b=a(this),c=b.data("ckeditorInstance");if(b.is("textarea")&&c){var f=new a.Deferred;c.setData(d,function(){f.resolve()});i.push(f.promise());
return!0}return g.call(b,d)});if(i.length){var b=new a.Deferred;a.when.apply(this,i).done(function(){b.resolveWith(k)});return b.promise()}return f}var f=a(this).eq(0),c=f.data("ckeditorInstance");return f.is("textarea")&&c?c.getData():g.call(f)}})))})(window.jQuery);
(function(a){if("undefined"==typeof a)throw Error("jQuery should be loaded before CKEditor jQuery adapter.");if("undefined"==typeof CKEDITOR)throw Error("CKEditor should be loaded before CKEditor jQuery adapter.");CKEDITOR.config.jqueryOverrideVal="undefined"==typeof CKEDITOR.config.jqueryOverrideVal?!0:CKEDITOR.config.jqueryOverrideVal;a.extend(a.fn,{ckeditorGet:function(){var a=this.eq(0).data("ckeditorInstance");if(!a)throw"CKEditor is not initialized yet, use ckeditor() with a callback.";return a},
ckeditor:function(g,d){if(!CKEDITOR.env.isCompatible)throw Error("The environment is incompatible.");if(!a.isFunction(g))var k=d,d=g,g=k;var i=[],d=d||{};this.each(function(){var b=a(this),c=b.data("ckeditorInstance"),f=b.data("_ckeditorInstanceLock"),h=this,j=new a.Deferred;i.push(j.promise());if(c&&!f)g&&g.apply(c,[this]),j.resolve();else if(f)c.once("instanceReady",function(){setTimeout(function(){c.element?(c.element.$==h&&g&&g.apply(c,[h]),j.resolve()):setTimeout(arguments.callee,100)},0)},null,
null,9999);else{if(d.autoUpdateElement||"undefined"==typeof d.autoUpdateElement&&CKEDITOR.config.autoUpdateElement)d.autoUpdateElementJquery=!0;d.autoUpdateElement=!1;b.data("_ckeditorInstanceLock",!0);c=a(this).is("textarea")?CKEDITOR.replace(h,d):CKEDITOR.inline(h,d);b.data("ckeditorInstance",c);c.on("instanceReady",function(d){var e=d.editor;setTimeout(function(){if(e.element){d.removeListener();e.on("dataReady",function(){b.trigger("dataReady.ckeditor",[e])});e.on("setData",function(a){b.trigger("setData.ckeditor",
[e,a.data])});e.on("getData",function(a){b.trigger("getData.ckeditor",[e,a.data])},999);e.on("destroy",function(){b.trigger("destroy.ckeditor",[e])});e.on("save",function(){a(h.form).submit();return!1},null,null,20);if(e.config.autoUpdateElementJquery&&b.is("textarea")&&a(h.form).length){var c=function(){b.ckeditor(function(){e.updateElement()})};a(h.form).submit(c);a(h.form).bind("form-pre-serialize",c);b.bind("destroy.ckeditor",function(){a(h.form).unbind("submit",c);a(h.form).unbind("form-pre-serialize",
c)})}e.on("destroy",function(){b.removeData("ckeditorInstance")});b.removeData("_ckeditorInstanceLock");b.trigger("instanceReady.ckeditor",[e]);g&&g.apply(e,[h]);j.resolve()}else setTimeout(arguments.callee,100)},0)},null,null,9999)}});var f=new a.Deferred;this.promise=f.promise();a.when.apply(this,i).then(function(){f.resolve()});this.editor=this.eq(0).data("ckeditorInstance");return this}});CKEDITOR.config.jqueryOverrideVal&&(a.fn.val=CKEDITOR.tools.override(a.fn.val,function(g){return function(d){if(arguments.length){var k=
this,i=[],f=this.each(function(){var b=a(this),c=b.data("ckeditorInstance");if(b.is("textarea")&&c){var f=new a.Deferred;c.setData(d,function(){f.resolve()});i.push(f.promise());return!0}return g.call(b,d)});if(i.length){var b=new a.Deferred;a.when.apply(this,i).done(function(){b.resolveWith(k)});return b.promise()}return f}var f=a(this).eq(0),c=f.data("ckeditorInstance");return f.is("textarea")&&c?c.getData():g.call(f)}}))})(window.jQuery);

View file

@ -42,6 +42,7 @@ var CKBUILDER_CONFIG = {
'.jscsrc',
'.jshintignore',
'.jshintrc',
'less',
'.mailmap',
'node_modules',
'package.json',

File diff suppressed because it is too large Load diff

View file

@ -94,8 +94,6 @@ pre
white-space: pre-wrap; /* CSS 2.1 */
word-wrap: break-word; /* IE7 */
-moz-tab-size: 4;
-o-tab-size: 4;
-webkit-tab-size: 4;
tab-size: 4;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show more