merge from 1.7.3.5(r13153:r13167)

git-svn-id: http://xe-core.googlecode.com/svn/trunk@13168 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ngleader 2013-09-29 23:32:39 +00:00
parent cc47d2b247
commit 2d3f149b5a
2042 changed files with 129266 additions and 126243 deletions

View file

@ -1,10 +1,13 @@
<?php
/**
* Cache class for APC
*
* @author NHN (developer@xpressengine.com)
**/
class CacheApc extends CacheBase {
* */
class CacheApc extends CacheBase
{
/**
* Default valid time
* @var int
@ -17,8 +20,10 @@ class CacheApc extends CacheBase {
* @param void $opt Not used
* @return CacheApc instance of CacheApc
*/
function getInstance($opt=null){
if(!$GLOBALS['__CacheApc__']) {
function getInstance($opt = null)
{
if(!$GLOBALS['__CacheApc__'])
{
$GLOBALS['__CacheApc__'] = new CacheApc();
}
return $GLOBALS['__CacheApc__'];
@ -29,7 +34,9 @@ class CacheApc extends CacheBase {
*
* @return void
*/
function CacheApc(){
function CacheApc()
{
}
/**
@ -37,7 +44,8 @@ class CacheApc extends CacheBase {
*
* @return bool Return true on support or false on not support
*/
function isSupport(){
function isSupport()
{
return function_exists('apc_add');
}
@ -47,13 +55,18 @@ class CacheApc extends CacheBase {
* @param string $key Store the variable using this name. $key are cache-unique, so storing a second value with the same $key will overwrite the original value.
* @param mixed $buff The variable to store
* @param int $valid_time Time To Live; store $buff in the cache for ttl seconds.
* After the ttl has passed., the stored variable will be expunged from the cache (on the next request).
* If no ttl is supplied, use the default valid time CacheApc::valid_time.
* After the ttl has passed., the stored variable will be expunged from the cache (on the next request).
* If no ttl is supplied, use the default valid time CacheApc::valid_time.
* @return bool Returns true on success or false on failure.
*/
function put($key, $buff, $valid_time = 0){
if($valid_time == 0) $valid_time = $this->valid_time;
return apc_store(md5(_XE_PATH_.$key), array(time(), $buff), $valid_time);
function put($key, $buff, $valid_time = 0)
{
if($valid_time == 0)
{
$valid_time = $this->valid_time;
}
return apc_store(md5(_XE_PATH_ . $key), array(time(), $buff), $valid_time);
}
/**
@ -61,20 +74,25 @@ class CacheApc extends CacheBase {
*
* @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.
* 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 = md5(_XE_PATH_.$key);
function isValid($key, $modified_time = 0)
{
$_key = md5(_XE_PATH_ . $key);
$obj = apc_fetch($_key, $success);
if(!$success || !is_array($obj)) return false;
if(!$success || !is_array($obj))
{
return false;
}
unset($obj[1]);
if($modified_time > 0 && $modified_time > $obj[0]) {
if($modified_time > 0 && $modified_time > $obj[0])
{
$this->_delete($_key);
return false;
}
return true;
}
@ -83,15 +101,20 @@ class CacheApc extends CacheBase {
*
* @param string $key The $key used to store the value.
* @param int $modified_time Unix time of data modified.
* If stored time is older then modified time, return false.
* 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 = md5(_XE_PATH_.$key);
function get($key, $modified_time = 0)
{
$_key = md5(_XE_PATH_ . $key);
$obj = apc_fetch($_key, $success);
if(!$success || !is_array($obj)) return false;
if(!$success || !is_array($obj))
{
return false;
}
if($modified_time > 0 && $modified_time > $obj[0]) {
if($modified_time > 0 && $modified_time > $obj[0])
{
$this->_delete($_key);
return false;
}
@ -105,8 +128,9 @@ class CacheApc extends CacheBase {
* @param string $_key Used to store the value.
* @return void
*/
function _delete($_key) {
$this->put($_key,null,1);
function _delete($_key)
{
$this->put($_key, null, 1);
}
/**
@ -115,7 +139,8 @@ class CacheApc extends CacheBase {
* @param string $key Used to store the value.
* @return void
*/
function delete($key) {
function delete($key)
{
$this->_delete($key);
}
@ -124,10 +149,11 @@ class CacheApc extends CacheBase {
*
* @return bool Returns true on success or false on failure.
*/
function truncate() {
function truncate()
{
return apc_clear_cache('user');
}
}
}
/* End of file CacheApc.class.php */
/* Location: ./classes/cache/CacheApc.class.php */

View file

@ -1,12 +1,15 @@
<?php
/**
* Cache class for file
*
* Filedisk Cache Handler
*
* @author Arnia Software (xe_dev@arnia.ro)
**/
class CacheFile extends CacheBase {
*/
class CacheFile extends CacheBase
{
/**
* Default valid time
* @var int
@ -18,14 +21,16 @@ class CacheFile extends CacheBase {
* @var string
*/
var $cache_dir = 'files/cache/store/';
/**
* Get instance of CacheFile
*
* @return CacheFile instance of CacheFile
*/
function getInstance(){
if(!$GLOBALS['__CacheFile__']) {
function getInstance()
{
if(!$GLOBALS['__CacheFile__'])
{
$GLOBALS['__CacheFile__'] = new CacheFile();
}
return $GLOBALS['__CacheFile__'];
@ -36,9 +41,13 @@ class CacheFile extends CacheBase {
*
* @return void
*/
function CacheFile(){
function CacheFile()
{
$this->cache_dir = _XE_PATH_ . $this->cache_dir;
if(!is_dir($this->cache_dir)) FileHandler::makeDir($this->cache_dir);
if(!is_dir($this->cache_dir))
{
FileHandler::makeDir($this->cache_dir);
}
}
/**
@ -47,16 +56,18 @@ class CacheFile extends CacheBase {
* @param string $key The key that will be associated with the item.
* @return string Returns cache file path
*/
function getCacheFileName($key){
function getCacheFileName($key)
{
return $this->cache_dir . str_replace(':', '_', $key);
}
/**
* Return whether support or not support cache
*
* @return true
*/
function isSupport(){
function isSupport()
{
return true;
}
@ -68,8 +79,9 @@ class CacheFile extends CacheBase {
* @param int $valid_time Not used
* @return void
*/
function put($key, $obj, $valid_time = 0){
$cache_file = $this->getCacheFileName($key);
function put($key, $obj, $valid_time = 0)
{
$cache_file = $this->getCacheFileName($key);
$text = serialize($obj);
FileHandler::writeFile($cache_file, $text);
}
@ -81,10 +93,14 @@ class CacheFile extends CacheBase {
* @param int $modified_time Not used
* @return bool Return true on valid or false on invalid.
*/
function isValid($key, $modified_time = 0) {
function isValid($key, $modified_time = 0)
{
$cache_file = $this->getCacheFileName($key);
if(file_exists($cache_file)) return true;
if(file_exists($cache_file))
{
return true;
}
return false;
}
@ -95,11 +111,15 @@ class CacheFile extends CacheBase {
* @param int $modified_time Not used
* @return false|mixed Return false on failure. Return the string associated with the $key on success.
*/
function get($key, $modified_time = 0) {
function get($key, $modified_time = 0)
{
$cache_file = $this->getCacheFileName($key);
$content = FileHandler::readFile($cache_file);
if(!$content) return false;
if(!$content)
{
return false;
}
return unserialize($content);
}
@ -109,7 +129,8 @@ class CacheFile extends CacheBase {
* @param string $_key Used to store the value.
* @return void
*/
function _delete($_key) {
function _delete($_key)
{
$cache_file = $this->getCacheFileName($_key);
FileHandler::removeFile($cache_file);
}
@ -120,7 +141,8 @@ class CacheFile extends CacheBase {
* @param string $key Used to store the value.
* @return void
*/
function delete($key) {
function delete($key)
{
$this->_delete($key);
}
@ -129,10 +151,11 @@ class CacheFile extends CacheBase {
*
* @return bool Returns true on success or false on failure.
*/
function truncate() {
function truncate()
{
FileHandler::removeFilesInDir($this->cache_dir);
}
}
}
/* End of file CacheFile.class.php */
/* Location: ./classes/cache/CacheFile.class.php */

View file

@ -1,10 +1,13 @@
<?php
/**
* CacheHandler
*
* @author NHN (developer@xpressengine.com)
**/
class CacheHandler extends Handler {
*/
class CacheHandler extends Handler
{
/**
* instance of cache handler
* @var CacheBase
@ -25,9 +28,11 @@ class CacheHandler extends Handler {
* @param boolean $always_use_file If set true, use a file cache always
* @return CacheHandler
*/
function &getInstance($target = 'object', $info = null, $always_use_file = false) {
function &getInstance($target = 'object', $info = null, $always_use_file = false)
{
$cache_handler_key = $target . ($always_use_file ? '_file' : '');
if(!$GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key]) {
if(!$GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key])
{
$GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key] = new CacheHandler($target, $info, $always_use_file);
}
return $GLOBALS['__XE_CACHE_HANDLER__'][$cache_handler_key];
@ -44,34 +49,67 @@ 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) {
if(!$info) $info = Context::getDBInfo();
if($info){
if($target == 'object'){
if($info->use_object_cache =='apc') $type = 'apc';
else if(substr($info->use_object_cache,0,8)=='memcache'){
function CacheHandler($target, $info = null, $always_use_file = false)
{
if(!$info)
{
$info = Context::getDBInfo();
}
if($info)
{
if($target == 'object')
{
if($info->use_object_cache == 'apc')
{
$type = 'apc';
}
else if(substr($info->use_object_cache, 0, 8) == 'memcache')
{
$type = 'memcache';
$url = $info->use_object_cache;
} else if($info->use_object_cache == 'wincache') $type = 'wincache';
else if($info->use_object_cache =='file') $type = 'file';
else if($always_use_file) $type = 'file';
}else if($target == 'template'){
if($info->use_template_cache =='apc') $type = 'apc';
else if(substr($info->use_template_cache,0,8)=='memcache'){
}
else if($info->use_object_cache == 'wincache')
{
$type = 'wincache';
}
else if($info->use_object_cache == 'file')
{
$type = 'file';
}
else if($always_use_file)
{
$type = 'file';
}
}
else if($target == 'template')
{
if($info->use_template_cache == 'apc')
{
$type = 'apc';
}
else if(substr($info->use_template_cache, 0, 8) == 'memcache')
{
$type = 'memcache';
$url = $info->use_template_cache;
} else if($info->use_template_cache == 'wincache') $type = 'wincache';
}
else if($info->use_template_cache == 'wincache')
{
$type = 'wincache';
}
}
if($type){
if($type)
{
$class = 'Cache' . ucfirst($type);
include_once sprintf('%sclasses/cache/%s.class.php', _XE_PATH_, $class);
$this->handler = call_user_func(array($class,'getInstance'), $url);
$this->keyGroupVersions = $this->handler->get('key_group_versions', 0);
if(!$this->keyGroupVersions) {
$this->keyGroupVersions = array();
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
}
$this->handler = call_user_func(array($class, 'getInstance'), $url);
$this->keyGroupVersions = $this->handler->get('key_group_versions', 0);
if(!$this->keyGroupVersions)
{
$this->keyGroupVersions = array();
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
}
}
}
}
@ -81,8 +119,12 @@ class CacheHandler extends Handler {
*
* @return boolean
*/
function isSupport(){
if($this->handler && $this->handler->isSupport()) return true;
function isSupport()
{
if($this->handler && $this->handler->isSupport())
{
return true;
}
return false;
}
@ -91,11 +133,15 @@ class CacheHandler extends Handler {
*
* @param string $key Cache key
* @param int $modified_time Unix time of data modified.
* If stored time is older then modified time, return false.
* 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){
if(!$this->handler) return false;
function get($key, $modified_time = 0)
{
if(!$this->handler)
{
return false;
}
return $this->handler->get($key, $modified_time);
}
@ -105,12 +151,16 @@ class CacheHandler extends Handler {
* @param string $key Cache key
* @param mixed $obj Value of a variable to store. $value supports all data types except resources, such as file handlers.
* @param int $valid_time Time for the variable to live in the cache in seconds.
* After the value specified in ttl has passed the stored variable will be deleted from the cache.
* If no ttl is supplied, use the default valid time.
* After the value specified in ttl has passed the stored variable will be deleted from the cache.
* If no ttl is supplied, use the default valid time.
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/
function put($key, $obj, $valid_time = 0){
if(!$this->handler) return false;
function put($key, $obj, $valid_time = 0)
{
if(!$this->handler)
{
return false;
}
return $this->handler->put($key, $obj, $valid_time);
}
@ -120,8 +170,12 @@ class CacheHandler extends Handler {
* @param string $key Cache key
* @return void
*/
function delete($key){
if(!$this->handler) return false;
function delete($key)
{
if(!$this->handler)
{
return false;
}
return $this->handler->delete($key);
}
@ -130,11 +184,15 @@ class CacheHandler extends Handler {
*
* @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.
* 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){
if(!$this->handler) return false;
function isValid($key, $modified_time)
{
if(!$this->handler)
{
return false;
}
return $this->handler->isValid($key, $modified_time);
}
@ -143,8 +201,12 @@ class CacheHandler extends Handler {
*
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/
function truncate(){
if(!$this->handler) return false;
function truncate()
{
if(!$this->handler)
{
return false;
}
return $this->handler->truncate();
}
@ -164,8 +226,10 @@ class CacheHandler extends Handler {
* @param string $key Cache key
* @return string
*/
function getGroupKey($keyGroupName, $key){
if(!$this->keyGroupVersions[$keyGroupName]){
function getGroupKey($keyGroupName, $key)
{
if(!$this->keyGroupVersions[$keyGroupName])
{
$this->keyGroupVersions[$keyGroupName] = 1;
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
}
@ -179,10 +243,12 @@ class CacheHandler extends Handler {
* @param string $keyGroupName Group name
* @return void
*/
function invalidateGroupKey($keyGroupName){
function invalidateGroupKey($keyGroupName)
{
$this->keyGroupVersions[$keyGroupName]++;
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
}
}
/**
@ -190,17 +256,19 @@ class CacheHandler extends Handler {
*
* @author NHN (developer@xpressengine.com)
*/
class CacheBase{
class CacheBase
{
/**
* Get cached data
*
* @param string $key Cache key
* @param int $modified_time Unix time of data modified.
* If stored time is older then modified time, return false.
* 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){
function get($key, $modified_time = 0)
{
return false;
}
@ -210,11 +278,12 @@ class CacheBase{
* @param string $key Cache key
* @param mixed $obj Value of a variable to store. $value supports all data types except resources, such as file handlers.
* @param int $valid_time Time for the variable to live in the cache in seconds.
* After the value specified in ttl has passed the stored variable will be deleted from the cache.
* If no ttl is supplied, use the default valid time.
* After the value specified in ttl has passed the stored variable will be deleted from the cache.
* If no ttl is supplied, use the default valid time.
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/
function put($key, $obj, $valid_time = 0){
function put($key, $obj, $valid_time = 0)
{
return false;
}
@ -223,10 +292,11 @@ class CacheBase{
*
* @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.
* 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){
function isValid($key, $modified_time = 0)
{
return false;
}
@ -235,7 +305,8 @@ class CacheBase{
*
* @return boolean
*/
function isSupport(){
function isSupport()
{
return false;
}
@ -244,10 +315,11 @@ class CacheBase{
*
* @return bool|void Returns true on success or false on failure. If use CacheFile, returns void.
*/
function truncate(){
function truncate()
{
return false;
}
}
}
/* End of file CacheHandler.class.php */
/* Location: ./classes/cache/CacheHandler.class.php */

View file

@ -1,10 +1,13 @@
<?php
/**
* Cache class for memcache
*
* @author NHN (developer@xpressengine.com)
**/
class CacheMemcache extends CacheBase {
*/
class CacheMemcache extends CacheBase
{
/**
* Default valid time
* @var int
@ -23,8 +26,10 @@ class CacheMemcache extends CacheBase {
* @param string $url url of memcache
* @return CacheMemcache instance of CacheMemcache
*/
function getInstance($url){
if(!$GLOBALS['__CacheMemcache__']) {
function getInstance($url)
{
if(!$GLOBALS['__CacheMemcache__'])
{
$GLOBALS['__CacheMemcache__'] = new CacheMemcache($url);
}
return $GLOBALS['__CacheMemcache__'];
@ -37,12 +42,14 @@ class CacheMemcache extends CacheBase {
* @param string $url url of memcache
* @return void
*/
function CacheMemcache($url){
function CacheMemcache($url)
{
//$config['url'] = array('memcache://localhost:11211');
$config['url'] = is_array($url)?$url:array($url);
$config['url'] = is_array($url) ? $url : array($url);
$this->Memcache = new Memcache;
foreach($config['url'] as $url) {
foreach($config['url'] as $url)
{
$info = parse_url($url);
$this->Memcache->addServer($info['host'], $info['port']);
}
@ -53,11 +60,18 @@ class CacheMemcache extends CacheBase {
*
* @return bool Return true on support or false on not support
*/
function isSupport(){
if($GLOBALS['XE_MEMCACHE_SUPPORT']) return true;
if($this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1)) {
function isSupport()
{
if($GLOBALS['XE_MEMCACHE_SUPPORT'])
{
return true;
}
if($this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1))
{
$GLOBALS['XE_MEMCACHE_SUPPORT'] = true;
} else {
}
else
{
$GLOBALS['XE_MEMCACHE_SUPPORT'] = false;
}
return $GLOBALS['XE_MEMCACHE_SUPPORT'];
@ -69,8 +83,9 @@ class CacheMemcache extends CacheBase {
* @param string $key Cache key
* @return string Return unique key
*/
function getKey($key){
return md5(_XE_PATH_.$key);
function getKey($key)
{
return md5(_XE_PATH_ . $key);
}
/**
@ -86,12 +101,16 @@ class CacheMemcache extends CacheBase {
* @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 CacheMemcache::valid_time.
* 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 CacheMemcache::valid_time.
* @return bool Returns true on success or false on failure.
*/
function put($key, $buff, $valid_time = 0){
if($valid_time == 0) $valid_time = $this->valid_time;
function put($key, $buff, $valid_time = 0)
{
if($valid_time == 0)
{
$valid_time = $this->valid_time;
}
return $this->Memcache->set($this->getKey($key), array(time(), $buff), MEMCACHE_COMPRESSED, $valid_time);
}
@ -101,17 +120,22 @@ class CacheMemcache extends CacheBase {
*
* @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.
* 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) {
function isValid($key, $modified_time = 0)
{
$_key = $this->getKey($key);
$obj = $this->Memcache->get($_key);
if(!$obj || !is_array($obj)) return false;
if(!$obj || !is_array($obj))
{
return false;
}
unset($obj[1]);
if($modified_time > 0 && $modified_time > $obj[0]) {
if($modified_time > 0 && $modified_time > $obj[0])
{
$this->_delete($_key);
return false;
}
@ -126,15 +150,20 @@ class CacheMemcache extends CacheBase {
*
* @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.
* 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) {
function get($key, $modified_time = 0)
{
$_key = $this->getKey($key);
$obj = $this->Memcache->get($_key);
if(!$obj || !is_array($obj)) return false;
if(!$obj || !is_array($obj))
{
return false;
}
if($modified_time > 0 && $modified_time > $obj[0]) {
if($modified_time > 0 && $modified_time > $obj[0])
{
$this->_delete($_key);
return false;
}
@ -152,7 +181,8 @@ class CacheMemcache extends CacheBase {
* @param string $key The key associated with the item to delete.
* @return void
*/
function delete($key) {
function delete($key)
{
$_key = $this->getKey($key);
$this->_delete($_key);
}
@ -164,7 +194,8 @@ class CacheMemcache extends CacheBase {
* @param string $_key The key associated with the item to delete.
* @return void
*/
function _delete($_key) {
function _delete($_key)
{
$this->Memcache->delete($_key);
}
@ -177,10 +208,11 @@ class CacheMemcache extends CacheBase {
*
* @return bool Returns true on success or false on failure.
*/
function truncate() {
function truncate()
{
return $this->Memcache->flush();
}
}
}
/* End of file CacheMemcache.class.php */
/* Location: ./classes/cache/CacheMemcache.class.php */

View file

@ -1,12 +1,15 @@
<?php
/**
* Cache class for Wincache
*
* Wincache Handler
*
* @author Arnia (support@xpressengine.org)
**/
class CacheWincache extends CacheBase {
*/
class CacheWincache extends CacheBase
{
/**
* Default valid time
* @var int
@ -19,8 +22,10 @@ class CacheWincache extends CacheBase {
* @param void $opt Not used
* @return CacheWincache instance of CacheWincache
*/
function getInstance($opt=null){
if(!$GLOBALS['__CacheWincache__']) {
function getInstance($opt = null)
{
if(!$GLOBALS['__CacheWincache__'])
{
$GLOBALS['__CacheWincache__'] = new CacheWincache();
}
return $GLOBALS['__CacheWincache__'];
@ -31,7 +36,9 @@ class CacheWincache extends CacheBase {
*
* @return void
*/
function CacheWincache(){
function CacheWincache()
{
}
/**
@ -39,7 +46,8 @@ class CacheWincache extends CacheBase {
*
* @return bool Return true on support or false on not support
*/
function isSupport(){
function isSupport()
{
return function_exists('wincache_ucache_set');
}
@ -47,16 +55,20 @@ class CacheWincache extends CacheBase {
* Adds a variable in user cache and overwrites a variable if it already exists in the cache
*
* @param string $key Store the variable using this $key value.
* If a variable with same $key is already present the function will overwrite the previous value with the new one.
* If a variable with same $key is already present the function will overwrite the previous value with the new one.
* @param mixed $buff Value of a variable to store. $value supports all data types except resources, such as file handlers.
* @param int $valid_time Time for the variable to live in the cache in seconds.
* After the value specified in ttl has passed the stored variable will be deleted from the cache.
* If no ttl is supplied, use the default valid time CacheWincache::valid_time.
* After the value specified in ttl has passed the stored variable will be deleted from the cache.
* If no ttl is supplied, use the default valid time CacheWincache::valid_time.
* @return bool Returns true on success or false on failure.
*/
function put($key, $buff, $valid_time = 0){
if($valid_time == 0) $valid_time = $this->valid_time;
return wincache_ucache_set(md5(_XE_PATH_.$key), array(time(), $buff), $valid_time);
function put($key, $buff, $valid_time = 0)
{
if($valid_time == 0)
{
$valid_time = $this->valid_time;
}
return wincache_ucache_set(md5(_XE_PATH_ . $key), array(time(), $buff), $valid_time);
}
/**
@ -64,20 +76,25 @@ class CacheWincache extends CacheBase {
*
* @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.
* 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 = md5(_XE_PATH_.$key);
function isValid($key, $modified_time = 0)
{
$_key = md5(_XE_PATH_ . $key);
$obj = wincache_ucache_get($_key, $success);
if(!$success || !is_array($obj)) return false;
if(!$success || !is_array($obj))
{
return false;
}
unset($obj[1]);
if($modified_time > 0 && $modified_time > $obj[0]) {
if($modified_time > 0 && $modified_time > $obj[0])
{
$this->_delete($_key);
return false;
}
return true;
}
@ -86,15 +103,20 @@ class CacheWincache extends CacheBase {
*
* @param string $key The $key that was used to store the variable in the cache.
* @param int $modified_time Unix time of data modified.
* If stored time is older then modified time, return false.
* 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 = md5(_XE_PATH_.$key);
function get($key, $modified_time = 0)
{
$_key = md5(_XE_PATH_ . $key);
$obj = wincache_ucache_get($_key, $success);
if(!$success || !is_array($obj)) return false;
if(!$success || !is_array($obj))
{
return false;
}
if($modified_time > 0 && $modified_time > $obj[0]) {
if($modified_time > 0 && $modified_time > $obj[0])
{
$this->_delete($_key);
return false;
}
@ -108,7 +130,8 @@ class CacheWincache extends CacheBase {
* @param string $_key Used to store the value.
* @return void
*/
function _delete($_key) {
function _delete($_key)
{
wincache_ucache_delete($_key);
}
@ -118,8 +141,9 @@ class CacheWincache extends CacheBase {
* @param string $key Used to store the value.
* @return void
*/
function delete($key) {
$_key = md5(_XE_PATH_.$key);
function delete($key)
{
$_key = md5(_XE_PATH_ . $key);
$this->_delete($_key);
}
@ -128,10 +152,11 @@ class CacheWincache extends CacheBase {
*
* @return bool Returns true on success or false on failure.
*/
function truncate() {
function truncate()
{
return wincache_ucache_clear();
}
}
}
/* End of file CacheWincache.class.php */
/* Location: ./classes/cache/CacheWincache.class.php */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,868 +0,0 @@
<?php
/**
* @class DBFirebird
* @author Kim Hyun Sik (dev.hyuns @ gmail.com)
* @brief class to use Firebird DBMS
* @version 0.3
*
* firebird handling class
**/
class DBFireBird extends DB {
/**
* @brief connection to Firebird DB
**/
var $prefix = 'xe_'; // / <prefix of XE tables(One more XE can be installed on a single DB)
var $idx_no = 0; // counter for creating an index
var $comment_syntax = '/* %s */';
/**
* @brief column type used in firebird
*
* column_type should be replaced for each DBMS's type
* becasue it uses commonly defined type in the schema/query xml
**/
var $column_type = array(
'bignumber' => 'BIGINT',
'number' => 'INTEGER',
'varchar' => 'VARCHAR',
'char' => 'CHAR',
'text' => 'BLOB SUB_TYPE TEXT SEGMENT SIZE 32',
'bigtext' => 'BLOB SUB_TYPE TEXT SEGMENT SIZE 32',
'date' => 'VARCHAR(14)',
'float' => 'FLOAT',
);
/**
* @brief constructor
**/
function DBFireBird() {
$this->_setDBInfo();
$this->_connect();
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBFireBird;
}
/**
* @brief Return if installable
**/
function isSupported() {
if(!function_exists('ibase_connect')) return false;
return true;
}
/**
* @brief DB Connection
**/
function __connect($connection) {
//if(strpos($this->hostname, ':')===false && $this->port) $this->hostname .= ':'.$this->port;
// attempts to connect
$host = $connection["db_hostname"]."/".$connection["db_port"].":".$connection["db_database"];
$result = ibase_connect($host, $connection["db_userid"], $connection["db_password"]);
if(ibase_errmsg()) {
$this->setError(ibase_errcode(), ibase_errmsg());
return;
}
// Error when Firebird version is lower than 2.0
if (($service = ibase_service_attach($connection["db_hostname"], $connection["db_userid"], $connection["db_password"])) != FALSE) {
// get server version and implementation strings
$server_info = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
ibase_service_detach($service);
}
else {
$this->setError(ibase_errcode(), ibase_errmsg());
ibase_close($result);
return;
}
$pos = strpos($server_info, "Firebird");
if($pos !== false) {
$ver = substr($server_info, $pos+strlen("Firebird"));
$ver = trim($ver);
}
if($ver < "2.0") {
$this->setError(-1, "XE cannot be installed under the version of firebird 2.0. Current firebird version is ".$ver);
ibase_close($result);
return;
}
return $result;
}
/**
* @brief DB disconnect
**/
function _close($connection) {
ibase_commit($connection);
ibase_close($connection);
}
/**
* @brief handles quatation of the string variables from the query
**/
function addQuotes($string) {
if(get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
if(!is_numeric($string)) $string = str_replace("'","''", $string);
return $string;
}
/**
* @brief put double quotes for tabls, column names in the query statement
**/
function addDoubleQuotes($string) {
if($string == "*") return $string;
if(strpos($string, "'")!==false) {
$string = str_replace("'", "\"", $string);
}
else if(strpos($string, "\"")!==false) {
}
else {
$string = "\"".$string."\"";
}
return $string;
}
/**
* @brief put double quotes for tabls, column names in the query statement
**/
function autoQuotes($string){
$string = strtolower($string);
// for substr function
if(strpos($string, "substr(") !== false) {
$tokken = strtok($string, "(,)");
$tokken = strtok("(,)");
while($tokken) {
$tokkens[] = $tokken;
$tokken = strtok("(,)");
}
if(count($tokkens) !== 3) return $string;
return sprintf("substring(%s from %s for %s)", $this->addDoubleQuotes($tokkens[0]), $tokkens[1], $tokkens[2]);
}
// as
$as = false;
if(($no1 = strpos($string," as ")) !== false) {
$as = substr($string, $no1, strlen($string)-$no1);
$string = substr($string, 0, $no1);
$as = str_replace(" as ", "", $as);
$as = trim($as);
$as = $this->addDoubleQuotes($as);
}
// for functions
$tmpFunc1 = null;
$tmpFunc2 = null;
if(($no1 = strpos($string,'('))!==false && ($no2 = strpos($string, ')'))!==false) {
$tmpFunc1 = substr($string, 0, $no1+1);
$tmpFunc2 = substr($string, $no2, strlen($string)-$no2+1);
$string = trim(substr($string, $no1+1, $no2-$no1-1));
}
// for (table.column) structure
preg_match("/((?i)[a-z0-9_-]+)[.]((?i)[a-z0-9_\-\*]+)/", $string, $matches);
if($matches) {
$string = $this->addDoubleQuotes($matches[1]).".".$this->addDoubleQuotes($matches[2]);
}
else {
$string = $this->addDoubleQuotes($string);
}
if($tmpFunc1 != null) $string = $tmpFunc1.$string;
if($tmpFunc2 != null) $string = $string.$tmpFunc2;
if($as !== false) $string = $string." as ".$as;
return $string;
}
function autoValueQuotes($string, $tables){
$tok = strtok($string, ",");
while($tok !== false) {
$values[] = $tok;
$tok = strtok(",");
}
foreach($values as $val1) {
// for (table.column) structure
preg_match("/((?i)[a-z0-9_-]+)[.]((?i)[a-z0-9_\-\*]+)/", $val1, $matches);
if($matches) {
$isTable = false;
foreach($tables as $key2 => $val2) {
if($key2 == $matches[1]) $isTable = true;
if($val2 == $matches[1]) $isTable = true;
}
if($isTable) {
$return[] = $this->addDoubleQuotes($matches[1]).".".$this->addDoubleQuotes($matches[2]);
}
else {
$return[] = $val1;
}
}
else if(!is_numeric($val1)) {
if(strpos($val1, "'") !== 0)
$return[] = "'".$val1."'";
else
$return[] = $val1;
}
else {
$return[] = $val1;
}
}
return implode(",", $return);
}
/**
* @brief Begin transaction
**/
function _begin() {
return true;
}
/**
* @brief Rollback
**/
function _rollback() {
$connection = $this->_getConnection('master');
ibase_rollback($connection);
return true;
}
/**
* @brief Commits
**/
function _commit() {
$connection = $this->_getConnection('master');
ibase_commit($connection);
return true;
}
/**
* @brief : Run a query and fetch the result
*
* query: run a query and return the result\n
* fetch: NULL if no value returned \n
* array object if rows returned \n
* object if a row returned \n
* return\n
**/
function __query($query, $connection, $params = null) {
if(count($params) == 0) {
// Execute the query statement
$result = ibase_query($connection, $query);
}
else {
// Execute the query(for blob type)
$query = ibase_prepare($connection, $query);
//$fnarr = array_merge(array($query), $params);
$result = ibase_execute($query);
}
// Error Check
if(ibase_errmsg()) $this->setError(ibase_errcode(), ibase_errmsg());
return $result;
}
function _queryInsertUpdateDeleteSelect($query, $params=null, $connection) {
if(!$connection) return;
if(count($params) == 0) {
// Notify to start a query execution
$this->actStart($query);
// Execute the query statement
$trans = ibase_trans(IBASE_DEFAULT,$connection);
$result = ibase_query($trans, $query);
ibase_commit($trans);
unset($trans);
}
else {
// Notify to start a query execution
$log = $query."\n\t\t\t";
$log .= implode(",", $params);
$this->actStart($log);
// Execute the query(for blob type)
$query = ibase_prepare($connection, $query);
//$fnarr = array_merge(array($query), $params);
$result = ibase_execute($query);
}
// Error Check
if(ibase_errmsg()) $this->setError(ibase_errcode(), ibase_errmsg());
// Notify to complete a query execution
$this->actFinish();
// Return the result
return $result;
}
function getTableInfo($result){
$coln = ibase_num_fields($result);
$column_type = array();
for ($i = 0; $i < $coln; $i++) {
$col_info = ibase_field_info($result, $i);
if($col_info['name'] === "") $column_type[$col_info['alias']] = $col_info['type'];
else $column_type[$col_info['name']] = $col_info['type'];
}
return $column_type;
}
/**
* @brief Fetch the result
**/
function _fetch($result, $output = null) {
if(!$this->isConnected() || $this->isError() || !$result) return;
$output->column_type = $this->getTableInfo($result);
while($tmp = ibase_fetch_object($result)) {
foreach($tmp as $key => $val) {
$type = $output->column_type[$key];
// type value is null when $key is an alias. so get a type by finding actual coloumn name
if($type == null && $output->columns && count($output->columns)) {
foreach($output->columns as $cols) {
if($cols['alias'] == $key) {
// checks if the format is table.column or a regular expression
preg_match("/\w+[.](\w+)/", $cols['name'], $matches);
if($matches) {
$type = $output->column_type[$matches[1]];
}
else {
$type = $output->column_type[$cols['name']];
}
}
}
}
if(($type == "text" || $type == "bigtext" || $type == "BLOB") && $tmp->{$key}) {
$blob_data = ibase_blob_info($tmp->{$key});
$blob_hndl = ibase_blob_open($tmp->{$key});
if($blob_data[1] === 1) {
$tmp->{$key} = ibase_blob_get($blob_hndl, $blob_data[0]);
} else {
for ($i = 0; $i < $blob_data[1]; $i++) {
$readsize = $blob_data[2];
if ($i == ($blob_data[1] - 1)) {
$readsize = $blob_data[0] - (($blob_data[1] - 1) * $blob_data[2]);
}
$totalimage .= ibase_blob_get($blob_hndl, $readsize);
}
}
ibase_blob_close($blob_hndl);
}
else if($type == "CHAR") {
$tmp->{$key} = trim($tmp->{$key}); // remove blanks generated when DB character set is UTF8
}
}
$return[] = $tmp;
}
if(count($return)==1) return $return[0];
return $return;
}
/**
* @brief return sequence value incremented by 1(increase the value of the generator in firebird)
**/
function getNextSequence() {
//$gen = "GEN_".$this->prefix."sequence_ID";
$gen = 'GEN_XE_SEQUENCE_ID';
$sequence = ibase_gen_id($gen, 1);
return $sequence;
}
/**
* @brief returns if the table already exists
**/
function isTableExists($target_name) {
$query = sprintf("select rdb\$relation_name from rdb\$relations where rdb\$system_flag=0 and rdb\$relation_name = '%s%s';", $this->prefix, $target_name);
$result = $this->_query($query);
$tmp = $this->_fetch($result);
$connection = $this->_getConnection('master');
if(!$tmp) {
if(!$this->transaction_started) ibase_rollback($connection);
return false;
}
if(!$this->transaction_started) ibase_commit($connection);
return true;
}
/**
* @brief add a column to the table
**/
function addColumn($table_name, $column_name, $type='number', $size='', $default = '', $notnull=false) {
$type = $this->column_type[$type];
if(strtoupper($type)=='INTEGER') $size = null;
else if(strtoupper($type)=='BIGINT') $size = null;
else if(strtoupper($type)=='BLOB SUB_TYPE TEXT SEGMENT SIZE 32') $size = null;
else if(strtoupper($type)=='VARCHAR' && !$size) $size = 256;
$query = sprintf("ALTER TABLE \"%s%s\" ADD \"%s\" ", $this->prefix, $table_name, $column_name);
if($size) $query .= sprintf(" %s(%s) ", $type, $size);
else $query .= sprintf(" %s ", $type);
if(!is_null($default)) $query .= sprintf(" DEFAULT '%s' ", $default);
if($notnull) $query .= " NOT NULL ";
$this->_query($query);
if(!$this->transaction_started) {
$connection = $this->_getConnection('master');
ibase_commit($connection);
}
}
/**
* @brief drop a column from the table
**/
function dropColumn($table_name, $column_name) {
$query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name);
$this->_query($query);
if(!$this->transaction_started) {
$connection = $this->_getConnection('master');
ibase_commit($connection);
}
}
/**
* @brief return column information of the table
**/
function isColumnExists($table_name, $column_name) {
$query = sprintf("SELECT RDB\$FIELD_NAME as \"FIELD\" FROM RDB\$RELATION_FIELDS WHERE RDB\$RELATION_NAME = '%s%s'", $this->prefix, $table_name);
$result = $this->_query($query);
$connection = $this->_getConnection('master');
if($this->isError()) {
if(!$this->transaction_started) ibase_rollback($connection);
return false;
}
$output = $this->_fetch($result);
if(!$this->transaction_started) ibase_commit($connection);
if($output) {
$column_name = strtolower($column_name);
foreach($output as $key => $val) {
$name = trim(strtolower($val->FIELD));
if($column_name == $name) return true;
}
}
return false;
}
/**
* @brief add an index to the table
* $target_columns = array(col1, col2)
* $is_unique? unique : none
**/
function addIndex($table_name, $index_name, $target_columns, $is_unique = false) {
// index name size should be limited to 31 byte. no index name assigned
// if index name omitted, Firebird automatically assign its name like "RDB $10"
// deletes indexes when deleting the table
if(!is_array($target_columns)) $target_columns = array($target_columns);
$query = sprintf('CREATE %s INDEX "" ON "%s%s" ("%s");', $is_unique?'UNIQUE':'', $this->prefix, $table_name, implode('", "',$target_columns));
$this->_query($query);
$connection = $this->_getConnection('master');
if(!$this->transaction_started) ibase_commit($connection);
}
/**
* @brief drop an index from the table
**/
function dropIndex($table_name, $index_name, $is_unique = false) {
$query = sprintf('DROP INDEX "%s" ON "%s%s"', $index_name, $this->prefix, $table_name);
$this->_query($query);
$connection = $this->_getConnection('master');
if(!$this->transaction_started) ibase_commit($connection);
}
/**
* @brief return index information of the table
**/
function isIndexExists($table_name, $index_name) {
$query = "SELECT\n";
$query .= " RDB\$INDICES.rdb\$index_name AS Key_name\n";
$query .= "FROM\n";
$query .= " RDB\$INDICES, rdb\$index_segments\n";
$query .= "WHERE\n";
$query .= " RDB\$INDICES.rdb\$index_name = rdb\$index_segments.rdb\$index_name AND\n";
$query .= " RDB\$INDICES.rdb\$relation_name = '";
$query .= $this->prefix;
$query .= $table_name;
$query .= "' AND\n";
$query .= " RDB\$INDICES.rdb\$index_name = '";
$query .= $index_name;
$query .= "'";
$result = $this->_query($query);
if($this->isError()) return;
$output = $this->_fetch($result);
if(!$output) {
$connection = $this->_getConnection('master');
if(!$this->transaction_started) ibase_rollback($connection);
return false;
}
if(!$this->transaction_started) {
$connection = $this->_getConnection('master');
ibase_commit($connection);
}
if(!is_array($output)) $output = array($output);
for($i=0;$i<count($output);$i++) {
if(trim($output[$i]->KEY_NAME) == $index_name) return true;
}
return false;
}
/**
* @brief creates a table by using xml file
**/
function createTableByXml($xml_doc) {
return $this->_createTable($xml_doc);
}
/**
* @brief creates a table by using xml file
**/
function createTableByXmlFile($file_name) {
if(!file_exists($file_name)) return;
// read xml file
$buff = FileHandler::readFile($file_name);
return $this->_createTable($buff);
}
/**
* @brief create table by using the schema xml
*
* type : number, varchar, text, char, date, \n
* opt : notnull, default, size\n
* index : primary key, index, unique\n
**/
function _createTable($xml_doc) {
// xml parsing
$oXml = new XmlParser();
$xml_obj = $oXml->parse($xml_doc);
// Create a table schema
$table_name = $xml_obj->table->attrs->name;
if($this->isTableExists($table_name)) return;
$table_name = $this->prefix.$table_name;
if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
else $columns = $xml_obj->table->column;
foreach($columns as $column) {
$name = $column->attrs->name;
$type = $column->attrs->type;
$size = $column->attrs->size;
$notnull = $column->attrs->notnull;
$primary_key = $column->attrs->primary_key;
$index = $column->attrs->index;
$unique = $column->attrs->unique;
$default = $column->attrs->default;
$auto_increment = $column->attrs->auto_increment;
if($this->column_type[$type]=='INTEGER') $size = null;
else if($this->column_type[$type]=='BIGINT') $size = null;
else if($this->column_type[$type]=='BLOB SUB_TYPE TEXT SEGMENT SIZE 32') $size = null;
else if($this->column_type[$type]=='VARCHAR' && !$size) $size = 256;
$column_schema[] = sprintf('"%s" %s%s %s %s',
$name,
$this->column_type[$type],
$size?'('.$size.')':'',
is_null($default)?"":"DEFAULT '".$default."'",
$notnull?'NOT NULL':'');
if($auto_increment) $auto_increment_list[] = $name;
if($primary_key) $primary_list[] = $name;
else if($unique) $unique_list[$unique][] = $name;
else if($index) $index_list[$index][] = $name;
}
if(count($primary_list)) {
$column_schema[] = sprintf("PRIMARY KEY(\"%s\")%s", implode("\",\"", $primary_list), "\n");
}
if(count($unique_list)) {
foreach($unique_list as $key => $val) {
$column_schema[] = sprintf("UNIQUE(\"%s\")%s", implode("\",\"", $val), "\n");
}
}
$schema = sprintf("CREATE TABLE \"%s\" (%s%s); \n", $table_name, "\n", implode($column_schema, ",\n"));
$output = $this->_query($schema);
if(!$this->transaction_started) {
$connection = $this->_getConnection('master');
ibase_commit($connection);
}
if(!$output) return false;
if(count($index_list)) {
foreach($index_list as $key => $val) {
// index name size should be limited to 31 byte. no index name assigned
// if index name omitted, Firebird automatically assign its name like "RDB $10"
// deletes indexes when deleting the table
$schema = sprintf("CREATE INDEX \"\" ON \"%s\" (\"%s\");",
$table_name, implode($val, "\",\""));
$output = $this->_query($schema);
if(!$this->transaction_started) {
$connection = $this->_getConnection('master');
ibase_commit($connection);
}
if(!$output) return false;
}
}
if($_GLOBALS['XE_EXISTS_SEQUENCE']) return;
$schema = 'CREATE GENERATOR GEN_XE_SEQUENCE_ID;';
$output = $this->_query($schema);
if(!$this->transaction_started) {
$connection = $this->_getConnection('master');
ibase_commit($connection);
}
if(!$output) return false;
$_GLOBALS['XE_EXISTS_SEQUENCE'] = true;
/*if($auto_increment_list)
foreach($auto_increment_list as $increment) {
$schema = sprintf('CREATE GENERATOR GEN_%s_ID;', $table_name);
$output = $this->_query($schema);
if(!$this->transaction_started) ibase_commit($this->fd);
if(!$output) return false;*/
// auto_increment in Firebird creates a generator which activates a trigger when insert occurs
// the generator increases the value of the generator and then insert to the table
// The trigger below acts like auto_increment however I commented the below because the trigger cannot be defined by a query statement
// php api has a function to increase a generator, so
// no need to use auto increment in XE
/*
$schema = 'SET TERM ^ ; ';
$schema .= sprintf('CREATE TRIGGER "%s_BI" FOR "%s" ', $table_name, $table_name);
$schema .= 'ACTIVE BEFORE INSERT POSITION 0 ';
$schema .= sprintf('AS BEGIN IF (NEW."%s" IS NULL) THEN ', $increment);
$schema .= sprintf('NEW."%s" = GEN_ID("GEN_%s_ID",1);', $increment, $table_name);
$schema .= 'END^ SET TERM ; ^';
$output = $this->_query($schema);
if(!$output) return false;
*/
//}
}
/**
* @brief Handle the insertAct
**/
function _executeInsertAct($queryObject) {
$query = $this->getInsertSql($queryObject);
if(is_a($query, 'Object')) return;
return $this->_queryInsertUpdateDeleteSelect($query);
}
/**
* @brief handles updateAct
**/
function _executeUpdateAct($queryObject) {
$query = $this->getUpdateSql($queryObject);
if(is_a($query, 'Object')) return;
return $this->_queryInsertUpdateDeleteSelect($query);
}
/**
* @brief handles deleteAct
**/
function _executeDeleteAct($queryObject) {
$query = $this->getDeleteSql($queryObject);
if(is_a($query, 'Object')) return;
return $this->_queryInsertUpdateDeleteSelect($query);
}
/**
* @brief Handle selectAct
*
* In order to get a list of pages easily when selecting \n
* it supports a method as navigation
**/
function _executeSelectAct($queryObject, $connection) {
$query = $this->getSelectSql($queryObject);
if(strpos($query, "substr")) {
$query = str_replace ("substr", "substring", $query);
$query = $this->replaceSubstrFormat($query);
}
if(is_a($query, 'Object')) return;
$query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
$result = $this->_queryInsertUpdateDeleteSelect ($query, null, $connection);
if ($this->isError ()) return $this->queryError($queryObject);
else return $this->queryPageLimit($queryObject, $result, $connection);
}
function queryError($queryObject) {
$limit = $queryObject->getLimit();
if ($limit && $limit->isPageHandler()) {
$buff = new Object ();
$buff->total_count = 0;
$buff->total_page = 0;
$buff->page = 1;
$buff->data = array();
$buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values
}else
return;
}
function queryPageLimit($queryObject, $result, $connection) {
$limit = $queryObject->getLimit();
if ($limit && $limit->isPageHandler()) {
// Total count
$temp_where = $queryObject->getWhereString(true, false);
$count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE ' . $temp_where));
if ($queryObject->getGroupByString() != '') {
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
}
$count_query .= ( __DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result_count = $this->_query($count_query, null, $connection);
$count_output = $this->_fetch($result_count);
$total_count = (int) $count_output->count;
$list_count = $limit->list_count->getValue();
if (!$list_count) $list_count = 20;
$page_count = $limit->page_count->getValue();
if (!$page_count) $page_count = 10;
$page = $limit->page->getValue();
if (!$page) $page = 1;
// Total pages
if ($total_count) $total_page = (int) (($total_count - 1) / $list_count) + 1;
else $total_page = 1;
// check the page variables
if ($page > $total_page) {
// If requested page is bigger than total number of pages, return empty list
$buff = new Object ();
$buff->total_count = $total_count;
$buff->total_page = $total_page;
$buff->page = $page;
$buff->data = array();
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
return $buff;
}
$start_count = ($page-1)*$list_count;
$query = $this->getSelectSql($queryObject, true, $start_count);
if(strpos($query, "substr")) {
$query = str_replace ("substr", "substring", $query);
$query = $this->replaceSubstrFormat($query);
}
$query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
$result = $this->_query ($query, null, $connection);
if ($this->isError ())
return $this->queryError($queryObject);
$virtual_no = $total_count - ($page - 1) * $list_count;
while ($tmp = ibase_fetch_object($result))
$data[$virtual_no--] = $tmp;
if (!$this->transaction_started)
ibase_commit($connection);
$buff = new Object ();
$buff->total_count = $total_count;
$buff->total_page = $total_page;
$buff->page = $page;
$buff->data = $data;
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
}else {
$data = $this->_fetch($result);
$buff = new Object ();
$buff->data = $data;
}
return $buff;
}
function getParser() {
return new DBParser('"', '"', $this->prefix);
}
function getSelectSql($query, $with_values = true, $start_count = 0) {
$limit = $query->getLimit();
if ($limit && $limit->isPageHandler()) {
$list_count = $limit->list_count->getValue();
if(!$limit->page) $page = 1;
else $page = $limit->page->getValue();
if(!$start_count)
$start_count = ($page - 1) * $list_count;
$limit = sprintf('SELECT FIRST %d SKIP %d ', $list_count, $start_count);
}
$select = $query->getSelectString($with_values);
if ($select == '')
return new Object(-1, "Invalid query");
if ($limit && $limit->isPageHandler())
$select = $limit . ' ' . $select;
else
$select = 'SELECT ' . $select;
$from = $query->getFromString($with_values);
if ($from == '')
return new Object(-1, "Invalid query");
$from = ' FROM ' . $from;
$where = $query->getWhereString($with_values);
if ($where != '')
$where = ' WHERE ' . $where;
$groupBy = $query->getGroupByString();
if ($groupBy != '')
$groupBy = ' GROUP BY ' . $groupBy;
$orderBy = $query->getOrderByString();
if ($orderBy != '')
$orderBy = ' ORDER BY ' . $orderBy;
return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy;
}
function getDeleteSql($query, $with_values = true){
$sql = 'DELETE ';
$from = $query->getFromString($with_values);
if($from == '') return new Object(-1, "Invalid query");
$sql .= ' FROM '.$from;
$where = $query->getWhereString($with_values);
if($where != '') $sql .= ' WHERE ' . $where;
return $sql;
}
function replaceSubstrFormat($queryString){
//replacing substr("string",number,number) with substr("string" from number for number)
$pattern = '/substring\("(\w+)",(\d+),(\d+)\)/i';
$replacement = 'substring("${1}" from $2 for $3)';
return preg_replace($pattern, $replacement, $queryString);
}
}
?>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,162 +1,218 @@
<?php
require_once('DBMysql.class.php');
require_once('DBMysql.class.php');
/**
* Class to use MySQL innoDB DBMS
* mysql innodb handling class
*
* Does not use prepared statements, since mysql driver does not support them
*
* @author NHN (developers@xpressengine.com)
* @package /classes/db
* @version 0.1
*/
class DBMysql_innodb extends DBMysql
{
/**
* Class to use MySQL innoDB DBMS
* mysql innodb handling class
*
* Does not use prepared statements, since mysql driver does not support them
*
* @author NHN (developers@xpressengine.com)
* @package /classes/db
* @version 0.1
**/
class DBMysql_innodb extends DBMysql {
* Constructor
* @return void
*/
function DBMysql_innodb()
{
$this->_setDBInfo();
$this->_connect();
}
/**
* Constructor
* @return void
**/
function DBMysql_innodb() {
$this->_setDBInfo();
$this->_connect();
}
/**
* Create an instance of this class
* @return DBMysql_innodb return DBMysql_innodb object instance
*/
function create()
{
return new DBMysql_innodb;
}
/**
* Create an instance of this class
* @return DBMysql_innodb return DBMysql_innodb object instance
*/
function create()
/**
* DB disconnection
* this method is private
* @param resource $connection
* @return void
*/
function _close($connection)
{
$this->_query("commit", $connection);
@mysql_close($connection);
}
/**
* DB transaction start
* this method is private
* @return boolean
*/
function _begin($transactionLevel)
{
$connection = $this->_getConnection('master');
if(!$transactionLevel)
{
return new DBMysql_innodb;
$this->_query("START TRANSACTION", $connection);
}
else
{
$this->_query("SAVEPOINT SP" . $transactionLevel, $connection);
}
return true;
}
/**
* DB transaction rollback
* this method is private
* @return boolean
*/
function _rollback($transactionLevel)
{
$connection = $this->_getConnection('master');
$point = $transactionLevel - 1;
if($point)
{
$this->_query("ROLLBACK TO SP" . $point, $connection);
}
else
{
$this->_query("ROLLBACK", $connection);
}
return true;
}
/**
* DB transaction commit
* this method is private
* @return boolean
*/
function _commit()
{
$connection = $this->_getConnection('master');
$this->_query("commit", $connection);
return true;
}
/**
* Execute the query
* this method is private
* @param string $query
* @param resource $connection
* @return resource
*/
function __query($query, $connection)
{
if(!$connection)
{
exit('XE cannot handle DB connection.');
}
// Run the query statement
$result = @mysql_query($query, $connection);
// Error Check
if(mysql_error($connection))
{
$this->setError(mysql_errno($connection), mysql_error($connection));
}
// Return result
return $result;
}
/**
* Create table by using the schema xml
*
* type : number, varchar, tinytext, text, bigtext, char, date, \n
* opt : notnull, default, size\n
* index : primary key, index, unique\n
* @param string $xml_doc xml schema contents
* @return void|object
*/
function _createTable($xml_doc)
{
// xml parsing
$oXml = new XmlParser();
$xml_obj = $oXml->parse($xml_doc);
// Create a table schema
$table_name = $xml_obj->table->attrs->name;
if($this->isTableExists($table_name))
{
return;
}
$table_name = $this->prefix . $table_name;
if(!is_array($xml_obj->table->column))
{
$columns[] = $xml_obj->table->column;
}
else
{
$columns = $xml_obj->table->column;
}
/**
* DB disconnection
* this method is private
* @param resource $connection
* @return void
*/
function _close($connection) {
$this->_query("commit", $connection);
@mysql_close($connection);
}
foreach($columns as $column)
{
$name = $column->attrs->name;
$type = $column->attrs->type;
$size = $column->attrs->size;
$notnull = $column->attrs->notnull;
$primary_key = $column->attrs->primary_key;
$index = $column->attrs->index;
$unique = $column->attrs->unique;
$default = $column->attrs->default;
$auto_increment = $column->attrs->auto_increment;
/**
* DB transaction start
* this method is private
* @return boolean
*/
function _begin() {
$connection = $this->_getConnection('master');
$this->_query("begin", $connection);
return true;
}
$column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : '');
/**
* DB transaction rollback
* this method is private
* @return boolean
*/
function _rollback() {
$connection = $this->_getConnection('master');
$this->_query("rollback", $connection);
return true;
}
if($primary_key)
{
$primary_list[] = $name;
}
else if($unique)
{
$unique_list[$unique][] = $name;
}
else if($index)
{
$index_list[$index][] = $name;
}
}
/**
* DB transaction commit
* this method is private
* @return boolean
*/
function _commit() {
$connection = $this->_getConnection('master');
$this->_query("commit", $connection);
return true;
}
if(count($primary_list))
{
$column_schema[] = sprintf("primary key (%s)", '`' . implode($primary_list, '`,`') . '`');
}
/**
* Execute the query
* this method is private
* @param string $query
* @param resource $connection
* @return resource
*/
function __query($query, $connection) {
// Run the query statement
$result = @mysql_query($query, $connection);
// Error Check
if(mysql_error($connection)) $this->setError(mysql_errno($connection), mysql_error($connection));
// Return result
return $result;
}
if(count($unique_list))
{
foreach($unique_list as $key => $val)
{
$column_schema[] = sprintf("unique %s (%s)", $key, '`' . implode($val, '`,`') . '`');
}
}
/**
* Create table by using the schema xml
*
* type : number, varchar, tinytext, text, bigtext, char, date, \n
* opt : notnull, default, size\n
* index : primary key, index, unique\n
* @param string $xml_doc xml schema contents
* @return void|object
*/
function _createTable($xml_doc) {
// xml parsing
$oXml = new XmlParser();
$xml_obj = $oXml->parse($xml_doc);
// Create a table schema
$table_name = $xml_obj->table->attrs->name;
if($this->isTableExists($table_name)) return;
$table_name = $this->prefix.$table_name;
if(count($index_list))
{
foreach($index_list as $key => $val)
{
$column_schema[] = sprintf("index %s (%s)", $key, '`' . implode($val, '`,`') . '`');
}
}
if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
else $columns = $xml_obj->table->column;
$schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci");
foreach($columns as $column) {
$name = $column->attrs->name;
$type = $column->attrs->type;
$size = $column->attrs->size;
$notnull = $column->attrs->notnull;
$primary_key = $column->attrs->primary_key;
$index = $column->attrs->index;
$unique = $column->attrs->unique;
$default = $column->attrs->default;
$auto_increment = $column->attrs->auto_increment;
$output = $this->_query($schema);
if(!$output)
{
return false;
}
}
$column_schema[] = sprintf('`%s` %s%s %s %s %s',
$name,
$this->column_type[$type],
$size?'('.$size.')':'',
isset($default)?"default '".$default."'":'',
$notnull?'not null':'',
$auto_increment?'auto_increment':''
);
if($primary_key) $primary_list[] = $name;
else if($unique) $unique_list[$unique][] = $name;
else if($index) $index_list[$index][] = $name;
}
if(count($primary_list)) {
$column_schema[] = sprintf("primary key (%s)", '`'.implode($primary_list,'`,`').'`');
}
if(count($unique_list)) {
foreach($unique_list as $key => $val) {
$column_schema[] = sprintf("unique %s (%s)", $key, '`'.implode($val,'`,`').'`');
}
}
if(count($index_list)) {
foreach($index_list as $key => $val) {
$column_schema[] = sprintf("index %s (%s)", $key, '`'.implode($val,'`,`').'`');
}
}
$schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema,",\n"), "ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci");
$output = $this->_query($schema);
if(!$output) return false;
}
}
?>
}
/* End of file DBMysql_innodb.class.php */
/* Location: ./classes/db/DBMysql_innodb.class.php */

View file

@ -1,386 +1,447 @@
<?php
require_once('DBMysql.class.php');
require_once('DBMysql.class.php');
/**
* Class to use MySQLi DBMS as mysqli_*
* mysql handling class
*
* Does not use prepared statements, since mysql driver does not support them
*
* @author NHN (developers@xpressengine.com)
* @package /classes/db
* @version 0.1
*/
class DBMysqli extends DBMysql
{
/**
* Class to use MySQLi DBMS as mysqli_*
* mysql handling class
*
* Does not use prepared statements, since mysql driver does not support them
*
* @author NHN (developers@xpressengine.com)
* @package /classes/db
* @version 0.1
**/
class DBMysqli extends DBMysql {
* Constructor
* @return void
*/
function DBMysqli()
{
$this->_setDBInfo();
$this->_connect();
}
/**
* Constructor
* @return void
**/
function DBMysqli() {
$this->_setDBInfo();
$this->_connect();
}
/**
* Return if supportable
* Check 'mysqli_connect' function exists.
* @return boolean
*/
function isSupported() {
if(!function_exists('mysqli_connect')) return false;
return true;
}
/**
* Create an instance of this class
* @return DBMysqli return DBMysqli object instance
*/
function create()
/**
* Return if supportable
* Check 'mysqli_connect' function exists.
* @return boolean
*/
function isSupported()
{
if(!function_exists('mysqli_connect'))
{
return new DBMysqli;
return false;
}
return true;
}
/**
* Create an instance of this class
* @return DBMysqli return DBMysqli object instance
*/
function create()
{
return new DBMysqli;
}
/**
* DB Connect
* this method is private
* @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
* @return resource
*/
function __connect($connection)
{
// Attempt to connect
if($connection["db_port"])
{
$result = @mysqli_connect($connection["db_hostname"]
, $connection["db_userid"]
, $connection["db_password"]
, $connection["db_database"]
, $connection["db_port"]);
}
else
{
$result = @mysqli_connect($connection["db_hostname"]
, $connection["db_userid"]
, $connection["db_password"]
, $connection["db_database"]);
}
$error = mysqli_connect_errno();
if($error)
{
$this->setError($error, mysqli_connect_error());
return;
}
mysqli_set_charset($result, 'utf8');
return $result;
}
/**
* DB disconnection
* this method is private
* @param resource $connection
* @return void
*/
function _close($connection)
{
mysqli_close($connection);
}
/**
* Handles quatation of the string variables from the query
* @param string $string
* @return string
*/
function addQuotes($string)
{
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc())
{
$string = stripslashes(str_replace("\\", "\\\\", $string));
}
if(!is_numeric($string))
{
$connection = $this->_getConnection('master');
$string = mysqli_escape_string($connection, $string);
}
return $string;
}
/**
* Execute the query
* this method is private
* @param string $query
* @param resource $connection
* @return resource
*/
function __query($query, $connection)
{
if($this->use_prepared_statements == 'Y')
{
// 1. Prepare query
$stmt = mysqli_prepare($connection, $query);
if($stmt)
{
$types = '';
$params = array();
$this->_prepareQueryParameters($types, $params);
if(!empty($params))
{
$args[0] = $stmt;
$args[1] = $types;
$i = 2;
foreach($params as $key => $param)
{
$copy[$key] = $param;
$args[$i++] = &$copy[$key];
}
// 2. Bind parameters
$status = call_user_func_array('mysqli_stmt_bind_param', $args);
if(!$status)
{
$this->setError(-1, "Invalid arguments: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true));
}
}
// 3. Execute query
$status = mysqli_stmt_execute($stmt);
if(!$status)
{
$this->setError(-1, "Prepared statement failed: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true));
}
// Return stmt for other processing - like retrieving resultset (_fetch)
return $stmt;
// mysqli_stmt_close($stmt);
}
}
// Run the query statement
$result = mysqli_query($connection, $query);
// Error Check
$error = mysqli_error($connection);
if($error)
{
$this->setError(mysqli_errno($connection), $error);
}
// Return result
return $result;
}
/**
* Before execute query, prepare statement
* this method is private
* @param string $types
* @param array $params
* @return void
*/
function _prepareQueryParameters(&$types, &$params)
{
$types = '';
$params = array();
if(!$this->param)
{
return;
}
/**
* DB Connect
* this method is private
* @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password
* @return resource
*/
function __connect($connection) {
// Attempt to connect
if ($connection["db_port"]) {
$result = @mysqli_connect($connection["db_hostname"]
, $connection["db_userid"]
, $connection["db_password"]
, $connection["db_database"]
, $connection["db_port"]);
} else {
$result = @mysqli_connect($connection["db_hostname"]
, $connection["db_userid"]
, $connection["db_password"]
, $connection["db_database"]);
}
$error = mysqli_connect_errno();
if($error) {
$this->setError($error,mysqli_connect_error());
return;
}
mysqli_set_charset($result,'utf8');
return $result;
}
foreach($this->param as $k => $o)
{
$value = $o->getUnescapedValue();
$type = $o->getType();
/**
* DB disconnection
* this method is private
* @param resource $connection
* @return void
*/
function _close($connection) {
mysqli_close($connection);
}
/**
* Handles quatation of the string variables from the query
* @param string $string
* @return string
*/
function addQuotes($string) {
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
if(!is_numeric($string)){
$connection = $this->_getConnection('master');
$string = mysqli_escape_string($connection,$string);
}
return $string;
}
/**
* Execute the query
* this method is private
* @param string $query
* @param resource $connection
* @return resource
*/
function __query($query, $connection) {
if($this->use_prepared_statements == 'Y')
{
// 1. Prepare query
$stmt = mysqli_prepare($connection, $query);
if($stmt){
$types = '';
$params = array();
$this->_prepareQueryParameters($types, $params);
if(!empty($params))
{
$args[0] = $stmt;
$args[1] = $types;
$i = 2;
foreach($params as $key => $param) {
$copy[$key] = $param;
$args[$i++] = &$copy[$key];
}
// 2. Bind parameters
$status = call_user_func_array('mysqli_stmt_bind_param',$args);
if(!$status)
$this->setError(-1, "Invalid arguments: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true));
}
// 3. Execute query
$status = mysqli_stmt_execute($stmt);
if(!$status)
$this->setError(-1, "Prepared statement failed: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true));
// Return stmt for other processing - like retrieving resultset (_fetch)
return $stmt;
// mysqli_stmt_close($stmt);
}
// Skip column names -> this should be concatenated to query string
if($o->isColumnName())
{
continue;
}
// Run the query statement
$result = mysqli_query($connection,$query);
// Error Check
$error = mysqli_error($connection);
if($error){
$this->setError(mysqli_errno($connection), $error);
switch($type)
{
case 'number' :
$type = 'i';
break;
case 'varchar' :
$type = 's';
break;
default:
$type = 's';
}
// Return result
return $result;
}
/**
* Before execute query, prepare statement
* this method is private
* @param string $types
* @param array $params
* @return void
*/
function _prepareQueryParameters(&$types, &$params){
$types = '';
$params = array();
if(!$this->param) return;
foreach($this->param as $k => $o){
$value = $o->getUnescapedValue();
$type = $o->getType();
// Skip column names -> this should be concatenated to query string
if($o->isColumnName()) continue;
switch($type)
if(is_array($value))
{
foreach($value as $v)
{
case 'number' :
$type = 'i';
break;
case 'varchar' :
$type = 's';
break;
default:
$type = 's';
}
if(is_array($value))
{
foreach($value as $v)
{
$params[] = $v;
$types .= $type;
}
}
else {
$params[] = $value;
$params[] = $v;
$types .= $type;
}
}
}
else
{
$params[] = $value;
$types .= $type;
}
}
/**
* Fetch the result
* @param resource $result
* @param int|NULL $arrayIndexEndValue
* @return array
*/
function _fetch($result, $arrayIndexEndValue = NULL) {
if($this->use_prepared_statements != 'Y'){
return parent::_fetch($result, $arrayIndexEndValue);
}
$output = array();
if(!$this->isConnected() || $this->isError() || !$result) return $output;
// Prepared stements: bind result variable and fetch data
$stmt = $result;
$meta = mysqli_stmt_result_metadata($stmt);
$fields = mysqli_fetch_fields($meta);
}
/**
* Mysqli has a bug that causes LONGTEXT columns not to get loaded
* Unless store_result is called before
* MYSQLI_TYPE for longtext is 252
*/
$longtext_exists = false;
foreach($fields as $field)
{
if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails
$field->name = 'repeat_' . $field->name;
// Array passed needs to contain references, not values
$row[$field->name] = "";
$resultArray[$field->name] = &$row[$field->name];
if($field->type == 252) $longtext_exists = true;
}
$resultArray = array_merge(array($stmt), $resultArray);
if($longtext_exists)
{
mysqli_stmt_store_result($stmt);
}
call_user_func_array('mysqli_stmt_bind_result', $resultArray);
$rows = array();
while(mysqli_stmt_fetch($stmt))
{
$resultObject = new stdClass();
foreach($resultArray as $key => $value)
{
if($key === 0) continue; // Skip stmt object
if(strpos($key, 'repeat_')) $key = substr($key, 6);
$resultObject->$key = $value;
}
$rows[] = $resultObject;
}
mysqli_stmt_close($stmt);
if($arrayIndexEndValue)
{
foreach($rows as $row)
{
$output[$arrayIndexEndValue--] = $row;
}
}
else
{
$output = $rows;
}
if(count($output)==1){
if(isset($arrayIndexEndValue)) return $output;
else return $output[0];
}
return $output;
}
/**
* Handles insertAct
* @param Object $queryObject
* @param boolean $with_values
* @return resource
*/
function _executeInsertAct($queryObject, $with_values = false){
if($this->use_prepared_statements != 'Y')
{
return parent::_executeInsertAct($queryObject);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeInsertAct($queryObject, $with_values);
unset($this->param);
return $result;
}
/**
* Handles updateAct
* @param Object $queryObject
* @param boolean $with_values
* @return resource
*/
function _executeUpdateAct($queryObject, $with_values = false) {
if($this->use_prepared_statements != 'Y')
{
return parent::_executeUpdateAct($queryObject);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeUpdateAct($queryObject, $with_values);
unset($this->param);
return $result;
}
/**
* Handles deleteAct
* @param Object $queryObject
* @param boolean $with_values
* @return resource
*/
function _executeDeleteAct($queryObject, $with_values = false) {
if($this->use_prepared_statements != 'Y')
{
return parent::_executeDeleteAct($queryObject);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeDeleteAct($queryObject, $with_values);
unset($this->param);
return $result;
}
/**
* Handle selectAct
* In order to get a list of pages easily when selecting \n
* it supports a method as navigation
* @param Object $queryObject
* @param resource $connection
* @param boolean $with_values
* @return Object
*/
function _executeSelectAct($queryObject, $connection = null, $with_values = false) {
if($this->use_prepared_statements != 'Y')
{
return parent::_executeSelectAct($queryObject, $connection);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeSelectAct($queryObject, $connection, $with_values);
unset($this->param);
return $result;
}
/**
* Get the ID generated in the last query
* Return next sequence from sequence table
* This method use only mysql
* @return int
*/
function db_insert_id()
/**
* Fetch the result
* @param resource $result
* @param int|NULL $arrayIndexEndValue
* @return array
*/
function _fetch($result, $arrayIndexEndValue = NULL)
{
if($this->use_prepared_statements != 'Y')
{
$connection = $this->_getConnection('master');
return mysqli_insert_id($connection);
return parent::_fetch($result, $arrayIndexEndValue);
}
$output = array();
if(!$this->isConnected() || $this->isError() || !$result)
{
return $output;
}
// Prepared stements: bind result variable and fetch data
$stmt = $result;
$meta = mysqli_stmt_result_metadata($stmt);
$fields = mysqli_fetch_fields($meta);
/**
* Fetch a result row as an object
* @param resource $result
* @return object
* Mysqli has a bug that causes LONGTEXT columns not to get loaded
* Unless store_result is called before
* MYSQLI_TYPE for longtext is 252
*/
function db_fetch_object(&$result)
$longtext_exists = false;
foreach($fields as $field)
{
return mysqli_fetch_object($result);
if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails
{
$field->name = 'repeat_' . $field->name;
}
// Array passed needs to contain references, not values
$row[$field->name] = "";
$resultArray[$field->name] = &$row[$field->name];
if($field->type == 252)
{
$longtext_exists = true;
}
}
/**
* Free result memory
* @param resource $result
* @return boolean Returns TRUE on success or FALSE on failure.
*/
function db_free_result(&$result){
return mysqli_free_result($result);
}
}
?>
$resultArray = array_merge(array($stmt), $resultArray);
if($longtext_exists)
{
mysqli_stmt_store_result($stmt);
}
call_user_func_array('mysqli_stmt_bind_result', $resultArray);
$rows = array();
while(mysqli_stmt_fetch($stmt))
{
$resultObject = new stdClass();
foreach($resultArray as $key => $value)
{
if($key === 0)
{
continue; // Skip stmt object
}
if(strpos($key, 'repeat_'))
{
$key = substr($key, 6);
}
$resultObject->$key = $value;
}
$rows[] = $resultObject;
}
mysqli_stmt_close($stmt);
if($arrayIndexEndValue)
{
foreach($rows as $row)
{
$output[$arrayIndexEndValue--] = $row;
}
}
else
{
$output = $rows;
}
if(count($output) == 1)
{
if(isset($arrayIndexEndValue))
{
return $output;
}
else
{
return $output[0];
}
}
return $output;
}
/**
* Handles insertAct
* @param Object $queryObject
* @param boolean $with_values
* @return resource
*/
function _executeInsertAct($queryObject, $with_values = false)
{
if($this->use_prepared_statements != 'Y')
{
return parent::_executeInsertAct($queryObject);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeInsertAct($queryObject, $with_values);
unset($this->param);
return $result;
}
/**
* Handles updateAct
* @param Object $queryObject
* @param boolean $with_values
* @return resource
*/
function _executeUpdateAct($queryObject, $with_values = false)
{
if($this->use_prepared_statements != 'Y')
{
return parent::_executeUpdateAct($queryObject);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeUpdateAct($queryObject, $with_values);
unset($this->param);
return $result;
}
/**
* Handles deleteAct
* @param Object $queryObject
* @param boolean $with_values
* @return resource
*/
function _executeDeleteAct($queryObject, $with_values = false)
{
if($this->use_prepared_statements != 'Y')
{
return parent::_executeDeleteAct($queryObject);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeDeleteAct($queryObject, $with_values);
unset($this->param);
return $result;
}
/**
* Handle selectAct
* In order to get a list of pages easily when selecting \n
* it supports a method as navigation
* @param Object $queryObject
* @param resource $connection
* @param boolean $with_values
* @return Object
*/
function _executeSelectAct($queryObject, $connection = null, $with_values = false)
{
if($this->use_prepared_statements != 'Y')
{
return parent::_executeSelectAct($queryObject, $connection);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeSelectAct($queryObject, $connection, $with_values);
unset($this->param);
return $result;
}
/**
* Get the ID generated in the last query
* Return next sequence from sequence table
* This method use only mysql
* @return int
*/
function db_insert_id()
{
$connection = $this->_getConnection('master');
return mysqli_insert_id($connection);
}
/**
* Fetch a result row as an object
* @param resource $result
* @return object
*/
function db_fetch_object(&$result)
{
return mysqli_fetch_object($result);
}
/**
* Free result memory
* @param resource $result
* @return boolean Returns TRUE on success or FALSE on failure.
*/
function db_free_result(&$result)
{
return mysqli_free_result($result);
}
}
/* End of file DBMysqli.class.php */
/* Location: ./classes/db/DBMysqli.class.php */

View file

@ -1,600 +0,0 @@
<?php
/**
* @class DBPostgreSQL
* @author ioseph (ioseph@postgresql.kr) updated by yoonjong.joh@gmail.com
* @brief Class to use PostgreSQL DBMS
* @version 0.2
*
* postgresql handling class
* 2009.02.10 update and delete query for the table name at runtime, eliminating the alias to use. Not Supported
* when running order by clause column alias to run a function to replace parts.
* 2009.02.11 dropColumn() function added
* 2009.02.13 addColumn() function changes
**/
class DBPostgresql extends DB
{
/**
* @brief Connection information for PostgreSQL DB
**/
var $prefix = 'xe'; // / <prefix of a tablename (One or more XEs can be installed in a single DB)
var $comment_syntax = '/* %s */';
/**
* @brief column type used in postgresql
*
* Becasue a common column type in schema/query xml is used for colum_type,
* it should be replaced properly for each DBMS
**/
var $column_type = array(
'bignumber' => 'bigint',
'number' => 'integer',
'varchar' => 'varchar',
'char' => 'char',
'text' => 'text',
'bigtext' => 'text',
'date' => 'varchar(14)',
'float' => 'real',
);
/**
* @brief constructor
**/
function DBPostgresql()
{
$this->_setDBInfo();
$this->_connect();
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBPostgresql;
}
/**
* @brief Return if it is installable
**/
function isSupported()
{
if (!function_exists('pg_connect'))
return false;
return true;
}
/**
* @brief DB Connection
**/
function __connect($connection)
{
// the connection string for PG
$conn_string = "";
// Create connection string
$conn_string .= ($connection["db_hostname"]) ? ' host='.$connection["db_hostname"] : "";
$conn_string .= ($connection["db_userid"]) ? " user=" . $connection["db_userid"] : "";
$conn_string .= ($connection["db_password"]) ? " password=" . $connection["db_password"] : "";
$conn_string .= ($connection["db_database"]) ? " dbname=" . $connection["db_database"] : "";
$conn_string .= ($connection["db_port"]) ? " port=" . $connection["db_port"] : "";
// Attempt to connect
$result = @pg_connect($conn_string);
if (!$result || pg_connection_status($result) != PGSQL_CONNECTION_OK) {
$this->setError(-1, "CONNECTION FAILURE");
return;
}
return $result;
}
/**
* @brief DB disconnection
**/
function _close($connection)
{
@pg_close($connection);
}
/**
* @brief Add quotes on the string variables in a query
**/
function addQuotes($string)
{
if (version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc())
$string = stripslashes(str_replace("\\", "\\\\", $string));
if (!is_numeric($string))
$string = @pg_escape_string($string);
return $string;
}
/**
* @brief Begin transaction
**/
function _begin()
{
$connection = $this->_getConnection('master');
if (!$this->_query('BEGIN')) return false;
return true;
}
/**
* @brief Rollback
**/
function _rollback()
{
if (!$this->_query('ROLLBACK')) return false;
return true;
}
/**
* @brief Commits
**/
function _commit()
{
if (!$this->_query('COMMIT')) return false;
return true;
}
/**
* @brief : Run a query and fetch the result
*
* query: run a query and return the result \n
* fetch: NULL if no value is returned \n
* array object if rows are returned \n
* object if a row is returned \n
* return\n
**/
function __query($query, $connection)
{
if (!$this->isConnected())
return;
/*
$l_query_array = explode(" ", $query);
if ($l_query_array[0] = "update")
{
if (strtolower($l_query_array[2]) == "as")
{
$l_query_array[2] = "";
$l_query_array[3] = "";
$query = implode(" ",$l_query_array);
}
}
else if ($l_query_array[0] = "delete")
{
if (strtolower($l_query_array[3]) == "as")
{
$l_query_array[3] = "";
$l_query_array[4] = "";
$query = implode(" ",$l_query_array);
}
}
*/
// Notify to start a query execution
// $arr = array('Hello', 'World!', 'Beautiful', 'Day!');
// Run the query statement
$result = @pg_query($connection, $query);
// Error Check
if (!$result) {
// var_dump($l_query_array);
//var_dump($query);
//die("\nin query statement\n");
//var_dump(debug_backtrace());
$this->setError(1, pg_last_error($connection));
}
// Return result
return $result;
}
/**
* @brief Fetch results
**/
// TODO This is duplicate code - maybe we can find away to abastract the driver
function _fetch($result, $arrayIndexEndValue = NULL)
{
if (!$this->isConnected() || $this->isError() || !$result)
return;
while ($tmp = pg_fetch_object($result)) {
if($arrayIndexEndValue) $output[$arrayIndexEndValue--] = $tmp;
else $output[] = $tmp;
}
if(count($output)==1){
if(isset($arrayIndexEndValue)) return $output;
else return $output[0];
}
return $output;
}
/**
* @brief Return sequence value incremented by 1(in postgresql, auto_increment is used in the sequence table only)
**/
function getNextSequence()
{
$query = sprintf("select nextval('%ssequence') as seq", $this->prefix);
$result = $this->_query($query);
$tmp = $this->_fetch($result);
return $tmp->seq;
}
/**
* @brief Return if a table already exists
**/
function isTableExists($target_name)
{
if ($target_name == "sequence")
return true;
$query = sprintf("SELECT tablename FROM pg_tables WHERE tablename = '%s%s' AND schemaname = current_schema()",
$this->prefix, $this->addQuotes($target_name));
$result = $this->_query($query);
$tmp = $this->_fetch($result);
if (!$tmp)
return false;
return true;
}
/**
* @brief Add a column to a table
**/
function addColumn($table_name, $column_name, $type = 'number', $size = '', $default =
NULL, $notnull = false)
{
$type = $this->column_type[$type];
if (strtoupper($type) == 'INTEGER' || strtoupper($type) == 'BIGINT')
$size = '';
$query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name);
if ($size)
$query .= sprintf(" %s(%s) ", $type, $size);
else
$query .= sprintf(" %s ", $type);
$this->_query($query);
if (isset($default)) {
$query = sprintf("alter table %s%s alter %s set default '%s' ", $this->prefix, $table_name, $column_name, $default);
$this->_query($query);
}
if ($notnull) {
$query = sprintf("update %s%s set %s = %s ", $this->prefix, $table_name, $column_name, $default);
$this->_query($query);
$query = sprintf("alter table %s%s alter %s set not null ", $this->prefix, $table_name, $column_name);
$this->_query($query);
}
}
/**
* @brief Return column information of a table
**/
function isColumnExists($table_name, $column_name)
{
$query = sprintf("SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = '%s%s') AND attname = '%s'",
$this->prefix, strtolower($table_name), strtolower($column_name));
// $query = sprintf("select column_name from information_schema.columns where table_schema = current_schema() and table_name = '%s%s' and column_name = '%s'", $this->prefix, $this->addQuotes($table_name), strtolower($column_name));
$result = $this->_query($query);
if ($this->isError()) {
return;
}
$output = $this->_fetch($result);
if ($output) {
return true;
}
return false;
}
/**
* @brief Add an index to a table
* $target_columns = array(col1, col2)
* $is_unique? unique : none
**/
function addIndex($table_name, $index_name, $target_columns, $is_unique = false)
{
if (!is_array($target_columns))
$target_columns = array($target_columns);
if (strpos($table_name, $this->prefix) === false)
$table_name = $this->prefix . $table_name;
// Use a tablename before an index name to avoid defining the same index
$index_name = $table_name . $index_name;
$query = sprintf("create %s index %s on %s (%s);", $is_unique ? 'unique' : '', $index_name,
$table_name, implode(',', $target_columns));
$this->_query($query);
}
/**
* @brief Delete a column from a table
**/
function dropColumn($table_name, $column_name)
{
$query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name);
$this->_query($query);
}
/**
* @brief Drop an index from a table
**/
function dropIndex($table_name, $index_name, $is_unique = false)
{
if (strpos($table_name, $this->prefix) === false)
$table_name = $this->prefix . $table_name;
// Use a tablename before an index name to avoid defining the same index
$index_name = $table_name . $index_name;
$query = sprintf("drop index %s", $index_name);
$this->_query($query);
}
/**
* @brief Return index information of a table
**/
function isIndexExists($table_name, $index_name)
{
if (strpos($table_name, $this->prefix) === false)
$table_name = $this->prefix . $table_name;
// Use a tablename before an index name to avoid defining the same index
$index_name = $table_name . $index_name;
//$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name);
$query = sprintf("select indexname from pg_indexes where schemaname = current_schema() and tablename = '%s' and indexname = '%s'",
$table_name, strtolower($index_name));
$result = $this->_query($query);
if ($this->isError())
return;
$output = $this->_fetch($result);
if ($output) {
return true;
}
// var_dump($query);
// die(" no index");
return false;
}
/**
* @brief Create a table by using xml file
**/
function createTableByXml($xml_doc)
{
return $this->_createTable($xml_doc);
}
/**
* @brief Create a table by using xml file
**/
function createTableByXmlFile($file_name)
{
if (!file_exists($file_name))
return;
// read xml file
$buff = FileHandler::readFile($file_name);
return $this->_createTable($buff);
}
/**
* @brief generate a query statement to create a table by using schema xml
*
* type : number, varchar, text, char, date, \n
* opt : notnull, default, size\n
* index : primary key, index, unique\n
**/
function _createTable($xml_doc)
{
// xml parsing
$oXml = new XmlParser();
$xml_obj = $oXml->parse($xml_doc);
// Create a table schema
$table_name = $xml_obj->table->attrs->name;
if ($table_name == 'sequence') {
$query = sprintf('create sequence %s', $this->prefix . $table_name);
return $this->_query($query);
}
if ($this->isTableExists($table_name))
return;
$table_name = $this->prefix . $table_name;
if (!is_array($xml_obj->table->column))
$columns[] = $xml_obj->table->column;
else
$columns = $xml_obj->table->column;
foreach ($columns as $column) {
$name = $column->attrs->name;
$type = $column->attrs->type;
$size = $column->attrs->size;
$notnull = $column->attrs->notnull;
$primary_key = $column->attrs->primary_key;
$index = $column->attrs->index;
$unique = $column->attrs->unique;
$default = $column->attrs->default;
$auto_increment = $column->attrs->auto_increment;
if ($type == "bignumber" || $type == "number")
$size = 0;
$column_schema[] = sprintf('%s %s%s %s %s', $name, $this->column_type[$type], $size ?
'(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ?
'not null' : '');
if ($primary_key)
$primary_list[] = $name;
else
if ($unique)
$unique_list[$unique][] = $name;
else
if ($index)
$index_list[$index][] = $name;
}
if (count($primary_list)) {
$column_schema[] = sprintf("primary key (%s)", implode($primary_list, ','));
}
if (count($unique_list)) {
foreach ($unique_list as $key => $val) {
$column_schema[] = sprintf("unique (%s)", implode($val, ','));
}
}
$schema = sprintf('create table %s (%s%s);', $this->addQuotes($table_name), "\n",
implode($column_schema, ",\n"));
$output = $this->_query($schema);
if (count($index_list)) {
foreach ($index_list as $key => $val) {
if (!$this->isIndexExists($table_name, $key))
$this->addIndex($table_name, $key, $val);
}
}
if (!$output)
return false;
}
/**
* @brief Handle the insertAct
**/
function _executeInsertAct($queryObject)
{
$query = $this->getInsertSql($queryObject);
if(is_a($query, 'Object')) return;
return $this->_query($query);
}
/**
* @brief Handle updateAct
**/
function _executeUpdateAct($queryObject)
{
$query = $this->getUpdateSql($queryObject);
if(is_a($query, 'Object')) return;
return $this->_query($query);
}
/**
* @brief Handle deleteAct
**/
function _executeDeleteAct($queryObject)
{
$query = $this->getDeleteSql($queryObject);
if(is_a($query, 'Object')) return;
return $this->_query($query);
}
/**
*
* override
* @param $queryObject
*/
function getSelectSql($query){
$select = $query->getSelectString();
if($select == '') return new Object(-1, "Invalid query");
$select = 'SELECT ' .$select;
$from = $query->getFromString();
if($from == '') return new Object(-1, "Invalid query");
$from = ' FROM '.$from;
$where = $query->getWhereString();
if($where != '') $where = ' WHERE ' . $where;
$groupBy = $query->getGroupByString();
if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy;
$orderBy = $query->getOrderByString();
if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy;
$limit = $query->getLimitString();
$limitObject = $query->getLimit();
if($limit != '') $limit = ' LIMIT ' . $limitObject->getLimit() . ' OFFSET ' . $limitObject->getOffset();
return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
}
/**
* @brief Handle selectAct
*
* In order to get a list of pages easily when selecting \n
* it supports a method as navigation
**/
function _executeSelectAct($queryObject, $connection)
{
$query = $this->getSelectSql($queryObject);
if(is_a($query, 'Object')) return;
$query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
// TODO Add support for click count
// TODO Add code for pagination
$result = $this->_query ($query, $connection);
if ($this->isError ()) {
if ($limit && $output->limit->isPageHandler()){
$buff = new Object ();
$buff->total_count = 0;
$buff->total_page = 0;
$buff->page = 1;
$buff->data = array ();
$buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values
return $buff;
}else
return;
}
$limit = $queryObject->getLimit();
if ($limit && $limit->isPageHandler()) {
// Total count
$temp_where = $queryObject->getWhereString(true, false);
$count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE '. $temp_where));
if ($queryObject->getGroupByString() != '') {
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
}
$count_query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
$result_count = $this->_query($count_query, $connection);
$count_output = $this->_fetch($result_count);
$total_count = (int)$count_output->count;
// Total pages
if ($total_count) {
$total_page = (int) (($total_count - 1) / $limit->list_count) + 1;
} else $total_page = 1;
$virtual_no = $total_count - ($limit->page - 1) * $limit->list_count;
$data = $this->_fetch($result, $virtual_no);
$buff = new Object ();
$buff->total_count = $total_count;
$buff->total_page = $total_page;
$buff->page = $limit->page->getValue();
$buff->data = $data;
$buff->page_navigation = new PageHandler($total_count, $total_page, $limit->page->getValue(), $limit->page_count);
}else{
$data = $this->_fetch($result);
$buff = new Object ();
$buff->data = $data;
}
return $buff;
}
function getParser(){
return new DBParser('"', '"', $this->prefix);
}
}
?>

View file

@ -1,636 +0,0 @@
<?php
/**
* @class DBSqlite3_pdo
* @author NHN (developers@xpressengine.com)
* @brief class to use SQLite3 with PDO
* @version 0.1
**/
class DBSqlite3_pdo extends DB {
/**
* DB information
**/
var $database = NULL; ///< database
var $prefix = 'xe'; // /< prefix of a tablename (many XEs can be installed in a single DB)
var $comment_syntax = '/* %s */';
/**
* Variables for using PDO
**/
var $handler = NULL;
var $stmt = NULL;
var $bind_idx = 0;
var $bind_vars = array();
/**
* @brief column type used in sqlite3
*
* column_type should be replaced for each DBMS properly
* because column_type uses a commonly defined type in schema/query xml files
**/
var $column_type = array(
'bignumber' => 'INTEGER',
'number' => 'INTEGER',
'varchar' => 'VARCHAR',
'char' => 'CHAR',
'text' => 'TEXT',
'bigtext' => 'TEXT',
'date' => 'VARCHAR(14)',
'float' => 'REAL',
);
/**
* @brief constructor
**/
function DBSqlite3_pdo() {
$this->_setDBInfo();
$this->_connect();
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBSqlite3_pdo;
}
/**
* @brief Return if installable
**/
function isSupported() {
return class_exists('PDO');
}
function isConnected() {
return $this->is_connected;
}
/**
* @brief DB settings and connect/close
**/
function _setDBInfo() {
$db_info = Context::getDBInfo();
$this->database = $db_info->master_db["db_database"];
$this->prefix = $db_info->master_db["db_table_prefix"];
//if(!substr($this->prefix,-1)!='_') $this->prefix .= '_';
}
/**
* @brief DB Connection
**/
function _connect() {
// override if db information not exists
if(!$this->database) return;
// Attempt to access the database file
try {
// PDO is only supported with PHP5,
// so it is allowed to use try~catch statment in this class.
$this->handler = new PDO('sqlite:'.$this->database);
} catch (PDOException $e) {
$this->setError(-1, 'Connection failed: '.$e->getMessage());
$this->is_connected = false;
return;
}
// Check connections
$this->is_connected = true;
$this->password = md5($this->password);
}
/**
* @brief disconnect to DB
**/
function close() {
if(!$this->is_connected) return;
$this->commit();
}
/**
* @brief Begin a transaction
**/
function begin() {
if(!$this->is_connected || $this->transaction_started) return;
if($this->handler->beginTransaction()) $this->transaction_started = true;
}
/**
* @brief Rollback
**/
function rollback() {
if(!$this->is_connected || !$this->transaction_started) return;
$this->handler->rollBack();
$this->transaction_started = false;
}
/**
* @brief Commit
**/
function commit($force = false) {
if(!$force && (!$this->is_connected || !$this->transaction_started)) return;
try {
$this->handler->commit();
}
catch(PDOException $e){
// There was no transaction started, so just continue.
error_log($e->getMessage());
}
$this->transaction_started = false;
}
/**
* @brief Add or change quotes to the query string variables
**/
function addQuotes($string) {
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
if(!is_numeric($string)) $string = str_replace("'","''",$string);
return $string;
}
/**
* @brief : Prepare a query statement
**/
function _prepare($query) {
if(!$this->is_connected) return;
// notify to start a query execution
$this->actStart($query);
$this->stmt = $this->handler->prepare($query);
if($this->handler->errorCode() != '00000') {
$this->setError($this->handler->errorCode(), print_r($this->handler->errorInfo(),true));
$this->actFinish();
}
$this->bind_idx = 0;
$this->bind_vars = array();
}
/**
* @brief : Binding params in stmt
**/
function _bind($val) {
if(!$this->is_connected || !$this->stmt) return;
$this->bind_idx ++;
$this->bind_vars[] = $val;
$this->stmt->bindParam($this->bind_idx, $val);
}
/**
* @brief : execute the prepared statement
**/
function _execute() {
if(!$this->is_connected || !$this->stmt) return;
$this->stmt->execute();
if($this->stmt->errorCode() === '00000') {
$output = null;
while($tmp = $this->stmt->fetch(PDO::FETCH_ASSOC)) {
unset($obj);
foreach($tmp as $key => $val) {
$pos = strpos($key, '.');
if($pos) $key = substr($key, $pos+1);
$obj->{$key} = str_replace("''","'",$val);
}
$output[] = $obj;
}
} else {
$this->setError($this->stmt->errorCode(),print_r($this->stmt->errorInfo(),true));
}
$this->stmt = null;
$this->actFinish();
if(is_array($output) && count($output)==1) return $output[0];
return $output;
}
/**
* @brief Return the sequence value incremented by 1
**/
function getNextSequence() {
$query = sprintf("insert into %ssequence (seq) values (NULL)", $this->prefix);
$this->_prepare($query);
$result = $this->_execute();
$sequence = $this->handler->lastInsertId();
if($sequence % 10000 == 0) {
$query = sprintf("delete from %ssequence where seq < %d", $this->prefix, $sequence);
$this->_prepare($query);
$result = $this->_execute();
}
return $sequence;
}
/**
* @brief return if the table already exists
**/
function isTableExists($target_name) {
$query = sprintf('pragma table_info(%s%s)', $this->prefix, $target_name);
$this->_prepare($query);
if(!$this->_execute()) return false;
return true;
}
/**
* @brief Add a column to a table
**/
function addColumn($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 add %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 ";
$this->_prepare($query);
return $this->_execute();
}
/**
* @brief Remove a column from a table
**/
function dropColumn($table_name, $column_name) {
$query = sprintf("alter table %s%s drop column %s ", $this->prefix, $table_name, $column_name);
$this->_query($query);
}
/**
* @brief Return column information of a table
**/
function isColumnExists($table_name, $column_name) {
$query = sprintf("pragma table_info(%s%s)", $this->prefix, $table_name);
$this->_prepare($query);
$output = $this->_execute();
if($output) {
$column_name = strtolower($column_name);
foreach($output as $key => $val) {
$name = strtolower($val->name);
if($column_name == $name) return true;
}
}
return false;
}
/**
* @brief Add an index to a table
* $target_columns = array(col1, col2)
* $is_unique? unique : none
**/
function addIndex($table_name, $index_name, $target_columns, $is_unique = false) {
if(!is_array($target_columns)) $target_columns = array($target_columns);
$key_name = sprintf('%s%s_%s', $this->prefix, $table_name, $index_name);
$query = sprintf('CREATE %s INDEX %s ON %s%s (%s)', $is_unique?'UNIQUE':'', $key_name, $this->prefix, $table_name, implode(',',$target_columns));
$this->_prepare($query);
$this->_execute();
}
/**
* @brief Drop an index from a table
**/
function dropIndex($table_name, $index_name, $is_unique = false) {
$key_name = sprintf('%s%s_%s', $this->prefix, $table_name, $index_name);
$query = sprintf("DROP INDEX %s", $this->prefix, $table_name, $key_name);
$this->_query($query);
}
/**
* @brief Return index information of a table
**/
function isIndexExists($table_name, $index_name) {
$key_name = sprintf('%s%s_%s', $this->prefix, $table_name, $index_name);
$query = sprintf("pragma index_info(%s)", $key_name);
$this->_prepare($query);
$output = $this->_execute();
if(!$output) return false;
return true;
}
/**
* @brief create a table from xml file
**/
function createTableByXml($xml_doc) {
return $this->_createTable($xml_doc);
}
/**
* @brief create a table from xml file
**/
function createTableByXmlFile($file_name) {
if(!file_exists($file_name)) return;
// read xml file
$buff = FileHandler::readFile($file_name);
return $this->_createTable($buff);
}
/**
* @brief generate a query to create a table using the schema xml
*
* type : number, varchar, text, char, date, \n
* opt : notnull, default, size\n
* index : primary key, index, unique\n
**/
function _createTable($xml_doc) {
// xml parsing
$oXml = new XmlParser();
$xml_obj = $oXml->parse($xml_doc);
// Create a table schema
$table_name = $xml_obj->table->attrs->name;
if($this->isTableExists($table_name)) return;
$table_name = $this->prefix.$table_name;
if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
else $columns = $xml_obj->table->column;
foreach($columns as $column) {
$name = $column->attrs->name;
$type = $column->attrs->type;
if(strtoupper($this->column_type[$type])=='INTEGER') $size = '';
else $size = $column->attrs->size;
$notnull = $column->attrs->notnull;
$primary_key = $column->attrs->primary_key;
$index = $column->attrs->index;
$unique = $column->attrs->unique;
$default = $column->attrs->default;
$auto_increment = $column->attrs->auto_increment;
if($auto_increment) {
$column_schema[] = sprintf('%s %s PRIMARY KEY %s',
$name,
$this->column_type[$type],
$auto_increment?'AUTOINCREMENT':''
);
} else {
$column_schema[] = sprintf('%s %s%s %s %s %s',
$name,
$this->column_type[$type],
$size?'('.$size.')':'',
$notnull?'NOT NULL':'',
$primary_key?'PRIMARY KEY':'',
isset($default)?"DEFAULT '".$default."'":''
);
}
if($unique) $unique_list[$unique][] = $name;
else if($index) $index_list[$index][] = $name;
}
$schema = sprintf('CREATE TABLE %s (%s%s) ;', $table_name," ", implode($column_schema,", "));
$this->_prepare($schema);
$this->_execute();
if($this->isError()) return;
if(count($unique_list)) {
foreach($unique_list as $key => $val) {
$query = sprintf('CREATE UNIQUE INDEX %s_%s ON %s (%s)', $this->addQuotes($table_name), $key, $this->addQuotes($table_name), implode(',',$val));
$this->_prepare($query);
$this->_execute();
if($this->isError()) $this->rollback();
}
}
if(count($index_list)) {
foreach($index_list as $key => $val) {
$query = sprintf('CREATE INDEX %s_%s ON %s (%s)', $this->addQuotes($table_name), $key, $this->addQuotes($table_name), implode(',',$val));
$this->_prepare($query);
$this->_execute();
if($this->isError()) $this->rollback();
}
}
}
function _getConnection($type = null){
return null;
}
/**
* @brief insertAct
* */
function _executeInsertAct($queryObject) {
$query = $this->getInsertSql($queryObject);
if (is_a($query, 'Object'))
return;
$this->_prepare($query);
$val_count = count($val_list);
for ($i = 0; $i < $val_count; $i++)
$this->_bind($val_list[$i]);
return $this->_execute();
}
/**
* @brief updateAct
* */
function _executeUpdateAct($queryObject) {
$query = $this->getUpdateSql($queryObject);
if (is_a($query, 'Object'))
return;
$this->_prepare($query);
return $this->_execute();
}
/**
* @brief deleteAct
* */
function _executeDeleteAct($queryObject) {
$query = $this->getDeleteSql($queryObject);
if (is_a($query, 'Object'))
return;
$this->_prepare($query);
return $this->_execute();
}
/**
* @brief selectAct
*
* To fetch a list of the page conveniently when selecting, \n
* navigation method supported
* */
function _executeSelectAct($queryObject) {
$query = $this->getSelectSql($queryObject);
if (is_a($query, 'Object'))
return;
$this->_prepare($query);
$data = $this->_execute();
// TODO isError is called twice
if ($this->isError())
return;
if ($this->isError())
return $this->queryError($queryObject);
else
return $this->queryPageLimit($queryObject, $data);
}
function queryError($queryObject) {
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) {
$buff = new Object ();
$buff->total_count = 0;
$buff->total_page = 0;
$buff->page = 1;
$buff->data = array();
$buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values
return $buff;
}else
return;
}
function queryPageLimit($queryObject, $data) {
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) {
// Total count
$temp_where = $queryObject->getWhereString(true, false);
$count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE ' . $temp_where));
if ($queryObject->getGroupByString() != '') {
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
}
$count_query .= ( __DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$this->_prepare($count_query);
$count_output = $this->_execute();
$total_count = (int) $count_output->count;
$list_count = $queryObject->getLimit()->list_count->getValue();
if (!$list_count) $list_count = 20;
$page_count = $queryObject->getLimit()->page_count->getValue();
if (!$page_count) $page_count = 10;
$page = $queryObject->getLimit()->page->getValue();
if (!$page) $page = 1;
// Total pages
if ($total_count) {
$total_page = (int) (($total_count - 1) / $list_count) + 1;
} else
$total_page = 1;
// check the page variables
if ($page > $total_page) {
// If requested page is bigger than total number of pages, return empty list
$buff = new Object ();
$buff->total_count = $total_count;
$buff->total_page = $total_page;
$buff->page = $page;
$buff->data = array();
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
return $buff;
}
$start_count = ($page - 1) * $list_count;
$this->_prepare($this->getSelectPageSql($queryObject, true, $start_count, $list_count));
$this->stmt->execute();
if ($this->stmt->errorCode() != '00000') {
$this->setError($this->stmt->errorCode(), print_r($this->stmt->errorInfo(), true));
$this->actFinish();
return $buff;
}
$output = null;
$virtual_no = $total_count - ($page - 1) * $list_count;
//$data = $this->_fetch($result, $virtual_no);
while ($tmp = $this->stmt->fetch(PDO::FETCH_ASSOC)) {
unset($obj);
foreach ($tmp as $key => $val) {
$pos = strpos($key, '.');
if ($pos)
$key = substr($key, $pos + 1);
$obj->{$key} = $val;
}
$datatemp[$virtual_no--] = $obj;
}
$this->stmt = null;
$this->actFinish();
$buff = new Object ();
$buff->total_count = $total_count;
$buff->total_page = $total_page;
$buff->page = $page;
$buff->data = $datatemp;
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
}else {
//$data = $this->_fetch($result);
$buff = new Object ();
$buff->data = $data;
}
return $buff;
}
function getSelectPageSql($query, $with_values = true, $start_count = 0, $list_count = 0) {
$select = $query->getSelectString($with_values);
if ($select == '')
return new Object(-1, "Invalid query");
$select = 'SELECT ' . $select;
$from = $query->getFromString($with_values);
if ($from == '')
return new Object(-1, "Invalid query");
$from = ' FROM ' . $from;
$where = $query->getWhereString($with_values);
if ($where != '')
$where = ' WHERE ' . $where;
$groupBy = $query->getGroupByString();
if ($groupBy != '')
$groupBy = ' GROUP BY ' . $groupBy;
$orderBy = $query->getOrderByString();
if ($orderBy != '')
$orderBy = ' ORDER BY ' . $orderBy;
$limit = $query->getLimitString();
if ($limit != '' && $query->getLimit()) {
$limit = sprintf(' LIMIT %d, %d',$start_count, $list_count);
}
return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
}
function getParser() {
return new DBParser('"', '"', $this->prefix);
}
function getUpdateSql($query, $with_values = true, $with_priority = false){
$columnsList = $query->getUpdateString($with_values);
if($columnsList == '') return new Object(-1, "Invalid query");
$tableName = $query->getFirstTableName();
if($tableName == '') return new Object(-1, "Invalid query");
$where = $query->getWhereString($with_values);
if($where != '') $where = ' WHERE ' . $where;
$priority = $with_priority?$query->getPriority():'';
return "UPDATE $priority $tableName SET $columnsList ".$where;
}
function getDeleteSql($query, $with_values = true, $with_priority = false){
$sql = 'DELETE ';
$tables = $query->getTables();
$from = $tables[0]->getName();
$sql .= ' FROM '.$from;
$where = $query->getWhereString($with_values);
if($where != '') $sql .= ' WHERE ' . $where;
return $sql;
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,65 +1,79 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts
* @version 0.1
*/
class Subquery extends Query
{
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts
* @version 0.1
* table alias
* @var string
*/
class Subquery extends Query {
/**
* table alias
* @var string
*/
var $alias;
/**
* join type
* @var string
*/
var $join_type;
var $alias;
/**
* constructor
* @param string $alias
* @param string|array $columns
* @param string|array $tables
* @param string|array $conditions
* @param string|array $groups
* @param string|array $orderby
* @param int $limit
* @param string $join_type
* @return void
*/
function Subquery($alias, $columns, $tables, $conditions, $groups, $orderby, $limit, $join_type = null){
$this->alias = $alias;
/**
* join type
* @var string
*/
var $join_type;
$this->queryID = null;
$this->action = "select";
/**
* constructor
* @param string $alias
* @param string|array $columns
* @param string|array $tables
* @param string|array $conditions
* @param string|array $groups
* @param string|array $orderby
* @param int $limit
* @param string $join_type
* @return void
*/
function Subquery($alias, $columns, $tables, $conditions, $groups, $orderby, $limit, $join_type = null)
{
$this->alias = $alias;
$this->columns = $columns;
$this->tables = $tables;
$this->conditions = $conditions;
$this->groups = $groups;
$this->orderby = $orderby;
$this->limit = $limit;
$this->join_type = $join_type;
}
$this->queryID = null;
$this->action = "select";
function getAlias(){
return $this->alias;
}
function isJoinTable(){
if($this->join_type) return true;
return false;
}
function toString($with_values = true){
$oDB = &DB::getInstance();
return '(' .$oDB->getSelectSql($this, $with_values) . ')';
}
function isSubquery(){
return true;
}
$this->columns = $columns;
$this->tables = $tables;
$this->conditions = $conditions;
$this->groups = $groups;
$this->orderby = $orderby;
$this->limit = $limit;
$this->join_type = $join_type;
}
function getAlias()
{
return $this->alias;
}
function isJoinTable()
{
if($this->join_type)
{
return true;
}
return false;
}
function toString($with_values = true)
{
$oDB = &DB::getInstance();
return '(' . $oDB->getSelectSql($this, $with_values) . ')';
}
function isSubquery()
{
return true;
}
}
/* End of file Subquery.class.php */
/* Location: ./classes/db/queryparts/Subquery.class.php */

View file

@ -1,223 +1,257 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
* @version 0.1
*/
class Condition
{
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
* @version 0.1
* column name
* @var string
*/
class Condition {
/**
* column name
* @var string
*/
var $column_name;
var $argument;
/**
* operation can use 'equal', 'more', 'excess', 'less', 'below', 'like_tail', 'like_prefix', 'like', 'notlike_tail',
* 'notlike_prefix', 'notlike', 'in', 'notin', 'not_in', 'and', 'or', 'xor', 'not', 'notequal', 'between'
* 'null', 'notnull'
* @var string
*/
var $operation;
/**
* pipe can use 'and', 'or'...
* @var string
*/
var $pipe;
var $column_name;
var $argument;
var $_value;
/**
* operation can use 'equal', 'more', 'excess', 'less', 'below', 'like_tail', 'like_prefix', 'like', 'notlike_tail',
* 'notlike_prefix', 'notlike', 'in', 'notin', 'not_in', 'and', 'or', 'xor', 'not', 'notequal', 'between'
* 'null', 'notnull'
* @var string
*/
var $operation;
var $_show;
var $_value_to_string;
/**
* pipe can use 'and', 'or'...
* @var string
*/
var $pipe;
var $_value;
var $_show;
var $_value_to_string;
/**
* constructor
* @param string $column_name
* @param mixed $argument
* @param string $operation
* @param string $pipe
* @return void
*/
function Condition($column_name, $argument, $operation, $pipe){
$this->column_name = $column_name;
$this->argument = $argument;
$this->operation = $operation;
$this->pipe = $pipe;
}
function getArgument(){
return null;
}
/**
* value to string
* @param boolean $withValue
* @return string
*/
function toString($withValue = true){
if (!isset($this->_value_to_string)) {
if (!$this->show())
{
$this->_value_to_string = '';
}
else if ($withValue)
{
$this->_value_to_string = $this->toStringWithValue();
}
else
{
$this->_value_to_string = $this->toStringWithoutValue();
}
}
return $this->_value_to_string;
}
/**
* change string without value
* @return string
*/
function toStringWithoutValue(){
return $this->pipe . ' ' . $this->getConditionPart($this->_value);
}
/**
* change string with value
* @return string
*/
function toStringWithValue(){
return $this->pipe . ' ' . $this->getConditionPart($this->_value);
}
function setPipe($pipe){
$this->pipe = $pipe;
}
/**
* @return boolean
*/
function show(){
if(!isset($this->_show)){
if(is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '') {
$this->_show = false;
}
else {
$this->_show = true;
switch($this->operation) {
case 'equal' :
case 'more' :
case 'excess' :
case 'less' :
case 'below' :
case 'like_tail' :
case 'like_prefix' :
case 'like' :
case 'notlike_tail' :
case 'notlike_prefix' :
case 'notlike' :
case 'in' :
case 'notin' :
case 'not_in' :
case 'and':
case 'or':
case 'xor':
case 'not':
case 'notequal' :
// if variable is not set or is not string or number, return
if(!isset($this->_value)) { $this->_show = false; break;}
if($this->_value === '') { $this->_show = false; break; }
$tmpArray = array('string'=>1, 'integer'=>1);
if(!isset($tmpArray[gettype($this->_value)]))
{
$this->_show = false; break;
}
break;
case 'between' :
if(!is_array($this->_value)) { $this->_show = false; break;}
if(count($this->_value)!=2) {$this->_show = false; break;}
case 'null':
case 'notnull':
break;
default:
// If operation is not one of the above, means the condition is invalid
$this->_show = false;
}
}
}
return $this->_show;
}
/**
* Return condition string
* @param int|string|array $value
* @return string
*/
function getConditionPart($value) {
$name = $this->column_name;
$operation = $this->operation;
switch($operation) {
case 'equal' :
return $name.' = '.$value;
break;
case 'more' :
return $name.' >= '.$value;
break;
case 'excess' :
return $name.' > '.$value;
break;
case 'less' :
return $name.' <= '.$value;
break;
case 'below' :
return $name.' < '.$value;
break;
case 'like_tail' :
case 'like_prefix' :
case 'like' :
if(defined('__CUBRID_VERSION__')
&& __CUBRID_VERSION__ >= '8.4.1')
return $name.' rlike '.$value;
else
return $name.' like '.$value;
break;
case 'notlike_tail' :
case 'notlike_prefix' :
case 'notlike' :
return $name.' not like '.$value;
break;
case 'in' :
return $name.' in '.$value;
break;
case 'notin' :
case 'not_in' :
return $name.' not in '.$value;
break;
case 'notequal' :
return $name.' <> '.$value;
break;
case 'notnull' :
return $name.' is not null';
break;
case 'null' :
return $name.' is null';
break;
case 'and' :
return $name.' & '.$value;
break;
case 'or' :
return $name.' | '.$value;
break;
case 'xor' :
return $name.' ^ '.$value;
break;
case 'not' :
return $name.' ~ '.$value;
break;
case 'between' :
return $name.' between ' . $value[0] . ' and ' . $value[1];
break;
}
}
/**
* constructor
* @param string $column_name
* @param mixed $argument
* @param string $operation
* @param string $pipe
* @return void
*/
function Condition($column_name, $argument, $operation, $pipe)
{
$this->column_name = $column_name;
$this->argument = $argument;
$this->operation = $operation;
$this->pipe = $pipe;
}
?>
function getArgument()
{
return null;
}
/**
* value to string
* @param boolean $withValue
* @return string
*/
function toString($withValue = true)
{
if(!isset($this->_value_to_string))
{
if(!$this->show())
{
$this->_value_to_string = '';
}
else if($withValue)
{
$this->_value_to_string = $this->toStringWithValue();
}
else
{
$this->_value_to_string = $this->toStringWithoutValue();
}
}
return $this->_value_to_string;
}
/**
* change string without value
* @return string
*/
function toStringWithoutValue()
{
return $this->pipe . ' ' . $this->getConditionPart($this->_value);
}
/**
* change string with value
* @return string
*/
function toStringWithValue()
{
return $this->pipe . ' ' . $this->getConditionPart($this->_value);
}
function setPipe($pipe)
{
$this->pipe = $pipe;
}
/**
* @return boolean
*/
function show()
{
if(!isset($this->_show))
{
if(is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '')
{
$this->_show = false;
}
else
{
$this->_show = true;
switch($this->operation)
{
case 'equal' :
case 'more' :
case 'excess' :
case 'less' :
case 'below' :
case 'like_tail' :
case 'like_prefix' :
case 'like' :
case 'notlike_tail' :
case 'notlike_prefix' :
case 'notlike' :
case 'in' :
case 'notin' :
case 'not_in' :
case 'and':
case 'or':
case 'xor':
case 'not':
case 'notequal' :
// if variable is not set or is not string or number, return
if(!isset($this->_value))
{
$this->_show = false;
break;
}
if($this->_value === '')
{
$this->_show = false;
break;
}
$tmpArray = array('string' => 1, 'integer' => 1);
if(!isset($tmpArray[gettype($this->_value)]))
{
$this->_show = false;
break;
}
break;
case 'between' :
if(!is_array($this->_value))
{
$this->_show = false;
break;
}
if(count($this->_value) != 2)
{
$this->_show = false;
break;
}
case 'null':
case 'notnull':
break;
default:
// If operation is not one of the above, means the condition is invalid
$this->_show = false;
}
}
}
return $this->_show;
}
/**
* Return condition string
* @param int|string|array $value
* @return string
*/
function getConditionPart($value)
{
$name = $this->column_name;
$operation = $this->operation;
switch($operation)
{
case 'equal' :
return $name . ' = ' . $value;
break;
case 'more' :
return $name . ' >= ' . $value;
break;
case 'excess' :
return $name . ' > ' . $value;
break;
case 'less' :
return $name . ' <= ' . $value;
break;
case 'below' :
return $name . ' < ' . $value;
break;
case 'like_tail' :
case 'like_prefix' :
case 'like' :
if(defined('__CUBRID_VERSION__')
&& __CUBRID_VERSION__ >= '8.4.1')
return $name . ' rlike ' . $value;
else
return $name . ' like ' . $value;
break;
case 'notlike_tail' :
case 'notlike_prefix' :
case 'notlike' :
return $name . ' not like ' . $value;
break;
case 'in' :
return $name . ' in ' . $value;
break;
case 'notin' :
case 'not_in' :
return $name . ' not in ' . $value;
break;
case 'notequal' :
return $name . ' <> ' . $value;
break;
case 'notnull' :
return $name . ' is not null';
break;
case 'null' :
return $name . ' is null';
break;
case 'and' :
return $name . ' & ' . $value;
break;
case 'or' :
return $name . ' | ' . $value;
break;
case 'xor' :
return $name . ' ^ ' . $value;
break;
case 'not' :
return $name . ' ~ ' . $value;
break;
case 'between' :
return $name . ' between ' . $value[0] . ' and ' . $value[1];
break;
}
}
}
/* End of file Condition.class.php */
/* Location: ./classes/db/queryparts/condition/Condition.class.php */

View file

@ -1,87 +1,119 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
* @version 0.1
*/
class ConditionGroup
{
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
* @version 0.1
* condition list
* @var array
*/
class ConditionGroup {
/**
* condition list
* @var array
*/
var $conditions;
/**
* pipe can use 'and', 'or'...
* @var string
*/
var $pipe;
var $conditions;
var $_group;
var $_show;
/**
* pipe can use 'and', 'or'...
* @var string
*/
var $pipe;
var $_group;
var $_show;
/**
* constructor
* @param array $conditions
* @param string $pipe
* @return void
*/
function ConditionGroup($conditions, $pipe = "") {
$this->conditions = array();
foreach($conditions as $condition){
if($condition->show())
$this->conditions[] = $condition;
}
if(count($this->conditions) === 0) $this->_show = false;
else $this->_show = true;
$this->pipe = $pipe;
/**
* constructor
* @param array $conditions
* @param string $pipe
* @return void
*/
function ConditionGroup($conditions, $pipe = "")
{
$this->conditions = array();
foreach($conditions as $condition)
{
if($condition->show())
{
$this->conditions[] = $condition;
}
}
if(count($this->conditions) === 0)
{
$this->_show = false;
}
else
{
$this->_show = true;
}
function show(){
return $this->_show;
}
$this->pipe = $pipe;
}
function setPipe($pipe){
if($this->pipe !== $pipe) $this->_group = null;
$this->pipe = $pipe;
}
function show()
{
return $this->_show;
}
/**
* value to string
* @param boolean $with_value
* @return string
*/
function toString($with_value = true){
if(!isset($this->_group)){
function setPipe($pipe)
{
if($this->pipe !== $pipe)
{
$this->_group = null;
}
$this->pipe = $pipe;
}
/**
* value to string
* @param boolean $with_value
* @return string
*/
function toString($with_value = true)
{
if(!isset($this->_group))
{
$cond_indx = 0;
$group = '';
$group = '';
foreach($this->conditions as $condition){
if($cond_indx === 0) $condition->setPipe("");
$group .= $condition->toString($with_value) . ' ';
$cond_indx++;
foreach($this->conditions as $condition)
{
if($cond_indx === 0)
{
$condition->setPipe("");
}
$group .= $condition->toString($with_value) . ' ';
$cond_indx++;
}
if($this->pipe !== "" && trim($group) !== ''){
$group = $this->pipe . ' (' . $group . ')';
}
if($this->pipe !== "" && trim($group) !== '')
{
$group = $this->pipe . ' (' . $group . ')';
}
$this->_group = $group;
}
return $this->_group;
}
/**
* return argument list
* @return array
*/
function getArguments(){
$args = array();
foreach($this->conditions as $condition){
$arg = $condition->getArgument();
if($arg) $args[] = $arg;
}
return $args;
$this->_group = $group;
}
return $this->_group;
}
?>
/**
* return argument list
* @return array
*/
function getArguments()
{
$args = array();
foreach($this->conditions as $condition)
{
$arg = $condition->getArgument();
if($arg)
{
$args[] = $arg;
}
}
return $args;
}
}
/* End of file ConditionGroup.class.php */
/* Location: ./classes/db/queryparts/condition/ConditionGroup.class.php */

View file

@ -1,23 +1,27 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
* @version 0.1
*/
class ConditionSubquery extends Condition {
/**
* constructor
* @param string $column_name
* @param mixed $argument
* @param string $operation
* @param string $pipe
* @return void
*/
function ConditionSubquery($column_name, $argument, $operation, $pipe = ""){
parent::Condition($column_name, $argument, $operation, $pipe);
$this->_value = $this->argument->toString();
}
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
* @version 0.1
*/
class ConditionSubquery extends Condition
{
/**
* constructor
* @param string $column_name
* @param mixed $argument
* @param string $operation
* @param string $pipe
* @return void
*/
function ConditionSubquery($column_name, $argument, $operation, $pipe = "")
{
parent::Condition($column_name, $argument, $operation, $pipe);
$this->_value = $this->argument->toString();
}
?>
}
/* End of file ConditionSubquery.class.php */
/* Location: ./classes/db/queryparts/condition/ConditionSubquery.class.php */

View file

@ -1,71 +1,98 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
* @version 0.1
*/
class ConditionWithArgument extends Condition
{
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
* @version 0.1
* constructor
* @param string $column_name
* @param mixed $argument
* @param string $operation
* @param string $pipe
* @return void
*/
class ConditionWithArgument extends Condition {
/**
* constructor
* @param string $column_name
* @param mixed $argument
* @param string $operation
* @param string $pipe
* @return void
*/
function ConditionWithArgument($column_name, $argument, $operation, $pipe = ""){
if($argument === null) { $this->_show = false; return; }
parent::Condition($column_name, $argument, $operation, $pipe);
$this->_value = $argument->getValue();
}
function getArgument(){
if(!$this->show()) return;
return $this->argument;
}
/**
* change string without value
* @return string
*/
function toStringWithoutValue(){
$value = $this->argument->getUnescapedValue();
if(is_array($value)){
$q = '';
foreach ($value as $v) $q .= '?,';
if($q !== '') $q = substr($q, 0, -1);
$q = '(' . $q . ')';
}
else
{
// Prepared statements: column names should not be sent as query arguments, but instead concatenated to query string
if($this->argument->isColumnName())
{
$q = $value;
}
else
{
$q = '?';
}
}
return $this->pipe . ' ' . $this->getConditionPart($q);
}
/**
* @return boolean
*/
function show(){
if(!isset($this->_show)){
if(!$this->argument->isValid()) $this->_show = false;
if($this->_value === '\'\'') $this->_show = false;
if(!isset($this->_show)){
return parent::show();
}
}
return $this->_show;
function ConditionWithArgument($column_name, $argument, $operation, $pipe = "")
{
if($argument === null)
{
$this->_show = false;
return;
}
parent::Condition($column_name, $argument, $operation, $pipe);
$this->_value = $argument->getValue();
}
?>
function getArgument()
{
if(!$this->show())
return;
return $this->argument;
}
/**
* change string without value
* @return string
*/
function toStringWithoutValue()
{
$value = $this->argument->getUnescapedValue();
if(is_array($value))
{
$q = '';
foreach($value as $v)
{
$q .= '?,';
}
if($q !== '')
{
$q = substr($q, 0, -1);
}
$q = '(' . $q . ')';
}
else
{
// Prepared statements: column names should not be sent as query arguments, but instead concatenated to query string
if($this->argument->isColumnName())
{
$q = $value;
}
else
{
$q = '?';
}
}
return $this->pipe . ' ' . $this->getConditionPart($q);
}
/**
* @return boolean
*/
function show()
{
if(!isset($this->_show))
{
if(!$this->argument->isValid())
{
$this->_show = false;
}
if($this->_value === '\'\'')
{
$this->_show = false;
}
if(!isset($this->_show))
{
return parent::show();
}
}
return $this->_show;
}
}
/* End of file ConditionWithArgument.class.php */
/* Location: ./classes/db/queryparts/condition/ConditionWithArgument.class.php */

View file

@ -1,29 +1,39 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
* @version 0.1
*/
class ConditionWithoutArgument extends Condition {
/**
* constructor
* @param string $column_name
* @param mixed $argument
* @param string $operation
* @param string $pipe
* @return void
*/
function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = ""){
parent::Condition($column_name, $argument, $operation, $pipe);
$tmpArray = array('in'=>1, 'notin'=>1, 'not_in'=>1);
if(isset($tmpArray[$operation])){
if(is_array($argument)) $argument = implode($argument, ',');
$this->_value = '('. $argument .')';
}
else
$this->_value = $argument;
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/condition
* @version 0.1
*/
class ConditionWithoutArgument extends Condition
{
/**
* constructor
* @param string $column_name
* @param mixed $argument
* @param string $operation
* @param string $pipe
* @return void
*/
function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = "")
{
parent::Condition($column_name, $argument, $operation, $pipe);
$tmpArray = array('in' => 1, 'notin' => 1, 'not_in' => 1);
if(isset($tmpArray[$operation]))
{
if(is_array($argument))
{
$argument = implode($argument, ',');
}
$this->_value = '(' . $argument . ')';
}
else
{
$this->_value = $argument;
}
}
?>
}
/* End of file ConditionWithoutArgument.class.php */
/* Location: ./classes/db/queryparts/condition/ConditionWithoutArgument.class.php */

View file

@ -1,53 +1,61 @@
<?php
<?php
/**
* ClickCountExpression
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
*/
class ClickCountExpression extends SelectExpression
{
/**
* ClickCountExpression
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
* click count
* @var bool
*/
class ClickCountExpression extends SelectExpression {
/**
* click count
* @var bool
*/
var $click_count;
/**
* constructor
* @param string $column_name
* @param string $alias
* @param bool $click_count
* @return void
*/
function ClickCountExpression($column_name, $alias = NULL, $click_count = false){
parent::SelectExpression($column_name, $alias);
if(!is_bool($click_count)){
// error_log("Click_count value for $column_name was not boolean", 0);
$this->click_count = false;
}
$this->click_count = $click_count;
var $click_count;
/**
* constructor
* @param string $column_name
* @param string $alias
* @param bool $click_count
* @return void
*/
function ClickCountExpression($column_name, $alias = NULL, $click_count = false)
{
parent::SelectExpression($column_name, $alias);
if(!is_bool($click_count))
{
// error_log("Click_count value for $column_name was not boolean", 0);
$this->click_count = false;
}
function show() {
return $this->click_count;
$this->click_count = $click_count;
}
function show()
{
return $this->click_count;
}
/**
* Return column expression, ex) column = column + 1
* @return string
*/
function getExpression()
{
$db_type = Context::getDBType();
if($db_type == 'cubrid')
{
return "INCR($this->column_name)";
}
/**
* Return column expression, ex) column = column + 1
* @return string
*/
function getExpression(){
$db_type = Context::getDBType();
if($db_type == 'cubrid')
{
return "INCR($this->column_name)";
}
else
{
return "$this->column_name";
}
else
{
return "$this->column_name";
}
}
?>
}
/* End of file ClickCountExpression.class.php */
/* Location: ./classes/db/queryparts/expression/ClickCountExpression.class.php */

View file

@ -1,50 +1,62 @@
<?php
/**
* DeleteExpression
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
* @todo Fix this class
*/
<?php
class DeleteExpression extends Expression {
/**
* column value
* @var mixed
*/
var $value;
/**
* constructor
* @param string $column_name
* @param mixed $value
* @return void
*/
function DeleteExpression($column_name, $value){
parent::Expression($column_name);
$this->value = $value;
}
/**
* Return column expression, ex) column = value
* @return string
*/
function getExpression(){
return "$this->column_name = $this->value";
}
function getValue(){
// TODO Escape value according to column type instead of variable type
if(!is_numeric($this->value)) return "'".$this->value."'";
return $this->value;
}
function show(){
if(!$this->value) return false;
return true;
}
/**
* DeleteExpression
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
* @todo Fix this class
*/
class DeleteExpression extends Expression
{
/**
* column value
* @var mixed
*/
var $value;
/**
* constructor
* @param string $column_name
* @param mixed $value
* @return void
*/
function DeleteExpression($column_name, $value)
{
parent::Expression($column_name);
$this->value = $value;
}
/**
* Return column expression, ex) column = value
* @return string
*/
function getExpression()
{
return "$this->column_name = $this->value";
}
?>
function getValue()
{
// TODO Escape value according to column type instead of variable type
if(!is_numeric($this->value))
{
return "'" . $this->value . "'";
}
return $this->value;
}
function show()
{
if(!$this->value)
{
return false;
}
return true;
}
}
/* End of file DeleteExpression.class.php */
/* Location: ./classes/db/queryparts/expression/DeleteExpression.class.php */

View file

@ -1,44 +1,55 @@
<?php
/**
* Expression
* Represents an expression used in select/update/insert/delete statements
*
* Examples (expressions are inside double square brackets):
* select [[columnA]], [[columnB as aliasB]] from tableA
* update tableA set [[columnA = valueA]] where columnB = something
*
* @author Corina
* @package /classes/db/queryparts/expression
* @version 0.1
*/
class Expression
{
/**
* Expression
* Represents an expression used in select/update/insert/delete statements
*
* Examples (expressions are inside double square brackets):
* select [[columnA]], [[columnB as aliasB]] from tableA
* update tableA set [[columnA = valueA]] where columnB = something
*
* @author Corina
* @package /classes/db/queryparts/expression
* @version 0.1
* column name
* @var string
*/
class Expression {
/**
* column name
* @var string
*/
var $column_name;
/**
* constructor
* @param string $column_name
* @return void
*/
function Expression($column_name){
$this->column_name = $column_name;
}
function getColumnName(){
return $this->column_name;
}
function show() {
return false;
}
/**
* Return column expression, ex) column as alias
* @return string
*/
function getExpression() {
}
var $column_name;
/**
* constructor
* @param string $column_name
* @return void
*/
function Expression($column_name)
{
$this->column_name = $column_name;
}
function getColumnName()
{
return $this->column_name;
}
function show()
{
return false;
}
/**
* Return column expression, ex) column as alias
* @return string
*/
function getExpression()
{
}
}
/* End of file Expression.class.php */
/* Location: ./classes/db/queryparts/expression/Expression.class.php */

View file

@ -1,53 +1,73 @@
<?php
/**
* InsertExpression
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
*/
class InsertExpression extends Expression
{
/**
* InsertExpression
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
* argument
* @var object
*/
class InsertExpression extends Expression {
/**
* argument
* @var object
*/
var $argument;
var $argument;
/**
* constructor
* @param string $column_name
* @param object $argument
* @return void
*/
function InsertExpression($column_name, $argument){
parent::Expression($column_name);
$this->argument = $argument;
}
/**
* constructor
* @param string $column_name
* @param object $argument
* @return void
*/
function InsertExpression($column_name, $argument)
{
parent::Expression($column_name);
$this->argument = $argument;
}
function getValue($with_values = true){
if($with_values)
return $this->argument->getValue();
return '?';
}
function show(){
if(!$this->argument) return false;
$value = $this->argument->getValue();
if(!isset($value)) return false;
return true;
}
function getArgument(){
return $this->argument;
}
function getArguments()
function getValue($with_values = true)
{
if($with_values)
{
if ($this->argument)
return array($this->argument);
else
return array();
return $this->argument->getValue();
}
return '?';
}
function show()
{
if(!$this->argument)
{
return false;
}
$value = $this->argument->getValue();
if(!isset($value))
{
return false;
}
return true;
}
function getArgument()
{
return $this->argument;
}
function getArguments()
{
if($this->argument)
{
return array($this->argument);
}
else
{
return array();
}
}
?>
}
/* End of file InsertExpression.class.php */
/* Location: ./classes/db/queryparts/expression/InsertExpression.class.php */

View file

@ -1,59 +1,69 @@
<?php
/**
* SelectExpression
* Represents an expresion that appears in the select clause
*
* $column_name can be:
* - a table column name
* - an sql function - like count(*)
* - an sql expression - substr(column_name, 1, 8) or score1 + score2
* $column_name is already escaped
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
*/
class SelectExpression extends Expression
{
/**
* SelectExpression
* Represents an expresion that appears in the select clause
*
* $column_name can be:
* - a table column name
* - an sql function - like count(*)
* - an sql expression - substr(column_name, 1, 8) or score1 + score2
* $column_name is already escaped
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
* column alias name
* @var string
*/
class SelectExpression extends Expression {
/**
* column alias name
* @var string
*/
var $column_alias;
var $column_alias;
/**
* constructor
* @param string $column_name
* @param string $alias
* @return void
*/
function SelectExpression($column_name, $alias = NULL){
parent::Expression($column_name);
$this->column_alias = $alias;
}
/**
* Return column expression, ex) column as alias
* @return string
*/
function getExpression() {
return sprintf("%s%s", $this->column_name, $this->column_alias ? " as ".$this->column_alias : "");
}
function show() {
return true;
}
function getArgument(){
return null;
}
function getArguments()
{
return array();
}
function isSubquery(){
return false;
}
/**
* constructor
* @param string $column_name
* @param string $alias
* @return void
*/
function SelectExpression($column_name, $alias = NULL)
{
parent::Expression($column_name);
$this->column_alias = $alias;
}
?>
/**
* Return column expression, ex) column as alias
* @return string
*/
function getExpression()
{
return sprintf("%s%s", $this->column_name, $this->column_alias ? " as " . $this->column_alias : "");
}
function show()
{
return true;
}
function getArgument()
{
return null;
}
function getArguments()
{
return array();
}
function isSubquery()
{
return false;
}
}
/* End of file SelectExpression.class.php */
/* Location: ./classes/db/queryparts/expression/SelectExpression.class.php */

View file

@ -1,28 +1,36 @@
<?php
/**
* StarExpression
* Represents the * in 'select * from ...' statements
*
* @author Corina
* @package /classes/db/queryparts/expression
* @version 0.1
*/
class StarExpression extends SelectExpression {
/**
* constructor, set the column to asterisk
* @return void
*/
function StarExpression(){
parent::SelectExpression("*");
}
function getArgument(){
return null;
}
<?php
function getArguments(){
// StarExpression has no arguments
return array();
}
/**
* StarExpression
* Represents the * in 'select * from ...' statements
*
* @author Corina
* @package /classes/db/queryparts/expression
* @version 0.1
*/
class StarExpression extends SelectExpression
{
/**
* constructor, set the column to asterisk
* @return void
*/
function StarExpression()
{
parent::SelectExpression("*");
}
?>
function getArgument()
{
return null;
}
function getArguments()
{
// StarExpression has no arguments
return array();
}
}
/* End of file StarExpression.class.php */
/* Location: ./classes/db/queryparts/expression/StarExpression.class.php */

View file

@ -1,89 +1,118 @@
<?php
/**
* UpdateExpression
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
*/
class UpdateExpression extends Expression
{
/**
* UpdateExpression
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
* argument
* @var object
*/
class UpdateExpression extends Expression {
/**
* argument
* @var object
*/
var $argument;
var $argument;
/**
* constructor
* @param string $column_name
* @param object $argument
* @return void
*/
function UpdateExpression($column_name, $argument){
parent::Expression($column_name);
$this->argument = $argument;
}
/**
* constructor
* @param string $column_name
* @param object $argument
* @return void
*/
function UpdateExpression($column_name, $argument)
{
parent::Expression($column_name);
$this->argument = $argument;
}
/**
* Return column expression, ex) column = value
* @return string
*/
function getExpression($with_value = true){
if($with_value)
return $this->getExpressionWithValue();
return $this->getExpressionWithoutValue();
}
/**
* Return column expression, ex) column = value
* @return string
*/
function getExpressionWithValue(){
$value = $this->argument->getValue();
$operation = $this->argument->getColumnOperation();
if(isset($operation))
return "$this->column_name = $this->column_name $operation $value";
return "$this->column_name = $value";
}
/**
* Return column expression, ex) column = ?
* Can use prepare statement
* @return string
*/
function getExpressionWithoutValue(){
$operation = $this->argument->getColumnOperation();
if(isset($operation))
return "$this->column_name = $this->column_name $operation ?";
return "$this->column_name = ?";
}
function getValue(){
// TODO Escape value according to column type instead of variable type
$value = $this->argument->getValue();
if(!is_numeric($value)) return "'".$value."'";
return $value;
}
function show(){
if(!$this->argument) return false;
$value = $this->argument->getValue();
if(!isset($value)) return false;
return true;
}
function getArgument(){
return $this->argument;
}
function getArguments()
/**
* Return column expression, ex) column = value
* @return string
*/
function getExpression($with_value = true)
{
if($with_value)
{
return $this->getExpressionWithValue();
}
return $this->getExpressionWithoutValue();
}
/**
* Return column expression, ex) column = value
* @return string
*/
function getExpressionWithValue()
{
$value = $this->argument->getValue();
$operation = $this->argument->getColumnOperation();
if(isset($operation))
{
return "$this->column_name = $this->column_name $operation $value";
}
return "$this->column_name = $value";
}
/**
* Return column expression, ex) column = ?
* Can use prepare statement
* @return string
*/
function getExpressionWithoutValue()
{
$operation = $this->argument->getColumnOperation();
if(isset($operation))
{
return "$this->column_name = $this->column_name $operation ?";
}
return "$this->column_name = ?";
}
function getValue()
{
// TODO Escape value according to column type instead of variable type
$value = $this->argument->getValue();
if(!is_numeric($value))
{
return "'" . $value . "'";
}
return $value;
}
function show()
{
if(!$this->argument)
{
return false;
}
$value = $this->argument->getValue();
if(!isset($value))
{
return false;
}
return true;
}
function getArgument()
{
return $this->argument;
}
function getArguments()
{
if($this->argument)
{
if ($this->argument)
return array($this->argument);
else
}
else
{
return array();
}
}
?>
}
/* End of file UpdateExpression.class.php */
/* Location: ./classes/db/queryparts/expression/UpdateExpression.class.php */

View file

@ -1,55 +1,73 @@
<?php
/**
* UpdateExpression
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
*/
class UpdateExpressionWithoutArgument extends UpdateExpression
{
/**
* UpdateExpression
*
* @author Arnia Software
* @package /classes/db/queryparts/expression
* @version 0.1
* argument
* @var object
*/
class UpdateExpressionWithoutArgument extends UpdateExpression {
/**
* argument
* @var object
*/
var $argument;
var $argument;
/**
* constructor
* @param string $column_name
* @param object $argument
* @return void
*/
function UpdateExpressionWithoutArgument($column_name, $argument){
parent::Expression($column_name);
$this->argument = $argument;
}
function getExpression($with_value = true){
return "$this->column_name = $this->argument";
}
function getValue(){
// TODO Escape value according to column type instead of variable type
$value = $this->argument;
if(!is_numeric($value)) return "'".$value."'";
return $value;
}
function show(){
if(!$this->argument) return false;
$value = $this->argument;
if(!isset($value)) return false;
return true;
}
function getArgument(){
return null;
}
function getArguments(){
return array();
}
/**
* constructor
* @param string $column_name
* @param object $argument
* @return void
*/
function UpdateExpressionWithoutArgument($column_name, $argument)
{
parent::Expression($column_name);
$this->argument = $argument;
}
function getExpression($with_value = true)
{
return "$this->column_name = $this->argument";
}
?>
function getValue()
{
// TODO Escape value according to column type instead of variable type
$value = $this->argument;
if(!is_numeric($value))
{
return "'" . $value . "'";
}
return $value;
}
function show()
{
if(!$this->argument)
{
return false;
}
$value = $this->argument;
if(!isset($value))
{
return false;
}
return true;
}
function getArgument()
{
return null;
}
function getArguments()
{
return array();
}
}
/* End of file UpdateExpressionWithoutArgument.class.php */
/* Location: ./classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php */

View file

@ -1,69 +1,95 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/limit
* @version 0.1
*/
class Limit {
/**
* start number
* @var int
*/
var $start;
/**
* list count
* @var int
*/
var $list_count;
/**
* page count
* @var int
*/
var $page_count;
/**
* current page
* @var int
*/
var $page;
<?php
/**
* constructor
* @param int $list_count
* @param int $page
* @param int $page_count
* @return void
*/
function Limit($list_count, $page= NULL, $page_count= NULL){
$this->list_count = $list_count;
if ($page){
$list_count_value = $list_count->getValue();
$page_value = $page->getValue();
$this->start = ($page_value - 1) * $list_count_value;
$this->page_count = $page_count;
$this->page = $page;
}
}
/**
* In case you choose to use query limit in other cases than page select
* @return boolean
*/
function isPageHandler(){
if ($this->page)return true;
else return false;
}
function getOffset(){
return $this->start;
}
function getLimit(){
return $this->list_count->getValue();
}
function toString(){
if ($this->page) return $this->start . ' , ' . $this->list_count->getValue();
else return $this->list_count->getValue();
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/limit
* @version 0.1
*/
class Limit
{
/**
* start number
* @var int
*/
var $start;
/**
* list count
* @var int
*/
var $list_count;
/**
* page count
* @var int
*/
var $page_count;
/**
* current page
* @var int
*/
var $page;
/**
* constructor
* @param int $list_count
* @param int $page
* @param int $page_count
* @return void
*/
function Limit($list_count, $page = NULL, $page_count = NULL)
{
$this->list_count = $list_count;
if($page)
{
$list_count_value = $list_count->getValue();
$page_value = $page->getValue();
$this->start = ($page_value - 1) * $list_count_value;
$this->page_count = $page_count;
$this->page = $page;
}
}
?>
/**
* In case you choose to use query limit in other cases than page select
* @return boolean
*/
function isPageHandler()
{
if($this->page)
{
return true;
}
else
{
return false;
}
}
function getOffset()
{
return $this->start;
}
function getLimit()
{
return $this->list_count->getValue();
}
function toString()
{
if($this->page)
{
return $this->start . ' , ' . $this->list_count->getValue();
}
else
{
return $this->list_count->getValue();
}
}
}
/* End of file Limit.class.php */
/* Location: ./classes/db/limit/Limit.class.php */

View file

@ -1,50 +1,73 @@
<?php
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/order
* @version 0.1
*/
class OrderByColumn
{
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/order
* @version 0.1
* column name
* @var string
*/
class OrderByColumn {
/**
* column name
* @var string
*/
var $column_name;
/**
* sort order
* @var string
*/
var $sort_order;
/**
* constructor
* @param string $column_name
* @param string $sort_order
* @return void
*/
function OrderByColumn($column_name, $sort_order){
$this->column_name = $column_name;
$this->sort_order = $sort_order;
var $column_name;
/**
* sort order
* @var string
*/
var $sort_order;
/**
* constructor
* @param string $column_name
* @param string $sort_order
* @return void
*/
function OrderByColumn($column_name, $sort_order)
{
$this->column_name = $column_name;
$this->sort_order = $sort_order;
}
function toString()
{
$result = $this->getColumnName();
$result .= ' ';
$result .= is_a($this->sort_order, 'Argument') ? $this->sort_order->getValue() : $this->sort_order;
return $result;
}
function getColumnName()
{
return is_a($this->column_name, 'Argument') ? $this->column_name->getValue() : $this->column_name;
}
function getPureColumnName()
{
return is_a($this->column_name, 'Argument') ? $this->column_name->getPureValue() : $this->column_name;
}
function getPureSortOrder()
{
return is_a($this->sort_order, 'Argument') ? $this->sort_order->getPureValue() : $this->sort_order;
}
function getArguments()
{
$args = array();
if(is_a($this->column_name, 'Argument'))
{
$args[] = $this->column_name;
}
function toString(){
$result = $this->getColumnName();
$result .= ' ';
$result .= is_a($this->sort_order, 'Argument') ? $this->sort_order->getValue() : $this->sort_order;
return $result;
}
function getColumnName(){
return is_a($this->column_name, 'Argument') ? $this->column_name->getValue() : $this->column_name;
}
function getArguments(){
$args = array();
if(is_a($this->column_name, 'Argument'))
$args[]= $this->column_name;
if(is_a($this->sort_order, 'Argument'))
$args[] = $this->sort_order;
if(is_a($this->sort_order, 'Argument'))
{
$args[] = $this->sort_order;
}
}
?>
}
/* End of file OrderByColumn.class.php */
/* Location: ./classes/db/order/OrderByColumn.class.php */

View file

@ -1,62 +1,71 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
* @version 0.1
*/
class CubridTableWithHint extends Table
{
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
* @version 0.1
* table name
* @var string
*/
class CubridTableWithHint extends Table {
/**
* table name
* @var string
*/
var $name;
/**
* table alias
* @var string
*/
var $alias;
/**
* index hint list
* @var array
*/
var $index_hints_list;
var $name;
/**
* constructor
* @param string $name
* @param string $alias
* @param array $index_hints_list
* @return void
*/
function CubridTableWithHint($name, $alias = NULL, $index_hints_list){
parent::Table($name, $alias);
$this->index_hints_list = $index_hints_list;
}
/**
* table alias
* @var string
*/
var $alias;
/**
* Return index hint string
* @return string
*/
function getIndexHintString(){
$result = '';
/**
* index hint list
* @var array
*/
var $index_hints_list;
// Retrieve table prefix, to add it to index name
$db_info = Context::getDBInfo();
$prefix = $db_info->master_db["db_table_prefix"];
foreach($this->index_hints_list as $index_hint){
$index_hint_type = $index_hint->getIndexHintType();
if($index_hint_type !== 'IGNORE'){
$result .= $this->alias . '.'
. '"' . $prefix . substr($index_hint->getIndexName(), 1)
. ($index_hint_type == 'FORCE' ? '(+)' : '')
. ', ';
}
}
$result = substr($result, 0, -2);
return $result;
}
/**
* constructor
* @param string $name
* @param string $alias
* @param array $index_hints_list
* @return void
*/
function CubridTableWithHint($name, $alias = NULL, $index_hints_list)
{
parent::Table($name, $alias);
$this->index_hints_list = $index_hints_list;
}
?>
/**
* Return index hint string
* @return string
*/
function getIndexHintString()
{
$result = '';
// Retrieve table prefix, to add it to index name
$db_info = Context::getDBInfo();
$prefix = $db_info->master_db["db_table_prefix"];
foreach($this->index_hints_list as $index_hint)
{
$index_hint_type = $index_hint->getIndexHintType();
if($index_hint_type !== 'IGNORE')
{
$result .= $this->alias . '.'
. '"' . $prefix . substr($index_hint->getIndexName(), 1)
. ($index_hint_type == 'FORCE' ? '(+)' : '')
. ', ';
}
}
$result = substr($result, 0, -2);
return $result;
}
}
/* End of file CubridTableWithHint.class.php */
/* Location: ./classes/db/queryparts/table/CubridTableWithHint.class.php */

View file

@ -1,39 +1,47 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
* @version 0.1
*/
class IndexHint
{
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
* @version 0.1
* index name
* @var string
*/
class IndexHint {
/**
* index name
* @var string
*/
var $index_name;
/**
* index hint type, ex) IGNORE, FORCE, USE...
* @var string
*/
var $index_hint_type;
var $index_name;
/**
* constructor
* @param string $index_name
* @param string $index_hint_type
* @return void
*/
function IndexHint($index_name, $index_hint_type){
$this->index_name = $index_name;
$this->index_hint_type = $index_hint_type;
}
/**
* index hint type, ex) IGNORE, FORCE, USE...
* @var string
*/
var $index_hint_type;
function getIndexName(){
return $this->index_name;
}
function getIndexHintType() {
return $this->index_hint_type;
}
/**
* constructor
* @param string $index_name
* @param string $index_hint_type
* @return void
*/
function IndexHint($index_name, $index_hint_type)
{
$this->index_name = $index_name;
$this->index_hint_type = $index_hint_type;
}
?>
function getIndexName()
{
return $this->index_name;
}
function getIndexHintType()
{
return $this->index_hint_type;
}
}
/* End of file IndexHint.class.php */
/* Location: ./classes/db/queryparts/table/IndexHint.class.php */

View file

@ -1,59 +1,70 @@
<?php
<?php
/**
* class JoinTable
* $conditions in an array of Condition objects
*
* @author Arnia Software
* @package /classes/db/queryparts/table
* @version 0.1
*/
class JoinTable extends Table
{
/**
* class JoinTable
* $conditions in an array of Condition objects
*
* @author Arnia Software
* @package /classes/db/queryparts/table
* @version 0.1
* join type
* @var string
*/
class JoinTable extends Table {
/**
* join type
* @var string
*/
var $join_type;
/**
* condition list
* @var array
*/
var $conditions;
/**
* constructor
* @param string $name
* @param string $alias
* @param string $join_type
* @param array $conditions
* @return void
*/
function JoinTable($name, $alias, $join_type, $conditions){
parent::Table($name, $alias);
$this->join_type = $join_type;
$this->conditions = $conditions;
}
function toString($with_value = true){
$part = $this->join_type . ' ' . $this->name ;
$part .= $this->alias ? ' as ' . $this->alias : '';
$part .= ' on ';
foreach($this->conditions as $conditionGroup)
$part .= $conditionGroup->toString($with_value);
return $part;
}
function isJoinTable(){
return true;
}
function getArguments()
{
$args = array();
foreach($this->conditions as $conditionGroup)
$args = array_merge($args, $conditionGroup->getArguments());
return $args;
}
var $join_type;
/**
* condition list
* @var array
*/
var $conditions;
/**
* constructor
* @param string $name
* @param string $alias
* @param string $join_type
* @param array $conditions
* @return void
*/
function JoinTable($name, $alias, $join_type, $conditions)
{
parent::Table($name, $alias);
$this->join_type = $join_type;
$this->conditions = $conditions;
}
?>
function toString($with_value = true)
{
$part = $this->join_type . ' ' . $this->name;
$part .= $this->alias ? ' as ' . $this->alias : '';
$part .= ' on ';
foreach($this->conditions as $conditionGroup)
{
$part .= $conditionGroup->toString($with_value);
}
return $part;
}
function isJoinTable()
{
return true;
}
function getArguments()
{
$args = array();
foreach($this->conditions as $conditionGroup)
{
$args = array_merge($args, $conditionGroup->getArguments());
}
return $args;
}
}
/* End of file JoinTable.class.php */
/* Location: ./classes/db/queryparts/table/JoinTable.class.php */

View file

@ -1,53 +1,65 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
* @version 0.1
*/
class MssqlTableWithHint extends Table
{
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
* @version 0.1
* table name
* @var string
*/
class MssqlTableWithHint extends Table {
/**
* table name
* @var string
*/
var $name;
/**
* table alias
* @var string
*/
var $alias;
/**
* index hint type, ex) IGNORE, FORCE, USE...
* @var array
*/
var $index_hints_list;
var $name;
/**
* constructor
* @param string $name
* @param string $alias
* @param string $index_hints_list
* @return void
*/
function MssqlTableWithHint($name, $alias = NULL, $index_hints_list){
parent::Table($name, $alias);
$this->index_hints_list = $index_hints_list;
}
/**
* table alias
* @var string
*/
var $alias;
function toString(){
$result = parent::toString();
/**
* index hint type, ex) IGNORE, FORCE, USE...
* @var array
*/
var $index_hints_list;
$index_hint_string = '';
$indexTypeList = array('USE'=>1, 'FORCE'=>1);
foreach($this->index_hints_list as $index_hint){
$index_hint_type = $index_hint->getIndexHintType();
if(isset($indexTypeList[$index_hint_type]))
$index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
}
if($index_hint_string != ''){
$result .= ' WITH(' . substr($index_hint_string, 0, -2) . ') ';
}
return $result;
}
/**
* constructor
* @param string $name
* @param string $alias
* @param string $index_hints_list
* @return void
*/
function MssqlTableWithHint($name, $alias = NULL, $index_hints_list)
{
parent::Table($name, $alias);
$this->index_hints_list = $index_hints_list;
}
?>
function toString()
{
$result = parent::toString();
$index_hint_string = '';
$indexTypeList = array('USE' => 1, 'FORCE' => 1);
foreach($this->index_hints_list as $index_hint)
{
$index_hint_type = $index_hint->getIndexHintType();
if(isset($indexTypeList[$index_hint_type]))
{
$index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
}
}
if($index_hint_string != '')
{
$result .= ' WITH(' . substr($index_hint_string, 0, -2) . ') ';
}
return $result;
}
}
/* End of file MssqlTableWithHint.class.php */
/* Location: ./classes/db/queryparts/table/MssqlTableWithHint.class.php */

View file

@ -1,59 +1,82 @@
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
* @version 0.1
*/
class MysqlTableWithHint extends Table
{
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
* @version 0.1
* table name
* @var string
*/
class MysqlTableWithHint extends Table {
/**
* table name
* @var string
*/
var $name;
/**
* table alias
* @var string
*/
var $alias;
/**
* index hint type, ex) IGNORE, FORCE, USE...
* @var array
*/
var $index_hints_list;
var $name;
/**
* constructor
* @param string $name
* @param string $alias
* @param string $index_hints_list
* @return void
*/
function MysqlTableWithHint($name, $alias = NULL, $index_hints_list){
parent::Table($name, $alias);
$this->index_hints_list = $index_hints_list;
}
/**
* table alias
* @var string
*/
var $alias;
function toString(){
$result = parent::toString();
/**
* index hint type, ex) IGNORE, FORCE, USE...
* @var array
*/
var $index_hints_list;
$use_index_hint = ''; $force_index_hint = ''; $ignore_index_hint = '';
foreach($this->index_hints_list as $index_hint){
$index_hint_type = $index_hint->getIndexHintType();
if($index_hint_type == 'USE') $use_index_hint .= $index_hint->getIndexName() . ', ';
else if($index_hint_type == 'FORCE') $force_index_hint .= $index_hint->getIndexName() . ', ';
else if($index_hint_type == 'IGNORE') $ignore_index_hint .= $index_hint->getIndexName() . ', ';
}
if($use_index_hint != ''){
$result .= ' USE INDEX (' . substr($use_index_hint, 0, -2) . ') ';
}
if($force_index_hint != ''){
$result .= ' FORCE INDEX (' . substr($force_index_hint, 0, -2) . ') ';
}
if($ignore_index_hint != ''){
$result .= ' IGNORE INDEX (' . substr($ignore_index_hint, 0, -2) . ') ';
}
return $result;
}
/**
* constructor
* @param string $name
* @param string $alias
* @param string $index_hints_list
* @return void
*/
function MysqlTableWithHint($name, $alias = NULL, $index_hints_list)
{
parent::Table($name, $alias);
$this->index_hints_list = $index_hints_list;
}
?>
function toString()
{
$result = parent::toString();
$use_index_hint = '';
$force_index_hint = '';
$ignore_index_hint = '';
foreach($this->index_hints_list as $index_hint)
{
$index_hint_type = $index_hint->getIndexHintType();
if($index_hint_type == 'USE')
{
$use_index_hint .= $index_hint->getIndexName() . ', ';
}
else if($index_hint_type == 'FORCE')
{
$force_index_hint .= $index_hint->getIndexName() . ', ';
}
else if($index_hint_type == 'IGNORE')
{
$ignore_index_hint .= $index_hint->getIndexName() . ', ';
}
}
if($use_index_hint != '')
{
$result .= ' USE INDEX (' . substr($use_index_hint, 0, -2) . ') ';
}
if($force_index_hint != '')
{
$result .= ' FORCE INDEX (' . substr($force_index_hint, 0, -2) . ') ';
}
if($ignore_index_hint != '')
{
$result .= ' IGNORE INDEX (' . substr($ignore_index_hint, 0, -2) . ') ';
}
return $result;
}
}
/* End of file MysqlTableWithHint.class.php */
/* Location: ./classes/db/queryparts/table/MysqlTableWithHint.class.php */

View file

@ -1,48 +1,58 @@
<?php
<?php
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
* @version 0.1
*/
class Table
{
/**
* @author NHN (developers@xpressengine.com)
* @package /classes/db/queryparts/table
* @version 0.1
* table name
* @var string
*/
class Table {
/**
* table name
* @var string
*/
var $name;
/**
* table alias
* @var string
*/
var $alias;
/**
* constructor
* @param string $name
* @param string $alias
* @return void
*/
function Table($name, $alias = NULL){
$this->name = $name;
$this->alias = $alias;
}
function toString(){
//return $this->name;
return sprintf("%s%s", $this->name, $this->alias ? ' as ' . $this->alias : '');
}
function getName(){
return $this->name;
}
function getAlias(){
return $this->alias;
}
function isJoinTable(){
return false;
}
var $name;
/**
* table alias
* @var string
*/
var $alias;
/**
* constructor
* @param string $name
* @param string $alias
* @return void
*/
function Table($name, $alias = NULL)
{
$this->name = $name;
$this->alias = $alias;
}
?>
function toString()
{
//return $this->name;
return sprintf("%s%s", $this->name, $this->alias ? ' as ' . $this->alias : '');
}
function getName()
{
return $this->name;
}
function getAlias()
{
return $this->alias;
}
function isJoinTable()
{
return false;
}
}
/* End of file Table.class.php */
/* Location: ./classes/db/queryparts/table/Table.class.php */

View file

@ -1,276 +1,364 @@
<?php
/**
* @class DisplayHandler
* @author NHN (developers@xpressengine.com)
* DisplayHandler is responsible for displaying the execution result. \n
* Depending on the request type, it can display either HTML or XML content.\n
* Xml content is simple xml presentation of variables in oModule while html content
* is the combination of the variables of oModue and template files/.
**/
class DisplayHandler extends Handler {
/**
* @class DisplayHandler
* @author NHN (developers@xpressengine.com)
* DisplayHandler is responsible for displaying the execution result. \n
* Depending on the request type, it can display either HTML or XML content.\n
* Xml content is simple xml presentation of variables in oModule while html content
* is the combination of the variables of oModue and template files/.
*/
class DisplayHandler extends Handler
{
var $content_size = 0; // /< The size of displaying contents
var $content_size = 0; // /< The size of displaying contents
var $gz_enabled = FALSE; // / <a flog variable whether to call contents after compressing by gzip
var $handler = NULL;
var $gz_enabled = false; // / <a flog variable whether to call contents after compressing by gzip
var $handler = null;
/**
* print either html or xml content given oModule object
* @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
* @param ModuleObject $oModule the module object
* @return void
**/
function printContent(&$oModule) {
// Check if the gzip encoding supported
if(
(defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1) &&
strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')!==false &&
function_exists('ob_gzhandler') &&
extension_loaded('zlib') &&
/**
* print either html or xml content given oModule object
* @remark addon execution and the trigger execution are included within this method, which might create inflexibility for the fine grained caching
* @param ModuleObject $oModule the module object
* @return void
*/
function printContent(&$oModule)
{
// Check if the gzip encoding supported
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
) $this->gz_enabled = true;
// Extract contents to display by the request method
if(Context::get('xeVirtualRequestMethod')=='xml') {
require_once("./classes/display/VirtualXMLDisplayHandler.php");
$handler = new VirtualXMLDisplayHandler();
}
else if(Context::getRequestMethod() == 'XMLRPC') {
require_once("./classes/display/XMLDisplayHandler.php");
$handler = new XMLDisplayHandler();
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) $this->gz_enabled = false;
}
else if(Context::getRequestMethod() == 'JSON') {
require_once("./classes/display/JSONDisplayHandler.php");
$handler = new JSONDisplayHandler();
}
else {
require_once("./classes/display/HTMLDisplayHandler.php");
$handler = new HTMLDisplayHandler();
}
)
{
$this->gz_enabled = TRUE;
}
$output = $handler->toDoc($oModule);
// call a trigger before display
ModuleHandler::triggerCall('display', 'before', $output);
// execute add-on
$called_position = 'before_display_content';
$oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file);
// Extract contents to display by the request method
if(Context::get('xeVirtualRequestMethod') == 'xml')
{
require_once("./classes/display/VirtualXMLDisplayHandler.php");
$handler = new VirtualXMLDisplayHandler();
}
else if(Context::getRequestMethod() == 'XMLRPC')
{
require_once("./classes/display/XMLDisplayHandler.php");
$handler = new XMLDisplayHandler();
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
{
$this->gz_enabled = FALSE;
}
}
else if(Context::getRequestMethod() == 'JSON')
{
require_once("./classes/display/JSONDisplayHandler.php");
$handler = new JSONDisplayHandler();
}
else if(Context::getRequestMethod() == 'JS_CALLBACK')
{
require_once("./classes/display/JSCallbackDisplayHandler.php");
$handler = new JSCallbackDisplayHandler();
}
else
{
require_once("./classes/display/HTMLDisplayHandler.php");
$handler = new HTMLDisplayHandler();
}
if(method_exists($handler, "prepareToPrint")) $handler->prepareToPrint($output);
// header output
if($this->gz_enabled) header("Content-Encoding: gzip");
$output = $handler->toDoc($oModule);
$httpStatusCode = $oModule->getHttpStatusCode();
if($httpStatusCode && $httpStatusCode != 200) $this->_printHttpStatusCode($httpStatusCode);
// call a trigger before display
ModuleHandler::triggerCall('display', 'before', $output);
// execute add-on
$called_position = 'before_display_content';
$oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
@include($addon_file);
if(method_exists($handler, "prepareToPrint"))
{
$handler->prepareToPrint($output);
}
// header output
if($this->gz_enabled)
{
header("Content-Encoding: gzip");
}
$httpStatusCode = $oModule->getHttpStatusCode();
if($httpStatusCode && $httpStatusCode != 200)
{
$this->_printHttpStatusCode($httpStatusCode);
}
else
{
if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK')
{
$this->_printJSONHeader();
}
else if(Context::getResponseMethod() != 'HTML')
{
$this->_printXMLHeader();
}
else
{
if(Context::getResponseMethod() == 'JSON') $this->_printJSONHeader();
else if(Context::getResponseMethod() != 'HTML') $this->_printXMLHeader();
else $this->_printHTMLHeader();
$this->_printHTMLHeader();
}
}
// debugOutput output
$this->content_size = strlen($output);
$output .= $this->_debugOutput();
// results directly output
if($this->gz_enabled)
{
print ob_gzhandler($output, 5);
}
else
{
print $output;
}
// call a trigger after display
ModuleHandler::triggerCall('display', 'after', $content);
}
/**
* Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
* This method only functions when __DEBUG__ variable is set to 1.
* __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php
* @return void
*/
function _debugOutput()
{
if(!__DEBUG__)
{
return;
}
$end = getMicroTime();
// Firebug console output
if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1)
{
static $firephp;
if(!isset($firephp))
{
$firephp = FirePHP::getInstance(true);
}
// debugOutput output
$this->content_size = strlen($output);
$output .= $this->_debugOutput();
// results directly output
if($this->gz_enabled) print ob_gzhandler($output, 5);
else print $output;
// call a trigger after display
ModuleHandler::triggerCall('display', 'after', $content);
}
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
{
$firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
return;
}
// display total execution time and Request/Response info
if(__DEBUG__ & 2)
{
$firephp->fb(
array(
'Request / Response info >>> ' . $_SERVER['REQUEST_METHOD'] . ' / ' . Context::getResponseMethod(),
array(
array('Request URI', 'Request method', 'Response method', 'Response contents size'),
array(
sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']),
$_SERVER['REQUEST_METHOD'],
Context::getResponseMethod(),
$this->content_size . ' byte'
)
)
),
'TABLE'
);
$firephp->fb(
array(
'Elapsed time >>> Total : ' . sprintf('%0.5f sec', $end - __StartTime__),
array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'),
array(
sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']),
sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']),
sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']),
sprintf('%0.5f sec', $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']),
sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']),
sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])
)
)
),
'TABLE'
);
}
/**
* Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
* This method only functions when __DEBUG__ variable is set to 1.
* __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php
* @return void
**/
function _debugOutput() {
if(!__DEBUG__) return;
$end = getMicroTime();
// Firebug console output
if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) {
static $firephp;
if(!isset($firephp)) $firephp = FirePHP::getInstance(true);
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
$firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
return;
}
// display total execution time and Request/Response info
if(__DEBUG__ & 2) {
$firephp->fb(
array('Request / Response info >>> '.$_SERVER['REQUEST_METHOD'].' / '.Context::getResponseMethod(),
array(
array('Request URI', 'Request method', 'Response method', 'Response contents size'),
array(
sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']),
$_SERVER['REQUEST_METHOD'],
Context::getResponseMethod(),
$this->content_size.' byte'
)
)
),
'TABLE'
);
$firephp->fb(
array('Elapsed time >>> Total : '.sprintf('%0.5f sec', $end - __StartTime__),
array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'),
array(
sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']),
sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']),
sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']),
sprintf('%0.5f sec', $end-__StartTime__-$GLOBALS['__template_elapsed__']-$GLOBALS['__xmlparse_elapsed__']-$GLOBALS['__db_elapsed_time__']-$GLOBALS['__elapsed_class_load__']),
sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']),
sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])
)
)
),
'TABLE'
);
}
// display DB query history
if((__DEBUG__ & 4) && $GLOBALS['__db_queries__']) {
$queries_output = array(array('Query', 'Elapsed time', 'Result'));
foreach($GLOBALS['__db_queries__'] as $query) {
array_push($queries_output, array($query['query'], sprintf('%0.5f', $query['elapsed_time']), $query['result']));
}
$firephp->fb(
array(
'DB Queries >>> '.count($GLOBALS['__db_queries__']).' Queries, '.sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
$queries_output
),
'TABLE'
);
}
// dislpay the file and HTML comments
} else {
// display total execution time and Request/Response info
if(__DEBUG__ & 2) {
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
return;
}
// Request/Response information
$buff .= "\n- Request/ Response info\n";
$buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']);
$buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']);
$buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod());
$buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->content_size);
// total execution time
$buff .= sprintf("\n- Total elapsed time : %0.5f sec\n", $end-__StartTime__);
$buff .= sprintf("\tclass file load elapsed time \t: %0.5f sec\n", $GLOBALS['__elapsed_class_load__']);
$buff .= sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)\n", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
$buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']);
$buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end-__StartTime__-$GLOBALS['__template_elapsed__']-$GLOBALS['__xmlparse_elapsed__']-$GLOBALS['__db_elapsed_time__']-$GLOBALS['__elapsed_class_load__']);
$buff .= sprintf("\tDB class elapsed time \t\t: %0.5f sec\n", $GLOBALS['__dbclass_elapsed_time__'] -$GLOBALS['__db_elapsed_time__']);
// widget execution time
$buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
// layout execution time
$buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
// Widgets, the editor component replacement time
$buff .= sprintf("\n\tTrans Content \t\t\t: %0.5f sec\n", $GLOBALS['__trans_content_elapsed__']);
}
// DB Logging
if(__DEBUG__ & 4) {
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
return;
}
if($GLOBALS['__db_queries__']) {
$buff .= sprintf("\n- DB Queries : %d Queries. %0.5f sec\n", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']);
$num = 0;
foreach($GLOBALS['__db_queries__'] as $query) {
$buff .= sprintf("\t%02d. %s\n\t\t%0.6f sec. ", ++$num, $query['query'], $query['elapsed_time']);
if($query['result'] == 'Success') {
$buff .= "Query Success\n";
} else {
$buff .= sprintf("Query $s : %d\n\t\t\t %s\n", $query['result'], $query['errno'], $query['errstr']);
}
$buff .= sprintf("\t\tConnection: %s\n", $query['connection']);
}
}
}
// Output in HTML comments
if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') {
$buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
$buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
}
return "<!--\r\n".$buff."\r\n-->";
}
// Output to a file
if($buff && __DEBUG_OUTPUT__ == 0) {
$debug_file = _XE_PATH_.'files/_debug_message.php';
$buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
$buff = str_repeat('=', 40)."\n".$buff.str_repeat('-', 40);
$buff = "\n<?php\n/*".$buff."*/\n?>\n";
if(@!$fp = fopen($debug_file, 'a')) return;
fwrite($fp, $buff);
fclose($fp);
}
}
}
/**
* print a HTTP HEADER for XML, which is encoded in UTF-8
* @return void
**/
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");
// display DB query history
if((__DEBUG__ & 4) && $GLOBALS['__db_queries__'])
{
$queries_output = array(array('Query', 'Elapsed time', 'Result'));
foreach($GLOBALS['__db_queries__'] as $query)
{
array_push($queries_output, array($query['query'], sprintf('%0.5f', $query['elapsed_time']), $query['result']));
}
$firephp->fb(
array(
'DB Queries >>> ' . count($GLOBALS['__db_queries__']) . ' Queries, ' . sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
$queries_output
),
'TABLE'
);
}
// dislpay the file and HTML comments
}
else
{
// display total execution time and Request/Response info
if(__DEBUG__ & 2)
{
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
{
return;
}
// Request/Response information
$buff .= "\n- Request/ Response info\n";
$buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']);
$buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']);
$buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod());
$buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->content_size);
/**
* print a HTTP HEADER for HTML, which is encoded in UTF-8
* @return void
**/
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");
// total execution time
$buff .= sprintf("\n- Total elapsed time : %0.5f sec\n", $end - __StartTime__);
$buff .= sprintf("\tclass file load elapsed time \t: %0.5f sec\n", $GLOBALS['__elapsed_class_load__']);
$buff .= sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)\n", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
$buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']);
$buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']);
$buff .= sprintf("\tDB class elapsed time \t\t: %0.5f sec\n", $GLOBALS['__dbclass_elapsed_time__'] - $GLOBALS['__db_elapsed_time__']);
// widget execution time
$buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
// layout execution time
$buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
// Widgets, the editor component replacement time
$buff .= sprintf("\n\tTrans Content \t\t\t: %0.5f sec\n", $GLOBALS['__trans_content_elapsed__']);
}
// DB Logging
if(__DEBUG__ & 4)
{
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
{
return;
}
if($GLOBALS['__db_queries__'])
{
$buff .= sprintf("\n- DB Queries : %d Queries. %0.5f sec\n", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']);
$num = 0;
foreach($GLOBALS['__db_queries__'] as $query)
{
$buff .= sprintf("\t%02d. %s\n\t\t%0.6f sec. ", ++$num, $query['query'], $query['elapsed_time']);
if($query['result'] == 'Success')
{
$buff .= "Query Success\n";
}
else
{
$buff .= sprintf("Query $s : %d\n\t\t\t %s\n", $query['result'], $query['errno'], $query['errstr']);
}
$buff .= sprintf("\t\tConnection: %s\n", $query['connection']);
}
}
}
// Output in HTML comments
if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML')
{
$buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
{
$buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
}
return "<!--\r\n" . $buff . "\r\n-->";
}
// Output to a file
if($buff && __DEBUG_OUTPUT__ == 0)
{
$debug_file = _XE_PATH_ . 'files/_debug_message.php';
$buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
$buff = str_repeat('=', 40) . "\n" . $buff . str_repeat('-', 40);
$buff = "\n<?php\n/*" . $buff . "*/\n?>\n";
if(@!$fp = fopen($debug_file, 'a'))
{
return;
}
fwrite($fp, $buff);
fclose($fp);
}
}
}
/**
* print a HTTP HEADER for XML, which is encoded in UTF-8
* @return void
*/
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");
}
/**
* print a HTTP HEADER for JSON, which is encoded in UTF-8
* @return void
**/
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");
}
/**
* print a HTTP HEADER for HTML, which is encoded in UTF-8
* @return void
*/
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");
}
/**
* print a HTTP HEADER for JSON, which is encoded in UTF-8
* @return void
*/
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");
}
/**
* print a HTTP HEADER for HTML, which is encoded in UTF-8
* @return void
**/
function _printHttpStatusCode($code) {
$statusMessage = Context::get('http_status_message');
header("HTTP/1.0 $code $statusMessage");
}
}
?>
/**
* print a HTTP HEADER for HTML, which is encoded in UTF-8
* @return void
*/
function _printHttpStatusCode($code)
{
$statusMessage = Context::get('http_status_message');
header("HTTP/1.0 $code $statusMessage");
}
}
/* End of file DisplayHandler.class.php */
/* Location: ./classes/display/DisplayHandler.class.php */

View file

@ -1,48 +1,54 @@
<?php
class HTMLDisplayHandler {
class HTMLDisplayHandler
{
/**
* Produce HTML compliant content given a module object.\n
* @param ModuleObject $oModule the module object
* @return string compiled template string
**/
*/
function toDoc(&$oModule)
{
$oTemplate = &TemplateHandler::getInstance();
$oTemplate = TemplateHandler::getInstance();
// compile module tpl
// deprecated themes skin
// deprecated themes skin
$template_path = $oModule->getTemplatePath();
if(!is_dir($template_path))
{
if ($oModule->module_info->module == $oModule->module)
$skin = $oModule->origin_module_info->skin;
else
$skin = $oModule->module_config->skin;
if(Context::get('module')!='admin' && strpos(Context::get('act'),'Admin') === false)
if($oModule->module_info->module == $oModule->module)
{
if ($skin && is_string($skin))
$skin = $oModule->origin_module_info->skin;
}
else
{
$skin = $oModule->module_config->skin;
}
if(Context::get('module') != 'admin' && strpos(Context::get('act'), 'Admin') === false)
{
if($skin && is_string($skin))
{
$theme_skin = explode('|@|', $skin);
$template_path = $oModule->getTemplatePath();
if (count($theme_skin) == 2)
if(count($theme_skin) == 2)
{
$theme_path = sprintf('./themes/%s',$theme_skin[0]);
if(substr($theme_path,0,strlen($theme_path)) != $theme_path)
$theme_path = sprintf('./themes/%s', $theme_skin[0]);
if(substr($theme_path, 0, strlen($theme_path)) != $theme_path)
{
$template_path = sprintf('%s/modules/%s/', $theme_path, $theme_skin[1]);
}
}
}
}
else
{
$template_path = $oModule->getTemplatePath();
}
}
else
else
{
$template_path = $oModule->getTemplatePath();
}
@ -53,11 +59,19 @@ class HTMLDisplayHandler {
$output = $oTemplate->compile($template_path, $tpl_file);
// add .x div for adminitration pages
if(Context::getResponseMethod() == 'HTML') {
if(Context::get('module')!='admin' && strpos(Context::get('act'),'Admin')>0) $output = '<div class="x">'.$output.'</div>';
if(Context::get('layout') != 'none') {
if(__DEBUG__==3) $start = getMicroTime();
if(Context::getResponseMethod() == 'HTML')
{
if(Context::get('module') != 'admin' && strpos(Context::get('act'), 'Admin') > 0)
{
$output = '<div class="x">' . $output . '</div>';
}
if(Context::get('layout') != 'none')
{
if(__DEBUG__ == 3)
{
$start = getMicroTime();
}
Context::set('content', $output, false);
@ -67,15 +81,17 @@ class HTMLDisplayHandler {
$edited_layout_file = $oModule->getEditedLayoutFile();
// get the layout information currently requested
$oLayoutModel = &getModel('layout');
$oLayoutModel = getModel('layout');
$layout_info = Context::get('layout_info');
$layout_srl = $layout_info->layout_srl;
// compile if connected to the layout
if($layout_srl > 0){
if($layout_srl > 0)
{
// handle separately if the layout is faceoff
if($layout_info && $layout_info->type == 'faceoff') {
if($layout_info && $layout_info->type == 'faceoff')
{
$oLayoutModel->doActivateFaceOff($layout_info);
Context::set('layout_info', $layout_info);
}
@ -83,15 +99,43 @@ class HTMLDisplayHandler {
// search if the changes CSS exists in the admin layout edit window
$edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl);
if(file_exists($edited_layout_css)) Context::loadFile(array($edited_layout_css,'all','',100));
if(file_exists($edited_layout_css))
{
Context::loadFile(array($edited_layout_css, 'all', '', 100));
}
}
if(!$layout_path)
{
$layout_path = './common/tpl';
}
if(!$layout_file)
{
$layout_file = 'default_layout';
}
if(!$layout_path) $layout_path = './common/tpl';
if(!$layout_file) $layout_file = 'default_layout';
$output = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file);
if(__DEBUG__==3) $GLOBALS['__layout_compile_elapsed__'] = getMicroTime()-$start;
// if popup_layout, remove admin bar.
$realLayoutPath = FileHandler::getRealPath($layout_path);
if(substr($realLayoutPath, -1) != '/')
{
$realLayoutPath .= '/';
}
if(preg_match('/MSIE/i',$_SERVER['HTTP_USER_AGENT']) && (Context::get('_use_ssl') == 'optional' || Context::get('_use_ssl') == 'always')) {
$pathInfo = pathinfo($layout_file);
$onlyLayoutFile = $pathInfo['filename'];
if($realLayoutPath === _XE_PATH_ . 'common/tpl/' && $onlyLayoutFile === 'popup_layout')
{
Context::set('admin_bar', 'false');
}
if(__DEBUG__ == 3)
{
$GLOBALS['__layout_compile_elapsed__'] = getMicroTime() - $start;
}
if(preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT']) && (Context::get('_use_ssl') == 'optional' || Context::get('_use_ssl') == 'always'))
{
Context::addHtmlFooter('<iframe id="xeTmpIframe" name="xeTmpIframe" style="width:1px;height:1px;position:absolute;top:-2px;left:-2px;"></iframe>');
}
}
@ -103,34 +147,46 @@ class HTMLDisplayHandler {
* when display mode is HTML, prepare code before print.
* @param string $output compiled template string
* @return void
**/
function prepareToPrint(&$output) {
if(Context::getResponseMethod() != 'HTML') return;
*/
function prepareToPrint(&$output)
{
if(Context::getResponseMethod() != 'HTML')
{
return;
}
if(__DEBUG__==3) $start = getMicroTime();
if(__DEBUG__ == 3)
{
$start = getMicroTime();
}
// move <style ..></style> in body to the header
$output = preg_replace_callback('!<style(.*?)<\/style>!is', array($this,'_moveStyleToHeader'), $output);
$output = preg_replace_callback('!<style(.*?)>(.*?)<\/style>!is', array($this, '_moveStyleToHeader'), $output);
// move <link ..></link> in body to the header
$output = preg_replace_callback('!<link(.*?)/>!is', array($this, '_moveLinkToHeader'), $output);
// move <meta ../> in body to the header
$output = preg_replace_callback('!<meta(.*?)(?:\/|)>!is', array($this,'_moveMetaToHeader'), $output);
$output = preg_replace_callback('!<meta(.*?)(?:\/|)>!is', array($this, '_moveMetaToHeader'), $output);
// change a meta fine(widget often put the tag like <!--Meta:path--> to the content because of caching)
$output = preg_replace_callback('/<!--(#)?Meta:([a-z0-9\_\/\.\@]+)-->/is', array($this,'_transMeta'), $output);
$output = preg_replace_callback('/<!--(#)?Meta:([a-z0-9\_\/\.\@]+)-->/is', array($this, '_transMeta'), $output);
// handles a relative path generated by using the rewrite module
if(Context::isAllowRewrite()) {
if(Context::isAllowRewrite())
{
$url = parse_url(Context::getRequestUri());
$real_path = $url['path'];
$pattern = '/src=("|\'){1}(\.\/)?(files\/attach|files\/cache|files\/faceOff|files\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\/([^"\']+)\.(jpg|jpeg|png|gif)("|\'){1}/s';
$output = preg_replace($pattern, 'src=$1'.$real_path.'$3/$4.$5$6', $output);
$output = preg_replace($pattern, 'src=$1' . $real_path . '$3/$4.$5$6', $output);
$pattern = '/href=("|\'){1}(\?[^"\']+)/s';
$output = preg_replace($pattern, 'href=$1'.$real_path.'$2', $output);
$output = preg_replace($pattern, 'href=$1' . $real_path . '$2', $output);
if(Context::get('vid')) {
$pattern = '/\/'.Context::get('vid').'\?([^=]+)=/is';
if(Context::get('vid'))
{
$pattern = '/\/' . Context::get('vid') . '\?([^=]+)=/is';
$output = preg_replace($pattern, '/?$1=', $output);
}
}
@ -142,20 +198,23 @@ class HTMLDisplayHandler {
{
$INPUT_ERROR = Context::get('INPUT_ERROR');
$keys = array_keys($INPUT_ERROR);
$keys = '('.implode('|', $keys).')';
$keys = '(' . implode('|', $keys) . ')';
$output = preg_replace_callback('@(<input)([^>]*?)\sname="'.$keys.'"([^>]*?)/?>@is', array(&$this, '_preserveValue'), $output);
$output = preg_replace_callback('@<select[^>]*\sname="'.$keys.'".+</select>@isU', array(&$this, '_preserveSelectValue'), $output);
$output = preg_replace_callback('@<textarea[^>]*\sname="'.$keys.'".+</textarea>@isU', array(&$this, '_preserveTextAreaValue'), $output);
$output = preg_replace_callback('@(<input)([^>]*?)\sname="' . $keys . '"([^>]*?)/?>@is', array(&$this, '_preserveValue'), $output);
$output = preg_replace_callback('@<select[^>]*\sname="' . $keys . '".+</select>@isU', array(&$this, '_preserveSelectValue'), $output);
$output = preg_replace_callback('@<textarea[^>]*\sname="' . $keys . '".+</textarea>@isU', array(&$this, '_preserveTextAreaValue'), $output);
}
if(__DEBUG__==3) $GLOBALS['__trans_content_elapsed__'] = getMicroTime()-$start;
if(__DEBUG__ == 3)
{
$GLOBALS['__trans_content_elapsed__'] = getMicroTime() - $start;
}
// Remove unnecessary information
$output = preg_replace('/member\_\-([0-9]+)/s','member_0',$output);
$output = preg_replace('/member\_\-([0-9]+)/s', 'member_0', $output);
// set icon
$oAdminModel = &getAdminModel('admin');
$oAdminModel = getAdminModel('admin');
$favicon_url = $oAdminModel->getFaviconUrl();
$mobicon_url = $oAdminModel->getMobileIconUrl();
Context::set('favicon_url', $favicon_url);
@ -163,19 +222,20 @@ class HTMLDisplayHandler {
// convert the final layout
Context::set('content', $output);
$oTemplate = &TemplateHandler::getInstance();
if(Mobile::isFromMobilePhone()) {
$oTemplate = TemplateHandler::getInstance();
if(Mobile::isFromMobilePhone())
{
$this->_loadMobileJSCSS();
$output = $oTemplate->compile('./common/tpl', 'mobile_layout');
}
else
{
$this->_loadJSCSS();
$this->_addMetaTag();
$output = $oTemplate->compile('./common/tpl', 'common_layout');
}
// replace the user-defined-language
$oModuleController = &getController('module');
$oModuleController = getController('module');
$oModuleController->replaceDefinedLangCode($output);
}
@ -183,21 +243,39 @@ class HTMLDisplayHandler {
* when display mode is HTML, prepare code before print about <input> tag value.
* @param array $match input value.
* @return string input value.
**/
*/
function _preserveValue($match)
{
$INPUT_ERROR = Context::get('INPUT_ERROR');
$str = $match[1].$match[2].' name="'.$match[3].'"'.$match[4];
$str = $match[1] . $match[2] . ' name="' . $match[3] . '"' . $match[4];
// get type
$type = 'text';
if(preg_match('/\stype="([a-z]+)"/i', $str, $m)) $type = strtolower($m[1]);
if(preg_match('/\stype="([a-z]+)"/i', $str, $m))
{
$type = strtolower($m[1]);
}
switch($type){
switch($type)
{
case 'text':
case 'hidden':
$str = preg_replace('@\svalue="[^"]*?"@', ' ', $str).' value="'.@htmlspecialchars($INPUT_ERROR[$match[3]]).'"';
case 'email':
case 'search':
case 'tel':
case 'url':
case 'email':
case 'datetime':
case 'date':
case 'month':
case 'week':
case 'time':
case 'datetime-local':
case 'number':
case 'range':
case 'color':
$str = preg_replace('@\svalue="[^"]*?"@', ' ', $str) . ' value="' . @htmlspecialchars($INPUT_ERROR[$match[3]]) . '"';
break;
case 'password':
$str = preg_replace('@\svalue="[^"]*?"@', ' ', $str);
@ -205,20 +283,21 @@ class HTMLDisplayHandler {
case 'radio':
case 'checkbox':
$str = preg_replace('@\schecked(="[^"]*?")?@', ' ', $str);
if(@preg_match('@\s(?i:value)="'.$INPUT_ERROR[$match[3]].'"@', $str)) {
if(@preg_match('@\s(?i:value)="' . $INPUT_ERROR[$match[3]] . '"@', $str))
{
$str .= ' checked="checked"';
}
break;
}
return $str.' />';
return $str . ' />';
}
/**
* when display mode is HTML, prepare code before print about <select> tag value.
* @param array $matches select tag.
* @return string select tag.
**/
*/
function _preserveSelectValue($matches)
{
$INPUT_ERROR = Context::get('INPUT_ERROR');
@ -232,22 +311,22 @@ class HTMLDisplayHandler {
{
return $matches[0];
}
$m[0][$key] = preg_replace('@(\svalue=".*?")@is', '$1 selected="selected"', $m[0][$key]);
return $mm[0].implode('', $m[0]).'</select>';
return $mm[0] . implode('', $m[0]) . '</select>';
}
/**
* when display mode is HTML, prepare code before print about <textarea> tag value.
* @param array $matches textarea tag information.
* @return string textarea tag
**/
*/
function _preserveTextAreaValue($matches)
{
$INPUT_ERROR = Context::get('INPUT_ERROR');
preg_match('@<textarea.*?>@is', $matches[0], $mm);
return $mm[0].$INPUT_ERROR[$matches[1]].'</textarea>';
return $mm[0] . $INPUT_ERROR[$matches[1]] . '</textarea>';
}
/**
@ -255,8 +334,24 @@ class HTMLDisplayHandler {
* printed inside <header></header> later.
* @param array $matches
* @return void
**/
function _moveStyleToHeader($matches) {
*/
function _moveStyleToHeader($matches)
{
if(isset($matches[1]) && stristr($matches[1], 'scoped'))
{
return $matches[0];
}
Context::addHtmlHeader($matches[0]);
}
/**
* add html link code extracted from html body to Context, which will be
* printed inside <header></header> later.
* @param array $matches
* @return void
*/
function _moveLinkToHeader($matches)
{
Context::addHtmlHeader($matches[0]);
}
@ -265,8 +360,9 @@ class HTMLDisplayHandler {
* printed inside <header></header> later.
* @param array $matches
* @return void
**/
function _moveMetaToHeader($matches) {
*/
function _moveMetaToHeader($matches)
{
Context::addHtmlHeader($matches[0]);
}
@ -274,59 +370,89 @@ class HTMLDisplayHandler {
* add given .css or .js file names in widget code to Context
* @param array $matches
* @return void
**/
function _transMeta($matches) {
if($matches[1]) return '';
*/
function _transMeta($matches)
{
if($matches[1])
{
return '';
}
Context::loadFile($matches[2]);
}
/**
* import basic .js files.
* @return void
**/
*/
function _loadJSCSS()
{
$oContext =& Context::getInstance();
$lang_type = Context::getLangType();
$oContext = Context::getInstance();
$lang_type = Context::getLangType();
// add common JS/CSS files
if(__DEBUG__) {
if(__DEBUG__)
{
$oContext->loadFile(array('./common/js/jquery.js', 'head', '', -100000), true);
$oContext->loadFile(array('./common/js/x.js', 'head', '', -100000), true);
$oContext->loadFile(array('./common/js/common.js', 'head', '', -100000), true);
$oContext->loadFile(array('./common/js/js_app.js', 'head', '', -100000), true);
$oContext->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000), true);
$oContext->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000), true);
$oContext->loadFile(array('./common/css/xe.css', 'all', '', -100000), true);
} else {
$oContext->loadFile(array('./common/css/xe.css', '', '', -1000000), true);
}
else
{
$oContext->loadFile(array('./common/js/jquery.min.js', 'head', '', -100000), true);
$oContext->loadFile(array('./common/js/x.min.js', 'head', '', -100000), true);
$oContext->loadFile(array('./common/js/xe.min.js', 'head', '', -100000), true);
$oContext->loadFile(array('./common/css/xe.min.css', 'all', '', -100000), true);
$oContext->loadFile(array('./common/css/xe.min.css', '', '', -1000000), true);
}
// for admin page, add admin css
if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0){
if(__DEBUG__) {
$oContext->loadFile(array('./modules/admin/tpl/css/admin.css', 'all', '', 100000), true);
$oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.css", 'all', '', 100000), true);
if(Context::get('module') == 'admin' || strpos(Context::get('act'), 'Admin') > 0)
{
if(__DEBUG__)
{
$oContext->loadFile(array('./modules/admin/tpl/css/admin.css', '', '', 10), true);
$oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.css", '', '', 10), true);
$oContext->loadFile(array("./modules/admin/tpl/css/admin.iefix.css", '', 'ie', 10), true);
$oContext->loadFile('./modules/admin/tpl/js/admin.js', true);
} else {
$oContext->loadFile(array('./modules/admin/tpl/css/admin.min.css', 'all', '', 100000), true);
$oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.css", 'all', '',10000), true);
$oContext->loadFile(array('./modules/admin/tpl/css/admin.bootstrap.css', '', '', 1), true);
$oContext->loadFile(array('./modules/admin/tpl/js/jquery.tmpl.js', '', '', 1), true);
$oContext->loadFile(array('./modules/admin/tpl/js/jquery.jstree.js', '', '', 1), true);
}
else
{
$oContext->loadFile(array('./modules/admin/tpl/css/admin.min.css', '', '', 10), true);
$oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.css", '', '', 10), true);
$oContext->loadFile(array("./modules/admin/tpl/css/admin.iefix.min.css", '', 'ie', 10), true);
$oContext->loadFile('./modules/admin/tpl/js/admin.min.js', true);
$oContext->loadFile(array('./modules/admin/tpl/css/admin.bootstrap.min.css', '', '', 1), true);
$oContext->loadFile(array('./modules/admin/tpl/js/jquery.tmpl.js', '', '', 1), true);
$oContext->loadFile(array('./modules/admin/tpl/js/jquery.jstree.js', '', '', 1), true);
}
}
}
/**
* add meta tag.
* @return void
**/
function _addMetaTag()
* import basic .js files for mobile
*/
private function _loadMobileJSCSS()
{
$oContext =& Context::getInstance();
$oContext->addMetaTag('Content-Type', 'text/html; charset=UTF-8', true);
$oContext->addMetaTag('imagetoolbar', 'no');
$oContext = Context::getInstance();
$lang_type = Context::getLangType();
// add common JS/CSS files
if(__DEBUG__)
{
$oContext->loadFile(array('./common/css/mobile.css', '', '', -1000000), true);
}
else
{
$oContext->loadFile(array('./common/css/mobile.min.css', '', '', -1000000), true);
}
}
}
/* End of file HTMLDisplayHandler.class.php */
/* Location: ./classes/display/HTMLDisplayHandler.class.php */

View file

@ -0,0 +1,23 @@
<?php
class JSCallbackDisplayHandler
{
/**
* Produce JSCallback compliant content given a module object.\n
* @param ModuleObject $oModule the module object
* @return string
*/
function toDoc(&$oModule)
{
$variables = $oModule->getVariables();
$variables['error'] = $oModule->getError();
$variables['message'] = $oModule->getMessage();
$json = str_replace(array("\r\n", "\n", "\t"), array('\n', '\n', '\t'), json_encode2($variables));
$output = sprintf('<script>%s(%s);</script>', Context::getJSCallbackFunc(), $json);
return $output;
}
}
/* End of file JSCallback.class.php */
/* Location: ./classes/display/JSCallback.class.php */

View file

@ -1,17 +1,22 @@
<?php
class JSONDisplayHandler {
class JSONDisplayHandler
{
/**
* Produce JSON compliant content given a module object.\n
* @param ModuleObject $oModule the module object
* @return string
**/
*/
function toDoc(&$oModule)
{
$variables = $oModule->getVariables();
$variables['error'] = $oModule->getError();
$variables['message'] = $oModule->getMessage();
$json = str_replace(array("\r\n","\n","\t"),array('\n','\n','\t'),json_encode2($variables));
$json = str_replace(array("\r\n", "\n", "\t"), array('\n', '\n', '\t'), json_encode2($variables));
return $json;
}
}
/* End of file JSONDisplayHandler.class.php */
/* Location: ./classes/display/JSONDisplayHandler.class.php */

View file

@ -1,12 +1,13 @@
<?php
class VirtualXMLDisplayHandler {
class VirtualXMLDisplayHandler
{
/**
* Produce virtualXML compliant content given a module object.\n
* @param ModuleObject $oModule the module object
* @return string
**/
*/
function toDoc(&$oModule)
{
$error = $oModule->getError();
@ -14,25 +15,49 @@ class VirtualXMLDisplayHandler {
$redirect_url = $oModule->get('redirect_url');
$request_uri = Context::get('xeRequestURI');
$request_url = Context::get('xeVirtualRequestUrl');
if(substr($request_url,-1)!='/') $request_url .= '/';
if($error === 0) {
if($message != 'success') $output->message = $message;
if($redirect_url) $output->url = $redirect_url;
else $output->url = $request_uri;
} else {
if($message != 'fail') $output->message = $message;
if(substr($request_url, -1) != '/')
{
$request_url .= '/';
}
$html = '<script type="text/javascript">'."\n";
if($output->message) $html .= 'alert("'.$output->message.'");'."\n";
if($output->url) {
$url = preg_replace('/#(.+)$/i','',$output->url);
$html .= 'self.location.href = "'.$request_url.'common/tpl/redirect.html?redirect_url='.urlencode($url).'";'."\n";
if($error === 0)
{
if($message != 'success')
{
$output->message = $message;
}
if($redirect_url)
{
$output->url = $redirect_url;
}
else
{
$output->url = $request_uri;
}
}
$html .= '</script>'."\n";
else
{
if($message != 'fail')
{
$output->message = $message;
}
}
$html = '<script>' . "\n";
if($output->message)
{
$html .= 'alert("' . $output->message . '");' . "\n";
}
if($output->url)
{
$url = preg_replace('/#(.+)$/i', '', $output->url);
$html .= 'self.location.href = "' . $request_url . 'common/tpl/redirect.html?redirect_url=' . urlencode($url) . '";' . "\n";
}
$html .= '</script>' . "\n";
return $html;
}
}
?>
}
/* End of file VirtualXMLDisplayHandler.class.php */
/* Location: ./classes/display/VirtualXMLDisplayHandler.class.php */

View file

@ -1,18 +1,20 @@
<?php
class XMLDisplayHandler {
class XMLDisplayHandler
{
/**
* Produce XML compliant content given a module object.\n
* @param ModuleObject $oModule the module object
* @return string
**/
*/
function toDoc(&$oModule)
{
$variables = $oModule->getVariables();
$xmlDoc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response>\n";
$xmlDoc .= sprintf("<error>%s</error>\n",$oModule->getError());
$xmlDoc .= sprintf("<message>%s</message>\n",str_replace(array('<','>','&'),array('&lt;','&gt;','&amp;'),$oModule->getMessage()));
$xmlDoc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response>\n";
$xmlDoc .= sprintf("<error>%s</error>\n", $oModule->getError());
$xmlDoc .= sprintf("<message>%s</message>\n", str_replace(array('<', '>', '&'), array('&lt;', '&gt;', '&amp;'), $oModule->getMessage()));
$xmlDoc .= $this->_makeXmlDoc($variables);
@ -25,22 +27,40 @@ class XMLDisplayHandler {
* produce XML code given variable object\n
* @param object $obj
* @return string
**/
function _makeXmlDoc($obj) {
if(!count($obj)) return;
*/
function _makeXmlDoc($obj)
{
if(!count($obj))
{
return;
}
$xmlDoc = '';
foreach($obj as $key => $val) {
if(is_numeric($key)) $key = 'item';
foreach($obj as $key => $val)
{
if(is_numeric($key))
{
$key = 'item';
}
if(is_string($val)) $xmlDoc .= sprintf('<%s><![CDATA[%s]]></%s>%s', $key, $val, $key,"\n");
else if(!is_array($val) && !is_object($val)) $xmlDoc .= sprintf('<%s>%s</%s>%s', $key, $val, $key,"\n");
else $xmlDoc .= sprintf('<%s>%s%s</%s>%s',$key, "\n", $this->_makeXmlDoc($val), $key, "\n");
if(is_string($val))
{
$xmlDoc .= sprintf('<%s><![CDATA[%s]]></%s>%s', $key, $val, $key, "\n");
}
else if(!is_array($val) && !is_object($val))
{
$xmlDoc .= sprintf('<%s>%s</%s>%s', $key, $val, $key, "\n");
}
else
{
$xmlDoc .= sprintf('<%s>%s%s</%s>%s', $key, "\n", $this->_makeXmlDoc($val), $key, "\n");
}
}
return $xmlDoc;
}
}
?>
}
/* End of file XMLDisplayHandler.class.php */
/* Location: ./classes/display/XMLDisplayHandler.class.php */

View file

@ -1,29 +1,35 @@
<?php
/**
* Superclass of the edit component.
* Set up the component variables
*
* @class EditorHandler
* @author NHN (developers@xpressengine.com)
**/
class EditorHandler extends Object {
/**
* Superclass of the edit component.
* Set up the component variables
*
* @class EditorHandler
* @author NHN (developers@xpressengine.com)
*/
class EditorHandler extends Object
{
/**
* set the xml and other information of the component
* @param object $info editor information
* @return void
**/
function setInfo($info) {
Context::set('component_info', $info);
/**
* set the xml and other information of the component
* @param object $info editor information
* @return void
* */
function setInfo($info)
{
Context::set('component_info', $info);
if(!$info->extra_vars) return;
if(!$info->extra_vars)
{
return;
}
foreach($info->extra_vars as $key => $val) {
$this->{$key} = trim($val->value);
}
}
foreach($info->extra_vars as $key => $val)
{
$this->{$key} = trim($val->value);
}
}
}
?>
}
/* End of file EditorHandler.class.php */
/* Location: ./classes/editor/EditorHandler.class.php */

View file

@ -1,397 +1,510 @@
<?php
/**
* A class to handle extra variables used in posts, member and others
/**
* A class to handle extra variables used in posts, member and others
*
* @author NHN (developers@xpressengine.com)
*/
class ExtraVar
{
/**
* sequence of module
* @var int
*/
var $module_srl = null;
/**
* Current module's Set of ExtraItem
* @var ExtraItem[]
*/
var $keys = null;
/**
* Get instance of ExtraVar (singleton)
*
* @author NHN (developers@xpressengine.com)
**/
class ExtraVar {
* @param int $module_srl Sequence of module
* @return ExtraVar
*/
function &getInstance($module_srl)
{
return new ExtraVar($module_srl);
}
/**
* sequence of module
* @var int
*/
var $module_srl = null;
/**
* Current module's Set of ExtraItem
* @var ExtraItem[]
*/
var $keys = null;
/**
* Get instance of ExtraVar (singleton)
*
* @param int $module_srl Sequence of module
* @return ExtraVar
**/
function &getInstance($module_srl) {
return new ExtraVar($module_srl);
}
/**
* Constructor
*
* @param int $module_srl Sequence of module
* @return void
**/
function ExtraVar($module_srl) {
$this->module_srl = $module_srl;
}
/**
* Register a key of extra variable
*
* @param object[] $extra_keys Array of extra variable. A value of array is object that contains module_srl, idx, name, default, desc, is_required, search, value, eid.
* @return void
**/
function setExtraVarKeys($extra_keys) {
if(!is_array($extra_keys) || !count($extra_keys)) return;
foreach($extra_keys as $key => $val) {
$obj = null;
$obj = new ExtraItem($val->module_srl, $val->idx, $val->name, $val->type, $val->default, $val->desc, $val->is_required, $val->search, $val->value, $val->eid);
$this->keys[$val->idx] = $obj;
}
}
/**
* Returns an array of ExtraItem
*
* @return ExtraItem[]
**/
function getExtraVars() {
return $this->keys;
}
}
/**
* Each value of the extra vars
/**
* Constructor
*
* @author NHN (developers@xpressengine.com)
**/
class ExtraItem {
/**
* Sequence of module
* @var int
*/
var $module_srl = 0;
* @param int $module_srl Sequence of module
* @return void
*/
function ExtraVar($module_srl)
{
$this->module_srl = $module_srl;
}
/**
* Index of extra variable
* @var int
*/
var $idx = 0;
/**
* Register a key of extra variable
*
* @param object[] $extra_keys Array of extra variable. A value of array is object that contains module_srl, idx, name, default, desc, is_required, search, value, eid.
* @return void
*/
function setExtraVarKeys($extra_keys)
{
if(!is_array($extra_keys) || !count($extra_keys))
{
return;
}
/**
* Name of extra variable
* @var string
*/
var $name = 0;
foreach($extra_keys as $key => $val)
{
$obj = null;
$obj = new ExtraItem($val->module_srl, $val->idx, $val->name, $val->type, $val->default, $val->desc, $val->is_required, $val->search, $val->value, $val->eid);
$this->keys[$val->idx] = $obj;
}
}
/**
* Type of extra variable
* @var string text, homepage, email_address, tel, textarea, checkbox, date, select, radio, kr_zip
*/
var $type = 'text';
/**
* Returns an array of ExtraItem
*
* @return ExtraItem[]
*/
function getExtraVars()
{
return $this->keys;
}
/**
* Default values
* @var string[]
*/
var $default = null;
}
/**
* Description
* @var string
*/
var $desc = '';
/**
* Each value of the extra vars
*
* @author NHN (developers@xpressengine.com)
*/
class ExtraItem
{
/**
* Whether required or not requred this extra variable
* @var string Y, N
*/
var $is_required = 'N';
/**
* Sequence of module
* @var int
*/
var $module_srl = 0;
/**
* Whether can or can not search this extra variable
* @var string Y, N
*/
var $search = 'N';
/**
* Index of extra variable
* @var int
*/
var $idx = 0;
/**
* Value
* @var string
*/
var $value = null;
/**
* Name of extra variable
* @var string
*/
var $name = 0;
/**
* Unique id of extra variable in module
* @var string
*/
var $eid = '';
/**
* Type of extra variable
* @var string text, homepage, email_address, tel, textarea, checkbox, date, select, radio, kr_zip
*/
var $type = 'text';
/**
* Constructor
*
* @param int $module_srl Sequence of module
* @param int $idx Index of extra variable
* @param string $type Type of extra variable. text, homepage, email_address, tel, textarea, checkbox, date, sleect, radio, kr_zip
* @param string[] $default Default values
* @param string $desc Description
* @param string $is_required Whether required or not requred this extra variable. Y, N
* @param string $search Whether can or can not search this extra variable
* @param string $value Value
* @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 = '') {
if(!$idx) return;
$this->module_srl = $module_srl;
$this->idx = $idx;
$this->name = $name;
$this->type = $type;
$this->default = $default;
$this->desc = $desc;
$this->is_required = $is_required;
$this->search = $search;
$this->value = $value;
$this->eid = $eid;
}
/**
* Default values
* @var string[]
*/
var $default = null;
/**
* Sets Value
*
* @param string $value The value to set
* @return void
**/
function setValue($value) {
$this->value = $value;
}
/**
* Description
* @var string
*/
var $desc = '';
/**
* Returns a given value converted based on its type
*
* @param string $type Type of variable
* @param string $value Value
* @return string Returns a converted value
**/
function _getTypeValue($type, $value) {
$value = trim($value);
if(!isset($value)) return;
switch($type) {
case 'homepage' :
if($value && !preg_match('/^([a-z]+):\/\//i',$value)) $value = 'http://'.$value;
return htmlspecialchars($value);
break;
case 'tel' :
if(is_array($value)) $values = $value;
elseif(strpos($value,'|@|')!==false) $values = explode('|@|', $value);
elseif(strpos($value,',')!==false) $values = explode(',', $value);
$values[0] = $values[0];
$values[1] = $values[1];
$values[2] = $values[2];
return $values;
break;
break;
case 'checkbox' :
case 'radio' :
case 'select' :
if(is_array($value)) $values = $value;
elseif(strpos($value,'|@|')!==false) $values = explode('|@|', $value);
elseif(strpos($value,',')!==false) $values = explode(',', $value);
else $values = array($value);
for($i=0;$i<count($values);$i++) $values[$i] = htmlspecialchars($values[$i]);
return $values;
break;
case 'kr_zip' :
if(is_array($value)) $values = $value;
elseif(strpos($value,'|@|')!==false) $values = explode('|@|', $value);
elseif(strpos($value,',')!==false) $values = explode(',', $value);
else $values = array($value);
return $values;
break;
//case 'date' :
//case 'email_address' :
//case 'text' :
//case 'textarea' :
default :
return htmlspecialchars($value);
break;
}
}
/**
* Whether required or not requred this extra variable
* @var string Y, N
*/
var $is_required = 'N';
/**
* Returns a value for HTML
*
* @return string Returns a value expressed in HTML.
**/
function getValueHTML() {
$value = $this->_getTypeValue($this->type, $this->value);
switch($this->type) {
case 'homepage' :
return ($value)?(sprintf('<a href="%s" target="_blank">%s</a>', $value, strlen($value)>60?substr($value,0,40).'...'.substr($value,-10):$value)):"";
case 'email_address' :
return ($value)?sprintf('<a href="mailto:%s">%s</a>', $value, $value):"";
break;
case 'tel' :
return sprintf('%s - %s - %s', $value[0],$value[1],$value[2]);
break;
case 'textarea' :
return nl2br($value);
break;
case 'checkbox' :
if(is_array($value)) return implode(', ',$value);
else return $value;
break;
case 'date' :
return zdate($value,"Y-m-d");
break;
case 'select' :
case 'radio' :
if(is_array($value)) return implode(', ',$value);
else return $value;
break;
case 'kr_zip' :
if(is_array($value)) return implode(' ',$value);
else return $value;
break;
// case 'text' :
default :
return $value;
}
}
/**
* Whether can or can not search this extra variable
* @var string Y, N
*/
var $search = 'N';
/**
* Returns a form based on its type
*
* @return string Returns a form html.
**/
function getFormHTML() {
static $id_num = 1000;
/**
* Value
* @var string
*/
var $value = null;
$type = $this->type;
$name = $this->name;
$value = $this->_getTypeValue($this->type, $this->value);
$default = $this->_getTypeValue($this->type, $this->default);
$column_name = 'extra_vars'.$this->idx;
$tmp_id = $column_name.'-'.$id_num++;
/**
* Unique id of extra variable in module
* @var string
*/
var $eid = '';
$buff = '';
switch($type) {
// Homepage
case 'homepage' :
$buff .= '<input type="text" name="'.$column_name.'" value="'.$value.'" class="homepage" />';
break;
// Email Address
case 'email_address' :
$buff .= '<input type="text" name="'.$column_name.'" value="'.$value.'" class="email_address" />';
break;
// Phone Number
case 'tel' :
$buff .=
'<input type="text" name="'.$column_name.'[]" value="'.$value[0].'" size="4" maxlength="4" class="tel" />'.
'<input type="text" name="'.$column_name.'[]" value="'.$value[1].'" size="4" maxlength="4" class="tel" />'.
'<input type="text" name="'.$column_name.'[]" value="'.$value[2].'" size="4" maxlength="4" class="tel" />';
break;
/**
* Constructor
*
* @param int $module_srl Sequence of module
* @param int $idx Index of extra variable
* @param string $type Type of extra variable. text, homepage, email_address, tel, textarea, checkbox, date, sleect, radio, kr_zip
* @param string[] $default Default values
* @param string $desc Description
* @param string $is_required Whether required or not requred this extra variable. Y, N
* @param string $search Whether can or can not search this extra variable
* @param string $value Value
* @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 = '')
{
if(!$idx)
{
return;
}
// textarea
case 'textarea' :
$buff .= '<textarea name="'.$column_name.'" rows="8" cols="42">'.$value.'</textarea>';
break;
// multiple choice
case 'checkbox' :
$buff .= '<ul>';
foreach($default as $v) {
if($value && in_array(trim($v), $value)) $checked = ' checked="checked"';
else $checked = '';
$this->module_srl = $module_srl;
$this->idx = $idx;
$this->name = $name;
$this->type = $type;
$this->default = $default;
$this->desc = $desc;
$this->is_required = $is_required;
$this->search = $search;
$this->value = $value;
$this->eid = $eid;
}
// Temporary ID for labeling
$tmp_id = $column_name.'-'.$id_num++;
/**
* Sets Value
*
* @param string $value The value to set
* @return void
*/
function setValue($value)
{
$this->value = $value;
}
$buff .='<li><input type="checkbox" name="'.$column_name.'[]" id="'.$tmp_id.'" value="'.htmlspecialchars($v).'" '.$checked.' /><label for="'.$tmp_id.'">'.$v.'</label></li>';
}
$buff .= '</ul>';
break;
// single choice
case 'select' :
$buff .= '<select name="'.$column_name.'" class="select">';
foreach($default as $v) {
if($value && in_array($v,$value)) $selected = ' selected="selected"';
else $selected = '';
$buff .= '<option value="'.$v.'" '.$selected.'>'.$v.'</option>';
}
$buff .= '</select>';
break;
/**
* Returns a given value converted based on its type
*
* @param string $type Type of variable
* @param string $value Value
* @return string Returns a converted value
*/
function _getTypeValue($type, $value)
{
$value = trim($value);
if(!isset($value))
{
return;
}
// radio
case 'radio' :
$buff .= '<ul>';
foreach($default as $v) {
if($value && in_array($v,$value)) $checked = ' checked="checked"';
else $checked = '';
switch($type)
{
case 'homepage' :
if($value && !preg_match('/^([a-z]+):\/\//i', $value))
{
$value = 'http://' . $value;
}
return htmlspecialchars($value);
// Temporary ID for labeling
$tmp_id = $column_name.'-'.$id_num++;
case 'tel' :
if(is_array($value))
{
$values = $value;
}
elseif(strpos($value, '|@|') !== FALSE)
{
$values = explode('|@|', $value);
}
elseif(strpos($value, ',') !== FALSE)
{
$values = explode(',', $value);
}
$buff .= '<li><input type="radio" name="'.$column_name.'" id="'.$tmp_id.'" '.$checked.' value="'.$v.'" class="radio" /><label for="'.$tmp_id.'">'.$v.'</label></li>';
}
$buff .= '</ul>';
break;
// date
case 'date' :
// datepicker javascript plugin load
Context::loadJavascriptPlugin('ui.datepicker');
$values[0] = $values[0];
$values[1] = $values[1];
$values[2] = $values[2];
return $values;
$buff .=
'<input type="hidden" name="'.$column_name.'" value="'.$value.'" />'.
'<input type="text" id="date_'.$column_name.'" value="'.zdate($value,'Y-m-d').'" class="date" /> <input type="button" value="' . Context::getLang('cmd_delete') . '" id="dateRemover_' . $column_name . '" />'."\n".
'<script type="text/javascript">'."\n".
'(function($){'."\n".
' $(function(){'."\n".
' var option = { dateFormat: "yy-mm-dd", changeMonth:true, changeYear:true, gotoCurrent: false,yearRange:\'-100:+10\', onSelect:function(){'."\n".
' $(this).prev(\'input[type="hidden"]\').val(this.value.replace(/-/g,""))}'."\n".
' };'."\n".
' $.extend(option,$.datepicker.regional[\''.Context::getLangType().'\']);'."\n".
' $("#date_'.$column_name.'").datepicker(option);'."\n".
' $("#dateRemover_' . $column_name . '").click(function(){' . "\n" .
' $(this).siblings("input").val("");' . "\n" .
' return false;' . "\n" .
' })' . "\n" .
' });'."\n".
'})(jQuery);'."\n".
'</script>';
break;
// address
case "kr_zip" :
// krzip address javascript plugin load
Context::loadJavascriptPlugin('ui.krzip');
case 'checkbox' :
case 'radio' :
case 'select' :
if(is_array($value))
{
$values = $value;
}
elseif(strpos($value, '|@|') !== FALSE)
{
$values = explode('|@|', $value);
}
elseif(strpos($value, ',') !== FALSE)
{
$values = explode(',', $value);
}
else
{
$values = array($value);
}
$buff .=
'<div id="addr_searched_'.$column_name.'" style="display:'.($value[0]?'block':'none').';">'.
'<input type="text" readonly="readonly" name="'.$column_name.'[]" value="'.$value[0].'" class="address" />'.
'<a href="#" onclick="doShowKrZipSearch(this, \''.$column_name.'\'); return false;" class="button red"><span>'.Context::getLang('cmd_cancel').'</span></a>'.
'</div>'.
for($i = 0; $i < count($values); $i++)
{
$values[$i] = htmlspecialchars($values[$i]);
}
'<div id="addr_list_'.$column_name.'" style="display:none;">'.
'<select name="addr_list_'.$column_name.'"></select>'.
'<a href="#" onclick="doSelectKrZip(this, \''.$column_name.'\'); return false;" class="button blue"><span>'.Context::getLang('cmd_select').'</span></a>'.
'<a href="#" onclick="doHideKrZipList(this, \''.$column_name.'\'); return false;" class="button red"><span>'.Context::getLang('cmd_cancel').'</span></a>'.
'</div>'.
return $values;
'<div id="addr_search_'.$column_name.'" style="display:'.($value[0]?'none':'block').'">'.
'<input type="text" name="addr_search_'.$column_name.'" class="address" value="" />'.
'<a href="#" onclick="doSearchKrZip(this, \''.$column_name.'\'); return false;" class="button green"><span>'.Context::getLang('cmd_search').'</span></a>'.
'</div>'.
case 'kr_zip' :
if(is_array($value))
{
$values = $value;
}
elseif(strpos($value, '|@|') !== false)
{
$values = explode('|@|', $value);
}
elseif(strpos($value, ',') !== false)
{
$values = explode(',', $value);
}
else
{
$values = array($value);
}
'<input type="text" name="'.$column_name.'[]" value="'.htmlspecialchars($value[1]).'" class="address" />'.
'';
break;
// General text
default :
$buff .=' <input type="text" name="'.$column_name.'" value="'.($value ? $value : $default).'" class="text" />';
break;
}
if($this->desc) $buff .= '<p>'.$this->desc.'</p>';
return $buff;
}
}
?>
return $values;
//case 'date' :
//case 'email_address' :
//case 'text' :
//case 'textarea' :
default :
return htmlspecialchars($value);
}
}
/**
* Returns a value for HTML
*
* @return string Returns a value expressed in HTML.
*/
function getValueHTML()
{
$value = $this->_getTypeValue($this->type, $this->value);
switch($this->type)
{
case 'homepage' :
return ($value) ? (sprintf('<a href="%s" target="_blank">%s</a>', $value, strlen($value) > 60 ? substr($value, 0, 40) . '...' . substr($value, -10) : $value)) : "";
case 'email_address' :
return ($value) ? sprintf('<a href="mailto:%s">%s</a>', $value, $value) : "";
case 'tel' :
return sprintf('%s - %s - %s', $value[0], $value[1], $value[2]);
case 'textarea' :
return nl2br($value);
case 'checkbox' :
if(is_array($value))
{
return implode(', ', $value);
}
else
{
return $value;
}
case 'date' :
return zdate($value, "Y-m-d");
case 'select' :
case 'radio' :
if(is_array($value))
{
return implode(', ', $value);
}
else
{
return $value;
}
case 'kr_zip' :
if(is_array($value))
{
return implode(' ', $value);
}
else
{
return $value;
}
// case 'text' :
default :
return $value;
}
}
/**
* Returns a form based on its type
*
* @return string Returns a form html.
*/
function getFormHTML()
{
static $id_num = 1000;
$type = $this->type;
$name = $this->name;
$value = $this->_getTypeValue($this->type, $this->value);
$default = $this->_getTypeValue($this->type, $this->default);
$column_name = 'extra_vars' . $this->idx;
$tmp_id = $column_name . '-' . $id_num++;
$buff = '';
switch($type)
{
// Homepage
case 'homepage' :
$buff .= '<input type="text" name="' . $column_name . '" value="' . $value . '" class="homepage" />';
break;
// Email Address
case 'email_address' :
$buff .= '<input type="text" name="' . $column_name . '" value="' . $value . '" class="email_address" />';
break;
// Phone Number
case 'tel' :
$buff .=
'<input type="text" name="' . $column_name . '[]" value="' . $value[0] . '" size="4" maxlength="4" class="tel" />' .
'<input type="text" name="' . $column_name . '[]" value="' . $value[1] . '" size="4" maxlength="4" class="tel" />' .
'<input type="text" name="' . $column_name . '[]" value="' . $value[2] . '" size="4" maxlength="4" class="tel" />';
break;
// textarea
case 'textarea' :
$buff .= '<textarea name="' . $column_name . '" rows="8" cols="42">' . $value . '</textarea>';
break;
// multiple choice
case 'checkbox' :
$buff .= '<ul>';
foreach($default as $v)
{
if($value && in_array(trim($v), $value))
{
$checked = ' checked="checked"';
}
else
{
$checked = '';
}
// Temporary ID for labeling
$tmp_id = $column_name . '-' . $id_num++;
$buff .='<li><input type="checkbox" name="' . $column_name . '[]" id="' . $tmp_id . '" value="' . htmlspecialchars($v) . '" ' . $checked . ' /><label for="' . $tmp_id . '">' . $v . '</label></li>';
}
$buff .= '</ul>';
break;
// single choice
case 'select' :
$buff .= '<select name="' . $column_name . '" class="select">';
foreach($default as $v)
{
if($value && in_array(trim($v), $value))
{
$selected = ' selected="selected"';
}
else
{
$selected = '';
}
$buff .= '<option value="' . $v . '" ' . $selected . '>' . $v . '</option>';
}
$buff .= '</select>';
break;
// radio
case 'radio' :
$buff .= '<ul>';
foreach($default as $v)
{
if($value && in_array(trim($v), $value))
{
$checked = ' checked="checked"';
}
else
{
$checked = '';
}
// Temporary ID for labeling
$tmp_id = $column_name . '-' . $id_num++;
$buff .= '<li><input type="radio" name="' . $column_name . '" id="' . $tmp_id . '" ' . $checked . ' value="' . $v . '" class="radio" /><label for="' . $tmp_id . '">' . $v . '</label></li>';
}
$buff .= '</ul>';
break;
// date
case 'date' :
// datepicker javascript plugin load
Context::loadJavascriptPlugin('ui.datepicker');
$buff .=
'<input type="hidden" name="' . $column_name . '" value="' . $value . '" />' .
'<input type="text" id="date_' . $column_name . '" value="' . zdate($value, 'Y-m-d') . '" class="date" /> <input type="button" value="' . Context::getLang('cmd_delete') . '" id="dateRemover_' . $column_name . '" />' . "\n" .
'<script>' . "\n" .
'(function($){' . "\n" .
' $(function(){' . "\n" .
' var option = { dateFormat: "yy-mm-dd", changeMonth:true, changeYear:true, gotoCurrent: false,yearRange:\'-100:+10\', onSelect:function(){' . "\n" .
' $(this).prev(\'input[type="hidden"]\').val(this.value.replace(/-/g,""))}' . "\n" .
' };' . "\n" .
' $.extend(option,$.datepicker.regional[\'' . Context::getLangType() . '\']);' . "\n" .
' $("#date_' . $column_name . '").datepicker(option);' . "\n" .
' $("#dateRemover_' . $column_name . '").click(function(){' . "\n" .
' $(this).siblings("input").val("");' . "\n" .
' return false;' . "\n" .
' })' . "\n" .
' });' . "\n" .
'})(jQuery);' . "\n" .
'</script>';
break;
// address
case "kr_zip" :
// krzip address javascript plugin load
Context::loadJavascriptPlugin('ui.krzip');
$buff .=
'<div id="addr_searched_' . $column_name . '" style="display:' . ($value[0] ? 'block' : 'none') . ';">' .
'<input type="text" readonly="readonly" name="' . $column_name . '[]" value="' . $value[0] . '" class="address" />' .
'<a href="#" onclick="doShowKrZipSearch(this, \'' . $column_name . '\'); return false;" class="button red"><span>' . Context::getLang('cmd_cancel') . '</span></a>' .
'</div>' .
'<div id="addr_list_' . $column_name . '" style="display:none;">' .
'<select name="addr_list_' . $column_name . '"></select>' .
'<a href="#" onclick="doSelectKrZip(this, \'' . $column_name . '\'); return false;" class="button blue"><span>' . Context::getLang('cmd_select') . '</span></a>' .
'<a href="#" onclick="doHideKrZipList(this, \'' . $column_name . '\'); return false;" class="button red"><span>' . Context::getLang('cmd_cancel') . '</span></a>' .
'</div>' .
'<div id="addr_search_' . $column_name . '" style="display:' . ($value[0] ? 'none' : 'block') . '">' .
'<input type="text" name="addr_search_' . $column_name . '" class="address" value="" />' .
'<a href="#" onclick="doSearchKrZip(this, \'' . $column_name . '\'); return false;" class="button green"><span>' . Context::getLang('cmd_search') . '</span></a>' .
'</div>' .
'<input type="text" name="' . $column_name . '[]" value="' . htmlspecialchars($value[1]) . '" class="address" />' .
'';
break;
// General text
default :
$buff .=' <input type="text" name="' . $column_name . '" value="' . ($value ? $value : $default) . '" class="text" />';
break;
}
if($this->desc)
{
$buff .= '<p>' . htmlspecialchars($this->desc) . '</p>';
}
return $buff;
}
}
/* End of file ExtraVar.class.php */
/* Location: ./classes/extravar/ExtraVar.class.php */

File diff suppressed because it is too large Load diff

View file

@ -1,22 +1,24 @@
<?php
/**
* File abstraction class
*
* @author NHN (developers@xpressengine.com)
**/
*/
class FileObject extends Object
{
/**
* File descriptor
* @var resource
*/
var $fp = null;
var $fp = NULL;
/**
* File path
* @var string
*/
var $path = null;
var $path = NULL;
/**
* File open mode
@ -30,10 +32,13 @@ class FileObject extends Object
* @param string $path Path of target file
* @param string $mode File open mode
* @return void
**/
*/
function FileObject($path, $mode)
{
if($path != null) $this->Open($path, $mode);
if($path != NULL)
{
$this->Open($path, $mode);
}
}
/**
@ -41,7 +46,7 @@ class FileObject extends Object
*
* @param string $file_name Path of target file
* @return void
**/
*/
function append($file_name)
{
$target = new FileObject($file_name, "r");
@ -57,7 +62,7 @@ class FileObject extends Object
* Check current file meets eof
*
* @return bool true: if eof. false: otherwise
**/
*/
function feof()
{
return feof($this->fp);
@ -68,24 +73,29 @@ class FileObject extends Object
*
* @param int $size Size to read
* @return string Returns the read string or false on failure.
**/
*/
function read($size = 1024)
{
return fread($this->fp, $size);
}
/**
* Write string to current file
*
* @param string $str String to write
* @return int Returns the number of bytes written, or false on error.
**/
*/
function write($str)
{
$len = strlen($str);
if(!$str || $len <= 0) return false;
if(!$this->fp) return false;
if(!$str || $len <= 0)
{
return FALSE;
}
if(!$this->fp)
{
return FALSE;
}
$written = fwrite($this->fp, $str);
return $written;
}
@ -101,34 +111,34 @@ class FileObject extends Object
*/
function open($path, $mode)
{
if($this->fp != null)
{
if($this->fp != NULL)
{
$this->close();
}
$this->fp = fopen($path, $mode);
if(! is_resource($this->fp) )
if(!is_resource($this->fp))
{
$this->fp = null;
return false;
$this->fp = NULL;
return FALSE;
}
$this->path = $path;
return true;
return TRUE;
}
/**
* Return current file's path
*
* @return string Returns the path of current file.
**/
*/
function getPath()
{
if($this->fp != null)
if($this->fp != NULL)
{
return $this->path;
}
else
{
return null;
return NULL;
}
}
@ -136,16 +146,16 @@ class FileObject extends Object
* Close file
*
* @return void
**/
*/
function close()
{
if($this->fp != null)
if($this->fp != NULL)
{
fclose($this->fp);
$this->fp = null;
$this->fp = NULL;
}
}
}
}
/* End of file FileObject.class.php */
/* Location: ./classes/file/FileObject.class.php */

View file

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

View file

@ -1,415 +1,452 @@
<?php
/**
* Handle front end files
* @author NHN (developers@xpressengine.com)
* */
class FrontEndFileHandler extends Handler
{
/**
* Handle front end files
* @author NHN (developers@xpressengine.com)
**/
class FrontEndFileHandler extends Handler
* Map for css
* @var array
*/
var $cssMap = array();
/**
* Map for Javascript at head
* @var array
*/
var $jsHeadMap = array();
/**
* Map for Javascript at body
* @var array
*/
var $jsBodyMap = array();
/**
* Index for css
* @var array
*/
var $cssMapIndex = array();
/**
* Index for javascript at head
* @var array
*/
var $jsHeadMapIndex = array();
/**
* Index for javascript at body
* @var array
*/
var $jsBodyMapIndex = array();
/**
* Check SSL
*
* @return bool If using ssl returns true, otherwise returns false.
*/
function isSsl()
{
/**
* Map for css
* @var array
*/
var $cssMap = array();
/**
* Map for Javascript at head
* @var array
*/
var $jsHeadMap = array();
/**
* Map for Javascript at body
* @var array
*/
var $jsBodyMap = array();
/**
* Index for css
* @var array
*/
var $cssMapIndex = array();
/**
* Index for javascript at head
* @var array
*/
var $jsHeadMapIndex = array();
/**
* Index for javascript at body
* @var array
*/
var $jsBodyMapIndex = array();
/**
* Check SSL
*
* @return bool If using ssl returns true, otherwise returns false.
*/
function isSsl()
if($GLOBAL['__XE_IS_SSL__'])
{
if ($GLOBAL['__XE_IS_SSL__']) return $GLOBAL['__XE_IS_SSL__'];
$url_info = parse_url(Context::getRequestUrl());
if ($url_info['scheme'] == 'https')
$GLOBAL['__XE_IS_SSL__'] = true;
else
$GLOBAL['__XE_IS_SSL__'] = false;
return $GLOBAL['__XE_IS_SSL__'];
}
/**
* Load front end file
*
* The $args is use as below. File type(js, css) is detected by file extension.
*
* <pre>
* case js
* $args[0]: file name
* $args[1]: type (head | body)
* $args[2]: target IE
* $args[3]: index
* case css
* $args[0]: file name
* $args[1]: media
* $args[2]: target IE
* $args[3]: index
* </pre>
*
* If $useCdn set true, use CDN instead local file.
* CDN path = $cdnPrefix . $cdnVersion . $args[0]<br />
*<br />
* i.e.<br />
* $cdnPrefix = 'http://static.xpressengine.com/core/';<br />
* $cdnVersion = 'ardent1';<br />
* $args[0] = './common/js/xe.js';<br />
* The CDN path is http://static.xprssengine.com/core/ardent1/common/js/xe.js.<br />
*
* @param array $args Arguments
* @param bool $useCdn If set true, use cdn instead local file
* @param string $cdnPrefix CDN url prefix. (http://static.xpressengine.com/core/)
* @param string $cdnVersion CDN version string (ardent1)
* @return void
**/
function loadFile($args, $useCdn = false, $cdnPrefix = '', $cdnVersion = '')
$url_info = parse_url(Context::getRequestUrl());
if($url_info['scheme'] == 'https')
{
if (!is_array($args)) $args = array($args);
$pathInfo = pathinfo($args[0]);
$file = new stdClass();
$file->fileName = $pathInfo['basename'];
$file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
$file->fileRealPath = FileHandler::getRealPath($pathInfo['dirname']);
$file->fileExtension = strtolower($pathInfo['extension']);
$file->fileNameNoExt = preg_replace('/\.min$/', '', $pathInfo['filename']);
$file->keyName = implode('.', array($file->fileNameNoExt, $file->fileExtension));
if(strpos($file->filePath, '://') === FALSE)
{
if(!__DEBUG__)
{
// if no debug mode, load minifed file
$minifiedFileName = implode('.', array($file->fileNameNoExt, 'min', $file->fileExtension));
$minifiedRealPath = implode('/', array($file->fileRealPath, $minifiedFileName));
if(file_exists($minifiedRealPath))
{
$file->fileName = $minifiedFileName;
}
}
else
{
// Remove .min
if(file_exists(implode('/', array($file->fileRealPath, $file->keyName))))
{
$file->fileName = $file->keyName;
}
}
$file->useCdn = $useCdn;
$file->cdnPath = $this->_normalizeFilePath($pathInfo['dirname']);
$file->cdnPrefix = $cdnPrefix;
$file->cdnVersion = $cdnVersion;
}
$availableExtension = array('css'=>1, 'js'=>1);
if (!isset($availableExtension[$file->fileExtension])) return;
$file->targetIe = $args[2];
$file->index = (int)$args[3];
if ($file->fileExtension == 'css')
{
$file->media = $args[1];
if (!$file->media) $file->media = 'all';
$map = &$this->cssMap;
$mapIndex = &$this->cssMapIndex;
$key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media;
$this->_arrangeCssIndex($pathInfo['dirname'], $file);
}
else if ($file->fileExtension == 'js')
{
$type = $args[1];
if ($type == 'body')
{
$map = &$this->jsBodyMap;
$mapIndex = &$this->jsBodyMapIndex;
}
else
{
$map = &$this->jsHeadMap;
$mapIndex = &$this->jsHeadMapIndex;
}
$key = $file->filePath . $file->keyName . "\t" . $file->targetIe;
}
(is_null($file->index))?$file->index=0:$file->index=$file->index;
if (!isset($map[$file->index][$key]) || $mapIndex[$key] > $file->index)
{
$this->unloadFile($args[0], $args[2], $args[1]);
$map[$file->index][$key] = $file;
$mapIndex[$key] = $file->index;
}
$GLOBAL['__XE_IS_SSL__'] = TRUE;
}
else
{
$GLOBAL['__XE_IS_SSL__'] = FALSE;
}
/**
* Unload front end file
*
* @param string $fileName The file name to unload
* @param string $targetIe Target IE of file to unload
* @param string $media Media of file to unload. Only use when file is css.
* @return void
*/
function unloadFile($fileName, $targetIe = '', $media = 'all')
return $GLOBAL['__XE_IS_SSL__'];
}
/**
* Load front end file
*
* The $args is use as below. File type(js, css) is detected by file extension.
*
* <pre>
* case js
* $args[0]: file name
* $args[1]: type (head | body)
* $args[2]: target IE
* $args[3]: index
* case css
* $args[0]: file name
* $args[1]: media
* $args[2]: target IE
* $args[3]: index
* </pre>
*
* If $useCdn set true, use CDN instead local file.
* CDN path = $cdnPrefix . $cdnVersion . $args[0]<br />
* <br />
* i.e.<br />
* $cdnPrefix = 'http://static.xpressengine.com/core/';<br />
* $cdnVersion = 'ardent1';<br />
* $args[0] = './common/js/xe.js';<br />
* The CDN path is http://static.xprssengine.com/core/ardent1/common/js/xe.js.<br />
*
* @param array $args Arguments
* @param bool $useCdn If set true, use cdn instead local file
* @param string $cdnPrefix CDN url prefix. (http://static.xpressengine.com/core/)
* @param string $cdnVersion CDN version string (ardent1)
* @return void
* */
function loadFile($args, $useCdn = FALSE, $cdnPrefix = '', $cdnVersion = '')
{
if(!is_array($args))
{
$pathInfo = pathinfo($fileName);
$fileName = $pathInfo['basename'];
$filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
$fileExtension = strtolower($pathInfo['extension']);
$key = $filePath . $fileName . "\t" . $targetIe;
if ($fileExtension == 'css')
{
if(empty($media))
{
$media = 'all';
}
$key .= "\t" . $media;
if (isset($this->cssMapIndex[$key]))
{
$index = $this->cssMapIndex[$key];
unset($this->cssMap[$index][$key]);
unset($this->cssMapIndex[$key]);
}
}
else
{
if (isset($this->jsHeadMapIndex[$key]))
{
$index = $this->jsHeadMapIndex[$key];
unset($this->jsHeadMap[$index][$key]);
unset($this->jsHeadMapIndex[$key]);
}
if (isset($this->jsBodyMapIndex[$key]))
{
$index = $this->jsBodyMapIndex[$key];
unset($this->jsBodyMap[$index][$key]);
unset($this->jsBodyMapIndex[$key]);
}
}
$args = array($args);
}
/**
* Unload all front end file
*
* @param string $type Type to unload. all, css, js
* @return void
*/
function unloadAllFiles($type = 'all')
{
if ($type == 'css' || $type == 'all')
{
$this->cssMap = array();
$this->cssMapIndex = array();
}
$file = $this->getFileInfo($args[0], $args[2], $args[1]);
if ($type == 'js' || $type == 'all')
{
$this->jsHeadMap = array();
$this->jsBodyMap = array();
$this->jsHeadMapIndex = array();
$this->jsBodyMapIndex = array();
}
$availableExtension = array('css' => 1, 'js' => 1);
if(!isset($availableExtension[$file->fileExtension]))
{
return;
}
/**
* Get css file list
*
* @return array Returns css file list. Array contains file, media, targetie.
*/
function getCssFileList()
$file->useCdn = $useCdn;
$file->cdnPrefix = $cdnPrefix;
$file->cdnVersion = $cdnVersion;
$file->index = (int) $args[3];
if($file->fileExtension == 'css')
{
$map = &$this->cssMap;
$mapIndex = &$this->cssMapIndex;
$this->_sortMap($map, $mapIndex);
$dbInfo = Context::getDBInfo();
$useCdn = $dbInfo->use_cdn;
$result = array();
foreach($map as $indexedMap)
{
foreach($indexedMap as $file)
{
if ($this->isSsl() == false && $useCdn == 'Y' && $file->useCdn && $file->cdnVersion != '%__XE_CDN_VERSION__%')
{
$fullFilePath = $file->cdnPrefix . $file->cdnVersion . '/' . substr($file->cdnPath, 2) . '/' . $file->fileName;
}
else
{
$noneCache = (is_readable($file->cdnPath.'/'.$file->fileName))?'?'.date('YmdHis', filemtime($file->cdnPath.'/'.$file->fileName)):'';
$fullFilePath = $file->filePath . '/' . $file->fileName.$noneCache;
}
$result[] = array('file' => $fullFilePath, 'media' => $file->media, 'targetie' => $file->targetIe);
}
}
return $result;
$this->_arrangeCssIndex($pathInfo['dirname'], $file);
}
/**
* Get javascript file list
*
* @param string $type Type of javascript. head, body
* @return array Returns javascript file list. Array contains file, targetie.
*/
function getJsFileList($type = 'head')
else if($file->fileExtension == 'js')
{
if ($type == 'head')
{
$map = &$this->jsHeadMap;
$mapIndex = &$this->jsHeadMapIndex;
}
else
$type = $args[1];
if($type == 'body')
{
$map = &$this->jsBodyMap;
$mapIndex = &$this->jsBodyMapIndex;
}
$this->_sortMap($map, $mapIndex);
$dbInfo = Context::getDBInfo();
$useCdn = $dbInfo->use_cdn;
$result = array();
foreach($map as $indexedMap)
else
{
foreach($indexedMap as $file)
{
if ($this->isSsl() == false && $useCdn == 'Y' && $file->useCdn && $file->cdnVersion != '%__XE_CDN_VERSION__%')
{
$fullFilePath = $file->cdnPrefix . $file->cdnVersion . '/' . substr($file->cdnPath, 2) . '/' . $file->fileName;
}
else
{
$noneCache = (is_readable($file->cdnPath.'/'.$file->fileName))?'?'.date('YmdHis', filemtime($file->cdnPath.'/'.$file->fileName)):'';
$fullFilePath = $file->filePath . '/' . $file->fileName.$noneCache;
}
$result[] = array('file' => $fullFilePath, 'targetie' => $file->targetIe);
}
$map = &$this->jsHeadMap;
$mapIndex = &$this->jsHeadMapIndex;
}
return $result;
}
/**
* Sort a map
*
* @param array $map Array to sort
* @param array $index Not used
* @return void
*/
function _sortMap(&$map, &$index)
(is_null($file->index)) ? $file->index = 0 : $file->index = $file->index;
if(!isset($mapIndex[$file->key]) || $mapIndex[$file->key] > $file->index)
{
ksort($map);
}
/**
* Normalize File path
*
* @param string $path Path to normalize
* @return string Normalized path
*/
function _normalizeFilePath($path)
{
if (strpos($path, '://') === false && $path{0} != '/' && $path{0} != '.')
{
$path = './' . $path;
}
$path = preg_replace('@/\./|(?<!:)\/\/@', '/', $path);
while(strpos($path, '/../'))
{
$path = preg_replace('/\/([^\/]+)\/\.\.\//s', '/', $path, 1);
}
return $path;
}
/**
* Get absolute file url
*
* @param string $path Path to get absolute url
* @return string Absolute url
*/
function _getAbsFileUrl($path)
{
$path = $this->_normalizeFilePath($path);
if(strpos($path, './') === 0)
{
if (dirname($_SERVER['SCRIPT_NAME']) == '/' || dirname($_SERVER['SCRIPT_NAME']) == '\\')
{
$path = '/' . substr($path, 2);
}
else
{
$path = dirname($_SERVER['SCRIPT_NAME']) . '/' . substr($path, 2);
}
}
else if(strpos($file, '../') === 0)
{
$path= $this->_normalizeFilePath(dirname($_SERVER['SCRIPT_NAME']) . "/{$path}");
}
return $path;
}
/**
* Arrage css index
*
* @param string $dirName First directory name of css path
* @param array $file file info.
* @return void
*/
function _arrangeCssIndex($dirName, &$file)
{
if($file->index !== 0)
{
return;
}
$dirName = str_replace('./', '', $dirName);
$tmp = explode('/', $dirName);
$cssSortList = array('common'=>-100000, 'layouts'=>-90000, 'modules'=>-80000, 'widgets'=>-70000, 'addons'=>-60000);
$file->index = $cssSortList[$tmp[0]];
$this->unloadFile($args[0], $args[2], $args[1]);
$map[$file->index][$file->key] = $file;
$mapIndex[$file->key] = $file->index;
}
}
/**
* Get file information
*
* @param string $fileName The file name
* @param string $targetIe Target IE of file
* @param string $media Media of file
* @return stdClass The file information
*/
private function getFileInfo($fileName, $targetIe = '', $media = 'all')
{
static $existsInfo = array();
if(isset($existsInfo[$existsKey]))
{
return $existsInfo[$existsKey];
}
$pathInfo = pathinfo($fileName);
$file = new stdClass();
$file->fileName = $pathInfo['basename'];
$file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
$file->fileRealPath = FileHandler::getRealPath($pathInfo['dirname']);
$file->fileExtension = strtolower($pathInfo['extension']);
$file->fileNameNoExt = preg_replace('/\.min$/', '', $pathInfo['filename']);
$file->keyName = implode('.', array($file->fileNameNoExt, $file->fileExtension));
$file->cdnPath = $this->_normalizeFilePath($pathInfo['dirname']);
if(strpos($file->filePath, '://') === FALSE)
{
if(!__DEBUG__)
{
// if no debug mode, load minifed file
$minifiedFileName = implode('.', array($file->fileNameNoExt, 'min', $file->fileExtension));
$minifiedRealPath = implode('/', array($file->fileRealPath, $minifiedFileName));
if(file_exists($minifiedRealPath))
{
$file->fileName = $minifiedFileName;
}
}
else
{
// Remove .min
if(file_exists(implode('/', array($file->fileRealPath, $file->keyName))))
{
$file->fileName = $file->keyName;
}
}
}
$file->targetIe = $targetIe;
if($file->fileExtension == 'css')
{
$file->media = $media;
if(!$file->media)
{
$file->media = 'all';
}
$file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media;
}
else if($file->fileExtension == 'js')
{
$file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe;
}
return $file;
}
/**
* Unload front end file
*
* @param string $fileName The file name to unload
* @param string $targetIe Target IE of file to unload
* @param string $media Media of file to unload. Only use when file is css.
* @return void
*/
function unloadFile($fileName, $targetIe = '', $media = 'all')
{
$file = $this->getFileInfo($fileName, $targetIe, $media);
if($file->fileExtension == 'css')
{
if(isset($this->cssMapIndex[$file->key]))
{
$index = $this->cssMapIndex[$file->key];
unset($this->cssMap[$index][$file->key]);
unset($this->cssMapIndex[$file->key]);
}
}
else
{
if(isset($this->jsHeadMapIndex[$file->key]))
{
$index = $this->jsHeadMapIndex[$file->key];
unset($this->jsHeadMap[$index][$file->key]);
unset($this->jsHeadMapIndex[$file->key]);
}
if(isset($this->jsBodyMapIndex[$file->key]))
{
$index = $this->jsBodyMapIndex[$file->key];
unset($this->jsBodyMap[$index][$file->key]);
unset($this->jsBodyMapIndex[$file->key]);
}
}
}
/**
* Unload all front end file
*
* @param string $type Type to unload. all, css, js
* @return void
*/
function unloadAllFiles($type = 'all')
{
if($type == 'css' || $type == 'all')
{
$this->cssMap = array();
$this->cssMapIndex = array();
}
if($type == 'js' || $type == 'all')
{
$this->jsHeadMap = array();
$this->jsBodyMap = array();
$this->jsHeadMapIndex = array();
$this->jsBodyMapIndex = array();
}
}
/**
* Get css file list
*
* @return array Returns css file list. Array contains file, media, targetie.
*/
function getCssFileList()
{
$map = &$this->cssMap;
$mapIndex = &$this->cssMapIndex;
$this->_sortMap($map, $mapIndex);
$dbInfo = Context::getDBInfo();
$useCdn = $dbInfo->use_cdn;
$result = array();
foreach($map as $indexedMap)
{
foreach($indexedMap as $file)
{
if($this->isSsl() == FALSE && $useCdn == 'Y' && $file->useCdn && $file->cdnVersion != '%__XE_CDN_VERSION__%')
{
$fullFilePath = $file->cdnPrefix . $file->cdnVersion . '/' . substr($file->cdnPath, 2) . '/' . $file->fileName;
}
else
{
$noneCache = (is_readable($file->cdnPath . '/' . $file->fileName)) ? '?' . date('YmdHis', filemtime($file->cdnPath . '/' . $file->fileName)) : '';
$fullFilePath = $file->filePath . '/' . $file->fileName . $noneCache;
}
$result[] = array('file' => $fullFilePath, 'media' => $file->media, 'targetie' => $file->targetIe);
}
}
return $result;
}
/**
* Get javascript file list
*
* @param string $type Type of javascript. head, body
* @return array Returns javascript file list. Array contains file, targetie.
*/
function getJsFileList($type = 'head')
{
if($type == 'head')
{
$map = &$this->jsHeadMap;
$mapIndex = &$this->jsHeadMapIndex;
}
else
{
$map = &$this->jsBodyMap;
$mapIndex = &$this->jsBodyMapIndex;
}
$this->_sortMap($map, $mapIndex);
$dbInfo = Context::getDBInfo();
$useCdn = $dbInfo->use_cdn;
$result = array();
foreach($map as $indexedMap)
{
foreach($indexedMap as $file)
{
if($this->isSsl() == FALSE && $useCdn == 'Y' && $file->useCdn && $file->cdnVersion != '%__XE_CDN_VERSION__%')
{
$fullFilePath = $file->cdnPrefix . $file->cdnVersion . '/' . substr($file->cdnPath, 2) . '/' . $file->fileName;
}
else
{
$noneCache = (is_readable($file->cdnPath . '/' . $file->fileName)) ? '?' . date('YmdHis', filemtime($file->cdnPath . '/' . $file->fileName)) : '';
$fullFilePath = $file->filePath . '/' . $file->fileName . $noneCache;
}
$result[] = array('file' => $fullFilePath, 'targetie' => $file->targetIe);
}
}
return $result;
}
/**
* Sort a map
*
* @param array $map Array to sort
* @param array $index Not used
* @return void
*/
function _sortMap(&$map, &$index)
{
ksort($map);
}
/**
* Normalize File path
*
* @param string $path Path to normalize
* @return string Normalized path
*/
function _normalizeFilePath($path)
{
if(strpos($path, '://') === FALSE && $path{0} != '/' && $path{0} != '.')
{
$path = './' . $path;
}
$path = preg_replace('@/\./|(?<!:)\/\/@', '/', $path);
while(strpos($path, '/../'))
{
$path = preg_replace('/\/([^\/]+)\/\.\.\//s', '/', $path, 1);
}
return $path;
}
/**
* Get absolute file url
*
* @param string $path Path to get absolute url
* @return string Absolute url
*/
function _getAbsFileUrl($path)
{
$path = $this->_normalizeFilePath($path);
if(strpos($path, './') === 0)
{
if(dirname($_SERVER['SCRIPT_NAME']) == '/' || dirname($_SERVER['SCRIPT_NAME']) == '\\')
{
$path = '/' . substr($path, 2);
}
else
{
$path = dirname($_SERVER['SCRIPT_NAME']) . '/' . substr($path, 2);
}
}
else if(strpos($file, '../') === 0)
{
$path = $this->_normalizeFilePath(dirname($_SERVER['SCRIPT_NAME']) . "/{$path}");
}
return $path;
}
/**
* Arrage css index
*
* @param string $dirName First directory name of css path
* @param array $file file info.
* @return void
*/
function _arrangeCssIndex($dirName, &$file)
{
if($file->index !== 0)
{
return;
}
$dirName = str_replace('./', '', $dirName);
$tmp = explode('/', $dirName);
$cssSortList = array('common' => -100000, 'layouts' => -90000, 'modules' => -80000, 'widgets' => -70000, 'addons' => -60000);
$file->index = $cssSortList[$tmp[0]];
}
}
/* End of file FrontEndFileHandler.class.php */
/* Location: ./classes/frontendfile/FrontEndFileHandler.class.php */

View file

@ -1,11 +1,13 @@
<?php
/**
* An abstract class of (*)Handler
*
* @author NHN (developers@xpressengine.com)
**/
class Handler {
/**
* An abstract class of (*)Handler
*
* @author NHN (developers@xpressengine.com)
*/
class Handler
{
}
?>
}
/* End of file Handler.class.php */
/* Location: ./classes/handler/Handler.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* - HttpRequest class
* - a class that is designed to be used for sending out HTTP request to an external server and retrieving response
@ -7,17 +8,21 @@
* @package /classes/httprequest
* @version 0.1
*/
class XEHttpRequest {
class XEHttpRequest
{
/**
* target host
* @var string
*/
var $m_host;
/**
* target Port
* @var int
*/
var $m_port;
/**
* target header
* @var array
@ -30,9 +35,9 @@ class XEHttpRequest {
*/
function XEHttpRequest($host, $port)
{
$this->m_host = $host;
$this->m_port = $port;
$this->m_headers = array();
$this->m_host = $host;
$this->m_port = $port;
$this->m_headers = array();
}
/**
@ -43,7 +48,7 @@ class XEHttpRequest {
*/
function addToHeader($key, $value)
{
$this->m_headers[$key] = $value;
$this->m_headers[$key] = $value;
}
/**
@ -54,26 +59,38 @@ class XEHttpRequest {
* @param array $post_vars variables to send
* @return object Returns an object containing HTTP Response body and HTTP response code
*/
function send($target='/', $method='GET', $timeout=3, $post_vars=null)
function send($target = '/', $method = 'GET', $timeout = 3, $post_vars = NULL)
{
static $allow_methods=null;
static $allow_methods = NULL;
$this->addToHeader('Host', $this->m_host);
$this->addToHeader('Connection', 'close');
$method = strtoupper($method);
if(!$allow_methods) $allow_methods = explode(' ', 'GET POST PUT');
if(!in_array($method, $allow_methods)) $method = $allow_methods[0];
if(!$allow_methods)
{
$allow_methods = explode(' ', 'GET POST PUT');
}
if(!in_array($method, $allow_methods))
{
$method = $allow_methods[0];
}
// $timeout should be an integer that is bigger than zero
$timout = max((int)$timeout, 0);
$timout = max((int) $timeout, 0);
// list of post variables
if(!is_array($post_vars)) $post_vars = array();
if(!is_array($post_vars))
{
$post_vars = array();
}
if(false && is_callable('curl_init')) {
if(FALSE && is_callable('curl_init'))
{
return $this->sendWithCurl($target, $method, $timeout, $post_vars);
} else {
}
else
{
return $this->sendWithSock($target, $method, $timeout, $post_vars);
}
}
@ -91,49 +108,65 @@ class XEHttpRequest {
static $crlf = "\r\n";
$sock = @fsockopen($this->m_host, $this->m_port, $errno, $errstr, $timeout);
if(!$sock) {
if(!$sock)
{
return new Object(-1, 'socket_connect_failed');
}
$headers = $this->m_headers + array();
if(!isset($headers['Accept-Encoding'])) $headers['Accept-Encoding'] = 'identity';
if(!isset($headers['Accept-Encoding']))
{
$headers['Accept-Encoding'] = 'identity';
}
// post body
$post_body = '';
if($method == 'POST' && count($post_vars)) {
foreach($post_vars as $key=>$value) {
$post_body .= urlencode($key).'='.urlencode($value).'&';
if($method == 'POST' && count($post_vars))
{
foreach($post_vars as $key => $value)
{
$post_body .= urlencode($key) . '=' . urlencode($value) . '&';
}
$post_body = substr($post_body, 0, -1);
$headers['Content-Length'] = strlen($post_body);
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
}
$request = "$method $target HTTP/1.1$crlf";
foreach($headers as $equiv=>$content) {
foreach($headers as $equiv => $content)
{
$request .= "$equiv: $content$crlf";
}
$request .= $crlf.$post_body;
$request .= $crlf . $post_body;
fwrite($sock, $request);
list($httpver, $code, $status) = preg_split('/ +/', rtrim(fgets($sock)), 3);
// read response headers
$is_chunked = false;
while(strlen(trim($line = fgets($sock)))) {
$is_chunked = FALSE;
while(strlen(trim($line = fgets($sock))))
{
list($equiv, $content) = preg_split('/ *: */', rtrim($line), 1);
if(!strcasecmp($equiv, 'Transfer-Encoding') && $content == 'chunked') {
$is_chunked = true;
if(!strcasecmp($equiv, 'Transfer-Encoding') && $content == 'chunked')
{
$is_chunked = TRUE;
}
}
$body = '';
while(!feof($sock)) {
if ($is_chunked) {
while(!feof($sock))
{
if($is_chunked)
{
$chunk_size = hexdec(fgets($sock));
if($chunk_size) $body .= fread($sock, $chunk_size);
} else {
if($chunk_size)
{
$body .= fread($sock, $chunk_size);
}
}
else
{
$body .= fgets($sock, 512);
}
}
@ -165,15 +198,18 @@ class XEHttpRequest {
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://{$this->m_host}{$target}");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_PORT, $this->m_port);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
switch($method) {
case 'GET': curl_setopt($ch, CURLOPT_HTTPGET, true); break;
case 'PUT': curl_setopt($ch, CURLOPT_PUT, true); break;
switch($method)
{
case 'GET': curl_setopt($ch, CURLOPT_HTTPGET, true);
break;
case 'PUT': curl_setopt($ch, CURLOPT_PUT, true);
break;
case 'POST':
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vars);
@ -181,14 +217,16 @@ class XEHttpRequest {
}
$arr_headers = array();
foreach($headers as $key=>$value){
foreach($headers as $key => $value)
{
$arr_headers[] = "$key: $value";
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $arr_headers);
$body = curl_exec($ch);
if(curl_errno($ch)) {
if(curl_errno($ch))
{
return new Object(-1, 'socket_connect_failed');
}
@ -200,5 +238,7 @@ class XEHttpRequest {
return $ret;
}
}
?>
/* End of file XEHttpRequest.class.php */
/* Location: ./classes/httprequest/XEHttpRequest.class.php */

View file

@ -1,4 +1,5 @@
<?php
if(version_compare(PHP_VERSION, '5.0.0', '>='))
{
require_once _XE_PATH_ . "libs/phpmailer/phpmailer.php";
@ -9,12 +10,13 @@ else
}
/**
* Mailing class for XpressEngine
*
* @author NHN (developers@xpressengine.com)
*/
* Mailing class for XpressEngine
*
* @author NHN (developers@xpressengine.com)
*/
class Mail extends PHPMailer
{
/**
* Sender name
* @var string
@ -85,7 +87,7 @@ class Mail extends PHPMailer
* Content attachements
* @var array
*/
var $cidAttachments = array();
var $cidAttachments = array();
/**
* ???
@ -130,22 +132,22 @@ class Mail extends PHPMailer
var $use_smtp = FALSE;
/**
* Constructor function
*
* @return void
*/
* Constructor function
*
* @return void
*/
function Mail()
{
}
/**
* Set parameters for using Gmail
*
* @param string $account_name Password
* @param string $account_passwd Secure method ('ssl','tls')
* @return void
*/
* Set parameters for using Gmail
*
* @param string $account_name Password
* @param string $account_passwd Secure method ('ssl','tls')
* @return void
*/
function useGmailAccount($account_name, $account_passwd)
{
$this->SMTPAuth = TRUE;
@ -165,24 +167,24 @@ class Mail extends PHPMailer
}
/**
* Set parameters for using SMTP protocol
*
* @param bool $auth SMTP authentication
* @param string $host SMTP host address
* @param string $user SMTP user id
* @param string $pass STMP user password
* @param string $secure method ('ssl','tls')
* @param int $port STMP port
*
* @return bool TRUE if SMTP is set correct, otherwise return FALSE
*/
* Set parameters for using SMTP protocol
*
* @param bool $auth SMTP authentication
* @param string $host SMTP host address
* @param string $user SMTP user id
* @param string $pass STMP user password
* @param string $secure method ('ssl','tls')
* @param int $port STMP port
*
* @return bool TRUE if SMTP is set correct, otherwise return FALSE
*/
function useSMTP($auth = NULL, $host = NULL, $user = NULL, $pass = NULL, $secure = NULL, $port = 25)
{
$this->SMTPAuth = $auth;
$this->Host = $host;
$this->Host = $host;
$this->Username = $user;
$this->Password = $pass;
$this->Port = $port;
$this->Port = $port;
if($secure == 'ssl' || $secure == 'tls')
{
@ -203,47 +205,47 @@ class Mail extends PHPMailer
}
/**
* Set additional parameters
*
* @param string $additional_params Additional parameters
* @return void
*/
* Set additional parameters
*
* @param string $additional_params Additional parameters
* @return void
*/
function setAdditionalParams($additional_params)
{
$this->additional_params = $additional_params;
}
/**
* Add file attachment
*
* @param string $filename File name to attach
* @param string $orgfilename Real path of file to attach
* @return void
*/
* Add file attachment
*
* @param string $filename File name to attach
* @param string $orgfilename Real path of file to attach
* @return void
*/
function addAttachment($filename, $orgfilename)
{
$this->attachments[$orgfilename] = $filename;
}
/**
* Add content attachment
*
* @param string $filename Real path of file to attach
* @param string $cid Content-CID
* @return void
*/
* Add content attachment
*
* @param string $filename Real path of file to attach
* @param string $cid Content-CID
* @return void
*/
function addCidAttachment($filename, $cid)
{
$this->cidAttachments[$cid] = $filename;
}
/**
* Set Sender (From:)
*
* @param string $name Sender name
* @param string $email Sender email address
* @return void
*/
* Set Sender (From:)
*
* @param string $name Sender name
* @param string $email Sender email address
* @return void
*/
function setSender($name, $email)
{
if($this->Mailer == "mail")
@ -258,10 +260,10 @@ class Mail extends PHPMailer
}
/**
* Get Sender (From:)
*
* @return string
*/
* Get Sender (From:)
*
* @return string
*/
function getSender()
{
if(!stristr(PHP_OS, 'win') && $this->sender_name)
@ -272,12 +274,12 @@ class Mail extends PHPMailer
}
/**
* Set Receiptor (TO:)
*
* @param string $name Receiptor name
* @param string $email Receiptor email address
* @return void
*/
* Set Receiptor (TO:)
*
* @param string $name Receiptor name
* @param string $email Receiptor email address
* @return void
*/
function setReceiptor($name, $email)
{
if($this->Mailer == "mail")
@ -292,10 +294,10 @@ class Mail extends PHPMailer
}
/**
* Get Receiptor (TO:)
*
* @return string
*/
* Get Receiptor (TO:)
*
* @return string
*/
function getReceiptor()
{
if(!stristr(PHP_OS, 'win') && $this->receiptor_name && $this->receiptor_name != $this->receiptor_email)
@ -306,11 +308,11 @@ class Mail extends PHPMailer
}
/**
* Set Email's Title
*
* @param string $title Title to set
* @return void
*/
* Set Email's Title
*
* @param string $title Title to set
* @return void
*/
function setTitle($title)
{
if($this->Mailer == "mail")
@ -324,21 +326,21 @@ class Mail extends PHPMailer
}
/**
* Get Email's Title
*
* @return string
*/
* Get Email's Title
*
* @return string
*/
function getTitle()
{
return '=?utf-8?b?' . base64_encode($this->title) . '?=';
}
/**
* Set BCC
*
* @param string $bcc
* @return void
*/
* Set BCC
*
* @param string $bcc
* @return void
*/
function setBCC($bcc)
{
if($this->Mailer == "mail")
@ -352,33 +354,33 @@ class Mail extends PHPMailer
}
/**
* Set Message ID
*
* @param string $messageId
* @return void
*/
* Set Message ID
*
* @param string $messageId
* @return void
*/
function setMessageID($messageId)
{
$this->messageId = $messageId;
}
/**
* Set references
*
* @param string $references
* @return void
*/
* Set references
*
* @param string $references
* @return void
*/
function setReferences($references)
{
$this->references = $references;
}
/**
* Set ReplyTo param
*
* @param string $replyTo
* @return void
*/
* Set ReplyTo param
*
* @param string $replyTo
* @return void
*/
function setReplyTo($replyTo)
{
if($this->Mailer == "mail")
@ -392,11 +394,11 @@ class Mail extends PHPMailer
}
/**
* Set message content
*
* @param string $content Content
* @return void
*/
* Set message content
*
* @param string $content Content
* @return void
*/
function setContent($content)
{
$content = preg_replace_callback('/<img([^>]+)>/i', array($this, 'replaceResourceRealPath'), $content);
@ -411,53 +413,53 @@ class Mail extends PHPMailer
}
/**
* Replace resourse path of the files
*
* @see Mail::setContent()
* @param array $matches Match info.
* @return string
*/
* Replace resourse path of the files
*
* @see Mail::setContent()
* @param array $matches Match info.
* @return string
*/
function replaceResourceRealPath($matches)
{
return preg_replace('/src=(["\']?)files/i', 'src=$1' . Context::getRequestUri() . 'files', $matches[0]);
}
/**
* Get the Plain content of body message
*
* @return string
*/
* Get the Plain content of body message
*
* @return string
*/
function getPlainContent()
{
return chunk_split(base64_encode(str_replace(array("<", ">", "&"), array("&lt;", "&gt;", "&amp;"), $this->content)));
}
/**
* Get the HTML content of body message
*
* @return string
*/
* Get the HTML content of body message
*
* @return string
*/
function getHTMLContent()
{
return chunk_split(base64_encode($this->content_type != 'html' ? nl2br($this->content):$this->content));
return chunk_split(base64_encode($this->content_type != 'html' ? nl2br($this->content) : $this->content));
}
/**
* Set the type of body's content
*
* @param string $mode
* @return void
*/
* Set the type of body's content
*
* @param string $mode
* @return void
*/
function setContentType($mode = 'html')
{
$this->content_type = $mode == 'html' ? 'html':'';
$this->content_type = $mode == 'html' ? 'html' : '';
}
/**
* Process the images from attachments
*
* @return void
*/
* Process the images from attachments
*
* @return void
*/
function procAttachments()
{
if($this->Mailer == "mail")
@ -477,19 +479,14 @@ class Mail extends PHPMailer
$file_str = $file_handler->readFile($attachment);
$chunks = chunk_split(base64_encode($file_str));
$tempBody = sprintf(
"--" . $boundary . $this->eol .
"Content-Type: %s;" . $this->eol .
"\tname=\"%s\"" . $this->eol .
"Content-Transfer-Encoding: base64" . $this->eol .
"Content-Description: %s" . $this->eol .
"Content-Disposition: attachment;" . $this->eol .
"\tfilename=\"%s\"" . $this->eol . $this->eol .
"%s" . $this->eol . $this->eol,
$type,
$filename,
$filename,
$filename,
$chunks);
"--" . $boundary . $this->eol .
"Content-Type: %s;" . $this->eol .
"\tname=\"%s\"" . $this->eol .
"Content-Transfer-Encoding: base64" . $this->eol .
"Content-Description: %s" . $this->eol .
"Content-Disposition: attachment;" . $this->eol .
"\tfilename=\"%s\"" . $this->eol . $this->eol .
"%s" . $this->eol . $this->eol, $type, $filename, $filename, $filename, $chunks);
$res[] = $tempBody;
}
$this->body = implode("", $res);
@ -509,10 +506,10 @@ class Mail extends PHPMailer
}
/**
* Process the images from body content. This functions is used if Mailer is set as mail not as SMTP
*
* @return void
*/
* Process the images from body content. This functions is used if Mailer is set as mail not as SMTP
*
* @return void
*/
function procCidAttachments()
{
if(count($this->cidAttachments) > 0)
@ -530,20 +527,14 @@ class Mail extends PHPMailer
$file_str = FileHandler::readFile($attachment);
$chunks = chunk_split(base64_encode($file_str));
$tempBody = sprintf(
"--" . $boundary . $this->eol .
"Content-Type: %s;" . $this->eol .
"\tname=\"%s\"" . $this->eol .
"Content-Transfer-Encoding: base64" . $this->eol .
"Content-ID: <%s>" . $this->eol .
"Content-Description: %s" . $this->eol .
"Content-Location: %s" . $this->eol . $this->eol .
"%s" . $this->eol . $this->eol,
$type,
$filename,
$cid,
$filename,
$filename,
$chunks);
"--" . $boundary . $this->eol .
"Content-Type: %s;" . $this->eol .
"\tname=\"%s\"" . $this->eol .
"Content-Transfer-Encoding: base64" . $this->eol .
"Content-ID: <%s>" . $this->eol .
"Content-Description: %s" . $this->eol .
"Content-Location: %s" . $this->eol . $this->eol .
"%s" . $this->eol . $this->eol, $type, $filename, $cid, $filename, $filename, $chunks);
$res[] = $tempBody;
}
$this->body = implode("", $res);
@ -552,10 +543,10 @@ class Mail extends PHPMailer
}
/**
* Send email
*
* @return bool TRUE in case of success, FALSE if sending fails
*/
* Send email
*
* @return bool TRUE in case of success, FALSE if sending fails
*/
function send()
{
if($this->Mailer == "mail")
@ -564,38 +555,28 @@ class Mail extends PHPMailer
$this->eol = $GLOBALS['_qmail_compatibility'] == "Y" ? "\n" : "\r\n";
$this->header = "Content-Type: multipart/alternative;" . $this->eol . "\tboundary=\"" . $boundary . "\"" . $this->eol . $this->eol;
$this->body = sprintf(
"--%s" . $this->eol .
"Content-Type: text/plain; charset=utf-8; format=flowed" . $this->eol .
"Content-Transfer-Encoding: base64" . $this->eol .
"Content-Disposition: inline" . $this->eol . $this->eol .
"%s" .
"--%s" . $this->eol .
"Content-Type: text/html; charset=utf-8" . $this->eol .
"Content-Transfer-Encoding: base64" . $this->eol .
"Content-Disposition: inline" . $this->eol . $this->eol .
"%s" .
"--%s--" .
"",
$boundary,
$this->getPlainContent(),
$boundary,
$this->getHTMLContent(),
$boundary
"--%s" . $this->eol .
"Content-Type: text/plain; charset=utf-8; format=flowed" . $this->eol .
"Content-Transfer-Encoding: base64" . $this->eol .
"Content-Disposition: inline" . $this->eol . $this->eol .
"%s" .
"--%s" . $this->eol .
"Content-Type: text/html; charset=utf-8" . $this->eol .
"Content-Transfer-Encoding: base64" . $this->eol .
"Content-Disposition: inline" . $this->eol . $this->eol .
"%s" .
"--%s--" .
"", $boundary, $this->getPlainContent(), $boundary, $this->getHTMLContent(), $boundary
);
$this->procCidAttachments();
$this->procAttachments();
$headers = sprintf(
"From: %s" . $this->eol .
"%s" .
"%s" .
"%s" .
"%s" .
"MIME-Version: 1.0" . $this->eol . "",
$this->getSender(),
$this->messageId ? ("Message-ID: <" . $this->messageId . ">" . $this->eol):"",
$this->replyTo ? ("Reply-To: <" . $this->replyTo . ">" . $this->eol):"",
$this->bcc ? ("Bcc: " . $this->bcc . $this->eol):"",
$this->references ? ("References: <" . $this->references . ">" . $this->eol . "In-Reply-To: <" . $this->references . ">" . $this->eol):""
"From: %s" . $this->eol .
"%s" .
"%s" .
"%s" .
"%s" .
"MIME-Version: 1.0" . $this->eol . "", $this->getSender(), $this->messageId ? ("Message-ID: <" . $this->messageId . ">" . $this->eol) : "", $this->replyTo ? ("Reply-To: <" . $this->replyTo . ">" . $this->eol) : "", $this->bcc ? ("Bcc: " . $this->bcc . $this->eol) : "", $this->references ? ("References: <" . $this->references . ">" . $this->eol . "In-Reply-To: <" . $this->references . ">" . $this->eol) : ""
);
$headers .= $this->header;
if($this->additional_params)
@ -612,11 +593,11 @@ class Mail extends PHPMailer
}
/**
* Check if DNS of param is real or fake
*
* @param string $email_address Email address
* @return boolean TRUE if param is valid DNS otherwise FALSE
*/
* Check if DNS of param is real or fake
*
* @param string $email_address Email address
* @return boolean TRUE if param is valid DNS otherwise FALSE
*/
function checkMailMX($email_address)
{
if(!Mail::isVaildMailAddress($email_address))
@ -639,11 +620,11 @@ class Mail extends PHPMailer
}
/**
* Check if param is a valid email or not
*
* @param string $email_address Email address
* @return string email address if param is valid email address otherwise blank string
*/
* Check if param is a valid email or not
*
* @param string $email_address Email address
* @return string email address if param is valid email address otherwise blank string
*/
function isVaildMailAddress($email_address)
{
if(preg_match("/([a-z0-9\_\-\.]+)@([a-z0-9\_\-\.]+)/i", $email_address))
@ -657,11 +638,11 @@ class Mail extends PHPMailer
}
/**
* Gets the MIME type of param
*
* @param string $filename filename
* @return string MIME type of ext
*/
* Gets the MIME type of param
*
* @param string $filename filename
* @return string MIME type of ext
*/
function returnMIMEType($filename)
{
preg_match("|\.([a-z0-9]{2,4})$|i", $filename, $fileSuffix);
@ -740,6 +721,7 @@ class Mail extends PHPMailer
return "unknown/" . trim($fileSuffix[0], ".");
}
}
}
/* End of file Mail.class.php */
/* Location: ./classes/mail/Mail.class.php */

View file

@ -5,21 +5,27 @@
*
* @author NHN (developers@xpressengine.com)
*/
class Mobile {
class Mobile
{
/**
* Whether mobile or not mobile mode
* @var bool
*/
var $ismobile = null;
var $ismobile = NULL;
/**
* Get instance of Mobile class(for singleton)
*
* @return Mobile
*/
function &getInstance() {
function &getInstance()
{
static $theInstance;
if(!isset($theInstance)) $theInstance = new Mobile();
if(!isset($theInstance))
{
$theInstance = new Mobile();
}
return $theInstance;
}
@ -28,8 +34,9 @@ class Mobile {
*
* @return bool If mobile mode returns true or false
*/
function isFromMobilePhone() {
$oMobile =& Mobile::getInstance();
function isFromMobilePhone()
{
$oMobile = & Mobile::getInstance();
return $oMobile->_isFromMobilePhone();
}
@ -38,11 +45,16 @@ class Mobile {
*
* @return bool
*/
function _isFromMobilePhone() {
if($this->ismobile !== null) return $this->ismobile;
function _isFromMobilePhone()
{
if($this->ismobile !== NULL)
{
return $this->ismobile;
}
$db_info = Context::getDBInfo();
if($db_info->use_mobile_view != "Y" || Context::get('full_browse') || $_COOKIE["FullBrowse"]) {
if($db_info->use_mobile_view != "Y" || Context::get('full_browse') || $_COOKIE["FullBrowse"])
{
return ($this->ismobile = false);
}
@ -52,19 +64,28 @@ class Mobile {
$this->ismobile = FALSE;
$m = Context::get('m');
if(strlen($m)==1) {
if($m == "1") {
$this->ismobile = true;
} elseif($m == "0") {
$this->ismobile = false;
if(strlen($m) == 1)
{
if($m == "1")
{
$this->ismobile = TRUE;
}
} elseif(isset($_COOKIE['mobile'])) {
elseif($m == "0")
{
$this->ismobile = FALSE;
}
}
elseif(isset($_COOKIE['mobile']))
{
if($_COOKIE['user-agent'] == md5($_SERVER['HTTP_USER_AGENT']))
{
if($_COOKIE['mobile'] == 'true') {
$this->ismobile = true;
} else {
$this->ismobile = false;
if($_COOKIE['mobile'] == 'true')
{
$this->ismobile = TRUE;
}
else
{
$this->ismobile = FALSE;
}
}
else
@ -111,7 +132,7 @@ class Mobile {
if($_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT']))
{
setcookie("user-agent",md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path);
setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path);
}
}
@ -126,11 +147,13 @@ class Mobile {
function isMobileCheckByAgent()
{
static $UACheck;
if(isset($UACheck)) return $UACheck;
if(isset($UACheck))
{
return $UACheck;
}
$oMobile =& Mobile::getInstance();
// stripos is only for PHP5.
$mobileAgent = unserialize(strtolower(serialize(array('iPod','iPhone','Android','BlackBerry','SymbianOS','Bada','Kindle','Wii','SCH-','SPH-','CANU-','Windows Phone','Windows CE','POLARIS','Palm','Dorothy Browser','Mobile','Opera Mobi','Opera Mini','Minimo','AvantGo','NetFront','Nokia','LGPlayer','SonyEricsson','HTC'))));
$oMobile = Mobile::getInstance();
$mobileAgent = array('iPod', 'iPhone', 'Android', 'BlackBerry', 'SymbianOS', 'Bada', 'Tizen', 'Kindle', 'Wii', 'SCH-', 'SPH-', 'CANU-', 'Windows Phone', 'Windows CE', 'POLARIS', 'Palm', 'Dorothy Browser', 'Mobile', 'Opera Mobi', 'Opera Mini', 'Minimo', 'AvantGo', 'NetFront', 'Nokia', 'LGPlayer', 'SonyEricsson', 'HTC');
if($oMobile->isMobilePadCheckByAgent())
{
@ -140,9 +163,7 @@ class Mobile {
foreach($mobileAgent as $agent)
{
// stripos is only for PHP5..
$httpUA = strtolower($_SERVER['HTTP_USER_AGENT']);
if(strpos($httpUA, $agent) !== FALSE)
if(stripos($_SERVER['HTTP_USER_AGENT'], $agent) !== FALSE)
{
$UACheck = TRUE;
return TRUE;
@ -160,12 +181,15 @@ class Mobile {
function isMobilePadCheckByAgent()
{
static $UACheck;
if(isset($UACheck)) return $UACheck;
$padAgent = array('iPad','Android','webOS','hp-tablet','PlayBook');
if(isset($UACheck))
{
return $UACheck;
}
$padAgent = array('iPad', 'Android', 'webOS', 'hp-tablet', 'PlayBook');
// Android with 'Mobile' string is not a tablet-like device, and 'Andoroid' without 'Mobile' string is a tablet-like device.
// $exceptionAgent[0] contains exception agents for all exceptions.
$exceptionAgent = array(0 => array('Opera Mini','Opera Mobi'),'Android' => 'Mobile');
$exceptionAgent = array(0 => array('Opera Mini', 'Opera Mobi'), 'Android' => 'Mobile');
foreach($padAgent as $agent)
{
@ -205,9 +229,9 @@ class Mobile {
*/
function setMobile($ismobile)
{
$oMobile =& Mobile::getInstance();
$oMobile = Mobile::getInstance();
$oMobile->ismobile = $ismobile;
}
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,386 +1,480 @@
<?php
/**
* @class ModuleObject
* @author NHN (developers@xpressengine.com)
* base class of ModuleHandler
**/
class ModuleObject extends Object {
/**
* @class ModuleObject
* @author NHN (developers@xpressengine.com)
* base class of ModuleHandler
* */
class ModuleObject extends Object
{
var $mid = NULL; ///< string to represent run-time instance of Module (XE Module)
var $module = NULL; ///< Class name of Xe Module that is identified by mid
var $module_srl = NULL; ///< integer value to represent a run-time instance of Module (XE Module)
var $module_info = NULL; ///< an object containing the module information
var $origin_module_info = NULL;
var $xml_info = NULL; ///< an object containing the module description extracted from XML file
var $mid = NULL; ///< string to represent run-time instance of Module (XE Module)
var $module = NULL; ///< Class name of Xe Module that is identified by mid
var $module_srl = NULL; ///< integer value to represent a run-time instance of Module (XE Module)
var $module_info = NULL; ///< an object containing the module information
var $origin_module_info = NULL;
var $xml_info = NULL; ///< an object containing the module description extracted from XML file
var $module_path = NULL; ///< a path to directory where module source code resides
var $act = NULL; ///< a string value to contain the action name
var $template_path = NULL; ///< a path of directory where template files reside
var $template_file = NULL; ///< name of template file
var $layout_path = ''; ///< a path of directory where layout files reside
var $layout_file = ''; ///< name of layout file
var $edited_layout_file = ''; ///< name of temporary layout files that is modified in an admin mode
var $stop_proc = false; ///< a flag to indicating whether to stop the execution of code.
var $module_config = NULL;
var $ajaxRequestMethod = array('XMLRPC', 'JSON');
var $gzhandler_enable = TRUE;
var $module_path = NULL; ///< a path to directory where module source code resides
/**
* setter to set the name of module
* @param string $module name of module
* @return void
* */
function setModule($module)
{
$this->module = $module;
}
var $act = NULL; ///< a string value to contain the action name
/**
* setter to set the name of module path
* @param string $path the directory path to a module directory
* @return void
* */
function setModulePath($path)
{
if(substr($path, -1) != '/')
{
$path.='/';
}
$this->module_path = $path;
}
var $template_path = NULL; ///< a path of directory where template files reside
var $template_file = NULL; ///< name of template file
/**
* setter to set an url for redirection
* @param string $url url for redirection
* @remark redirect_url is used only for ajax requests
* @return void
* */
function setRedirectUrl($url = './', $output = NULL)
{
$ajaxRequestMethod = array_flip($this->ajaxRequestMethod);
if(!isset($ajaxRequestMethod[Context::getRequestMethod()]))
{
$this->add('redirect_url', $url);
}
var $layout_path = ''; ///< a path of directory where layout files reside
var $layout_file = ''; ///< name of layout file
var $edited_layout_file = ''; ///< name of temporary layout files that is modified in an admin mode
if($output !== NULL && is_object($output))
{
return $output;
}
}
var $stop_proc = false; ///< a flag to indicating whether to stop the execution of code.
/**
* get url for redirection
* @return string redirect_url
* */
function getRedirectUrl()
{
return $this->get('redirect_url');
}
var $module_config = NULL;
var $ajaxRequestMethod = array('XMLRPC', 'JSON');
/**
* set message
* @param string $message a message string
* @param string $type type of message (error, info, update)
* @return void
* */
function setMessage($message, $type = NULL)
{
parent::setMessage($message);
$this->setMessageType($type);
}
var $gzhandler_enable = TRUE;
/**
* set type of message
* @param string $type type of message (error, info, update)
* @return void
* */
function setMessageType($type)
{
$this->add('message_type', $type);
}
/**
* setter to set the name of module
* @param string $module name of module
* @return void
**/
function setModule($module) {
$this->module = $module;
}
/**
* get type of message
* @return string $type
* */
function getMessageType()
{
$type = $this->get('message_type');
$typeList = array('error' => 1, 'info' => 1, 'update' => 1);
if(!isset($typeList[$type]))
{
$type = $this->getError() ? 'error' : 'info';
}
return $type;
}
/**
* setter to set the name of module path
* @param string $path the directory path to a module directory
* @return void
**/
function setModulePath($path) {
if(substr($path,-1)!='/') $path.='/';
$this->module_path = $path;
}
/**
* sett to set the template path for refresh.html
* refresh.html is executed as a result of method execution
* Tpl as the common run of the refresh.html ..
* @return void
* */
function setRefreshPage()
{
$this->setTemplatePath('./common/tpl');
$this->setTemplateFile('refresh');
}
/**
* setter to set an url for redirection
* @param string $url url for redirection
* @remark redirect_url is used only for ajax requests
* @return void
**/
function setRedirectUrl($url='./', $output = NULL) {
$ajaxRequestMethod = array_flip($this->ajaxRequestMethod);
if(!isset($ajaxRequestMethod[Context::getRequestMethod()]))
/**
* sett to set the action name
* @param string $act
* @return void
* */
function setAct($act)
{
$this->act = $act;
}
/**
* sett to set module information
* @param object $module_info object containing module information
* @param object $xml_info object containing module description
* @return void
* */
function setModuleInfo($module_info, $xml_info)
{
// The default variable settings
$this->mid = $module_info->mid;
$this->module_srl = $module_info->module_srl;
$this->module_info = $module_info;
$this->origin_module_info = $module_info;
$this->xml_info = $xml_info;
$this->skin_vars = $module_info->skin_vars;
// validate certificate info and permission settings necessary in Web-services
$is_logged = Context::get('is_logged');
$logged_info = Context::get('logged_info');
// module model create an object
$oModuleModel = getModel('module');
// permission settings. access, manager(== is_admin) are fixed and privilege name in XE
$module_srl = Context::get('module_srl');
if(!$module_info->mid && !is_array($module_srl) && preg_match('/^([0-9]+)$/', $module_srl))
{
$request_module = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if($request_module->module_srl == $module_srl)
{
$this->add('redirect_url', $url);
$grant = $oModuleModel->getGrant($request_module, $logged_info);
}
if($output !== NULL && is_object($output))
}
else
{
$grant = $oModuleModel->getGrant($module_info, $logged_info, $xml_info);
// have at least access grant
if(substr_count($this->act, 'Member') || substr_count($this->act, 'Communication'))
{
return $output;
$grant->access = 1;
}
}
/**
* get url for redirection
* @return string redirect_url
**/
function getRedirectUrl(){
return $this->get('redirect_url');
}
/**
* set message
* @param string $message a message string
* @param string $type type of message (error, info, update)
* @return void
**/
function setMessage($message, $type = null){
parent::setMessage($message);
$this->setMessageType($type);
}
/**
* set type of message
* @param string $type type of message (error, info, update)
* @return void
**/
function setMessageType($type){
$this->add('message_type', $type);
}
/**
* get type of message
* @return string $type
**/
function getMessageType(){
$type = $this->get('message_type');
$typeList = array('error'=>1, 'info'=>1, 'update'=>1);
if (!isset($typeList[$type])){
$type = $this->getError()?'error':'info';
// display no permission if the current module doesn't have an access privilege
//if(!$grant->access) return $this->stop("msg_not_permitted");
// checks permission and action if you don't have an admin privilege
if(!$grant->manager)
{
// get permission types(guest, member, manager, root) of the currently requested action
$permission_target = $xml_info->permission->{$this->act};
// check manager if a permission in module.xml otherwise action if no permission
if(!$permission_target && substr_count($this->act, 'Admin'))
{
$permission_target = 'manager';
}
return $type;
}
/**
* sett to set the template path for refresh.html
* refresh.html is executed as a result of method execution
* Tpl as the common run of the refresh.html ..
* @return void
**/
function setRefreshPage() {
$this->setTemplatePath('./common/tpl');
$this->setTemplateFile('refresh');
}
/**
* sett to set the action name
* @param string $act
* @return void
**/
function setAct($act) {
$this->act = $act;
}
/**
* sett to set module information
* @param object $module_info object containing module information
* @param object $xml_info object containing module description
* @return void
**/
function setModuleInfo($module_info, $xml_info) {
// The default variable settings
$this->mid = $module_info->mid;
$this->module_srl = $module_info->module_srl;
$this->module_info = $module_info;
$this->origin_module_info = $module_info;
$this->xml_info = $xml_info;
$this->skin_vars = $module_info->skin_vars;
// validate certificate info and permission settings necessary in Web-services
$is_logged = Context::get('is_logged');
$logged_info = Context::get('logged_info');
// module model create an object
$oModuleModel = &getModel('module');
// permission settings. access, manager(== is_admin) are fixed and privilege name in XE
$module_srl = Context::get('module_srl');
if(!$module_info->mid && !is_array($module_srl) && preg_match('/^([0-9]+)$/',$module_srl)) {
$request_module = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if($request_module->module_srl == $module_srl) {
$grant = $oModuleModel->getGrant($request_module, $logged_info);
}
} else {
$grant = $oModuleModel->getGrant($module_info, $logged_info, $xml_info);
// have at least access grant
if( substr_count($this->act, 'Member') || substr_count($this->act, 'Communication'))
$grant->access = 1;
}
// display no permission if the current module doesn't have an access privilege
//if(!$grant->access) return $this->stop("msg_not_permitted");
// checks permission and action if you don't have an admin privilege
if(!$grant->manager) {
// get permission types(guest, member, manager, root) of the currently requested action
$permission_target = $xml_info->permission->{$this->act};
// check manager if a permission in module.xml otherwise action if no permission
if(!$permission_target && substr_count($this->act, 'Admin')) $permission_target = 'manager';
// Check permissions
switch($permission_target) {
case 'root' :
case 'manager' :
$this->stop('msg_is_not_administrator');
// Check permissions
switch($permission_target)
{
case 'root' :
case 'manager' :
$this->stop('msg_is_not_administrator');
return;
case 'member' :
if(!$is_logged)
{
$this->stop('msg_not_permitted_act');
return;
case 'member' :
if(!$is_logged)
{
$this->stop('msg_not_permitted_act');
return;
}
break;
}
}
// permission variable settings
$this->grant = $grant;
}
break;
}
}
// permission variable settings
$this->grant = $grant;
Context::set('grant', $grant);
Context::set('grant', $grant);
$this->module_config = $oModuleModel->getModuleConfig($this->module, $module_info->site_srl);
$this->module_config = $oModuleModel->getModuleConfig($this->module, $module_info->site_srl);
if(method_exists($this, 'init')) $this->init();
}
if(method_exists($this, 'init'))
{
$this->init();
}
}
/**
* set the stop_proc and approprate message for msg_code
* @param string $msg_code an error code
* @return ModuleObject $this
**/
function stop($msg_code) {
// flag setting to stop the proc processing
$this->stop_proc = true;
// Error handling
$this->setError(-1);
$this->setMessage($msg_code);
// Error message display by message module
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($msg_code);
$oMessageObject->dispMessage();
/**
* set the stop_proc and approprate message for msg_code
* @param string $msg_code an error code
* @return ModuleObject $this
* */
function stop($msg_code)
{
// flag setting to stop the proc processing
$this->stop_proc = TRUE;
// Error handling
$this->setError(-1);
$this->setMessage($msg_code);
// Error message display by message module
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($msg_code);
$oMessageObject->dispMessage();
$this->setTemplatePath($oMessageObject->getTemplatePath());
$this->setTemplateFile($oMessageObject->getTemplateFile());
$this->setTemplatePath($oMessageObject->getTemplatePath());
$this->setTemplateFile($oMessageObject->getTemplateFile());
return $this;
}
return $this;
}
/**
* set the file name of the template file
* @param string name of file
* @return void
**/
function setTemplateFile($filename) {
if(substr($filename,-5)!='.html') $filename .= '.html';
$this->template_file = $filename;
}
/**
* set the file name of the template file
* @param string name of file
* @return void
* */
function setTemplateFile($filename)
{
if(substr($filename, -5) != '.html')
{
$filename .= '.html';
}
$this->template_file = $filename;
}
/**
* retrieve the directory path of the template directory
* @return string
**/
function getTemplateFile() {
return $this->template_file;
}
/**
* retrieve the directory path of the template directory
* @return string
* */
function getTemplateFile()
{
return $this->template_file;
}
/**
* set the directory path of the template directory
* @param string path of template directory.
* @return void
**/
function setTemplatePath($path) {
if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
if(substr($path,-1)!='/') $path .= '/';
$this->template_path = $path;
}
/**
* set the directory path of the template directory
* @param string path of template directory.
* @return void
* */
function setTemplatePath($path)
{
if(substr($path, 0, 1) != '/' && substr($path, 0, 2) != './')
{
$path = './' . $path;
}
if(substr($path, -1) != '/')
{
$path .= '/';
}
$this->template_path = $path;
}
/**
* retrieve the directory path of the template directory
* @return string
**/
function getTemplatePath() {
return $this->template_path;
}
/**
* retrieve the directory path of the template directory
* @return string
* */
function getTemplatePath()
{
return $this->template_path;
}
/**
* set the file name of the temporarily modified by admin
* @param string name of file
* @return void
**/
function setEditedLayoutFile($filename) {
if(substr($filename,-5)!='.html') $filename .= '.html';
$this->edited_layout_file = $filename;
}
/**
* set the file name of the temporarily modified by admin
* @param string name of file
* @return void
* */
function setEditedLayoutFile($filename)
{
if(substr($filename, -5) != '.html')
{
$filename .= '.html';
}
$this->edited_layout_file = $filename;
}
/**
* retreived the file name of edited_layout_file
* @return string
**/
function getEditedLayoutFile() {
return $this->edited_layout_file;
}
/**
* retreived the file name of edited_layout_file
* @return string
* */
function getEditedLayoutFile()
{
return $this->edited_layout_file;
}
/**
* set the file name of the layout file
* @param string name of file
* @return void
**/
function setLayoutFile($filename) {
if(substr($filename,-5)!='.html') $filename .= '.html';
$this->layout_file = $filename;
}
/**
* set the file name of the layout file
* @param string name of file
* @return void
* */
function setLayoutFile($filename)
{
if(substr($filename, -5) != '.html')
{
$filename .= '.html';
}
$this->layout_file = $filename;
}
/**
* get the file name of the layout file
* @return string
**/
function getLayoutFile() {
return $this->layout_file;
}
/**
* get the file name of the layout file
* @return string
* */
function getLayoutFile()
{
return $this->layout_file;
}
/**
* set the directory path of the layout directory
* @param string path of layout directory.
**/
function setLayoutPath($path) {
if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
if(substr($path,-1)!='/') $path .= '/';
$this->layout_path = $path;
}
/**
* set the directory path of the layout directory
* @param string path of layout directory.
* */
function setLayoutPath($path)
{
if(substr($path, 0, 1) != '/' && substr($path, 0, 2) != './')
{
$path = './' . $path;
}
if(substr($path, -1) != '/')
{
$path .= '/';
}
$this->layout_path = $path;
}
/**
* set the directory path of the layout directory
* @return string
**/
function getLayoutPath() {
return $this->layout_path;
}
/**
* set the directory path of the layout directory
* @return string
* */
function getLayoutPath()
{
return $this->layout_path;
}
/**
* excute the member method specified by $act variable
* @return boolean true : success false : fail
**/
function proc() {
// pass if stop_proc is true
if($this->stop_proc) return false;
/**
* excute the member method specified by $act variable
* @return boolean true : success false : fail
* */
function proc()
{
// pass if stop_proc is true
if($this->stop_proc)
{
return false;
}
// trigger call
$triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'before', $this);
if(!$triggerOutput->toBool()) {
$this->setError($triggerOutput->getError());
$this->setMessage($triggerOutput->getMessage());
return false;
}
// trigger call
$triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'before', $this);
if(!$triggerOutput->toBool())
{
$this->setError($triggerOutput->getError());
$this->setMessage($triggerOutput->getMessage());
return false;
}
// execute an addon(call called_position as before_module_proc)
$called_position = 'before_module_proc';
$oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file);
// execute an addon(call called_position as before_module_proc)
$called_position = 'before_module_proc';
$oAddonController = getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
@include($addon_file);
if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) {
// Check permissions
if($this->module_srl && !$this->grant->access){
$this->stop("msg_not_permitted_act");
return FALSE;
if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act))
{
// Check permissions
if($this->module_srl && !$this->grant->access)
{
$this->stop("msg_not_permitted_act");
return FALSE;
}
// integrate skin information of the module(change to sync skin info with the target module only by seperating its table)
$is_default_skin = ((!Mobile::isFromMobilePhone() && $this->module_info->is_skin_fix == 'N') || (Mobile::isFromMobilePhone() && $this->module_info->is_mskin_fix == 'N'));
$usedSkinModule = !($this->module == 'page' && ($this->module_info->page_type == 'OUTSIDE' || $this->module_info->page_type == 'WIDGET'));
if($usedSkinModule && $is_default_skin && $this->module != 'admin' && strpos($this->act, 'Admin') === false && $this->module == $this->module_info->module)
{
$dir = (Mobile::isFromMobilePhone()) ? 'm.skins' : 'skins';
$valueName = (Mobile::isFromMobilePhone()) ? 'mskin' : 'skin';
$oModuleModel = getModel('module');
$skinType = (Mobile::isFromMobilePhone()) ? 'M' : 'P';
$skinName = $oModuleModel->getModuleDefaultSkin($this->module, $skinType);
if($this->module == 'page')
{
$this->module_info->{$valueName} = $skinName;
}
// integrate skin information of the module(change to sync skin info with the target module only by seperating its table)
$oModuleModel = &getModel('module');
$oModuleModel->syncSkinInfoToModuleInfo($this->module_info);
Context::set('module_info', $this->module_info);
// Run
$output = $this->{$this->act}();
}
else {
else
{
$isTemplatPath = (strpos($this->getTemplatePath(), '/tpl/') !== FALSE);
if(!$isTemplatPath)
{
$this->setTemplatePath(sprintf('%s%s/%s/', $this->module_path, $dir, $skinName));
}
}
}
$oModuleModel = getModel('module');
$oModuleModel->syncSkinInfoToModuleInfo($this->module_info);
Context::set('module_info', $this->module_info);
// Run
$output = $this->{$this->act}();
}
else
{
return false;
}
// trigger call
$triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this);
if(!$triggerOutput->toBool())
{
$this->setError($triggerOutput->getError());
$this->setMessage($triggerOutput->getMessage());
return false;
}
// execute an addon(call called_position as after_module_proc)
$called_position = 'after_module_proc';
$oAddonController = getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
@include($addon_file);
if(is_a($output, 'Object') || is_subclass_of($output, 'Object'))
{
$this->setError($output->getError());
$this->setMessage($output->getMessage());
if(!$output->toBool())
{
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')
{
if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON')
{
$oAPI = getAPI($this->module_info->module, 'api');
if(method_exists($oAPI, $this->act))
{
$oAPI->{$this->act}($this);
}
}
}
return true;
}
// trigger call
$triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this);
if(!$triggerOutput->toBool()) {
$this->setError($triggerOutput->getError());
$this->setMessage($triggerOutput->getMessage());
return false;
}
// execute an addon(call called_position as after_module_proc)
$called_position = 'after_module_proc';
$oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file);
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
$this->setError($output->getError());
$this->setMessage($output->getMessage());
if (!$output->toBool()) 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'){
if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') {
$oAPI = getAPI($this->module_info->module, 'api');
if(method_exists($oAPI, $this->act)) {
$oAPI->{$this->act}($this);
}
}
}
return true;
}
}
}
?>

View file

@ -1,11 +1,12 @@
<?php
/**
* Every modules inherits from Object class. It includes error, message, and other variables for communicatin purpose.
*
* @author NHN (developers@xpressengine.com)
*/
class Object {
class Object
{
/**
* Error code. If `0`, it is not an error.
@ -17,7 +18,7 @@ class Object {
* Error message. If `success`, it is not an error.
* @var string
*/
var $message = 'success';
var $message = 'success';
/**
* An additional variable
@ -31,7 +32,6 @@ class Object {
*/
var $httpStatusCode = NULL;
/**
* Constructor
*
@ -39,19 +39,20 @@ class Object {
* @param string $message Error message
* @return void
*/
function Object($error = 0, $message = 'success') {
function Object($error = 0, $message = 'success')
{
$this->setError($error);
$this->setMessage($message);
}
/**
* Setter to set error code
*
* @param int $error error code
* @return void
*/
function setError($error = 0) {
function setError($error = 0)
{
$this->error = $error;
}
@ -60,7 +61,8 @@ class Object {
*
* @return int Returns an error code
*/
function getError() {
function getError()
{
return $this->error;
}
@ -91,12 +93,14 @@ class Object {
* @param string $message Error message
* @return bool Alaways returns true.
*/
function setMessage($message = 'success') {
if(Context::getLang($message)) $message = Context::getLang($message);
function setMessage($message = 'success')
{
if(Context::getLang($message))
$message = Context::getLang($message);
$this->message = $message;
// TODO This method always returns True. We'd better remove it
return true;
return TRUE;
}
/**
@ -104,7 +108,8 @@ class Object {
*
* @return string Returns message
*/
function getMessage() {
function getMessage()
{
return $this->message;
}
@ -115,7 +120,8 @@ class Object {
* @param mixed $val A value for the variable
* @return void
*/
function add($key, $val) {
function add($key, $val)
{
$this->variables[$key] = $val;
}
@ -130,11 +136,14 @@ class Object {
if(is_object($object))
{
$object = get_object_vars($object);
}
}
if(is_array($object))
{
foreach($object as $key => $val) $this->variables[$key] = $val;
foreach($object as $key => $val)
{
$this->variables[$key] = $val;
}
}
}
@ -144,20 +153,22 @@ class Object {
* @param string $key
* @return string Returns value to a given key
*/
function get($key) {
function get($key)
{
return $this->variables[$key];
}
/**
* Method to retrieve an object containing a key/value paris
*
* @return Object Returns an object containing key/value pairs
*/
function gets() {
function gets()
{
$num_args = func_num_args();
$args_list = func_get_args();
for($i=0;$i<$num_args;$i++) {
for($i = 0; $i < $num_args; $i++)
{
$key = $args_list[$i];
$output->{$key} = $this->get($key);
}
@ -169,7 +180,8 @@ class Object {
*
* @return array
*/
function getVariables() {
function getVariables()
{
return $this->variables;
}
@ -178,8 +190,13 @@ class Object {
*
* @return Object
*/
function getObjectVars() {
foreach($this->variables as $key => $val) $output->{$key} = $val;
function getObjectVars()
{
$output = new stdClass();
foreach($this->variables as $key => $val)
{
$output->{$key} = $val;
}
return $output;
}
@ -188,21 +205,22 @@ class Object {
*
* @return bool Retruns true : error isn't 0 or false : otherwise.
*/
function toBool() {
function toBool()
{
// TODO This method is misleading in that it returns true if error is 0, which should be true in boolean representation.
return $this->error==0?true:false;
return $this->error == 0 ? TRUE : FALSE;
}
/**
* Method to return either true or false depnding on the value in a 'error' variable
*
* @return bool
*/
function toBoolean() {
return $this->toBool();
function toBoolean()
{
return $this->toBool();
}
}
}
/* End of file Object.class.php */
/* Location: ./classes/object/Object.class.php */

View file

@ -1,68 +1,92 @@
<?php
/**
* @class PageHandler
* @author NHN (developers@xpressengine.com)
* handles page navigation
* @version 0.1
*
* @remarks Getting total counts, number of pages, current page number, number of items per page,
* this class implements methods and contains variables for page navigation
**/
class PageHandler extends Handler {
/**
* @class PageHandler
* @author NHN (developers@xpressengine.com)
* handles page navigation
* @version 0.1
*
* @remarks Getting total counts, number of pages, current page number, number of items per page,
* this class implements methods and contains variables for page navigation
*/
class PageHandler extends Handler
{
var $total_count = 0; ///< number of total items
var $total_page = 0; ///< number of total pages
var $cur_page = 0; ///< current page number
var $page_count = 10; ///< number of page links displayed at one time
var $first_page = 1; ///< first page number
var $last_page = 1; ///< last page number
var $point = 0; ///< increments per getNextPage()
var $total_count = 0; ///< number of total items
var $total_page = 0; ///< number of total pages
var $cur_page = 0; ///< current page number
var $page_count = 10; ///< number of page links displayed at one time
var $first_page = 1; ///< first page number
var $last_page = 1; ///< last page number
var $point = 0; ///< increments per getNextPage()
/**
* constructor
* @param int $total_count number of total items
* @param int $total_page number of total pages
* @param int $cur_page current page number
* @param int $page_count number of page links displayed at one time
* @return void
**/
function PageHandler($total_count, $total_page, $cur_page, $page_count = 10) {
$this->total_count = $total_count;
$this->total_page = $total_page;
$this->cur_page = $cur_page;
$this->page_count = $page_count;
$this->point = 0;
/**
* constructor
* @param int $total_count number of total items
* @param int $total_page number of total pages
* @param int $cur_page current page number
* @param int $page_count number of page links displayed at one time
* @return void
*/
$first_page = $cur_page - (int)($page_count/2);
if($first_page<1) $first_page = 1;
$last_page = $total_page;
if($last_page>$total_page) $last_page = $total_page;
function PageHandler($total_count, $total_page, $cur_page, $page_count = 10)
{
$this->total_count = $total_count;
$this->total_page = $total_page;
$this->cur_page = $cur_page;
$this->page_count = $page_count;
$this->point = 0;
$this->first_page = $first_page;
$this->last_page = $last_page;
if($total_page < $this->page_count) $this->page_count = $total_page;
}
/**
* request next page
* @return int next page number
**/
function getNextPage() {
$page = $this->first_page+$this->point++;
if($this->point > $this->page_count || $page > $this->last_page) $page = 0;
return $page;
}
/**
* return number of page that added offset.
* @param int $offset
* @return int
**/
function getPage($offset)
$first_page = $cur_page - (int) ($page_count / 2);
if($first_page < 1)
{
return max(min($this->cur_page + $offset, $this->total_page), '');
$first_page = 1;
}
}
?>
if($total_page > $page_count && $first_page + $page_count - 1 > $total_page)
{
$first_page -= $first_page + $page_count - 1 - $total_page;
}
$last_page = $total_page;
if($last_page > $total_page)
{
$last_page = $total_page;
}
$this->first_page = $first_page;
$this->last_page = $last_page;
if($total_page < $this->page_count)
{
$this->page_count = $total_page;
}
}
/**
* request next page
* @return int next page number
*/
function getNextPage()
{
$page = $this->first_page + $this->point++;
if($this->point > $this->page_count || $page > $this->last_page)
{
$page = 0;
}
return $page;
}
/**
* return number of page that added offset.
* @param int $offset
* @return int
*/
function getPage($offset)
{
return max(min($this->cur_page + $offset, $this->total_page), '');
}
}
/* End of file PageHandler.class.php */
/* Location: ./classes/page/PageHandler.class.php */

View file

@ -1,13 +1,16 @@
<?php
include _XE_PATH_ . 'classes/security/phphtmlparser/src/htmlparser.inc';
class EmbedFilter
{
/**
* allow script access list
* @var array
*/
var $allowscriptaccessList = array();
/**
* allow script access key
* @var int
@ -18,238 +21,238 @@ class EmbedFilter
var $whiteUrlList = array();
var $whiteIframeUrlList = array();
var $parser = NULL;
var $mimeTypeList = array('application/andrew-inset'=>1, 'application/applixware'=>1, 'application/atom+xml'=>1, 'application/atomcat+xml'=>1, 'application/atomsvc+xml'=>1,
'application/ccxml+xml'=>1, 'application/cdmi-capability'=>1, 'application/cdmi-container'=>1, 'application/cdmi-domain'=>1, 'application/cdmi-object'=>1,
'application/cdmi-queue'=>1, 'application/cu-seeme'=>1, 'application/davmount+xml'=>1, 'application/docbook+xml'=>1, 'application/dssc+der'=>1, 'application/dssc+xml'=>1,
'application/ecmascript'=>1, 'application/emma+xml'=>1, 'application/epub+zip'=>1, 'application/exi'=>1, 'application/font-tdpfr'=>1, 'application/gml+xml'=>1,
'application/gpx+xml'=>1, 'application/gxf'=>1, 'application/hyperstudio'=>1, 'application/inkml+xml'=>1, 'application/inkml+xml'=>1, 'application/ipfix'=>1,
'application/java-archive'=>1, 'application/java-serialized-object'=>1, 'application/java-vm'=>1, 'application/javascript'=>1, 'application/json'=>1,
'application/jsonml+json'=>1, 'application/lost+xml'=>1, 'application/mac-binhex40'=>1, 'application/mac-compactpro'=>1, 'application/mads+xml'=>1,
'application/marc'=>1, 'application/marcxml+xml'=>1, 'application/mathematica'=>1, 'application/mathematica'=>1, 'application/mathematica'=>1, 'application/mathml+xml'=>1,
'application/mbox'=>1, 'application/mediaservercontrol+xml'=>1, 'application/metalink+xml'=>1, 'application/metalink4+xml'=>1, 'application/mets+xml'=>1,
'application/mods+xml'=>1, 'application/mp21'=>1, 'application/mp4'=>1, 'application/msword'=>1, 'application/mxf'=>1, 'application/octet-stream'=>1,
'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1,
'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1, 'application/octet-stream'=>1,
'application/octet-stream'=>1, 'application/oda'=>1, 'application/oebps-package+xml'=>1, 'application/ogg'=>1, 'application/omdoc+xml'=>1, 'application/onenote'=>1,
'application/onenote'=>1, 'application/onenote'=>1, 'application/onenote'=>1, 'application/oxps'=>1, 'application/patch-ops-error+xml'=>1, 'application/pdf'=>1,
'application/pgp-encrypted'=>1, 'application/pgp-signature'=>1, 'application/pgp-signature'=>1, 'application/pics-rules'=>1, 'application/pkcs10'=>1,
'application/pkcs7-mime'=>1, 'application/pkcs7-mime'=>1, 'application/pkcs7-signature'=>1, 'application/pkcs8'=>1, 'application/pkix-attr-cert'=>1,
'application/pkix-cert'=>1, 'application/pkix-crl'=>1, 'application/pkix-pkipath'=>1, 'application/pkixcmp'=>1, 'application/pls+xml'=>1,
'application/postscript'=>1, 'application/postscript'=>1, 'application/postscript'=>1, 'application/prs.cww'=>1, 'application/pskc+xml'=>1,
'application/rdf+xml'=>1, 'application/reginfo+xml'=>1, 'application/relax-ng-compact-syntax'=>1, 'application/resource-lists+xml'=>1,
'application/resource-lists-diff+xml'=>1, 'application/rls-services+xml'=>1, 'application/rpki-ghostbusters'=>1, 'application/rpki-manifest'=>1,
'application/rpki-roa'=>1, 'application/rsd+xml'=>1, 'application/rss+xml'=>1, 'application/rtf'=>1, 'application/sbml+xml'=>1, 'application/scvp-cv-request'=>1,
'application/scvp-cv-response'=>1, 'application/scvp-vp-request'=>1, 'application/scvp-vp-response'=>1, 'application/sdp'=>1, 'application/set-payment-initiation'=>1,
'application/set-registration-initiation'=>1, 'application/shf+xml'=>1, 'application/smil+xml'=>1, 'application/smil+xml'=>1, 'application/sparql-query'=>1,
'application/sparql-results+xml'=>1, 'application/srgs'=>1, 'application/srgs+xml'=>1, 'application/sru+xml'=>1, 'application/ssdl+xml'=>1,
'application/ssml+xml'=>1, 'application/tei+xml'=>1, 'application/tei+xml'=>1, 'application/thraud+xml'=>1, 'application/timestamped-data'=>1,
'application/vnd.3gpp.pic-bw-large'=>1, 'application/vnd.3gpp.pic-bw-small'=>1, 'application/vnd.3gpp.pic-bw-var'=>1, 'application/vnd.3gpp2.tcap'=>1,
'application/vnd.3m.post-it-notes'=>1, 'application/vnd.accpac.simply.aso'=>1, 'application/vnd.accpac.simply.imp'=>1, 'application/vnd.acucobol'=>1,
'application/vnd.acucorp'=>1, 'application/vnd.acucorp'=>1, 'application/vnd.adobe.air-application-installer-package+zip'=>1, 'application/vnd.adobe.formscentral.fcdt'=>1,
'application/vnd.adobe.fxp'=>1, 'application/vnd.adobe.fxp'=>1, 'application/vnd.adobe.xdp+xml'=>1, 'application/vnd.adobe.xfdf'=>1, 'application/vnd.ahead.space'=>1,
'application/vnd.airzip.filesecure.azf'=>1, 'application/vnd.airzip.filesecure.azs'=>1, 'application/vnd.amazon.ebook'=>1, 'application/vnd.americandynamics.acc'=>1,
'application/vnd.amiga.ami'=>1, 'application/vnd.android.package-archive'=>1, 'application/vnd.anser-web-certificate-issue-initiation'=>1,
'application/vnd.anser-web-funds-transfer-initiation'=>1, 'application/vnd.antix.game-component'=>1, 'application/vnd.apple.installer+xml'=>1,
'application/vnd.apple.mpegurl'=>1, 'application/vnd.aristanetworks.swi'=>1, 'application/vnd.astraea-software.iota'=>1, 'application/vnd.audiograph'=>1,
'application/vnd.blueice.multipass'=>1, 'application/vnd.bmi'=>1, 'application/vnd.businessobjects'=>1, 'application/vnd.chemdraw+xml'=>1,
'application/vnd.chipnuts.karaoke-mmd'=>1, 'application/vnd.cinderella'=>1, 'application/vnd.claymore'=>1, 'application/vnd.cloanto.rp9'=>1,
'application/vnd.clonk.c4group'=>1, 'application/vnd.clonk.c4group'=>1, 'application/vnd.clonk.c4group'=>1, 'application/vnd.clonk.c4group'=>1,
'application/vnd.clonk.c4group'=>1, 'application/vnd.cluetrust.cartomobile-config'=>1, 'application/vnd.cluetrust.cartomobile-config-pkg'=>1,
'application/vnd.commonspace'=>1, 'application/vnd.contact.cmsg'=>1, 'application/vnd.cosmocaller'=>1, 'application/vnd.crick.clicker'=>1,
'application/vnd.crick.clicker.keyboard'=>1, 'application/vnd.crick.clicker.palette'=>1, 'application/vnd.crick.clicker.template'=>1,
'application/vnd.crick.clicker.wordbank'=>1, 'application/vnd.criticaltools.wbs+xml'=>1, 'application/vnd.ctc-posml'=>1, 'application/vnd.cups-ppd'=>1,
'application/vnd.curl.car'=>1, 'application/vnd.curl.pcurl'=>1, 'application/vnd.dart'=>1, 'application/vnd.data-vision.rdz'=>1, 'application/vnd.dece.data'=>1,
'application/vnd.dece.data'=>1, 'application/vnd.dece.data'=>1, 'application/vnd.dece.data'=>1, 'application/vnd.dece.ttml+xml'=>1, 'application/vnd.dece.ttml+xml'=>1,
'application/vnd.dece.unspecified'=>1, 'application/vnd.dece.unspecified'=>1, 'application/vnd.dece.zip'=>1, 'application/vnd.dece.zip'=>1,
'application/vnd.denovo.fcselayout-link'=>1, 'application/vnd.dna'=>1, 'application/vnd.dolby.mlp'=>1, 'application/vnd.dpgraph'=>1, 'application/vnd.dreamfactory'=>1,
'application/vnd.ds-keypoint'=>1, 'application/vnd.dvb.ait'=>1, 'application/vnd.dvb.service'=>1, 'application/vnd.dynageo'=>1, 'application/vnd.ecowin.chart'=>1,
'application/vnd.enliven'=>1, 'application/vnd.epson.esf'=>1, 'application/vnd.epson.msf'=>1, 'application/vnd.epson.quickanime'=>1, 'application/vnd.epson.salt'=>1,
'application/vnd.epson.ssf'=>1, 'application/vnd.eszigno3+xml'=>1, 'application/vnd.eszigno3+xml'=>1, 'application/vnd.ezpix-album'=>1, 'application/vnd.ezpix-package'=>1,
'application/vnd.fdf'=>1, 'application/vnd.fdsn.mseed'=>1, 'application/vnd.fdsn.seed'=>1, 'application/vnd.fdsn.seed'=>1, 'application/vnd.flographit'=>1,
'application/vnd.fluxtime.clip'=>1, 'application/vnd.framemaker'=>1, 'application/vnd.framemaker'=>1, 'application/vnd.framemaker'=>1, 'application/vnd.framemaker'=>1,
'application/vnd.frogans.fnc'=>1, 'application/vnd.frogans.ltf'=>1, 'application/vnd.fsc.weblaunch'=>1, 'application/vnd.fujitsu.oasys'=>1,
'application/vnd.fujitsu.oasys2'=>1, 'application/vnd.fujitsu.oasys3'=>1, 'application/vnd.fujitsu.oasysgp'=>1, 'application/vnd.fujitsu.oasysprs'=>1,
'application/vnd.fujixerox.ddd'=>1, 'application/vnd.fujixerox.docuworks'=>1, 'application/vnd.fujixerox.docuworks.binder'=>1, 'application/vnd.fuzzysheet'=>1,
'application/vnd.genomatix.tuxedo'=>1, 'application/vnd.geogebra.file'=>1, 'application/vnd.geogebra.tool'=>1, 'application/vnd.geometry-explorer'=>1,
'application/vnd.geometry-explorer'=>1, 'application/vnd.geonext'=>1, 'application/vnd.geoplan'=>1, 'application/vnd.geospace'=>1, 'application/vnd.gmx'=>1,
'application/vnd.google-earth.kml+xml'=>1, 'application/vnd.google-earth.kmz'=>1, 'application/vnd.grafeq'=>1, 'application/vnd.grafeq'=>1,
'application/vnd.groove-account'=>1, 'application/vnd.groove-help'=>1, 'application/vnd.groove-identity-message'=>1, 'application/vnd.groove-injector'=>1,
'application/vnd.groove-tool-message'=>1, 'application/vnd.groove-tool-template'=>1, 'application/vnd.groove-vcard'=>1, 'application/vnd.hal+xml'=>1,
'application/vnd.handheld-entertainment+xml'=>1, 'application/vnd.hbci'=>1, 'application/vnd.hhe.lesson-player'=>1, 'application/vnd.hp-hpgl'=>1,
'application/vnd.hp-hpid'=>1, 'application/vnd.hp-hps'=>1, 'application/vnd.hp-jlyt'=>1, 'application/vnd.hp-pcl'=>1, 'application/vnd.hp-pclxl'=>1,
'application/vnd.hydrostatix.sof-data'=>1, 'application/vnd.ibm.minipay'=>1, 'application/vnd.ibm.modcap'=>1, 'application/vnd.ibm.modcap'=>1, 'application/vnd.ibm.modcap'=>1,
'application/vnd.ibm.rights-management'=>1, 'application/vnd.ibm.secure-container'=>1, 'application/vnd.iccprofile'=>1, 'application/vnd.iccprofile'=>1,
'application/vnd.igloader'=>1, 'application/vnd.immervision-ivp'=>1, 'application/vnd.immervision-ivu'=>1, 'application/vnd.insors.igm'=>1, 'application/vnd.intercon.formnet'=>1,
'application/vnd.intercon.formnet'=>1, 'application/vnd.intergeo'=>1, 'application/vnd.intu.qbo'=>1, 'application/vnd.intu.qfx'=>1, 'application/vnd.ipunplugged.rcprofile'=>1,
'application/vnd.irepository.package+xml'=>1, 'application/vnd.is-xpr'=>1, 'application/vnd.isac.fcs'=>1, 'application/vnd.jam'=>1, 'application/vnd.jcp.javame.midlet-rms'=>1,
'application/vnd.jisp'=>1, 'application/vnd.joost.joda-archive'=>1, 'application/vnd.kahootz'=>1, 'application/vnd.kahootz'=>1, 'application/vnd.kde.karbon'=>1,
'application/vnd.kde.kchart'=>1, 'application/vnd.kde.kformula'=>1, 'application/vnd.kde.kivio'=>1, 'application/vnd.kde.kontour'=>1, 'application/vnd.kde.kpresenter'=>1,
'application/vnd.kde.kpresenter'=>1, 'application/vnd.kde.kspread'=>1, 'application/vnd.kde.kword'=>1, 'application/vnd.kde.kword'=>1, 'application/vnd.kenameaapp'=>1,
'application/vnd.kidspiration'=>1, 'application/vnd.kinar'=>1, 'application/vnd.kinar'=>1, 'application/vnd.koan'=>1, 'application/vnd.koan'=>1, 'application/vnd.koan'=>1,
'application/vnd.koan'=>1, 'application/vnd.kodak-descriptor'=>1, 'application/vnd.las.las+xml'=>1, 'application/vnd.llamagraphics.life-balance.desktop'=>1,
'application/vnd.llamagraphics.life-balance.exchange+xml'=>1, 'application/vnd.lotus-1-2-3'=>1, 'application/vnd.lotus-approach'=>1, 'application/vnd.lotus-freelance'=>1,
'application/vnd.lotus-notes'=>1, 'application/vnd.lotus-organizer'=>1, 'application/vnd.lotus-screencam'=>1, 'application/vnd.lotus-wordpro'=>1,
'application/vnd.macports.portpkg'=>1, 'application/vnd.mcd'=>1, 'application/vnd.medcalcdata'=>1, 'application/vnd.mediastation.cdkey'=>1, 'application/vnd.mfer'=>1,
'application/vnd.mfmp'=>1, 'application/vnd.micrografx.flo'=>1, 'application/vnd.micrografx.igx'=>1, 'application/vnd.mif'=>1, 'application/vnd.mobius.daf'=>1,
'application/vnd.mobius.dis'=>1, 'application/vnd.mobius.mbk'=>1, 'application/vnd.mobius.mqy'=>1, 'application/vnd.mobius.msl'=>1, 'application/vnd.mobius.plc'=>1,
'application/vnd.mobius.txf'=>1, 'application/vnd.mophun.application'=>1, 'application/vnd.mophun.certificate'=>1, 'application/vnd.mozilla.xul+xml'=>1,
'application/vnd.ms-artgalry'=>1, 'application/vnd.ms-cab-compressed'=>1, 'application/vnd.ms-excel'=>1, 'application/vnd.ms-excel'=>1, 'application/vnd.ms-excel'=>1,
'application/vnd.ms-excel'=>1, 'application/vnd.ms-excel'=>1, 'application/vnd.ms-excel'=>1, 'application/vnd.ms-excel.addin.macroenabled.12'=>1,
'application/vnd.ms-excel.sheet.binary.macroenabled.12'=>1, 'application/vnd.ms-excel.sheet.macroenabled.12'=>1, 'application/vnd.ms-excel.template.macroenabled.12'=>1,
'application/vnd.ms-fontobject'=>1, 'application/vnd.ms-htmlhelp'=>1, 'application/vnd.ms-ims'=>1, 'application/vnd.ms-lrm'=>1, 'application/vnd.ms-officetheme'=>1,
'application/vnd.ms-pki.seccat'=>1, 'application/vnd.ms-pki.stl'=>1, 'application/vnd.ms-powerpoint'=>1, 'application/vnd.ms-powerpoint'=>1,
'application/vnd.ms-powerpoint'=>1, 'application/vnd.ms-powerpoint.addin.macroenabled.12'=>1, 'application/vnd.ms-powerpoint.presentation.macroenabled.12'=>1,
'application/vnd.ms-powerpoint.slide.macroenabled.12'=>1, 'application/vnd.ms-powerpoint.slideshow.macroenabled.12'=>1,
'application/vnd.ms-powerpoint.template.macroenabled.12'=>1, 'application/vnd.ms-project'=>1, 'application/vnd.ms-project'=>1,
'application/vnd.ms-word.document.macroenabled.12'=>1, 'application/vnd.ms-word.template.macroenabled.12'=>1, 'application/vnd.ms-works'=>1,
'application/vnd.ms-works'=>1, 'application/vnd.ms-works'=>1, 'application/vnd.ms-works'=>1, 'application/vnd.ms-wpl'=>1, 'application/vnd.ms-xpsdocument'=>1,
'application/vnd.mseq'=>1, 'application/vnd.musician'=>1, 'application/vnd.muvee.style'=>1, 'application/vnd.mynfc'=>1, 'application/vnd.neurolanguage.nlu'=>1,
'application/vnd.nitf'=>1, 'application/vnd.nitf'=>1, 'application/vnd.noblenet-directory'=>1, 'application/vnd.noblenet-sealer'=>1, 'application/vnd.noblenet-web'=>1,
'application/vnd.nokia.n-gage.data'=>1, 'application/vnd.nokia.n-gage.symbian.install'=>1, 'application/vnd.nokia.radio-preset'=>1, 'application/vnd.nokia.radio-presets'=>1,
'application/vnd.novadigm.edm'=>1, 'application/vnd.novadigm.edx'=>1, 'application/vnd.novadigm.ext'=>1, 'application/vnd.oasis.opendocument.chart'=>1,
'application/vnd.oasis.opendocument.chart-template'=>1, 'application/vnd.oasis.opendocument.database'=>1, 'application/vnd.oasis.opendocument.formula'=>1,
'application/vnd.oasis.opendocument.formula-template'=>1, 'application/vnd.oasis.opendocument.graphics'=>1, 'application/vnd.oasis.opendocument.graphics-template'=>1,
'application/vnd.oasis.opendocument.image'=>1, 'application/vnd.oasis.opendocument.image-template'=>1, 'application/vnd.oasis.opendocument.presentation'=>1,
'application/vnd.oasis.opendocument.presentation-template'=>1, 'application/vnd.oasis.opendocument.spreadsheet'=>1, 'application/vnd.oasis.opendocument.spreadsheet-template'=>1,
'application/vnd.oasis.opendocument.text'=>1, 'application/vnd.oasis.opendocument.text-master'=>1, 'application/vnd.oasis.opendocument.text-template'=>1,
'application/vnd.oasis.opendocument.text-web'=>1, 'application/vnd.olpc-sugar'=>1, 'application/vnd.oma.dd2+xml'=>1, 'application/vnd.openofficeorg.extension'=>1,
'application/vnd.openxmlformats-officedocument.presentationml.presentation'=>1, 'application/vnd.openxmlformats-officedocument.presentationml.slide'=>1,
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'=>1, 'application/vnd.openxmlformats-officedocument.presentationml.template'=>1,
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'=>1, 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'=>1,
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'=>1, 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'=>1,
'application/vnd.osgeo.mapguide.package'=>1, 'application/vnd.osgi.dp'=>1, 'application/vnd.osgi.subsystem'=>1, 'application/vnd.palm'=>1, 'application/vnd.palm'=>1,
'application/vnd.palm'=>1, 'application/vnd.pawaafile'=>1, 'application/vnd.pg.format'=>1, 'application/vnd.pg.osasli'=>1, 'application/vnd.picsel'=>1, 'application/vnd.pmi.widget'=>1,
'application/vnd.pocketlearn'=>1, 'application/vnd.powerbuilder6'=>1, 'application/vnd.previewsystems.box'=>1, 'application/vnd.proteus.magazine'=>1,
'application/vnd.publishare-delta-tree'=>1, 'application/vnd.pvi.ptid1'=>1, 'application/vnd.quark.quarkxpress'=>1, 'application/vnd.quark.quarkxpress'=>1,
'application/vnd.quark.quarkxpress'=>1, 'application/vnd.quark.quarkxpress'=>1, 'application/vnd.quark.quarkxpress'=>1, 'application/vnd.quark.quarkxpress'=>1,
'application/vnd.realvnc.bed'=>1, 'application/vnd.recordare.musicxml'=>1, 'application/vnd.recordare.musicxml+xml'=>1, 'application/vnd.rig.cryptonote'=>1,
'application/vnd.rim.cod'=>1, 'application/vnd.rn-realmedia'=>1, 'application/vnd.rn-realmedia-vbr'=>1, 'application/vnd.route66.link66+xml'=>1, 'application/vnd.sailingtracker.track'=>1,
'application/vnd.seemail'=>1, 'application/vnd.sema'=>1, 'application/vnd.semd'=>1, 'application/vnd.semf'=>1, 'application/vnd.shana.informed.formdata'=>1,
'application/vnd.shana.informed.formtemplate'=>1, 'application/vnd.shana.informed.interchange'=>1, 'application/vnd.shana.informed.package'=>1, 'application/vnd.simtech-mindmapper'=>1,
'application/vnd.simtech-mindmapper'=>1, 'application/vnd.smaf'=>1, 'application/vnd.smart.teacher'=>1, 'application/vnd.solent.sdkm+xml'=>1, 'application/vnd.solent.sdkm+xml'=>1,
'application/vnd.spotfire.dxp'=>1, 'application/vnd.spotfire.sfs'=>1, 'application/vnd.stardivision.calc'=>1, 'application/vnd.stardivision.draw'=>1,
'application/vnd.stardivision.impress'=>1, 'application/vnd.stardivision.math'=>1, 'application/vnd.stardivision.writer'=>1, 'application/vnd.stardivision.writer'=>1,
'application/vnd.stardivision.writer-global'=>1, 'application/vnd.stepmania.package'=>1, 'application/vnd.stepmania.stepchart'=>1, 'application/vnd.sun.xml.calc'=>1,
'application/vnd.sun.xml.calc.template'=>1, 'application/vnd.sun.xml.draw'=>1, 'application/vnd.sun.xml.draw.template'=>1, 'application/vnd.sun.xml.impress'=>1,
'application/vnd.sun.xml.impress.template'=>1, 'application/vnd.sun.xml.math'=>1, 'application/vnd.sun.xml.writer'=>1, 'application/vnd.sun.xml.writer.global'=>1,
'application/vnd.sun.xml.writer.template'=>1, 'application/vnd.sus-calendar'=>1, 'application/vnd.sus-calendar'=>1, 'application/vnd.svd'=>1, 'application/vnd.symbian.install'=>1,
'application/vnd.symbian.install'=>1, 'application/vnd.syncml+xml'=>1, 'application/vnd.syncml.dm+wbxml'=>1, 'application/vnd.syncml.dm+xml'=>1,
'application/vnd.tao.intent-module-archive'=>1, 'application/vnd.tcpdump.pcap'=>1, 'application/vnd.tcpdump.pcap'=>1, 'application/vnd.tcpdump.pcap'=>1,
'application/vnd.tmobile-livetv'=>1, 'application/vnd.trid.tpt'=>1, 'application/vnd.triscape.mxs'=>1, 'application/vnd.trueapp'=>1, 'application/vnd.ufdl'=>1, 'application/vnd.ufdl'=>1,
'application/vnd.uiq.theme'=>1, 'application/vnd.umajin'=>1, 'application/vnd.unity'=>1, 'application/vnd.uoml+xml'=>1, 'application/vnd.vcx'=>1, 'application/vnd.visio'=>1,
'application/vnd.visio'=>1, 'application/vnd.visio'=>1, 'application/vnd.visio'=>1, 'application/vnd.visionary'=>1, 'application/vnd.vsf'=>1, 'application/vnd.wap.wbxml'=>1,
'application/vnd.wap.wmlc'=>1, 'application/vnd.wap.wmlscriptc'=>1, 'application/vnd.webturbo'=>1, 'application/vnd.wolfram.player'=>1, 'application/vnd.wordperfect'=>1,
'application/vnd.wqd'=>1, 'application/vnd.wt.stf'=>1, 'application/vnd.xara'=>1, 'application/vnd.xfdl'=>1, 'application/vnd.yamaha.hv-dic'=>1, 'application/vnd.yamaha.hv-script'=>1,
'application/vnd.yamaha.hv-voice'=>1, 'application/vnd.yamaha.openscoreformat'=>1, 'application/vnd.yamaha.openscoreformat.osfpvg+xml'=>1, 'application/vnd.yamaha.smaf-audio'=>1,
'application/vnd.yamaha.smaf-phrase'=>1, 'application/vnd.yellowriver-custom-menu'=>1, 'application/vnd.zul'=>1, 'application/vnd.zul'=>1, 'application/vnd.zzazz.deck+xml'=>1,
'application/voicexml+xml'=>1, 'application/widget'=>1, 'application/winhlp'=>1, 'application/wsdl+xml'=>1, 'application/wspolicy+xml'=>1, 'application/x-7z-compressed'=>1,
'application/x-abiword'=>1, 'application/x-ace-compressed'=>1, 'application/x-apple-diskimage'=>1, 'application/x-authorware-bin'=>1, 'application/x-authorware-bin'=>1,
'application/x-authorware-bin'=>1, 'application/x-authorware-bin'=>1, 'application/x-authorware-map'=>1, 'application/x-authorware-seg'=>1, 'application/x-bcpio'=>1,
'application/x-bittorrent'=>1, 'application/x-blorb'=>1, 'application/x-blorb'=>1, 'application/x-bzip'=>1, 'application/x-bzip2'=>1, 'application/x-bzip2'=>1, 'application/x-cbr'=>1,
'application/x-cbr'=>1, 'application/x-cbr'=>1, 'application/x-cbr'=>1, 'application/x-cbr'=>1, 'application/x-cdlink'=>1, 'application/x-cfs-compressed'=>1, 'application/x-chat'=>1,
'application/x-chess-pgn'=>1, 'application/x-conference'=>1, 'application/x-cpio'=>1, 'application/x-csh'=>1, 'application/x-debian-package'=>1, 'application/x-debian-package'=>1,
'application/x-dgc-compressed'=>1, 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-director'=>1,
'application/x-director'=>1, 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-director'=>1, 'application/x-doom'=>1, 'application/x-dtbncx+xml'=>1,
'application/x-dtbook+xml'=>1, 'application/x-dtbresource+xml'=>1, 'application/x-dvi'=>1, 'application/x-envoy'=>1, 'application/x-eva'=>1, 'application/x-font-bdf'=>1,
'application/x-font-ghostscript'=>1, 'application/x-font-linux-psf'=>1, 'application/x-font-otf'=>1, 'application/x-font-pcf'=>1, 'application/x-font-snf'=>1,
'application/x-font-ttf'=>1, 'application/x-font-ttf'=>1, 'application/x-font-type1'=>1, 'application/x-font-type1'=>1, 'application/x-font-type1'=>1, 'application/x-font-type1'=>1,
'application/x-font-woff'=>1, 'application/x-freearc'=>1, 'application/x-futuresplash'=>1, 'application/x-gca-compressed'=>1, 'application/x-glulx'=>1, 'application/x-gnumeric'=>1,
'application/x-gramps-xml'=>1, 'application/x-gtar'=>1, 'application/x-hdf'=>1, 'application/x-install-instructions'=>1, 'application/x-iso9660-image'=>1,
'application/x-java-jnlp-file'=>1, 'application/x-latex'=>1, 'application/x-lzh-compressed'=>1, 'application/x-lzh-compressed'=>1, 'application/x-mie'=>1,
'application/x-mobipocket-ebook'=>1, 'application/x-mobipocket-ebook'=>1, 'application/x-ms-application'=>1, 'application/x-ms-shortcut'=>1, 'application/x-ms-wmd'=>1,
'application/x-ms-wmz'=>1, 'application/x-ms-xbap'=>1, 'application/x-msaccess'=>1, 'application/x-msbinder'=>1, 'application/x-mscardfile'=>1, 'application/x-msclip'=>1,
'application/x-msdownload'=>1, 'application/x-msdownload'=>1, 'application/x-msdownload'=>1, 'application/x-msdownload'=>1, 'application/x-msdownload'=>1, 'application/x-msmediaview'=>1,
'application/x-msmediaview'=>1, 'application/x-msmediaview'=>1, 'application/x-msmetafile'=>1, 'application/x-msmetafile'=>1, 'application/x-msmetafile'=>1, 'application/x-msmetafile'=>1,
'application/x-msmoney'=>1, 'application/x-mspublisher'=>1, 'application/x-msschedule'=>1, 'application/x-msterminal'=>1, 'application/x-mswrite'=>1, 'application/x-netcdf'=>1,
'application/x-netcdf'=>1, 'application/x-nzb'=>1, 'application/x-pkcs12'=>1, 'application/x-pkcs12'=>1, 'application/x-pkcs7-certificates'=>1, 'application/x-pkcs7-certificates'=>1,
'application/x-pkcs7-certreqresp'=>1, 'application/x-rar-compressed'=>1, 'application/x-research-info-systems'=>1, 'application/x-sh'=>1, 'application/x-shar'=>1,
'application/x-shockwave-flash'=>1, 'application/x-silverlight-app'=>1, 'application/x-silverlight-2'=>1, 'application/x-sql'=>1, 'application/x-stuffit'=>1, 'application/x-stuffitx'=>1,
'application/x-subrip'=>1, 'application/x-sv4cpio'=>1, 'application/x-sv4crc'=>1, 'application/x-t3vm-image'=>1, 'application/x-tads'=>1, 'application/x-tar'=>1, 'application/x-tcl'=>1,
'application/x-tex'=>1, 'application/x-tex-tfm'=>1, 'application/x-texinfo'=>1, 'application/x-texinfo'=>1, 'application/x-tgif'=>1, 'application/x-ustar'=>1, 'application/x-wais-source'=>1,
'application/x-x509-ca-cert'=>1, 'application/x-x509-ca-cert'=>1, 'application/x-xfig'=>1, 'application/x-xliff+xml'=>1, 'application/x-xpinstall'=>1, 'application/x-xz'=>1,
'application/x-zmachine'=>1, 'application/x-zmachine'=>1, 'application/x-zmachine'=>1, 'application/x-zmachine'=>1, 'application/x-zmachine'=>1, 'application/x-zmachine'=>1,
'application/x-zmachine'=>1, 'application/x-zmachine'=>1, 'application/xaml+xml'=>1, 'application/xcap-diff+xml'=>1, 'application/xenc+xml'=>1, 'application/xhtml+xml'=>1,
'application/xhtml+xml'=>1, 'application/xml'=>1, 'application/xml'=>1, 'application/xml-dtd'=>1, 'application/xop+xml'=>1, 'application/xproc+xml'=>1, 'application/xslt+xml'=>1,
'application/xspf+xml'=>1, 'application/xv+xml'=>1, 'application/xv+xml'=>1, 'application/xv+xml'=>1, 'application/xv+xml'=>1, 'application/yang'=>1, 'application/yin+xml'=>1,
'application/zip'=>1, 'audio/adpcm'=>1, 'audio/basic'=>1, 'audio/basic'=>1, 'audio/midi'=>1, 'audio/midi'=>1, 'audio/midi'=>1, 'audio/midi'=>1, 'audio/mp4'=>1, 'audio/mpeg'=>1,
'audio/mpeg'=>1, 'audio/mpeg'=>1, 'audio/mpeg'=>1, 'audio/mpeg'=>1, 'audio/mpeg'=>1, 'audio/ogg'=>1, 'audio/ogg'=>1, 'audio/ogg'=>1, 'audio/s3m'=>1, 'audio/silk'=>1,
'audio/vnd.dece.audio'=>1, 'audio/vnd.dece.audio'=>1, 'audio/vnd.digital-winds'=>1, 'audio/vnd.dra'=>1, 'audio/vnd.dts'=>1, 'audio/vnd.dts.hd'=>1, 'audio/vnd.lucent.voice'=>1,
'audio/vnd.ms-playready.media.pya'=>1, 'audio/vnd.nuera.ecelp4800'=>1, 'audio/vnd.nuera.ecelp7470'=>1, 'audio/vnd.nuera.ecelp9600'=>1, 'audio/vnd.rip'=>1, 'audio/webm'=>1,
'audio/x-aac'=>1, 'audio/x-aiff'=>1, 'audio/x-aiff'=>1, 'audio/x-aiff'=>1, 'audio/x-caf'=>1, 'audio/x-flac'=>1, 'audio/x-matroska'=>1, 'audio/x-mpegurl'=>1, 'audio/x-ms-wax'=>1,
'audio/x-ms-wma'=>1, 'audio/x-pn-realaudio'=>1, 'audio/x-pn-realaudio'=>1, 'audio/x-pn-realaudio-plugin'=>1, 'audio/x-wav'=>1, 'audio/xm'=>1, 'chemical/x-cdx'=>1, 'chemical/x-cif'=>1,
'chemical/x-cmdf'=>1, 'chemical/x-cml'=>1, 'chemical/x-csml'=>1, 'chemical/x-xyz'=>1, 'image/bmp'=>1, 'image/cgm'=>1, 'image/g3fax'=>1, 'image/gif'=>1, 'image/ief'=>1, 'image/jpeg'=>1,
'image/jpeg'=>1, 'image/jpeg'=>1, 'image/ktx'=>1, 'image/png'=>1, 'image/prs.btif'=>1, 'image/sgi'=>1, 'image/svg+xml'=>1, 'image/svg+xml'=>1, 'image/tiff'=>1, 'image/tiff'=>1,
'image/vnd.adobe.photoshop'=>1, 'image/vnd.dece.graphic'=>1, 'image/vnd.dece.graphic'=>1, 'image/vnd.dece.graphic'=>1, 'image/vnd.dece.graphic'=>1, 'image/vnd.dvb.subtitle'=>1,
'image/vnd.djvu'=>1, 'image/vnd.djvu'=>1, 'image/vnd.dwg'=>1, 'image/vnd.dxf'=>1, 'image/vnd.fastbidsheet'=>1, 'image/vnd.fpx'=>1, 'image/vnd.fst'=>1, 'image/vnd.fujixerox.edmics-mmr'=>1,
'image/vnd.fujixerox.edmics-rlc'=>1, 'image/vnd.ms-modi'=>1, 'image/vnd.ms-photo'=>1, 'image/vnd.net-fpx'=>1, 'image/vnd.wap.wbmp'=>1, 'image/vnd.xiff'=>1, 'image/webp'=>1,
'image/x-3ds'=>1, 'image/x-cmu-raster'=>1, 'image/x-cmx'=>1, 'image/x-freehand'=>1, 'image/x-freehand'=>1, 'image/x-freehand'=>1, 'image/x-freehand'=>1, 'image/x-freehand'=>1,
'image/x-icon'=>1, 'image/x-mrsid-image'=>1, 'image/x-pcx'=>1, 'image/x-pict'=>1, 'image/x-pict'=>1, 'image/x-portable-anymap'=>1, 'image/x-portable-bitmap'=>1,
'image/x-portable-graymap'=>1, 'image/x-portable-pixmap'=>1, 'image/x-rgb'=>1, 'image/x-tga'=>1, 'image/x-xbitmap'=>1, 'image/x-xpixmap'=>1, 'image/x-xwindowdump'=>1,
'message/rfc822'=>1, 'message/rfc822'=>1, 'model/iges'=>1, 'model/iges'=>1, 'model/mesh'=>1, 'model/mesh'=>1, 'model/mesh'=>1, 'model/vnd.collada+xml'=>1, 'model/vnd.dwf'=>1,
'model/vnd.gdl'=>1, 'model/vnd.gtw'=>1, 'model/vnd.mts'=>1, 'model/vnd.vtu'=>1, 'model/vrml'=>1, 'model/vrml'=>1, 'model/x3d+binary'=>1, 'model/x3d+binary'=>1, 'model/x3d+vrml'=>1,
'model/x3d+vrml'=>1, 'model/x3d+xml'=>1, 'model/x3d+xml'=>1, 'video/3gpp'=>1, 'video/3gpp2'=>1, 'video/h261'=>1, 'video/h263'=>1, 'video/h264'=>1, 'video/jpeg'=>1, 'video/jpm'=>1,
'video/jpm'=>1, 'video/mj2'=>1, 'video/mj2'=>1, 'video/mp4'=>1, 'video/mp4'=>1, 'video/mp4'=>1, 'video/mpeg'=>1, 'video/mpeg'=>1, 'video/mpeg'=>1, 'video/mpeg'=>1, 'video/mpeg'=>1,
'video/ogg'=>1, 'video/quicktime'=>1, 'video/quicktime'=>1, 'video/vnd.dece.hd'=>1, 'video/vnd.dece.hd'=>1, 'video/vnd.dece.mobile'=>1, 'video/vnd.dece.mobile'=>1, 'video/vnd.dece.pd'=>1,
'video/vnd.dece.pd'=>1, 'video/vnd.dece.sd'=>1, 'video/vnd.dece.sd'=>1, 'video/vnd.dece.video'=>1, 'video/vnd.dece.video'=>1, 'video/vnd.dvb.file'=>1, 'video/vnd.fvt'=>1,
'video/vnd.mpegurl'=>1, 'video/vnd.mpegurl'=>1, 'video/vnd.ms-playready.media.pyv'=>1, 'video/vnd.uvvu.mp4'=>1, 'video/vnd.uvvu.mp4'=>1, 'video/vnd.vivo'=>1, 'video/webm'=>1,
'video/x-f4v'=>1, 'video/x-fli'=>1, 'video/x-flv'=>1, 'video/x-m4v'=>1, 'video/x-matroska'=>1, 'video/x-matroska'=>1, 'video/x-matroska'=>1, 'video/x-mng'=>1, 'video/x-ms-asf'=>1,
'video/x-ms-asf'=>1, 'video/x-ms-vob'=>1, 'video/x-ms-wm'=>1, 'video/x-ms-wmv'=>1, 'video/x-ms-wmx'=>1, 'video/x-ms-wvx'=>1, 'video/x-msvideo'=>1, 'video/x-sgi-movie'=>1,
'video/x-smv'=>1, 'x-conference/x-cooltalk'=>1
var $mimeTypeList = array('application/andrew-inset' => 1, 'application/applixware' => 1, 'application/atom+xml' => 1, 'application/atomcat+xml' => 1, 'application/atomsvc+xml' => 1,
'application/ccxml+xml' => 1, 'application/cdmi-capability' => 1, 'application/cdmi-container' => 1, 'application/cdmi-domain' => 1, 'application/cdmi-object' => 1,
'application/cdmi-queue' => 1, 'application/cu-seeme' => 1, 'application/davmount+xml' => 1, 'application/docbook+xml' => 1, 'application/dssc+der' => 1, 'application/dssc+xml' => 1,
'application/ecmascript' => 1, 'application/emma+xml' => 1, 'application/epub+zip' => 1, 'application/exi' => 1, 'application/font-tdpfr' => 1, 'application/gml+xml' => 1,
'application/gpx+xml' => 1, 'application/gxf' => 1, 'application/hyperstudio' => 1, 'application/inkml+xml' => 1, 'application/inkml+xml' => 1, 'application/ipfix' => 1,
'application/java-archive' => 1, 'application/java-serialized-object' => 1, 'application/java-vm' => 1, 'application/javascript' => 1, 'application/json' => 1,
'application/jsonml+json' => 1, 'application/lost+xml' => 1, 'application/mac-binhex40' => 1, 'application/mac-compactpro' => 1, 'application/mads+xml' => 1,
'application/marc' => 1, 'application/marcxml+xml' => 1, 'application/mathematica' => 1, 'application/mathematica' => 1, 'application/mathematica' => 1, 'application/mathml+xml' => 1,
'application/mbox' => 1, 'application/mediaservercontrol+xml' => 1, 'application/metalink+xml' => 1, 'application/metalink4+xml' => 1, 'application/mets+xml' => 1,
'application/mods+xml' => 1, 'application/mp21' => 1, 'application/mp4' => 1, 'application/msword' => 1, 'application/mxf' => 1, 'application/octet-stream' => 1,
'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1,
'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1, 'application/octet-stream' => 1,
'application/octet-stream' => 1, 'application/oda' => 1, 'application/oebps-package+xml' => 1, 'application/ogg' => 1, 'application/omdoc+xml' => 1, 'application/onenote' => 1,
'application/onenote' => 1, 'application/onenote' => 1, 'application/onenote' => 1, 'application/oxps' => 1, 'application/patch-ops-error+xml' => 1, 'application/pdf' => 1,
'application/pgp-encrypted' => 1, 'application/pgp-signature' => 1, 'application/pgp-signature' => 1, 'application/pics-rules' => 1, 'application/pkcs10' => 1,
'application/pkcs7-mime' => 1, 'application/pkcs7-mime' => 1, 'application/pkcs7-signature' => 1, 'application/pkcs8' => 1, 'application/pkix-attr-cert' => 1,
'application/pkix-cert' => 1, 'application/pkix-crl' => 1, 'application/pkix-pkipath' => 1, 'application/pkixcmp' => 1, 'application/pls+xml' => 1,
'application/postscript' => 1, 'application/postscript' => 1, 'application/postscript' => 1, 'application/prs.cww' => 1, 'application/pskc+xml' => 1,
'application/rdf+xml' => 1, 'application/reginfo+xml' => 1, 'application/relax-ng-compact-syntax' => 1, 'application/resource-lists+xml' => 1,
'application/resource-lists-diff+xml' => 1, 'application/rls-services+xml' => 1, 'application/rpki-ghostbusters' => 1, 'application/rpki-manifest' => 1,
'application/rpki-roa' => 1, 'application/rsd+xml' => 1, 'application/rss+xml' => 1, 'application/rtf' => 1, 'application/sbml+xml' => 1, 'application/scvp-cv-request' => 1,
'application/scvp-cv-response' => 1, 'application/scvp-vp-request' => 1, 'application/scvp-vp-response' => 1, 'application/sdp' => 1, 'application/set-payment-initiation' => 1,
'application/set-registration-initiation' => 1, 'application/shf+xml' => 1, 'application/smil+xml' => 1, 'application/smil+xml' => 1, 'application/sparql-query' => 1,
'application/sparql-results+xml' => 1, 'application/srgs' => 1, 'application/srgs+xml' => 1, 'application/sru+xml' => 1, 'application/ssdl+xml' => 1,
'application/ssml+xml' => 1, 'application/tei+xml' => 1, 'application/tei+xml' => 1, 'application/thraud+xml' => 1, 'application/timestamped-data' => 1,
'application/vnd.3gpp.pic-bw-large' => 1, 'application/vnd.3gpp.pic-bw-small' => 1, 'application/vnd.3gpp.pic-bw-var' => 1, 'application/vnd.3gpp2.tcap' => 1,
'application/vnd.3m.post-it-notes' => 1, 'application/vnd.accpac.simply.aso' => 1, 'application/vnd.accpac.simply.imp' => 1, 'application/vnd.acucobol' => 1,
'application/vnd.acucorp' => 1, 'application/vnd.acucorp' => 1, 'application/vnd.adobe.air-application-installer-package+zip' => 1, 'application/vnd.adobe.formscentral.fcdt' => 1,
'application/vnd.adobe.fxp' => 1, 'application/vnd.adobe.fxp' => 1, 'application/vnd.adobe.xdp+xml' => 1, 'application/vnd.adobe.xfdf' => 1, 'application/vnd.ahead.space' => 1,
'application/vnd.airzip.filesecure.azf' => 1, 'application/vnd.airzip.filesecure.azs' => 1, 'application/vnd.amazon.ebook' => 1, 'application/vnd.americandynamics.acc' => 1,
'application/vnd.amiga.ami' => 1, 'application/vnd.android.package-archive' => 1, 'application/vnd.anser-web-certificate-issue-initiation' => 1,
'application/vnd.anser-web-funds-transfer-initiation' => 1, 'application/vnd.antix.game-component' => 1, 'application/vnd.apple.installer+xml' => 1,
'application/vnd.apple.mpegurl' => 1, 'application/vnd.aristanetworks.swi' => 1, 'application/vnd.astraea-software.iota' => 1, 'application/vnd.audiograph' => 1,
'application/vnd.blueice.multipass' => 1, 'application/vnd.bmi' => 1, 'application/vnd.businessobjects' => 1, 'application/vnd.chemdraw+xml' => 1,
'application/vnd.chipnuts.karaoke-mmd' => 1, 'application/vnd.cinderella' => 1, 'application/vnd.claymore' => 1, 'application/vnd.cloanto.rp9' => 1,
'application/vnd.clonk.c4group' => 1, 'application/vnd.clonk.c4group' => 1, 'application/vnd.clonk.c4group' => 1, 'application/vnd.clonk.c4group' => 1,
'application/vnd.clonk.c4group' => 1, 'application/vnd.cluetrust.cartomobile-config' => 1, 'application/vnd.cluetrust.cartomobile-config-pkg' => 1,
'application/vnd.commonspace' => 1, 'application/vnd.contact.cmsg' => 1, 'application/vnd.cosmocaller' => 1, 'application/vnd.crick.clicker' => 1,
'application/vnd.crick.clicker.keyboard' => 1, 'application/vnd.crick.clicker.palette' => 1, 'application/vnd.crick.clicker.template' => 1,
'application/vnd.crick.clicker.wordbank' => 1, 'application/vnd.criticaltools.wbs+xml' => 1, 'application/vnd.ctc-posml' => 1, 'application/vnd.cups-ppd' => 1,
'application/vnd.curl.car' => 1, 'application/vnd.curl.pcurl' => 1, 'application/vnd.dart' => 1, 'application/vnd.data-vision.rdz' => 1, 'application/vnd.dece.data' => 1,
'application/vnd.dece.data' => 1, 'application/vnd.dece.data' => 1, 'application/vnd.dece.data' => 1, 'application/vnd.dece.ttml+xml' => 1, 'application/vnd.dece.ttml+xml' => 1,
'application/vnd.dece.unspecified' => 1, 'application/vnd.dece.unspecified' => 1, 'application/vnd.dece.zip' => 1, 'application/vnd.dece.zip' => 1,
'application/vnd.denovo.fcselayout-link' => 1, 'application/vnd.dna' => 1, 'application/vnd.dolby.mlp' => 1, 'application/vnd.dpgraph' => 1, 'application/vnd.dreamfactory' => 1,
'application/vnd.ds-keypoint' => 1, 'application/vnd.dvb.ait' => 1, 'application/vnd.dvb.service' => 1, 'application/vnd.dynageo' => 1, 'application/vnd.ecowin.chart' => 1,
'application/vnd.enliven' => 1, 'application/vnd.epson.esf' => 1, 'application/vnd.epson.msf' => 1, 'application/vnd.epson.quickanime' => 1, 'application/vnd.epson.salt' => 1,
'application/vnd.epson.ssf' => 1, 'application/vnd.eszigno3+xml' => 1, 'application/vnd.eszigno3+xml' => 1, 'application/vnd.ezpix-album' => 1, 'application/vnd.ezpix-package' => 1,
'application/vnd.fdf' => 1, 'application/vnd.fdsn.mseed' => 1, 'application/vnd.fdsn.seed' => 1, 'application/vnd.fdsn.seed' => 1, 'application/vnd.flographit' => 1,
'application/vnd.fluxtime.clip' => 1, 'application/vnd.framemaker' => 1, 'application/vnd.framemaker' => 1, 'application/vnd.framemaker' => 1, 'application/vnd.framemaker' => 1,
'application/vnd.frogans.fnc' => 1, 'application/vnd.frogans.ltf' => 1, 'application/vnd.fsc.weblaunch' => 1, 'application/vnd.fujitsu.oasys' => 1,
'application/vnd.fujitsu.oasys2' => 1, 'application/vnd.fujitsu.oasys3' => 1, 'application/vnd.fujitsu.oasysgp' => 1, 'application/vnd.fujitsu.oasysprs' => 1,
'application/vnd.fujixerox.ddd' => 1, 'application/vnd.fujixerox.docuworks' => 1, 'application/vnd.fujixerox.docuworks.binder' => 1, 'application/vnd.fuzzysheet' => 1,
'application/vnd.genomatix.tuxedo' => 1, 'application/vnd.geogebra.file' => 1, 'application/vnd.geogebra.tool' => 1, 'application/vnd.geometry-explorer' => 1,
'application/vnd.geometry-explorer' => 1, 'application/vnd.geonext' => 1, 'application/vnd.geoplan' => 1, 'application/vnd.geospace' => 1, 'application/vnd.gmx' => 1,
'application/vnd.google-earth.kml+xml' => 1, 'application/vnd.google-earth.kmz' => 1, 'application/vnd.grafeq' => 1, 'application/vnd.grafeq' => 1,
'application/vnd.groove-account' => 1, 'application/vnd.groove-help' => 1, 'application/vnd.groove-identity-message' => 1, 'application/vnd.groove-injector' => 1,
'application/vnd.groove-tool-message' => 1, 'application/vnd.groove-tool-template' => 1, 'application/vnd.groove-vcard' => 1, 'application/vnd.hal+xml' => 1,
'application/vnd.handheld-entertainment+xml' => 1, 'application/vnd.hbci' => 1, 'application/vnd.hhe.lesson-player' => 1, 'application/vnd.hp-hpgl' => 1,
'application/vnd.hp-hpid' => 1, 'application/vnd.hp-hps' => 1, 'application/vnd.hp-jlyt' => 1, 'application/vnd.hp-pcl' => 1, 'application/vnd.hp-pclxl' => 1,
'application/vnd.hydrostatix.sof-data' => 1, 'application/vnd.ibm.minipay' => 1, 'application/vnd.ibm.modcap' => 1, 'application/vnd.ibm.modcap' => 1, 'application/vnd.ibm.modcap' => 1,
'application/vnd.ibm.rights-management' => 1, 'application/vnd.ibm.secure-container' => 1, 'application/vnd.iccprofile' => 1, 'application/vnd.iccprofile' => 1,
'application/vnd.igloader' => 1, 'application/vnd.immervision-ivp' => 1, 'application/vnd.immervision-ivu' => 1, 'application/vnd.insors.igm' => 1, 'application/vnd.intercon.formnet' => 1,
'application/vnd.intercon.formnet' => 1, 'application/vnd.intergeo' => 1, 'application/vnd.intu.qbo' => 1, 'application/vnd.intu.qfx' => 1, 'application/vnd.ipunplugged.rcprofile' => 1,
'application/vnd.irepository.package+xml' => 1, 'application/vnd.is-xpr' => 1, 'application/vnd.isac.fcs' => 1, 'application/vnd.jam' => 1, 'application/vnd.jcp.javame.midlet-rms' => 1,
'application/vnd.jisp' => 1, 'application/vnd.joost.joda-archive' => 1, 'application/vnd.kahootz' => 1, 'application/vnd.kahootz' => 1, 'application/vnd.kde.karbon' => 1,
'application/vnd.kde.kchart' => 1, 'application/vnd.kde.kformula' => 1, 'application/vnd.kde.kivio' => 1, 'application/vnd.kde.kontour' => 1, 'application/vnd.kde.kpresenter' => 1,
'application/vnd.kde.kpresenter' => 1, 'application/vnd.kde.kspread' => 1, 'application/vnd.kde.kword' => 1, 'application/vnd.kde.kword' => 1, 'application/vnd.kenameaapp' => 1,
'application/vnd.kidspiration' => 1, 'application/vnd.kinar' => 1, 'application/vnd.kinar' => 1, 'application/vnd.koan' => 1, 'application/vnd.koan' => 1, 'application/vnd.koan' => 1,
'application/vnd.koan' => 1, 'application/vnd.kodak-descriptor' => 1, 'application/vnd.las.las+xml' => 1, 'application/vnd.llamagraphics.life-balance.desktop' => 1,
'application/vnd.llamagraphics.life-balance.exchange+xml' => 1, 'application/vnd.lotus-1-2-3' => 1, 'application/vnd.lotus-approach' => 1, 'application/vnd.lotus-freelance' => 1,
'application/vnd.lotus-notes' => 1, 'application/vnd.lotus-organizer' => 1, 'application/vnd.lotus-screencam' => 1, 'application/vnd.lotus-wordpro' => 1,
'application/vnd.macports.portpkg' => 1, 'application/vnd.mcd' => 1, 'application/vnd.medcalcdata' => 1, 'application/vnd.mediastation.cdkey' => 1, 'application/vnd.mfer' => 1,
'application/vnd.mfmp' => 1, 'application/vnd.micrografx.flo' => 1, 'application/vnd.micrografx.igx' => 1, 'application/vnd.mif' => 1, 'application/vnd.mobius.daf' => 1,
'application/vnd.mobius.dis' => 1, 'application/vnd.mobius.mbk' => 1, 'application/vnd.mobius.mqy' => 1, 'application/vnd.mobius.msl' => 1, 'application/vnd.mobius.plc' => 1,
'application/vnd.mobius.txf' => 1, 'application/vnd.mophun.application' => 1, 'application/vnd.mophun.certificate' => 1, 'application/vnd.mozilla.xul+xml' => 1,
'application/vnd.ms-artgalry' => 1, 'application/vnd.ms-cab-compressed' => 1, 'application/vnd.ms-excel' => 1, 'application/vnd.ms-excel' => 1, 'application/vnd.ms-excel' => 1,
'application/vnd.ms-excel' => 1, 'application/vnd.ms-excel' => 1, 'application/vnd.ms-excel' => 1, 'application/vnd.ms-excel.addin.macroenabled.12' => 1,
'application/vnd.ms-excel.sheet.binary.macroenabled.12' => 1, 'application/vnd.ms-excel.sheet.macroenabled.12' => 1, 'application/vnd.ms-excel.template.macroenabled.12' => 1,
'application/vnd.ms-fontobject' => 1, 'application/vnd.ms-htmlhelp' => 1, 'application/vnd.ms-ims' => 1, 'application/vnd.ms-lrm' => 1, 'application/vnd.ms-officetheme' => 1,
'application/vnd.ms-pki.seccat' => 1, 'application/vnd.ms-pki.stl' => 1, 'application/vnd.ms-powerpoint' => 1, 'application/vnd.ms-powerpoint' => 1,
'application/vnd.ms-powerpoint' => 1, 'application/vnd.ms-powerpoint.addin.macroenabled.12' => 1, 'application/vnd.ms-powerpoint.presentation.macroenabled.12' => 1,
'application/vnd.ms-powerpoint.slide.macroenabled.12' => 1, 'application/vnd.ms-powerpoint.slideshow.macroenabled.12' => 1,
'application/vnd.ms-powerpoint.template.macroenabled.12' => 1, 'application/vnd.ms-project' => 1, 'application/vnd.ms-project' => 1,
'application/vnd.ms-word.document.macroenabled.12' => 1, 'application/vnd.ms-word.template.macroenabled.12' => 1, 'application/vnd.ms-works' => 1,
'application/vnd.ms-works' => 1, 'application/vnd.ms-works' => 1, 'application/vnd.ms-works' => 1, 'application/vnd.ms-wpl' => 1, 'application/vnd.ms-xpsdocument' => 1,
'application/vnd.mseq' => 1, 'application/vnd.musician' => 1, 'application/vnd.muvee.style' => 1, 'application/vnd.mynfc' => 1, 'application/vnd.neurolanguage.nlu' => 1,
'application/vnd.nitf' => 1, 'application/vnd.nitf' => 1, 'application/vnd.noblenet-directory' => 1, 'application/vnd.noblenet-sealer' => 1, 'application/vnd.noblenet-web' => 1,
'application/vnd.nokia.n-gage.data' => 1, 'application/vnd.nokia.n-gage.symbian.install' => 1, 'application/vnd.nokia.radio-preset' => 1, 'application/vnd.nokia.radio-presets' => 1,
'application/vnd.novadigm.edm' => 1, 'application/vnd.novadigm.edx' => 1, 'application/vnd.novadigm.ext' => 1, 'application/vnd.oasis.opendocument.chart' => 1,
'application/vnd.oasis.opendocument.chart-template' => 1, 'application/vnd.oasis.opendocument.database' => 1, 'application/vnd.oasis.opendocument.formula' => 1,
'application/vnd.oasis.opendocument.formula-template' => 1, 'application/vnd.oasis.opendocument.graphics' => 1, 'application/vnd.oasis.opendocument.graphics-template' => 1,
'application/vnd.oasis.opendocument.image' => 1, 'application/vnd.oasis.opendocument.image-template' => 1, 'application/vnd.oasis.opendocument.presentation' => 1,
'application/vnd.oasis.opendocument.presentation-template' => 1, 'application/vnd.oasis.opendocument.spreadsheet' => 1, 'application/vnd.oasis.opendocument.spreadsheet-template' => 1,
'application/vnd.oasis.opendocument.text' => 1, 'application/vnd.oasis.opendocument.text-master' => 1, 'application/vnd.oasis.opendocument.text-template' => 1,
'application/vnd.oasis.opendocument.text-web' => 1, 'application/vnd.olpc-sugar' => 1, 'application/vnd.oma.dd2+xml' => 1, 'application/vnd.openofficeorg.extension' => 1,
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 1, 'application/vnd.openxmlformats-officedocument.presentationml.slide' => 1,
'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 1, 'application/vnd.openxmlformats-officedocument.presentationml.template' => 1,
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 1, 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 1,
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 1, 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 1,
'application/vnd.osgeo.mapguide.package' => 1, 'application/vnd.osgi.dp' => 1, 'application/vnd.osgi.subsystem' => 1, 'application/vnd.palm' => 1, 'application/vnd.palm' => 1,
'application/vnd.palm' => 1, 'application/vnd.pawaafile' => 1, 'application/vnd.pg.format' => 1, 'application/vnd.pg.osasli' => 1, 'application/vnd.picsel' => 1, 'application/vnd.pmi.widget' => 1,
'application/vnd.pocketlearn' => 1, 'application/vnd.powerbuilder6' => 1, 'application/vnd.previewsystems.box' => 1, 'application/vnd.proteus.magazine' => 1,
'application/vnd.publishare-delta-tree' => 1, 'application/vnd.pvi.ptid1' => 1, 'application/vnd.quark.quarkxpress' => 1, 'application/vnd.quark.quarkxpress' => 1,
'application/vnd.quark.quarkxpress' => 1, 'application/vnd.quark.quarkxpress' => 1, 'application/vnd.quark.quarkxpress' => 1, 'application/vnd.quark.quarkxpress' => 1,
'application/vnd.realvnc.bed' => 1, 'application/vnd.recordare.musicxml' => 1, 'application/vnd.recordare.musicxml+xml' => 1, 'application/vnd.rig.cryptonote' => 1,
'application/vnd.rim.cod' => 1, 'application/vnd.rn-realmedia' => 1, 'application/vnd.rn-realmedia-vbr' => 1, 'application/vnd.route66.link66+xml' => 1, 'application/vnd.sailingtracker.track' => 1,
'application/vnd.seemail' => 1, 'application/vnd.sema' => 1, 'application/vnd.semd' => 1, 'application/vnd.semf' => 1, 'application/vnd.shana.informed.formdata' => 1,
'application/vnd.shana.informed.formtemplate' => 1, 'application/vnd.shana.informed.interchange' => 1, 'application/vnd.shana.informed.package' => 1, 'application/vnd.simtech-mindmapper' => 1,
'application/vnd.simtech-mindmapper' => 1, 'application/vnd.smaf' => 1, 'application/vnd.smart.teacher' => 1, 'application/vnd.solent.sdkm+xml' => 1, 'application/vnd.solent.sdkm+xml' => 1,
'application/vnd.spotfire.dxp' => 1, 'application/vnd.spotfire.sfs' => 1, 'application/vnd.stardivision.calc' => 1, 'application/vnd.stardivision.draw' => 1,
'application/vnd.stardivision.impress' => 1, 'application/vnd.stardivision.math' => 1, 'application/vnd.stardivision.writer' => 1, 'application/vnd.stardivision.writer' => 1,
'application/vnd.stardivision.writer-global' => 1, 'application/vnd.stepmania.package' => 1, 'application/vnd.stepmania.stepchart' => 1, 'application/vnd.sun.xml.calc' => 1,
'application/vnd.sun.xml.calc.template' => 1, 'application/vnd.sun.xml.draw' => 1, 'application/vnd.sun.xml.draw.template' => 1, 'application/vnd.sun.xml.impress' => 1,
'application/vnd.sun.xml.impress.template' => 1, 'application/vnd.sun.xml.math' => 1, 'application/vnd.sun.xml.writer' => 1, 'application/vnd.sun.xml.writer.global' => 1,
'application/vnd.sun.xml.writer.template' => 1, 'application/vnd.sus-calendar' => 1, 'application/vnd.sus-calendar' => 1, 'application/vnd.svd' => 1, 'application/vnd.symbian.install' => 1,
'application/vnd.symbian.install' => 1, 'application/vnd.syncml+xml' => 1, 'application/vnd.syncml.dm+wbxml' => 1, 'application/vnd.syncml.dm+xml' => 1,
'application/vnd.tao.intent-module-archive' => 1, 'application/vnd.tcpdump.pcap' => 1, 'application/vnd.tcpdump.pcap' => 1, 'application/vnd.tcpdump.pcap' => 1,
'application/vnd.tmobile-livetv' => 1, 'application/vnd.trid.tpt' => 1, 'application/vnd.triscape.mxs' => 1, 'application/vnd.trueapp' => 1, 'application/vnd.ufdl' => 1, 'application/vnd.ufdl' => 1,
'application/vnd.uiq.theme' => 1, 'application/vnd.umajin' => 1, 'application/vnd.unity' => 1, 'application/vnd.uoml+xml' => 1, 'application/vnd.vcx' => 1, 'application/vnd.visio' => 1,
'application/vnd.visio' => 1, 'application/vnd.visio' => 1, 'application/vnd.visio' => 1, 'application/vnd.visionary' => 1, 'application/vnd.vsf' => 1, 'application/vnd.wap.wbxml' => 1,
'application/vnd.wap.wmlc' => 1, 'application/vnd.wap.wmlscriptc' => 1, 'application/vnd.webturbo' => 1, 'application/vnd.wolfram.player' => 1, 'application/vnd.wordperfect' => 1,
'application/vnd.wqd' => 1, 'application/vnd.wt.stf' => 1, 'application/vnd.xara' => 1, 'application/vnd.xfdl' => 1, 'application/vnd.yamaha.hv-dic' => 1, 'application/vnd.yamaha.hv-script' => 1,
'application/vnd.yamaha.hv-voice' => 1, 'application/vnd.yamaha.openscoreformat' => 1, 'application/vnd.yamaha.openscoreformat.osfpvg+xml' => 1, 'application/vnd.yamaha.smaf-audio' => 1,
'application/vnd.yamaha.smaf-phrase' => 1, 'application/vnd.yellowriver-custom-menu' => 1, 'application/vnd.zul' => 1, 'application/vnd.zul' => 1, 'application/vnd.zzazz.deck+xml' => 1,
'application/voicexml+xml' => 1, 'application/widget' => 1, 'application/winhlp' => 1, 'application/wsdl+xml' => 1, 'application/wspolicy+xml' => 1, 'application/x-7z-compressed' => 1,
'application/x-abiword' => 1, 'application/x-ace-compressed' => 1, 'application/x-apple-diskimage' => 1, 'application/x-authorware-bin' => 1, 'application/x-authorware-bin' => 1,
'application/x-authorware-bin' => 1, 'application/x-authorware-bin' => 1, 'application/x-authorware-map' => 1, 'application/x-authorware-seg' => 1, 'application/x-bcpio' => 1,
'application/x-bittorrent' => 1, 'application/x-blorb' => 1, 'application/x-blorb' => 1, 'application/x-bzip' => 1, 'application/x-bzip2' => 1, 'application/x-bzip2' => 1, 'application/x-cbr' => 1,
'application/x-cbr' => 1, 'application/x-cbr' => 1, 'application/x-cbr' => 1, 'application/x-cbr' => 1, 'application/x-cdlink' => 1, 'application/x-cfs-compressed' => 1, 'application/x-chat' => 1,
'application/x-chess-pgn' => 1, 'application/x-conference' => 1, 'application/x-cpio' => 1, 'application/x-csh' => 1, 'application/x-debian-package' => 1, 'application/x-debian-package' => 1,
'application/x-dgc-compressed' => 1, 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-director' => 1,
'application/x-director' => 1, 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-director' => 1, 'application/x-doom' => 1, 'application/x-dtbncx+xml' => 1,
'application/x-dtbook+xml' => 1, 'application/x-dtbresource+xml' => 1, 'application/x-dvi' => 1, 'application/x-envoy' => 1, 'application/x-eva' => 1, 'application/x-font-bdf' => 1,
'application/x-font-ghostscript' => 1, 'application/x-font-linux-psf' => 1, 'application/x-font-otf' => 1, 'application/x-font-pcf' => 1, 'application/x-font-snf' => 1,
'application/x-font-ttf' => 1, 'application/x-font-ttf' => 1, 'application/x-font-type1' => 1, 'application/x-font-type1' => 1, 'application/x-font-type1' => 1, 'application/x-font-type1' => 1,
'application/x-font-woff' => 1, 'application/x-freearc' => 1, 'application/x-futuresplash' => 1, 'application/x-gca-compressed' => 1, 'application/x-glulx' => 1, 'application/x-gnumeric' => 1,
'application/x-gramps-xml' => 1, 'application/x-gtar' => 1, 'application/x-hdf' => 1, 'application/x-install-instructions' => 1, 'application/x-iso9660-image' => 1,
'application/x-java-jnlp-file' => 1, 'application/x-latex' => 1, 'application/x-lzh-compressed' => 1, 'application/x-lzh-compressed' => 1, 'application/x-mie' => 1,
'application/x-mobipocket-ebook' => 1, 'application/x-mobipocket-ebook' => 1, 'application/x-ms-application' => 1, 'application/x-ms-shortcut' => 1, 'application/x-ms-wmd' => 1,
'application/x-ms-wmz' => 1, 'application/x-ms-xbap' => 1, 'application/x-msaccess' => 1, 'application/x-msbinder' => 1, 'application/x-mscardfile' => 1, 'application/x-msclip' => 1,
'application/x-msdownload' => 1, 'application/x-msdownload' => 1, 'application/x-msdownload' => 1, 'application/x-msdownload' => 1, 'application/x-msdownload' => 1, 'application/x-msmediaview' => 1,
'application/x-msmediaview' => 1, 'application/x-msmediaview' => 1, 'application/x-msmetafile' => 1, 'application/x-msmetafile' => 1, 'application/x-msmetafile' => 1, 'application/x-msmetafile' => 1,
'application/x-msmoney' => 1, 'application/x-mspublisher' => 1, 'application/x-msschedule' => 1, 'application/x-msterminal' => 1, 'application/x-mswrite' => 1, 'application/x-netcdf' => 1,
'application/x-netcdf' => 1, 'application/x-nzb' => 1, 'application/x-pkcs12' => 1, 'application/x-pkcs12' => 1, 'application/x-pkcs7-certificates' => 1, 'application/x-pkcs7-certificates' => 1,
'application/x-pkcs7-certreqresp' => 1, 'application/x-rar-compressed' => 1, 'application/x-research-info-systems' => 1, 'application/x-sh' => 1, 'application/x-shar' => 1,
'application/x-shockwave-flash' => 1, 'application/x-silverlight-app' => 1, 'application/x-silverlight-2' => 1, 'application/x-sql' => 1, 'application/x-stuffit' => 1, 'application/x-stuffitx' => 1,
'application/x-subrip' => 1, 'application/x-sv4cpio' => 1, 'application/x-sv4crc' => 1, 'application/x-t3vm-image' => 1, 'application/x-tads' => 1, 'application/x-tar' => 1, 'application/x-tcl' => 1,
'application/x-tex' => 1, 'application/x-tex-tfm' => 1, 'application/x-texinfo' => 1, 'application/x-texinfo' => 1, 'application/x-tgif' => 1, 'application/x-ustar' => 1, 'application/x-wais-source' => 1,
'application/x-x509-ca-cert' => 1, 'application/x-x509-ca-cert' => 1, 'application/x-xfig' => 1, 'application/x-xliff+xml' => 1, 'application/x-xpinstall' => 1, 'application/x-xz' => 1,
'application/x-zmachine' => 1, 'application/x-zmachine' => 1, 'application/x-zmachine' => 1, 'application/x-zmachine' => 1, 'application/x-zmachine' => 1, 'application/x-zmachine' => 1,
'application/x-zmachine' => 1, 'application/x-zmachine' => 1, 'application/xaml+xml' => 1, 'application/xcap-diff+xml' => 1, 'application/xenc+xml' => 1, 'application/xhtml+xml' => 1,
'application/xhtml+xml' => 1, 'application/xml' => 1, 'application/xml' => 1, 'application/xml-dtd' => 1, 'application/xop+xml' => 1, 'application/xproc+xml' => 1, 'application/xslt+xml' => 1,
'application/xspf+xml' => 1, 'application/xv+xml' => 1, 'application/xv+xml' => 1, 'application/xv+xml' => 1, 'application/xv+xml' => 1, 'application/yang' => 1, 'application/yin+xml' => 1,
'application/zip' => 1, 'audio/adpcm' => 1, 'audio/basic' => 1, 'audio/basic' => 1, 'audio/midi' => 1, 'audio/midi' => 1, 'audio/midi' => 1, 'audio/midi' => 1, 'audio/mp4' => 1, 'audio/mpeg' => 1,
'audio/mpeg' => 1, 'audio/mpeg' => 1, 'audio/mpeg' => 1, 'audio/mpeg' => 1, 'audio/mpeg' => 1, 'audio/ogg' => 1, 'audio/ogg' => 1, 'audio/ogg' => 1, 'audio/s3m' => 1, 'audio/silk' => 1,
'audio/vnd.dece.audio' => 1, 'audio/vnd.dece.audio' => 1, 'audio/vnd.digital-winds' => 1, 'audio/vnd.dra' => 1, 'audio/vnd.dts' => 1, 'audio/vnd.dts.hd' => 1, 'audio/vnd.lucent.voice' => 1,
'audio/vnd.ms-playready.media.pya' => 1, 'audio/vnd.nuera.ecelp4800' => 1, 'audio/vnd.nuera.ecelp7470' => 1, 'audio/vnd.nuera.ecelp9600' => 1, 'audio/vnd.rip' => 1, 'audio/webm' => 1,
'audio/x-aac' => 1, 'audio/x-aiff' => 1, 'audio/x-aiff' => 1, 'audio/x-aiff' => 1, 'audio/x-caf' => 1, 'audio/x-flac' => 1, 'audio/x-matroska' => 1, 'audio/x-mpegurl' => 1, 'audio/x-ms-wax' => 1,
'audio/x-ms-wma' => 1, 'audio/x-pn-realaudio' => 1, 'audio/x-pn-realaudio' => 1, 'audio/x-pn-realaudio-plugin' => 1, 'audio/x-wav' => 1, 'audio/xm' => 1, 'chemical/x-cdx' => 1, 'chemical/x-cif' => 1,
'chemical/x-cmdf' => 1, 'chemical/x-cml' => 1, 'chemical/x-csml' => 1, 'chemical/x-xyz' => 1, 'image/bmp' => 1, 'image/cgm' => 1, 'image/g3fax' => 1, 'image/gif' => 1, 'image/ief' => 1, 'image/jpeg' => 1,
'image/jpeg' => 1, 'image/jpeg' => 1, 'image/ktx' => 1, 'image/png' => 1, 'image/prs.btif' => 1, 'image/sgi' => 1, 'image/svg+xml' => 1, 'image/svg+xml' => 1, 'image/tiff' => 1, 'image/tiff' => 1,
'image/vnd.adobe.photoshop' => 1, 'image/vnd.dece.graphic' => 1, 'image/vnd.dece.graphic' => 1, 'image/vnd.dece.graphic' => 1, 'image/vnd.dece.graphic' => 1, 'image/vnd.dvb.subtitle' => 1,
'image/vnd.djvu' => 1, 'image/vnd.djvu' => 1, 'image/vnd.dwg' => 1, 'image/vnd.dxf' => 1, 'image/vnd.fastbidsheet' => 1, 'image/vnd.fpx' => 1, 'image/vnd.fst' => 1, 'image/vnd.fujixerox.edmics-mmr' => 1,
'image/vnd.fujixerox.edmics-rlc' => 1, 'image/vnd.ms-modi' => 1, 'image/vnd.ms-photo' => 1, 'image/vnd.net-fpx' => 1, 'image/vnd.wap.wbmp' => 1, 'image/vnd.xiff' => 1, 'image/webp' => 1,
'image/x-3ds' => 1, 'image/x-cmu-raster' => 1, 'image/x-cmx' => 1, 'image/x-freehand' => 1, 'image/x-freehand' => 1, 'image/x-freehand' => 1, 'image/x-freehand' => 1, 'image/x-freehand' => 1,
'image/x-icon' => 1, 'image/x-mrsid-image' => 1, 'image/x-pcx' => 1, 'image/x-pict' => 1, 'image/x-pict' => 1, 'image/x-portable-anymap' => 1, 'image/x-portable-bitmap' => 1,
'image/x-portable-graymap' => 1, 'image/x-portable-pixmap' => 1, 'image/x-rgb' => 1, 'image/x-tga' => 1, 'image/x-xbitmap' => 1, 'image/x-xpixmap' => 1, 'image/x-xwindowdump' => 1,
'message/rfc822' => 1, 'message/rfc822' => 1, 'model/iges' => 1, 'model/iges' => 1, 'model/mesh' => 1, 'model/mesh' => 1, 'model/mesh' => 1, 'model/vnd.collada+xml' => 1, 'model/vnd.dwf' => 1,
'model/vnd.gdl' => 1, 'model/vnd.gtw' => 1, 'model/vnd.mts' => 1, 'model/vnd.vtu' => 1, 'model/vrml' => 1, 'model/vrml' => 1, 'model/x3d+binary' => 1, 'model/x3d+binary' => 1, 'model/x3d+vrml' => 1,
'model/x3d+vrml' => 1, 'model/x3d+xml' => 1, 'model/x3d+xml' => 1, 'video/3gpp' => 1, 'video/3gpp2' => 1, 'video/h261' => 1, 'video/h263' => 1, 'video/h264' => 1, 'video/jpeg' => 1, 'video/jpm' => 1,
'video/jpm' => 1, 'video/mj2' => 1, 'video/mj2' => 1, 'video/mp4' => 1, 'video/mp4' => 1, 'video/mp4' => 1, 'video/mpeg' => 1, 'video/mpeg' => 1, 'video/mpeg' => 1, 'video/mpeg' => 1, 'video/mpeg' => 1,
'video/ogg' => 1, 'video/quicktime' => 1, 'video/quicktime' => 1, 'video/vnd.dece.hd' => 1, 'video/vnd.dece.hd' => 1, 'video/vnd.dece.mobile' => 1, 'video/vnd.dece.mobile' => 1, 'video/vnd.dece.pd' => 1,
'video/vnd.dece.pd' => 1, 'video/vnd.dece.sd' => 1, 'video/vnd.dece.sd' => 1, 'video/vnd.dece.video' => 1, 'video/vnd.dece.video' => 1, 'video/vnd.dvb.file' => 1, 'video/vnd.fvt' => 1,
'video/vnd.mpegurl' => 1, 'video/vnd.mpegurl' => 1, 'video/vnd.ms-playready.media.pyv' => 1, 'video/vnd.uvvu.mp4' => 1, 'video/vnd.uvvu.mp4' => 1, 'video/vnd.vivo' => 1, 'video/webm' => 1,
'video/x-f4v' => 1, 'video/x-fli' => 1, 'video/x-flv' => 1, 'video/x-m4v' => 1, 'video/x-matroska' => 1, 'video/x-matroska' => 1, 'video/x-matroska' => 1, 'video/x-mng' => 1, 'video/x-ms-asf' => 1,
'video/x-ms-asf' => 1, 'video/x-ms-vob' => 1, 'video/x-ms-wm' => 1, 'video/x-ms-wmv' => 1, 'video/x-ms-wmx' => 1, 'video/x-ms-wvx' => 1, 'video/x-msvideo' => 1, 'video/x-sgi-movie' => 1,
'video/x-smv' => 1, 'x-conference/x-cooltalk' => 1
);
var $extList = array('ez'=>1, 'aw'=>1, 'atom'=>1, 'atomcat'=>1, 'atomsvc'=>1, 'ccxml'=>1, 'cdmia'=>1, 'cdmic'=>1, 'cdmid'=>1, 'cdmio'=>1, 'cdmiq'=>1, 'cu'=>1, 'davmount'=>1,
'dbk'=>1, 'dssc'=>1, 'xdssc'=>1, 'ecma'=>1, 'emma'=>1, 'epub'=>1, 'exi'=>1, 'pfr'=>1, 'gml'=>1, 'gpx'=>1, 'gxf'=>1, 'stk'=>1, 'ink'=>1, 'inkml'=>1, 'ipfix'=>1, 'jar'=>1,
'ser'=>1, 'class'=>1, 'js'=>1, 'json'=>1, 'jsonml'=>1, 'lostxml'=>1, 'hqx'=>1, 'cpt'=>1, 'mads'=>1, 'mrc'=>1, 'mrcx'=>1, 'ma'=>1, 'nb'=>1, 'mb'=>1, 'mathml'=>1, 'mbox'=>1,
'mscml'=>1, 'metalink'=>1, 'meta4'=>1, 'mets'=>1, 'mods'=>1, 'm21 mp21'=>1, 'mp4s'=>1, 'doc dot'=>1, 'mxf'=>1, 'bin'=>1, 'dms'=>1, 'lrf'=>1, 'mar'=>1, 'so'=>1, 'dist'=>1,
'distz'=>1, 'pkg'=>1, 'bpk'=>1, 'dump'=>1, 'elc'=>1, 'deploy'=>1, 'oda'=>1, 'opf'=>1, 'ogx'=>1, 'omdoc'=>1, 'onetoc'=>1, 'onetoc2'=>1, 'onetmp'=>1, 'onepkg'=>1, 'oxps'=>1,
'xer'=>1, 'pdf'=>1, 'pgp'=>1, 'asc'=>1, 'sig'=>1, 'prf'=>1, 'p10'=>1, 'p7m'=>1, 'p7c'=>1, 'p7s'=>1, 'p8'=>1, 'ac'=>1, 'cer'=>1, 'crl'=>1, 'pkipath'=>1, 'pki'=>1, 'pls'=>1,
'ai'=>1, 'eps'=>1, 'ps'=>1, 'cww'=>1, 'pskcxml'=>1, 'rdf'=>1, 'rif'=>1, 'rnc'=>1, 'rl'=>1, 'rld'=>1, 'rs'=>1, 'gbr'=>1, 'mft'=>1, 'roa'=>1, 'rsd'=>1, 'rss'=>1, 'rtf'=>1,
'sbml'=>1, 'scq'=>1, 'scs'=>1, 'spq'=>1, 'spp'=>1, 'sdp'=>1, 'setpay'=>1, 'setreg'=>1, 'shf'=>1, 'smi'=>1, 'smil'=>1, 'rq'=>1, 'srx'=>1, 'gram'=>1, 'grxml'=>1, 'sru'=>1,
'ssdl'=>1, 'ssml'=>1, 'tei'=>1, 'teicorpus'=>1, 'tfi'=>1, 'tsd'=>1, 'plb'=>1, 'psb'=>1, 'pvb'=>1, 'tcap'=>1, 'pwn'=>1, 'aso'=>1, 'imp'=>1, 'acu'=>1, 'atc'=>1, 'acutc'=>1,
'air'=>1, 'fcdt'=>1, 'fxp'=>1, 'fxpl'=>1, 'xdp'=>1, 'xfdf'=>1, 'ahead'=>1, 'azf'=>1, 'azs'=>1, 'azw'=>1, 'acc'=>1, 'ami'=>1, 'apk'=>1, 'cii'=>1, 'fti'=>1, 'atx'=>1, 'mpkg'=>1,
'm3u8'=>1, 'swi'=>1, 'iota'=>1, 'aep'=>1, 'mpm'=>1, 'bmi'=>1, 'rep'=>1, 'cdxml'=>1, 'mmd'=>1, 'cdy'=>1, 'cla'=>1, 'rp9'=>1, 'c4g'=>1, 'c4d'=>1, 'c4f'=>1, 'c4p'=>1, 'c4u'=>1,
'c11amc'=>1, 'c11amz'=>1, 'csp'=>1, 'cdbcmsg'=>1, 'cmc'=>1, 'clkx'=>1, 'clkk'=>1, 'clkp'=>1, 'clkt'=>1, 'clkw'=>1, 'wbs'=>1, 'pml'=>1, 'ppd'=>1, 'car'=>1, 'pcurl'=>1, 'dart'=>1,
'rdz'=>1, 'uvf'=>1, 'uvvf'=>1, 'uvd'=>1, 'uvvd'=>1, 'uvt'=>1, 'uvvt'=>1, 'uvx'=>1, 'uvvx'=>1, 'uvz'=>1, 'uvvz'=>1, 'fe_launch'=>1, 'dna'=>1, 'mlp'=>1, 'dpg'=>1, 'dfac'=>1,
'kpxx'=>1, 'ait'=>1, 'svc'=>1, 'geo'=>1, 'mag'=>1, 'nml'=>1, 'esf'=>1, 'msf'=>1, 'qam'=>1, 'slt'=>1, 'ssf'=>1, 'es3'=>1, 'et3'=>1, 'ez2'=>1, 'ez3'=>1, 'fdf'=>1, 'mseed'=>1,
'seed'=>1, 'dataless'=>1, 'gph'=>1, 'ftc'=>1, 'fm'=>1, 'frame'=>1, 'maker'=>1, 'book'=>1, 'fnc'=>1, 'ltf'=>1, 'fsc'=>1, 'oas'=>1, 'oa2'=>1, 'oa3'=>1, 'fg5'=>1, 'bh2'=>1, 'ddd'=>1,
'xdw'=>1, 'xbd'=>1, 'fzs'=>1, 'txd'=>1, 'ggb'=>1, 'ggt'=>1, 'gex'=>1, 'gre'=>1, 'gxt'=>1, 'g2w'=>1, 'g3w'=>1, 'gmx'=>1, 'kml'=>1, 'kmz'=>1, 'gqf'=>1, 'gqs'=>1, 'gac'=>1, 'ghf'=>1,
'gim'=>1, 'grv'=>1, 'gtm'=>1, 'tpl'=>1, 'vcg'=>1, 'hal'=>1, 'zmm'=>1, 'hbci'=>1, 'les'=>1, 'hpgl'=>1, 'hpid'=>1, 'hps'=>1, 'jlt'=>1, 'pcl'=>1, 'pclxl'=>1, 'sfd-hdstx'=>1, 'mpy'=>1,
'afp'=>1, 'listafp'=>1, 'list3820'=>1, 'irm'=>1, 'sc'=>1, 'icc'=>1, 'icm'=>1, 'igl'=>1, 'ivp'=>1, 'ivu'=>1, 'igm'=>1, 'xpw'=>1, 'xpx'=>1, 'i2g'=>1, 'qbo'=>1, 'qfx'=>1,
'rcprofile'=>1, 'irp'=>1, 'xpr'=>1, 'fcs'=>1, 'jam'=>1, 'rms'=>1, 'jisp'=>1, 'joda'=>1, 'ktz'=>1, 'ktr'=>1, 'karbon'=>1, 'chrt'=>1, 'kfo'=>1, 'flw'=>1, 'kon'=>1, 'kpr'=>1, 'kpt'=>1,
'ksp'=>1, 'kwd'=>1, 'kwt'=>1, 'htke'=>1, 'kia'=>1, 'kne'=>1, 'knp'=>1, 'skp'=>1, 'skd'=>1, 'skt'=>1, 'skm'=>1, 'sse'=>1, 'lasxml'=>1, 'lbd'=>1, 'lbe'=>1, '123'=>1, 'apr'=>1,
'pre'=>1, 'nsf'=>1, 'org'=>1, 'scm'=>1, 'lwp'=>1, 'portpkg'=>1, 'mcd'=>1, 'mc1'=>1, 'cdkey'=>1, 'mwf'=>1, 'mfm'=>1, 'flo'=>1, 'igx'=>1, 'mif'=>1, 'daf'=>1, 'dis'=>1, 'mbk'=>1,
'mqy'=>1, 'msl'=>1, 'plc'=>1, 'txf'=>1, 'mpn'=>1, 'mpc'=>1, 'xul'=>1, 'cil'=>1, 'cab'=>1, 'xls'=>1, 'xlm'=>1, 'xla'=>1, 'xlc'=>1, 'xlt'=>1, 'xlw'=>1, 'xlam'=>1, 'xlsb'=>1, 'xlsm'=>1,
'xltm'=>1, 'eot'=>1, 'chm'=>1, 'ims'=>1, 'lrm'=>1, 'thmx'=>1, 'cat'=>1, 'stl'=>1, 'ppt'=>1, 'pps'=>1, 'pot'=>1, 'ppam'=>1, 'pptm'=>1, 'sldm'=>1, 'ppsm'=>1, 'potm'=>1, 'mpp'=>1,
'mpt'=>1, 'docm'=>1, 'dotm'=>1, 'wps'=>1, 'wks'=>1, 'wcm'=>1, 'wdb'=>1, 'wpl'=>1, 'xps'=>1, 'mseq'=>1, 'mus'=>1, 'msty'=>1, 'taglet'=>1, 'nlu'=>1, 'nitf'=>1, 'nitf'=>1, 'nnd'=>1,
'nns'=>1, 'nnw'=>1, 'ngdat'=>1, 'n-gage'=>1, 'rpst'=>1, 'rpss'=>1, 'edm'=>1, 'edx'=>1, 'ext'=>1, 'odc'=>1, 'otc'=>1, 'odb'=>1, 'odf'=>1, 'odft'=>1, 'odg'=>1, 'otg'=>1, 'odi'=>1,
'oti'=>1, 'odp'=>1, 'otp'=>1, 'ods'=>1, 'ots'=>1, 'odt'=>1, 'odm'=>1, 'ott'=>1, 'oth'=>1, 'xo'=>1, 'dd2'=>1, 'oxt'=>1, 'pptx'=>1, 'sldx'=>1, 'ppsx'=>1, 'potx'=>1, 'xlsx'=>1, 'xltx'=>1,
'docx'=>1, 'dotx'=>1, 'mgp'=>1, 'dp'=>1, 'esa'=>1, 'pdb'=>1, 'pqa'=>1, 'oprc'=>1, 'paw'=>1, 'str'=>1, 'ei6'=>1, 'efif'=>1, 'wg'=>1, 'plf'=>1, 'pbd'=>1, 'box'=>1, 'mgz'=>1, 'qps'=>1,
'ptid'=>1, 'qxd'=>1, 'qxt'=>1, 'qwd'=>1, 'qwt'=>1, 'qxl'=>1, 'qxb'=>1, 'bed'=>1, 'mxl'=>1, 'musicxml'=>1, 'cryptonote'=>1, 'cod'=>1, 'rm'=>1, 'rmvb'=>1, 'link66'=>1, 'st'=>1, 'see'=>1,
'sema'=>1, 'semd'=>1, 'semf'=>1, 'ifm'=>1, 'itp'=>1, 'iif'=>1, 'ipk'=>1, 'twd'=>1, 'twds'=>1, 'mmf'=>1, 'teacher'=>1, 'sdkm'=>1, 'sdkd'=>1, 'dxp'=>1, 'sfs'=>1, 'sdc'=>1, 'sda'=>1,
'sdd'=>1, 'smf'=>1, 'sdw'=>1, 'vor'=>1, 'sgl'=>1, 'smzip'=>1, 'sm'=>1, 'sxc'=>1, 'stc'=>1, 'sxd'=>1, 'std'=>1, 'sxi'=>1, 'sti'=>1, 'sxm'=>1, 'sxw'=>1, 'sxg'=>1, 'stw'=>1, 'sus'=>1,
'susp'=>1, 'svd'=>1, 'sis'=>1, 'sisx'=>1, 'xsm'=>1, 'bdm'=>1, 'xdm'=>1, 'tao'=>1, 'pcap'=>1, 'cap'=>1, 'dmp'=>1, 'tmo'=>1, 'tpt'=>1, 'mxs'=>1, 'tra'=>1, 'ufd'=>1, 'ufdl'=>1, 'utz'=>1,
'umj'=>1, 'unityweb'=>1, 'uoml'=>1, 'vcx'=>1, 'vsd'=>1, 'vst'=>1, 'vss'=>1, 'vsw'=>1, 'vis'=>1, 'vsf'=>1, 'wbxml'=>1, 'wmlc'=>1, 'wmlsc'=>1, 'wtb'=>1, 'nbp'=>1, 'wpd'=>1, 'wqd'=>1,
'stf'=>1, 'xar'=>1, 'xfdl'=>1, 'hvd'=>1, 'hvs'=>1, 'hvp'=>1, 'osf'=>1, 'osfpvg'=>1, 'saf'=>1, 'spf'=>1, 'cmp'=>1, 'zir'=>1, 'zirz'=>1, 'zaz'=>1, 'vxml'=>1, 'wgt'=>1, 'hlp'=>1, 'wsdl'=>1,
'wspolicy'=>1, '7z'=>1, 'abw'=>1, 'ace'=>1, 'dmg'=>1, 'aab'=>1, 'x32'=>1, 'u32'=>1, 'vox'=>1, 'aam'=>1, 'aas'=>1, 'bcpio'=>1, 'torrent'=>1, 'blb'=>1, 'blorb'=>1, 'bz'=>1, 'bz2'=>1,
'boz'=>1, 'cbr'=>1, 'cba'=>1, 'cbt'=>1, 'cbz'=>1, 'cb7'=>1, 'vcd'=>1, 'cfs'=>1, 'chat'=>1, 'pgn'=>1, 'nsc'=>1, 'cpio'=>1, 'csh'=>1, 'deb'=>1, 'udeb'=>1, 'dgc'=>1, 'dir'=>1, 'dcr'=>1,
'dxr'=>1, 'cst'=>1, 'cct'=>1, 'cxt'=>1, 'w3d'=>1, 'fgd'=>1, 'swa'=>1, 'wad'=>1, 'ncx'=>1, 'dtb'=>1, 'res'=>1, 'dvi'=>1, 'evy'=>1, 'eva'=>1, 'bdf'=>1, 'gsf'=>1, 'psf'=>1, 'otf'=>1,
'pcf'=>1, 'snf'=>1, 'ttf'=>1, 'ttc'=>1, 'pfa'=>1, 'pfb'=>1, 'pfm'=>1, 'afm'=>1, 'woff'=>1, 'arc'=>1, 'spl'=>1, 'gca'=>1, 'ulx'=>1, 'gnumeric'=>1, 'gramps'=>1, 'gtar'=>1, 'hdf'=>1,
'install'=>1, 'iso'=>1, 'jnlp'=>1, 'latex'=>1, 'lzh'=>1, 'lha'=>1, 'mie'=>1, 'prc'=>1, 'mobi'=>1, 'application'=>1, 'lnk'=>1, 'wmd'=>1, 'wmz'=>1, 'xbap'=>1, 'mdb'=>1, 'obd'=>1,
'crd'=>1, 'clp'=>1, 'exe'=>1, 'dll'=>1, 'com'=>1, 'bat'=>1, 'msi'=>1, 'mvb'=>1, 'm13'=>1, 'm14'=>1, 'wmf'=>1, 'wmz'=>1, 'emf'=>1, 'emz'=>1, 'mny'=>1, 'pub'=>1, 'scd'=>1, 'trm'=>1,
'wri'=>1, 'nc'=>1, 'cdf'=>1, 'nzb'=>1, 'p12'=>1, 'pfx'=>1, 'p7b'=>1, 'spc'=>1, 'p7r'=>1, 'rar'=>1, 'ris'=>1, 'sh'=>1, 'shar'=>1, 'swf'=>1, 'xap'=>1, 'sql'=>1, 'sit'=>1, 'sitx'=>1,
'srt'=>1, 'sv4cpio'=>1, 'sv4crc'=>1, 't3'=>1, 'gam'=>1, 'tar'=>1, 'tcl'=>1, 'tex'=>1, 'tfm'=>1, 'texinfo'=>1, 'texi'=>1, 'obj'=>1, 'ustar'=>1, 'src'=>1, 'der'=>1, 'crt'=>1, 'fig'=>1,
'xlf'=>1, 'xpi'=>1, 'xz'=>1, 'z1'=>1, 'z2'=>1, 'z3'=>1, 'z4'=>1, 'z5'=>1, 'z6'=>1, 'z7'=>1, 'z8'=>1, 'xaml'=>1, 'xdf'=>1, 'xenc'=>1, 'xhtml'=>1, 'xht'=>1, 'xml'=>1, 'xsl'=>1, 'dtd'=>1,
'xop'=>1, 'xpl'=>1, 'xslt'=>1, 'xspf'=>1, 'mxml'=>1, 'xhvml'=>1, 'xvml'=>1, 'xvm'=>1, 'yang'=>1, 'yin'=>1, 'zip'=>1, 'adp'=>1, 'au'=>1, 'snd'=>1, 'mid'=>1, 'midi'=>1, 'kar'=>1, 'rmi'=>1,
'mp4a'=>1, 'mpga'=>1, 'mp2'=>1, 'mp2a'=>1, 'mp3'=>1, 'm2a'=>1, 'm3a'=>1, 'oga'=>1, 'ogg'=>1, 'spx'=>1, 's3m'=>1, 'sil'=>1, 'uva'=>1, 'uvva'=>1, 'eol'=>1, 'dra'=>1, 'dts'=>1, 'dtshd'=>1,
'lvp'=>1, 'pya'=>1, 'ecelp4800'=>1, 'ecelp7470'=>1, 'ecelp9600'=>1, 'rip'=>1, 'weba'=>1, 'aac'=>1, 'aif'=>1, 'aiff'=>1, 'aifc'=>1, 'caf'=>1, 'flac'=>1, 'mka'=>1, 'm3u'=>1, 'wax'=>1,
'wma'=>1, 'ram'=>1, 'ra'=>1, 'rmp'=>1, 'wav'=>1, 'xm'=>1, 'cdx'=>1, 'cif'=>1, 'cmdf'=>1, 'cml'=>1, 'csml'=>1, 'xyz'=>1, 'bmp'=>1, 'cgm'=>1, 'g3'=>1, 'gif'=>1, 'ief'=>1, 'jpeg'=>1,
'jpg'=>1, 'jpe'=>1, 'ktx'=>1, 'png'=>1, 'btif'=>1, 'sgi'=>1, 'svg'=>1, 'svgz'=>1, 'tiff'=>1, 'tif'=>1, 'psd'=>1, 'uvi'=>1, 'uvvi'=>1, 'uvg'=>1, 'uvvg'=>1, 'sub'=>1, 'djvu'=>1, 'djv'=>1,
'dwg'=>1, 'dxf'=>1, 'fbs'=>1, 'fpx'=>1, 'fst'=>1, 'mmr'=>1, 'rlc'=>1, 'mdi'=>1, 'wdp'=>1, 'npx'=>1, 'wbmp'=>1, 'xif'=>1, 'webp'=>1, '3ds'=>1, 'ras'=>1, 'cmx'=>1, 'fh'=>1, 'fhc'=>1,
'fh4'=>1, 'fh5'=>1, 'fh7'=>1, 'ico'=>1, 'sid'=>1, 'pcx'=>1, 'pic'=>1, 'pct'=>1, 'pnm'=>1, 'pbm'=>1, 'pgm'=>1, 'ppm'=>1, 'rgb'=>1, 'tga'=>1, 'xbm'=>1, 'xpm'=>1, 'xwd'=>1, 'eml'=>1,
'mime'=>1, 'igs'=>1, 'iges'=>1, 'msh'=>1, 'mesh'=>1, 'silo'=>1, 'dae'=>1, 'dwf'=>1, 'gdl'=>1, 'gtw'=>1, 'mts'=>1, 'vtu'=>1, 'wrl'=>1, 'vrml'=>1, 'x3db'=>1, 'x3dbz'=>1, 'x3dv'=>1,
'x3dvz'=>1, 'x3d'=>1, 'x3dz'=>1, '3gp'=>1, '3g2'=>1, 'h261'=>1, 'h263'=>1, 'h264'=>1, 'jpgv'=>1, 'jpm'=>1, 'jpgm'=>1, 'mj2'=>1, 'mjp2'=>1, 'mp4'=>1, 'mp4v'=>1, 'mpg4'=>1, 'mpeg'=>1,
'mpg'=>1, 'mpe'=>1, 'm1v'=>1, 'm2v'=>1, 'ogv'=>1, 'qt'=>1, 'mov'=>1, 'uvh'=>1, 'uvvh'=>1, 'uvm'=>1, 'uvvm'=>1, 'uvp'=>1, 'uvvp'=>1, 'uvs'=>1, 'uvvs'=>1, 'uvv'=>1, 'uvvv'=>1, 'dvb'=>1,
'fvt'=>1, 'mxu'=>1, 'm4u'=>1, 'pyv'=>1, 'uvu'=>1, 'uvvu'=>1, 'viv'=>1, 'webm'=>1, 'f4v'=>1, 'fli'=>1, 'flv'=>1, 'm4v'=>1, 'mkv'=>1, 'mk3d'=>1, 'mks'=>1, 'mng'=>1, 'asf'=>1, 'asx'=>1,
'vob'=>1, 'wm'=>1, 'wmv'=>1, 'wmx'=>1, 'wvx'=>1, 'avi'=>1, 'movie'=>1, 'smv'=>1, 'ice'=>1,
var $extList = array('ez' => 1, 'aw' => 1, 'atom' => 1, 'atomcat' => 1, 'atomsvc' => 1, 'ccxml' => 1, 'cdmia' => 1, 'cdmic' => 1, 'cdmid' => 1, 'cdmio' => 1, 'cdmiq' => 1, 'cu' => 1, 'davmount' => 1,
'dbk' => 1, 'dssc' => 1, 'xdssc' => 1, 'ecma' => 1, 'emma' => 1, 'epub' => 1, 'exi' => 1, 'pfr' => 1, 'gml' => 1, 'gpx' => 1, 'gxf' => 1, 'stk' => 1, 'ink' => 1, 'inkml' => 1, 'ipfix' => 1, 'jar' => 1,
'ser' => 1, 'class' => 1, 'js' => 1, 'json' => 1, 'jsonml' => 1, 'lostxml' => 1, 'hqx' => 1, 'cpt' => 1, 'mads' => 1, 'mrc' => 1, 'mrcx' => 1, 'ma' => 1, 'nb' => 1, 'mb' => 1, 'mathml' => 1, 'mbox' => 1,
'mscml' => 1, 'metalink' => 1, 'meta4' => 1, 'mets' => 1, 'mods' => 1, 'm21 mp21' => 1, 'mp4s' => 1, 'doc dot' => 1, 'mxf' => 1, 'bin' => 1, 'dms' => 1, 'lrf' => 1, 'mar' => 1, 'so' => 1, 'dist' => 1,
'distz' => 1, 'pkg' => 1, 'bpk' => 1, 'dump' => 1, 'elc' => 1, 'deploy' => 1, 'oda' => 1, 'opf' => 1, 'ogx' => 1, 'omdoc' => 1, 'onetoc' => 1, 'onetoc2' => 1, 'onetmp' => 1, 'onepkg' => 1, 'oxps' => 1,
'xer' => 1, 'pdf' => 1, 'pgp' => 1, 'asc' => 1, 'sig' => 1, 'prf' => 1, 'p10' => 1, 'p7m' => 1, 'p7c' => 1, 'p7s' => 1, 'p8' => 1, 'ac' => 1, 'cer' => 1, 'crl' => 1, 'pkipath' => 1, 'pki' => 1, 'pls' => 1,
'ai' => 1, 'eps' => 1, 'ps' => 1, 'cww' => 1, 'pskcxml' => 1, 'rdf' => 1, 'rif' => 1, 'rnc' => 1, 'rl' => 1, 'rld' => 1, 'rs' => 1, 'gbr' => 1, 'mft' => 1, 'roa' => 1, 'rsd' => 1, 'rss' => 1, 'rtf' => 1,
'sbml' => 1, 'scq' => 1, 'scs' => 1, 'spq' => 1, 'spp' => 1, 'sdp' => 1, 'setpay' => 1, 'setreg' => 1, 'shf' => 1, 'smi' => 1, 'smil' => 1, 'rq' => 1, 'srx' => 1, 'gram' => 1, 'grxml' => 1, 'sru' => 1,
'ssdl' => 1, 'ssml' => 1, 'tei' => 1, 'teicorpus' => 1, 'tfi' => 1, 'tsd' => 1, 'plb' => 1, 'psb' => 1, 'pvb' => 1, 'tcap' => 1, 'pwn' => 1, 'aso' => 1, 'imp' => 1, 'acu' => 1, 'atc' => 1, 'acutc' => 1,
'air' => 1, 'fcdt' => 1, 'fxp' => 1, 'fxpl' => 1, 'xdp' => 1, 'xfdf' => 1, 'ahead' => 1, 'azf' => 1, 'azs' => 1, 'azw' => 1, 'acc' => 1, 'ami' => 1, 'apk' => 1, 'cii' => 1, 'fti' => 1, 'atx' => 1, 'mpkg' => 1,
'm3u8' => 1, 'swi' => 1, 'iota' => 1, 'aep' => 1, 'mpm' => 1, 'bmi' => 1, 'rep' => 1, 'cdxml' => 1, 'mmd' => 1, 'cdy' => 1, 'cla' => 1, 'rp9' => 1, 'c4g' => 1, 'c4d' => 1, 'c4f' => 1, 'c4p' => 1, 'c4u' => 1,
'c11amc' => 1, 'c11amz' => 1, 'csp' => 1, 'cdbcmsg' => 1, 'cmc' => 1, 'clkx' => 1, 'clkk' => 1, 'clkp' => 1, 'clkt' => 1, 'clkw' => 1, 'wbs' => 1, 'pml' => 1, 'ppd' => 1, 'car' => 1, 'pcurl' => 1, 'dart' => 1,
'rdz' => 1, 'uvf' => 1, 'uvvf' => 1, 'uvd' => 1, 'uvvd' => 1, 'uvt' => 1, 'uvvt' => 1, 'uvx' => 1, 'uvvx' => 1, 'uvz' => 1, 'uvvz' => 1, 'fe_launch' => 1, 'dna' => 1, 'mlp' => 1, 'dpg' => 1, 'dfac' => 1,
'kpxx' => 1, 'ait' => 1, 'svc' => 1, 'geo' => 1, 'mag' => 1, 'nml' => 1, 'esf' => 1, 'msf' => 1, 'qam' => 1, 'slt' => 1, 'ssf' => 1, 'es3' => 1, 'et3' => 1, 'ez2' => 1, 'ez3' => 1, 'fdf' => 1, 'mseed' => 1,
'seed' => 1, 'dataless' => 1, 'gph' => 1, 'ftc' => 1, 'fm' => 1, 'frame' => 1, 'maker' => 1, 'book' => 1, 'fnc' => 1, 'ltf' => 1, 'fsc' => 1, 'oas' => 1, 'oa2' => 1, 'oa3' => 1, 'fg5' => 1, 'bh2' => 1, 'ddd' => 1,
'xdw' => 1, 'xbd' => 1, 'fzs' => 1, 'txd' => 1, 'ggb' => 1, 'ggt' => 1, 'gex' => 1, 'gre' => 1, 'gxt' => 1, 'g2w' => 1, 'g3w' => 1, 'gmx' => 1, 'kml' => 1, 'kmz' => 1, 'gqf' => 1, 'gqs' => 1, 'gac' => 1, 'ghf' => 1,
'gim' => 1, 'grv' => 1, 'gtm' => 1, 'tpl' => 1, 'vcg' => 1, 'hal' => 1, 'zmm' => 1, 'hbci' => 1, 'les' => 1, 'hpgl' => 1, 'hpid' => 1, 'hps' => 1, 'jlt' => 1, 'pcl' => 1, 'pclxl' => 1, 'sfd-hdstx' => 1, 'mpy' => 1,
'afp' => 1, 'listafp' => 1, 'list3820' => 1, 'irm' => 1, 'sc' => 1, 'icc' => 1, 'icm' => 1, 'igl' => 1, 'ivp' => 1, 'ivu' => 1, 'igm' => 1, 'xpw' => 1, 'xpx' => 1, 'i2g' => 1, 'qbo' => 1, 'qfx' => 1,
'rcprofile' => 1, 'irp' => 1, 'xpr' => 1, 'fcs' => 1, 'jam' => 1, 'rms' => 1, 'jisp' => 1, 'joda' => 1, 'ktz' => 1, 'ktr' => 1, 'karbon' => 1, 'chrt' => 1, 'kfo' => 1, 'flw' => 1, 'kon' => 1, 'kpr' => 1, 'kpt' => 1,
'ksp' => 1, 'kwd' => 1, 'kwt' => 1, 'htke' => 1, 'kia' => 1, 'kne' => 1, 'knp' => 1, 'skp' => 1, 'skd' => 1, 'skt' => 1, 'skm' => 1, 'sse' => 1, 'lasxml' => 1, 'lbd' => 1, 'lbe' => 1, '123' => 1, 'apr' => 1,
'pre' => 1, 'nsf' => 1, 'org' => 1, 'scm' => 1, 'lwp' => 1, 'portpkg' => 1, 'mcd' => 1, 'mc1' => 1, 'cdkey' => 1, 'mwf' => 1, 'mfm' => 1, 'flo' => 1, 'igx' => 1, 'mif' => 1, 'daf' => 1, 'dis' => 1, 'mbk' => 1,
'mqy' => 1, 'msl' => 1, 'plc' => 1, 'txf' => 1, 'mpn' => 1, 'mpc' => 1, 'xul' => 1, 'cil' => 1, 'cab' => 1, 'xls' => 1, 'xlm' => 1, 'xla' => 1, 'xlc' => 1, 'xlt' => 1, 'xlw' => 1, 'xlam' => 1, 'xlsb' => 1, 'xlsm' => 1,
'xltm' => 1, 'eot' => 1, 'chm' => 1, 'ims' => 1, 'lrm' => 1, 'thmx' => 1, 'cat' => 1, 'stl' => 1, 'ppt' => 1, 'pps' => 1, 'pot' => 1, 'ppam' => 1, 'pptm' => 1, 'sldm' => 1, 'ppsm' => 1, 'potm' => 1, 'mpp' => 1,
'mpt' => 1, 'docm' => 1, 'dotm' => 1, 'wps' => 1, 'wks' => 1, 'wcm' => 1, 'wdb' => 1, 'wpl' => 1, 'xps' => 1, 'mseq' => 1, 'mus' => 1, 'msty' => 1, 'taglet' => 1, 'nlu' => 1, 'nitf' => 1, 'nitf' => 1, 'nnd' => 1,
'nns' => 1, 'nnw' => 1, 'ngdat' => 1, 'n-gage' => 1, 'rpst' => 1, 'rpss' => 1, 'edm' => 1, 'edx' => 1, 'ext' => 1, 'odc' => 1, 'otc' => 1, 'odb' => 1, 'odf' => 1, 'odft' => 1, 'odg' => 1, 'otg' => 1, 'odi' => 1,
'oti' => 1, 'odp' => 1, 'otp' => 1, 'ods' => 1, 'ots' => 1, 'odt' => 1, 'odm' => 1, 'ott' => 1, 'oth' => 1, 'xo' => 1, 'dd2' => 1, 'oxt' => 1, 'pptx' => 1, 'sldx' => 1, 'ppsx' => 1, 'potx' => 1, 'xlsx' => 1, 'xltx' => 1,
'docx' => 1, 'dotx' => 1, 'mgp' => 1, 'dp' => 1, 'esa' => 1, 'pdb' => 1, 'pqa' => 1, 'oprc' => 1, 'paw' => 1, 'str' => 1, 'ei6' => 1, 'efif' => 1, 'wg' => 1, 'plf' => 1, 'pbd' => 1, 'box' => 1, 'mgz' => 1, 'qps' => 1,
'ptid' => 1, 'qxd' => 1, 'qxt' => 1, 'qwd' => 1, 'qwt' => 1, 'qxl' => 1, 'qxb' => 1, 'bed' => 1, 'mxl' => 1, 'musicxml' => 1, 'cryptonote' => 1, 'cod' => 1, 'rm' => 1, 'rmvb' => 1, 'link66' => 1, 'st' => 1, 'see' => 1,
'sema' => 1, 'semd' => 1, 'semf' => 1, 'ifm' => 1, 'itp' => 1, 'iif' => 1, 'ipk' => 1, 'twd' => 1, 'twds' => 1, 'mmf' => 1, 'teacher' => 1, 'sdkm' => 1, 'sdkd' => 1, 'dxp' => 1, 'sfs' => 1, 'sdc' => 1, 'sda' => 1,
'sdd' => 1, 'smf' => 1, 'sdw' => 1, 'vor' => 1, 'sgl' => 1, 'smzip' => 1, 'sm' => 1, 'sxc' => 1, 'stc' => 1, 'sxd' => 1, 'std' => 1, 'sxi' => 1, 'sti' => 1, 'sxm' => 1, 'sxw' => 1, 'sxg' => 1, 'stw' => 1, 'sus' => 1,
'susp' => 1, 'svd' => 1, 'sis' => 1, 'sisx' => 1, 'xsm' => 1, 'bdm' => 1, 'xdm' => 1, 'tao' => 1, 'pcap' => 1, 'cap' => 1, 'dmp' => 1, 'tmo' => 1, 'tpt' => 1, 'mxs' => 1, 'tra' => 1, 'ufd' => 1, 'ufdl' => 1, 'utz' => 1,
'umj' => 1, 'unityweb' => 1, 'uoml' => 1, 'vcx' => 1, 'vsd' => 1, 'vst' => 1, 'vss' => 1, 'vsw' => 1, 'vis' => 1, 'vsf' => 1, 'wbxml' => 1, 'wmlc' => 1, 'wmlsc' => 1, 'wtb' => 1, 'nbp' => 1, 'wpd' => 1, 'wqd' => 1,
'stf' => 1, 'xar' => 1, 'xfdl' => 1, 'hvd' => 1, 'hvs' => 1, 'hvp' => 1, 'osf' => 1, 'osfpvg' => 1, 'saf' => 1, 'spf' => 1, 'cmp' => 1, 'zir' => 1, 'zirz' => 1, 'zaz' => 1, 'vxml' => 1, 'wgt' => 1, 'hlp' => 1, 'wsdl' => 1,
'wspolicy' => 1, '7z' => 1, 'abw' => 1, 'ace' => 1, 'dmg' => 1, 'aab' => 1, 'x32' => 1, 'u32' => 1, 'vox' => 1, 'aam' => 1, 'aas' => 1, 'bcpio' => 1, 'torrent' => 1, 'blb' => 1, 'blorb' => 1, 'bz' => 1, 'bz2' => 1,
'boz' => 1, 'cbr' => 1, 'cba' => 1, 'cbt' => 1, 'cbz' => 1, 'cb7' => 1, 'vcd' => 1, 'cfs' => 1, 'chat' => 1, 'pgn' => 1, 'nsc' => 1, 'cpio' => 1, 'csh' => 1, 'deb' => 1, 'udeb' => 1, 'dgc' => 1, 'dir' => 1, 'dcr' => 1,
'dxr' => 1, 'cst' => 1, 'cct' => 1, 'cxt' => 1, 'w3d' => 1, 'fgd' => 1, 'swa' => 1, 'wad' => 1, 'ncx' => 1, 'dtb' => 1, 'res' => 1, 'dvi' => 1, 'evy' => 1, 'eva' => 1, 'bdf' => 1, 'gsf' => 1, 'psf' => 1, 'otf' => 1,
'pcf' => 1, 'snf' => 1, 'ttf' => 1, 'ttc' => 1, 'pfa' => 1, 'pfb' => 1, 'pfm' => 1, 'afm' => 1, 'woff' => 1, 'arc' => 1, 'spl' => 1, 'gca' => 1, 'ulx' => 1, 'gnumeric' => 1, 'gramps' => 1, 'gtar' => 1, 'hdf' => 1,
'install' => 1, 'iso' => 1, 'jnlp' => 1, 'latex' => 1, 'lzh' => 1, 'lha' => 1, 'mie' => 1, 'prc' => 1, 'mobi' => 1, 'application' => 1, 'lnk' => 1, 'wmd' => 1, 'wmz' => 1, 'xbap' => 1, 'mdb' => 1, 'obd' => 1,
'crd' => 1, 'clp' => 1, 'exe' => 1, 'dll' => 1, 'com' => 1, 'bat' => 1, 'msi' => 1, 'mvb' => 1, 'm13' => 1, 'm14' => 1, 'wmf' => 1, 'wmz' => 1, 'emf' => 1, 'emz' => 1, 'mny' => 1, 'pub' => 1, 'scd' => 1, 'trm' => 1,
'wri' => 1, 'nc' => 1, 'cdf' => 1, 'nzb' => 1, 'p12' => 1, 'pfx' => 1, 'p7b' => 1, 'spc' => 1, 'p7r' => 1, 'rar' => 1, 'ris' => 1, 'sh' => 1, 'shar' => 1, 'swf' => 1, 'xap' => 1, 'sql' => 1, 'sit' => 1, 'sitx' => 1,
'srt' => 1, 'sv4cpio' => 1, 'sv4crc' => 1, 't3' => 1, 'gam' => 1, 'tar' => 1, 'tcl' => 1, 'tex' => 1, 'tfm' => 1, 'texinfo' => 1, 'texi' => 1, 'obj' => 1, 'ustar' => 1, 'src' => 1, 'der' => 1, 'crt' => 1, 'fig' => 1,
'xlf' => 1, 'xpi' => 1, 'xz' => 1, 'z1' => 1, 'z2' => 1, 'z3' => 1, 'z4' => 1, 'z5' => 1, 'z6' => 1, 'z7' => 1, 'z8' => 1, 'xaml' => 1, 'xdf' => 1, 'xenc' => 1, 'xhtml' => 1, 'xht' => 1, 'xml' => 1, 'xsl' => 1, 'dtd' => 1,
'xop' => 1, 'xpl' => 1, 'xslt' => 1, 'xspf' => 1, 'mxml' => 1, 'xhvml' => 1, 'xvml' => 1, 'xvm' => 1, 'yang' => 1, 'yin' => 1, 'zip' => 1, 'adp' => 1, 'au' => 1, 'snd' => 1, 'mid' => 1, 'midi' => 1, 'kar' => 1, 'rmi' => 1,
'mp4a' => 1, 'mpga' => 1, 'mp2' => 1, 'mp2a' => 1, 'mp3' => 1, 'm2a' => 1, 'm3a' => 1, 'oga' => 1, 'ogg' => 1, 'spx' => 1, 's3m' => 1, 'sil' => 1, 'uva' => 1, 'uvva' => 1, 'eol' => 1, 'dra' => 1, 'dts' => 1, 'dtshd' => 1,
'lvp' => 1, 'pya' => 1, 'ecelp4800' => 1, 'ecelp7470' => 1, 'ecelp9600' => 1, 'rip' => 1, 'weba' => 1, 'aac' => 1, 'aif' => 1, 'aiff' => 1, 'aifc' => 1, 'caf' => 1, 'flac' => 1, 'mka' => 1, 'm3u' => 1, 'wax' => 1,
'wma' => 1, 'ram' => 1, 'ra' => 1, 'rmp' => 1, 'wav' => 1, 'xm' => 1, 'cdx' => 1, 'cif' => 1, 'cmdf' => 1, 'cml' => 1, 'csml' => 1, 'xyz' => 1, 'bmp' => 1, 'cgm' => 1, 'g3' => 1, 'gif' => 1, 'ief' => 1, 'jpeg' => 1,
'jpg' => 1, 'jpe' => 1, 'ktx' => 1, 'png' => 1, 'btif' => 1, 'sgi' => 1, 'svg' => 1, 'svgz' => 1, 'tiff' => 1, 'tif' => 1, 'psd' => 1, 'uvi' => 1, 'uvvi' => 1, 'uvg' => 1, 'uvvg' => 1, 'sub' => 1, 'djvu' => 1, 'djv' => 1,
'dwg' => 1, 'dxf' => 1, 'fbs' => 1, 'fpx' => 1, 'fst' => 1, 'mmr' => 1, 'rlc' => 1, 'mdi' => 1, 'wdp' => 1, 'npx' => 1, 'wbmp' => 1, 'xif' => 1, 'webp' => 1, '3ds' => 1, 'ras' => 1, 'cmx' => 1, 'fh' => 1, 'fhc' => 1,
'fh4' => 1, 'fh5' => 1, 'fh7' => 1, 'ico' => 1, 'sid' => 1, 'pcx' => 1, 'pic' => 1, 'pct' => 1, 'pnm' => 1, 'pbm' => 1, 'pgm' => 1, 'ppm' => 1, 'rgb' => 1, 'tga' => 1, 'xbm' => 1, 'xpm' => 1, 'xwd' => 1, 'eml' => 1,
'mime' => 1, 'igs' => 1, 'iges' => 1, 'msh' => 1, 'mesh' => 1, 'silo' => 1, 'dae' => 1, 'dwf' => 1, 'gdl' => 1, 'gtw' => 1, 'mts' => 1, 'vtu' => 1, 'wrl' => 1, 'vrml' => 1, 'x3db' => 1, 'x3dbz' => 1, 'x3dv' => 1,
'x3dvz' => 1, 'x3d' => 1, 'x3dz' => 1, '3gp' => 1, '3g2' => 1, 'h261' => 1, 'h263' => 1, 'h264' => 1, 'jpgv' => 1, 'jpm' => 1, 'jpgm' => 1, 'mj2' => 1, 'mjp2' => 1, 'mp4' => 1, 'mp4v' => 1, 'mpg4' => 1, 'mpeg' => 1,
'mpg' => 1, 'mpe' => 1, 'm1v' => 1, 'm2v' => 1, 'ogv' => 1, 'qt' => 1, 'mov' => 1, 'uvh' => 1, 'uvvh' => 1, 'uvm' => 1, 'uvvm' => 1, 'uvp' => 1, 'uvvp' => 1, 'uvs' => 1, 'uvvs' => 1, 'uvv' => 1, 'uvvv' => 1, 'dvb' => 1,
'fvt' => 1, 'mxu' => 1, 'm4u' => 1, 'pyv' => 1, 'uvu' => 1, 'uvvu' => 1, 'viv' => 1, 'webm' => 1, 'f4v' => 1, 'fli' => 1, 'flv' => 1, 'm4v' => 1, 'mkv' => 1, 'mk3d' => 1, 'mks' => 1, 'mng' => 1, 'asf' => 1, 'asx' => 1,
'vob' => 1, 'wm' => 1, 'wmv' => 1, 'wmx' => 1, 'wvx' => 1, 'avi' => 1, 'movie' => 1, 'smv' => 1, 'ice' => 1,
);
/**
@ -279,6 +282,16 @@ class EmbedFilter
return $GLOBALS['__EMBEDFILTER_INSTANCE__'];
}
public function getWhiteUrlList()
{
return $this->whiteUrlList;
}
public function getWhiteIframeUrlList()
{
return $this->whiteIframeUrlList;
}
/**
* Check the content.
* @return void
@ -300,11 +313,11 @@ class EmbedFilter
*/
function checkObjectTag(&$content)
{
preg_match_all('/<\s*object\s*[^>]+(?:\/?>)/is', $content, $m);
preg_match_all('/<\s*object\s*[^>]+(?:\/?>?)/is', $content, $m);
$objectTagList = $m[0];
if($objectTagList)
{
foreach($objectTagList AS $key=>$objectTag)
foreach($objectTagList AS $key => $objectTag)
{
$isWhiteDomain = true;
$isWhiteMimetype = true;
@ -316,12 +329,12 @@ class EmbedFilter
{
if(is_array($parser->iNodeAttributes))
{
foreach($parser->iNodeAttributes AS $attrName=>$attrValue)
foreach($parser->iNodeAttributes AS $attrName => $attrValue)
{
// data url check
if($attrValue && strtolower($attrName) == 'data')
{
$ext = strtolower(substr(strrchr($attrValue,"."),1));
$ext = strtolower(substr(strrchr($attrValue, "."), 1));
$isWhiteDomain = $this->isWhiteDomain($attrValue);
}
@ -353,15 +366,15 @@ class EmbedFilter
*/
function checkEmbedTag(&$content)
{
preg_match_all('/<\s*embed\s*[^>]+(?:\/?>)/is', $content, $m);
preg_match_all('/<\s*embed\s*[^>]+(?:\/?>?)/is', $content, $m);
$embedTagList = $m[0];
if($embedTagList)
{
foreach($embedTagList AS $key=>$embedTag)
foreach($embedTagList AS $key => $embedTag)
{
$isWhiteDomain = true;
$isWhiteMimetype = true;
$isWhiteExt = true;
$isWhiteDomain = TRUE;
$isWhiteMimetype = TRUE;
$isWhiteExt = TRUE;
$ext = '';
$parser = new HtmlParser($embedTag);
@ -369,12 +382,12 @@ class EmbedFilter
{
if(is_array($parser->iNodeAttributes))
{
foreach($parser->iNodeAttributes AS $attrName=>$attrValue)
foreach($parser->iNodeAttributes AS $attrName => $attrValue)
{
// src url check
if($attrValue && strtolower($attrName) == 'src')
{
$ext = strtolower(substr(strrchr($attrValue,"."),1));
$ext = strtolower(substr(strrchr($attrValue, "."), 1));
$isWhiteDomain = $this->isWhiteDomain($attrValue);
}
@ -406,13 +419,16 @@ class EmbedFilter
*/
function checkIframeTag(&$content)
{
preg_match_all('/<\s*iframe\s*[^>]+(?:\/?>)/is', $content, $m);
// check in Purifier class
return;
preg_match_all('/<\s*iframe\s*[^>]+(?:\/?>?)/is', $content, $m);
$iframeTagList = $m[0];
if($iframeTagList)
{
foreach($iframeTagList AS $key=>$iframeTag)
foreach($iframeTagList AS $key => $iframeTag)
{
$isWhiteDomain = true;
$isWhiteDomain = TRUE;
$ext = '';
$parser = new HtmlParser($iframeTag);
@ -420,12 +436,12 @@ class EmbedFilter
{
if(is_array($parser->iNodeAttributes))
{
foreach($parser->iNodeAttributes AS $attrName=>$attrValue)
foreach($parser->iNodeAttributes AS $attrName => $attrValue)
{
// src url check
if(strtolower($attrName) == 'src' && $attrValue)
{
$ext = strtolower(substr(strrchr($attrValue,"."),1));
$ext = strtolower(substr(strrchr($attrValue, "."), 1));
$isWhiteDomain = $this->isWhiteIframeDomain($attrValue);
}
}
@ -446,14 +462,14 @@ class EmbedFilter
*/
function checkParamTag(&$content)
{
preg_match_all('/<\s*param\s*[^>]+(?:\/?>)/is', $content, $m);
preg_match_all('/<\s*param\s*[^>]+(?:\/?>?)/is', $content, $m);
$paramTagList = $m[0];
if($paramTagList)
{
foreach($paramTagList AS $key=>$paramTag)
foreach($paramTagList AS $key => $paramTag)
{
$isWhiteDomain = true;
$isWhiteExt = true;
$isWhiteDomain = TRUE;
$isWhiteExt = TRUE;
$ext = '';
$parser = new HtmlParser($paramTag);
@ -464,7 +480,7 @@ class EmbedFilter
$name = strtolower($parser->iNodeAttributes['name']);
if($name == 'movie' || $name == 'src' || $name == 'href' || $name == 'url' || $name == 'source')
{
$ext = strtolower(substr(strrchr($parser->iNodeAttributes['value'],"."),1));
$ext = strtolower(substr(strrchr($parser->iNodeAttributes['value'], "."), 1));
$isWhiteDomain = $this->isWhiteDomain($parser->iNodeAttributes['value']);
if(!$isWhiteDomain && $ext)
@ -491,15 +507,15 @@ class EmbedFilter
{
if(is_array($this->whiteUrlList))
{
foreach($this->whiteUrlList AS $key=>$value)
foreach($this->whiteUrlList AS $key => $value)
{
if(preg_match('@^'.preg_quote($value).'@i', $urlAttribute))
if(preg_match('@^' . preg_quote($value) . '@i', $urlAttribute))
{
return true;
return TRUE;
}
}
}
return false;
return FALSE;
}
/**
@ -510,15 +526,15 @@ class EmbedFilter
{
if(is_array($this->whiteIframeUrlList))
{
foreach($this->whiteIframeUrlList AS $key=>$value)
foreach($this->whiteIframeUrlList AS $key => $value)
{
if(preg_match('@^'.preg_quote($value).'@i', $urlAttribute))
if(preg_match('@^' . preg_quote($value) . '@i', $urlAttribute))
{
return true;
return TRUE;
}
}
}
return false;
return FALSE;
}
/**
@ -529,18 +545,18 @@ class EmbedFilter
{
if(isset($this->mimeTypeList[$mimeType]))
{
return true;
return TRUE;
}
return false;
return FALSE;
}
function isWhiteExt($ext)
{
if(isset($this->extList[$ext]))
{
return true;
return TRUE;
}
return false;
return FALSE;
}
function _checkAllowScriptAccess($m)
@ -559,7 +575,7 @@ class EmbedFilter
{
$m[0] .= '/';
}
$this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--;
$this->allowscriptaccessList[count($this->allowscriptaccessList) - 1]--;
}
}
else if($m[1] == 'embed')
@ -580,7 +596,7 @@ class EmbedFilter
{
if($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1)
{
$m[0] = $m[0].'<param name="allowscriptaccess" value="never"></param>';
$m[0] = $m[0] . '<param name="allowscriptaccess" value="never"></param>';
}
$this->allowscriptaccessKey++;
return $m[0];
@ -600,7 +616,7 @@ class EmbedFilter
{
$isMake = true;
}
if( file_exists($whiteUrlCacheFile) && filemtime($whiteUrlCacheFile)<filemtime($whiteUrlXmlFile) )
if(file_exists($whiteUrlCacheFile) && filemtime($whiteUrlCacheFile) < filemtime($whiteUrlXmlFile))
{
$isMake = true;
}
@ -614,41 +630,52 @@ class EmbedFilter
$embedDomainList = $domainListObj->whiteurl->embed->domain;
$iframeDomainList = $domainListObj->whiteurl->iframe->domain;
$buff = '<?php if(!defined("__ZBXE__")) exit();';
$buff = '<?php if(!defined("__XE__")) exit();';
$buff .= '$whiteUrlList = array();';
$buff .= '$whiteIframeUrlList = array();';
if(is_array($embedDomainList))
{
foreach($embedDomainList AS $key=>$value)
foreach($embedDomainList AS $key => $value)
{
$patternList = $value->pattern;
if(is_array($patternList))
{
foreach($patternList AS $key=>$value)
foreach($patternList AS $key => $value)
{
$buff .= sprintf('$whiteUrlList[] = \'%s\';', $value->body);
}
}
else $buff .= sprintf('$whiteUrlList[] = \'%s\';', $patternList->body);
else
$buff .= sprintf('$whiteUrlList[] = \'%s\';', $patternList->body);
}
}
if(is_array($iframeDomainList))
{
foreach($iframeDomainList AS $key=>$value)
foreach($iframeDomainList AS $key => $value)
{
$patternList = $value->pattern;
if(is_array($patternList))
{
foreach($patternList AS $key=>$value)
foreach($patternList AS $key => $value)
{
$buff .= sprintf('$whiteIframeUrlList[] = \'%s\';', $value->body);
}
}
else $buff .= sprintf('$whiteIframeUrlList[] = \'%s\';', $patternList->body);
else
$buff .= sprintf('$whiteIframeUrlList[] = \'%s\';', $patternList->body);
}
}
if(Context::getDefaultUrl())
{
$buff .= sprintf('$whiteIframeUrlList[] = \'%s\';', Context::getDefaultUrl());
}
$buff .= '?>';
FileHandler::writeFile($this->whiteUrlCacheFile, $buff);
}
}
}
/* End of file : EmbedFilter.class.php */
/* Location: ./classes/security/EmbedFilter.class.php */

View file

@ -0,0 +1,180 @@
<?php
class Purifier
{
private $_cacheDir;
private $_htmlPurifier;
private $_config;
private $_def;
public function Purifier()
{
$this->_checkCacheDir();
// purifier setting
require_once _XE_PATH_ . 'classes/security/htmlpurifier/library/HTMLPurifier.auto.php';
require_once 'HTMLPurifier.func.php';
$this->_setConfig();
}
public function getInstance()
{
if(!isset($GLOBALS['__PURIFIER_INSTANCE__']))
{
$GLOBALS['__PURIFIER_INSTANCE__'] = new Purifier();
}
return $GLOBALS['__PURIFIER_INSTANCE__'];
}
private function _setConfig()
{
$whiteDomainRegex = $this->_getWhiteDomainRegx();
//$allowdClasses = array('emoticon');
$this->_config = HTMLPurifier_Config::createDefault();
$this->_config->set('HTML.TidyLevel', 'light');
$this->_config->set('Output.FlashCompat', TRUE);
$this->_config->set('HTML.SafeObject', TRUE);
$this->_config->set('HTML.SafeEmbed', TRUE);
$this->_config->set('HTML.SafeIframe', TRUE);
$this->_config->set('URI.SafeIframeRegexp', $whiteDomainRegex);
$this->_config->set('Cache.SerializerPath', $this->_cacheDir);
//$this->_config->set('Attr.AllowedClasses', $allowdClasses);
$this->_def = $this->_config->getHTMLDefinition(TRUE);
}
private function _setDefinition(&$content)
{
// add attribute for edit component
$editComponentAttrs = $this->_searchEditComponent($content);
if(is_array($editComponentAttrs))
{
foreach($editComponentAttrs AS $k => $v)
{
$this->_def->addAttribute('img', $v, 'CDATA');
$this->_def->addAttribute('div', $v, 'CDATA');
}
}
// add attribute for widget component
$widgetAttrs = $this->_searchWidget($content);
if(is_array($widgetAttrs))
{
foreach($widgetAttrs AS $k => $v)
{
$this->_def->addAttribute('img', $v, 'CDATA');
}
}
}
/**
* Search attribute of edit component tag
* @param string $content
* @return array
*/
private function _searchEditComponent($content)
{
preg_match_all('!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is', $content, $m);
$attributeList = array();
if(is_array($m[2]))
{
foreach($m[2] AS $key => $value)
{
unset($script, $m2);
$script = " {$m[2][$key]} editor_component={$m[3][$key]}";
preg_match_all('/([a-z0-9_-]+)="([^"]+)"/is', $script, $m2);
if(is_array($m2[1]))
{
foreach($m2[1] AS $key2 => $value2)
{
array_push($attributeList, $value2);
}
}
}
}
return array_unique($attributeList);
}
/**
* Search edit component tag
* @param string $content
* @return array
*/
private function _searchWidget(&$content)
{
preg_match_all('!<(?:(div)|img)([^>]*)class="zbxe_widget_output"([^>]*)>(?(1)(.*?)</div>)!is', $content, $m);
$attributeList = array();
if(is_array($m[3]))
{
$content = str_replace('<img class="zbxe_widget_output"', '<img src="" class="zbxe_widget_output"', $content);
foreach($m[3] AS $key => $value)
{
preg_match_all('/([a-z0-9_-]+)="([^"]+)"/is', $m[3][$key], $m2);
if(is_array($m2[1]))
{
foreach($m2[1] AS $key2 => $value2)
{
array_push($attributeList, $value2);
}
}
}
}
return array_unique($attributeList);
}
private function _getWhiteDomainRegx()
{
require_once(_XE_PATH_ . 'classes/security/EmbedFilter.class.php');
$oEmbedFilter = EmbedFilter::getInstance();
$whiteIframeUrlList = $oEmbedFilter->getWhiteIframeUrlList();
$whiteDomainRegex = '%^(';
$whiteDomainCount = count($whiteIframeUrlList);
$i=1;
if(is_array($whiteIframeUrlList))
{
foreach($whiteIframeUrlList AS $key => $value)
{
$whiteDomainRegex .= $value;
if($i < $whiteDomainCount)
{
$whiteDomainRegex .= '|';
}
$i++;
}
}
$whiteDomainRegex .= ')%';
return $whiteDomainRegex;
}
private function _checkCacheDir()
{
// check htmlpurifier cache directory
$this->_cacheDir = _XE_PATH_ . 'files/cache/htmlpurifier';
if(!file_exists($this->_cacheDir))
{
FileHandler::makeDir($this->_cacheDir);
}
}
public function purify(&$content)
{
$this->_setDefinition($content);
$this->_htmlPurifier = new HTMLPurifier($this->_config);
$content = $this->_htmlPurifier->purify($content);
}
}
/* End of file : Purifier.class.php */
/* Location: ./classes/security/Purifier.class.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* - Security class
* - This class helps to solve security problems.
@ -8,18 +9,19 @@
*/
class Security
{
/**
* Action target variable. If this value is null, the method will use Context variables
* @var mixed
**/
var $_targetVar = null;
*/
var $_targetVar = NULL;
/**
* @constructor
* @param mixed $var Target context
* @return void
*/
function Security($var = null)
function Security($var = NULL)
{
$this->_targetVar = $var;
}
@ -31,43 +33,73 @@ class Security
* separate the owner(object or array) and the item(property or element) using a dot(.)
* @return mixed
*/
function encodeHTML(/*, $varName1, $varName2, ... */)
function encodeHTML(/* , $varName1, $varName2, ... */)
{
$varNames = func_get_args();
if(count($varNames) < 0) return false;
if(count($varNames) < 0)
{
return FALSE;
}
$use_context = is_null($this->_targetVar);
if(!$use_context) {
if(!count($varNames) || (!is_object($this->_targetVar) && !is_array($this->_targetVar)) ) return $this->_encodeHTML($this->_targetVar);
if(!$use_context)
{
if(!count($varNames) || (!is_object($this->_targetVar) && !is_array($this->_targetVar)))
{
return $this->_encodeHTML($this->_targetVar);
}
$is_object = is_object($this->_targetVar);
}
foreach($varNames as $varName) {
$varName = explode('.', $varName);
foreach($varNames as $varName)
{
$varName = explode('.', $varName);
$varName0 = array_shift($varName);
if($use_context) {
if($use_context)
{
$var = Context::get($varName0);
} elseif($varName0) {
}
elseif($varName0)
{
$var = $is_object ? $this->_targetVar->{$varName0} : $this->_targetVar[$varName0];
} else {
}
else
{
$var = $this->_targetVar;
}
$var = $this->_encodeHTML($var, $varName);
if($var === false) continue;
if($var === FALSE)
{
continue;
}
if($use_context) {
if($use_context)
{
Context::set($varName0, $var);
} elseif($varName0) {
if($is_object) $this->_targetVar->{$varName0} = $var;
else $this->_targetVar[$varName0] = $var;
} else {
}
elseif($varName0)
{
if($is_object)
{
$this->_targetVar->{$varName0} = $var;
}
else
{
$this->_targetVar[$varName0] = $var;
}
}
else
{
$this->_targetVar = $var;
}
}
if (!$use_context) return $this->_targetVar;
if(!$use_context)
{
return $this->_targetVar;
}
}
/**
@ -76,43 +108,71 @@ class Security
* @param array $name
* @return mixed
*/
function _encodeHTML($var, $name=array())
function _encodeHTML($var, $name = array())
{
if(is_string($var)) {
if (!preg_match('/^\$user_lang->/', $var)) $var = htmlspecialchars($var);
if(is_string($var))
{
if(!preg_match('/^\$user_lang->/', $var))
{
$var = htmlspecialchars($var);
}
return $var;
}
if(!count($name) || (!is_array($var) && !is_object($var)) ) return false;
if(!count($name) || (!is_array($var) && !is_object($var)))
{
return false;
}
$is_object = is_object($var);
$name0 = array_shift($name);
$name0 = array_shift($name);
if(strlen($name0)) {
if(strlen($name0))
{
$target = $is_object ? $var->{$name0} : $var[$name0];
$target = $this->_encodeHTML($target, $name);
if($target === false) return $var;
if($target === false)
{
return $var;
}
if($is_object) $var->{$name0} = $target;
else $var[$name0] = $target;
if($is_object)
{
$var->{$name0} = $target;
}
else
{
$var[$name0] = $target;
}
return $var;
}
foreach($var as $key=>$target) {
foreach($var as $key => $target)
{
$cloned_name = array_slice($name, 0);
$target = $this->_encodeHTML($target, $name);
$name = $cloned_name;
$name = $cloned_name;
if($target === false) continue;
if($target === false)
{
continue;
}
if($is_object) $var->{$key} = $target;
else $var[$key] = $target;
if($is_object)
{
$var->{$key} = $target;
}
else
{
$var[$key] = $target;
}
}
return $var;
}
}
}
/* End of file : Security.class.php */
/* Location: ./classes/security/Security.class.php */

View file

@ -36,6 +36,8 @@
<domain name="http://www.youtube.com" desc="Youtube">
<pattern>http://www.youtube.com/v/</pattern>
<pattern>http://www.youtube-nocookie.com/</pattern>
<pattern>//www.youtube.com/v/</pattern>
<pattern>//www.youtube-nocookie.com/</pattern>
</domain>
<domain name="http://www.mgoon.com" desc="엠군">
<pattern>http://play.mgoon.com/Video/</pattern>
@ -199,6 +201,8 @@
<pattern>https://www.youtube.com/</pattern>
<pattern>http://www.youtube-nocookie.com/</pattern>
<pattern>https://www.youtube-nocookie.com/</pattern>
<pattern>//www.youtube.com/v/</pattern>
<pattern>//www.youtube-nocookie.com/</pattern>
</domain>
<domain name="http://maps.google.com" desc="구글맵스" mobile="true">
<pattern>http://maps.google.com/</pattern>

View file

@ -1 +0,0 @@
configdoc/usage.xml -crlf

View file

@ -1,22 +0,0 @@
tags
conf/
test-settings.php
config-schema.php
library/HTMLPurifier/DefinitionCache/Serializer/*/
library/standalone/
library/HTMLPurifier.standalone.php
library/HTMLPurifier*.tgz
library/package*.xml
smoketests/test-schema.html
configdoc/*.html
configdoc/configdoc.xml
docs/doxygen*
*.phpt.diff
*.phpt.exp
*.phpt.log
*.phpt.out
*.phpt.php
*.phpt.skip.php
*.htmlt.ini
*.patch
/*.php

File diff suppressed because it is too large Load diff

View file

@ -1,13 +0,0 @@
8 - Minor security fixes
[ Appendix A: Release focus IDs ]
0 - N/A
1 - Initial freshmeat announcement
2 - Documentation
3 - Code cleanup
4 - Minor feature enhancements
5 - Major feature enhancements
6 - Minor bugfixes
7 - Major bugfixes
8 - Minor security fixes
9 - Major security fixes

View file

@ -1,374 +0,0 @@
Install
How to install HTML Purifier
HTML Purifier is designed to run out of the box, so actually using the
library is extremely easy. (Although... if you were looking for a
step-by-step installation GUI, you've downloaded the wrong software!)
While the impatient can get going immediately with some of the sample
code at the bottom of this library, it's well worth reading this entire
document--most of the other documentation assumes that you are familiar
with these contents.
---------------------------------------------------------------------------
1. Compatibility
HTML Purifier is PHP 5 only, and is actively tested from PHP 5.0.5 and
up. It has no core dependencies with other libraries. PHP
4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0.
HTML Purifier is not compatible with zend.ze1_compatibility_mode.
These optional extensions can enhance the capabilities of HTML Purifier:
* iconv : Converts text to and from non-UTF-8 encodings
* bcmath : Used for unit conversion and imagecrash protection
* tidy : Used for pretty-printing HTML
These optional libraries can enhance the capabilities of HTML Purifier:
* CSSTidy : Clean CSS stylesheets using %Core.ExtractStyleBlocks
* Net_IDNA2 (PEAR) : IRI support using %Core.EnableIDNA
---------------------------------------------------------------------------
2. Reconnaissance
A big plus of HTML Purifier is its inerrant support of standards, so
your web-pages should be standards-compliant. (They should also use
semantic markup, but that's another issue altogether, one HTML Purifier
cannot fix without reading your mind.)
HTML Purifier can process these doctypes:
* XHTML 1.0 Transitional (default)
* XHTML 1.0 Strict
* HTML 4.01 Transitional
* HTML 4.01 Strict
* XHTML 1.1
...and these character encodings:
* UTF-8 (default)
* Any encoding iconv supports (with crippled internationalization support)
These defaults reflect what my choices would be if I were authoring an
HTML document, however, what you choose depends on the nature of your
codebase. If you don't know what doctype you are using, you can determine
the doctype from this identifier at the top of your source code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
...and the character encoding from this code:
<meta http-equiv="Content-type" content="text/html;charset=ENCODING">
If the character encoding declaration is missing, STOP NOW, and
read 'docs/enduser-utf8.html' (web accessible at
http://htmlpurifier.org/docs/enduser-utf8.html). In fact, even if it is
present, read this document anyway, as many websites specify their
document's character encoding incorrectly.
---------------------------------------------------------------------------
3. Including the library
The procedure is quite simple:
require_once '/path/to/library/HTMLPurifier.auto.php';
This will setup an autoloader, so the library's files are only included
when you use them.
Only the contents in the library/ folder are necessary, so you can remove
everything else when using HTML Purifier in a production environment.
If you installed HTML Purifier via PEAR, all you need to do is:
require_once 'HTMLPurifier.auto.php';
Please note that the usual PEAR practice of including just the classes you
want will not work with HTML Purifier's autoloading scheme.
Advanced users, read on; other users can skip to section 4.
Autoload compatibility
----------------------
HTML Purifier attempts to be as smart as possible when registering an
autoloader, but there are some cases where you will need to change
your own code to accomodate HTML Purifier. These are those cases:
PHP VERSION IS LESS THAN 5.1.2, AND YOU'VE DEFINED __autoload
Because spl_autoload_register() doesn't exist in early versions
of PHP 5, HTML Purifier has no way of adding itself to the autoload
stack. Modify your __autoload function to test
HTMLPurifier_Bootstrap::autoload($class)
For example, suppose your autoload function looks like this:
function __autoload($class) {
require str_replace('_', '/', $class) . '.php';
return true;
}
A modified version with HTML Purifier would look like this:
function __autoload($class) {
if (HTMLPurifier_Bootstrap::autoload($class)) return true;
require str_replace('_', '/', $class) . '.php';
return true;
}
Note that there *is* some custom behavior in our autoloader; the
original autoloader in our example would work for 99% of the time,
but would fail when including language files.
AN __autoload FUNCTION IS DECLARED AFTER OUR AUTOLOADER IS REGISTERED
spl_autoload_register() has the curious behavior of disabling
the existing __autoload() handler. Users need to explicitly
spl_autoload_register('__autoload'). Because we use SPL when it
is available, __autoload() will ALWAYS be disabled. If __autoload()
is declared before HTML Purifier is loaded, this is not a problem:
HTML Purifier will register the function for you. But if it is
declared afterwards, it will mysteriously not work. This
snippet of code (after your autoloader is defined) will fix it:
spl_autoload_register('__autoload')
Users should also be on guard if they use a version of PHP previous
to 5.1.2 without an autoloader--HTML Purifier will define __autoload()
for you, which can collide with an autoloader that was added by *you*
later.
For better performance
----------------------
Opcode caches, which greatly speed up PHP initialization for scripts
with large amounts of code (HTML Purifier included), don't like
autoloaders. We offer an include file that includes all of HTML Purifier's
files in one go in an opcode cache friendly manner:
// If /path/to/library isn't already in your include path, uncomment
// the below line:
// require '/path/to/library/HTMLPurifier.path.php';
require 'HTMLPurifier.includes.php';
Optional components still need to be included--you'll know if you try to
use a feature and you get a class doesn't exists error! The autoloader
can be used in conjunction with this approach to catch classes that are
missing. Simply add this afterwards:
require 'HTMLPurifier.autoload.php';
Standalone version
------------------
HTML Purifier has a standalone distribution; you can also generate
a standalone file from the full version by running the script
maintenance/generate-standalone.php . The standalone version has the
benefit of having most of its code in one file, so parsing is much
faster and the library is easier to manage.
If HTMLPurifier.standalone.php exists in the library directory, you
can use it like this:
require '/path/to/HTMLPurifier.standalone.php';
This is equivalent to including HTMLPurifier.includes.php, except that
the contents of standalone/ will be added to your path. To override this
behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can
be found (usually, this will be one directory up, the "true" library
directory in full distributions). Don't forget to set your path too!
The autoloader can be added to the end to ensure the classes are
loaded when necessary; otherwise you can manually include them.
To use the autoloader, use this:
require 'HTMLPurifier.autoload.php';
For advanced users
------------------
HTMLPurifier.auto.php performs a number of operations that can be done
individually. These are:
HTMLPurifier.path.php
Puts /path/to/library in the include path. For high performance,
this should be done in php.ini.
HTMLPurifier.autoload.php
Registers our autoload handler HTMLPurifier_Bootstrap::autoload($class).
You can do these operations by yourself--in fact, you must modify your own
autoload handler if you are using a version of PHP earlier than PHP 5.1.2
(See "Autoload compatibility" above).
---------------------------------------------------------------------------
4. Configuration
HTML Purifier is designed to run out-of-the-box, but occasionally HTML
Purifier needs to be told what to do. If you answer no to any of these
questions, read on; otherwise, you can skip to the next section (or, if you're
into configuring things just for the heck of it, skip to 4.3).
* Am I using UTF-8?
* Am I using XHTML 1.0 Transitional?
If you answered no to any of these questions, instantiate a configuration
object and read on:
$config = HTMLPurifier_Config::createDefault();
4.1. Setting a different character encoding
You really shouldn't use any other encoding except UTF-8, especially if you
plan to support multilingual websites (read section three for more details).
However, switching to UTF-8 is not always immediately feasible, so we can
adapt.
HTML Purifier uses iconv to support other character encodings, as such,
any encoding that iconv supports <http://www.gnu.org/software/libiconv/>
HTML Purifier supports with this code:
$config->set('Core.Encoding', /* put your encoding here */);
An example usage for Latin-1 websites (the most common encoding for English
websites):
$config->set('Core.Encoding', 'ISO-8859-1');
Note that HTML Purifier's support for non-Unicode encodings is crippled by the
fact that any character not supported by that encoding will be silently
dropped, EVEN if it is ampersand escaped. If you want to work around
this, you are welcome to read docs/enduser-utf8.html for a fix,
but please be cognizant of the issues the "solution" creates (for this
reason, I do not include the solution in this document).
4.2. Setting a different doctype
For those of you using HTML 4.01 Transitional, you can disable
XHTML output like this:
$config->set('HTML.Doctype', 'HTML 4.01 Transitional');
Other supported doctypes include:
* HTML 4.01 Strict
* HTML 4.01 Transitional
* XHTML 1.0 Strict
* XHTML 1.0 Transitional
* XHTML 1.1
4.3. Other settings
There are more configuration directives which can be read about
here: <http://htmlpurifier.org/live/configdoc/plain.html> They're a bit boring,
but they can help out for those of you who like to exert maximum control over
your code. Some of the more interesting ones are configurable at the
demo <http://htmlpurifier.org/demo.php> and are well worth looking into
for your own system.
For example, you can fine tune allowed elements and attributes, convert
relative URLs to absolute ones, and even autoparagraph input text! These
are, respectively, %HTML.Allowed, %URI.MakeAbsolute and %URI.Base, and
%AutoFormat.AutoParagraph. The %Namespace.Directive naming convention
translates to:
$config->set('Namespace.Directive', $value);
E.g.
$config->set('HTML.Allowed', 'p,b,a[href],i');
$config->set('URI.Base', 'http://www.example.com');
$config->set('URI.MakeAbsolute', true);
$config->set('AutoFormat.AutoParagraph', true);
---------------------------------------------------------------------------
5. Caching
HTML Purifier generates some cache files (generally one or two) to speed up
its execution. For maximum performance, make sure that
library/HTMLPurifier/DefinitionCache/Serializer is writeable by the webserver.
If you are in the library/ folder of HTML Purifier, you can set the
appropriate permissions using:
chmod -R 0755 HTMLPurifier/DefinitionCache/Serializer
If the above command doesn't work, you may need to assign write permissions
to all. This may be necessary if your webserver runs as nobody, but is
not recommended since it means any other user can write files in the
directory. Use:
chmod -R 0777 HTMLPurifier/DefinitionCache/Serializer
You can also chmod files via your FTP client; this option
is usually accessible by right clicking the corresponding directory and
then selecting "chmod" or "file permissions".
Starting with 2.0.1, HTML Purifier will generate friendly error messages
that will tell you exactly what you have to chmod the directory to, if in doubt,
follow its advice.
If you are unable or unwilling to give write permissions to the cache
directory, you can either disable the cache (and suffer a performance
hit):
$config->set('Core.DefinitionCache', null);
Or move the cache directory somewhere else (no trailing slash):
$config->set('Cache.SerializerPath', '/home/user/absolute/path');
---------------------------------------------------------------------------
6. Using the code
The interface is mind-numbingly simple:
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify( $dirty_html );
That's it! For more examples, check out docs/examples/ (they aren't very
different though). Also, docs/enduser-slow.html gives advice on what to
do if HTML Purifier is slowing down your application.
---------------------------------------------------------------------------
7. Quick install
First, make sure library/HTMLPurifier/DefinitionCache/Serializer is
writable by the webserver (see Section 5: Caching above for details).
If your website is in UTF-8 and XHTML Transitional, use this code:
<?php
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($dirty_html);
?>
If your website is in a different encoding or doctype, use this code:
<?php
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', 'ISO-8859-1'); // replace with your encoding
$config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($dirty_html);
?>
vim: et sw=4 sts=4

View file

@ -1,69 +0,0 @@

Installation
Comment installer HTML Purifier
Attention: Ce document a encode en UTF-8. Si les lettres avec les accents
est essoreuse, prenez un mieux editeur de texte.
À L'Aide: Je ne suis pas un diseur natif de français. Si vous trouvez une
erreur dans ce document, racontez-moi! Merci.
L'installation de HTML Purifier est trés simple, parce qu'il ne doit pas
la configuration. Dans le pied de de document, les utilisateurs
impatient peuvent trouver le code, mais je recommande que vous lisez
ce document pour quelques choses.
1. Compatibilité
HTML Purifier fonctionne dans PHP 5. PHP 5.0.5 est le dernier
version que je le testais. Il ne dépend de les autre librairies.
Les extensions optionnel est iconv (en général déjà installer) et
tidy (répandu aussi). Si vous utilisez UTF-8 et ne voulez pas
l'indentation, vous pouvez utiliser HTML Purifier sans ces extensions.
2. Inclure la librarie
Utilisez:
require_once '/path/to/library/HTMLPurifier.auto.php';
...quand vous devez utiliser HTML Purifier (ne inclure pas quand vous
ne devez pas, parce que HTML Purifier est trés grand.)
HTML Purifier utilise 'autoload'. Si vous avez définu la fonction
__autoload, vous doivez ajoute cet programme:
spl_autoload_register('__autoload')
Plus d'information est dans le document 'INSTALL'.
3. Installation vite
Si votre site web est en UTF-8 et XHTML Transitional, utilisez:
<?php
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$purificateur = new HTMLPurifier();
$html_propre = $purificateur->purify($html_salle);
?>
Sinon, utilisez:
<?php
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('Core', 'Encoding', 'ISO-8859-1'); //remplacez avec votre encoding
$config->set('Core', 'XHTML', true); //remplacez avec false si HTML 4.01
$purificateur = new HTMLPurifier($config);
$html_propre = $purificateur->purify($html_salle);
?>
vim: et sw=4 sts=4

File diff suppressed because it is too large Load diff

View file

@ -1,24 +0,0 @@
README
All about HTML Purifier
HTML Purifier is an HTML filtering solution that uses a unique combination
of robust whitelists and agressive parsing to ensure that not only are
XSS attacks thwarted, but the resulting HTML is standards compliant.
HTML Purifier is oriented towards richly formatted documents from
untrusted sources that require CSS and a full tag-set. This library can
be configured to accept a more restrictive set of tags, but it won't be
as efficient as more bare-bones parsers. It will, however, do the job
right, which may be more important.
Places to go:
* See INSTALL for a quick installation guide
* See docs/ for developer-oriented documentation, code examples and
an in-depth installation guide.
* See WYSIWYG for information on editors like TinyMCE and FCKeditor
HTML Purifier can be found on the web at: http://htmlpurifier.org/
vim: et sw=4 sts=4

View file

@ -1,149 +0,0 @@
TODO List
= KEY ====================
# Flagship
- Regular
? Maybe I'll Do It
==========================
If no interest is expressed for a feature that may require a considerable
amount of effort to implement, it may get endlessly delayed. Do not be
afraid to cast your vote for the next feature to be implemented!
Things to do as soon as possible:
- Think about allowing explicit order of operations hooks for transforms
- Fix "<.<" bug (trailing < is removed if not EOD)
- Build in better internal state dumps and debugging tools for remote
debugging
- Allowed/Allowed* have strange interactions when both set
? Transform lone embeds into object tags
- Deprecated config options that emit warnings when you set them (with'
a way of muting the warning if you really want to)
- Make HTML.Trusted work with Output.FlashCompat
- HTML.Trusted and HTML.SafeObject have funny interaction; general
problem is what to do when a module "supersedes" another
(see also tables and basic tables.) This is a little dicier
because HTML.SafeObject has some extra functionality that
trusted might find useful. See http://htmlpurifier.org/phorum/read.php?3,5762,6100
FUTURE VERSIONS
---------------
4.5 release [OMG CONFIG PONIES]
! Fix Printer. It's from the old days when we didn't have decent XML classes
! Factor demo.php into a set of Printer classes, and then create a stub
file for users here (inside the actual HTML Purifier library)
- Fix error handling with form construction
- Do encoding validation in Printers, or at least, where user data comes in
- Config: Add examples to everything (make built-in which also automatically
gives output)
- Add "register" field to config schemas to eliminate dependence on
naming conventions (try to remember why we ultimately decided on tihs)
5.0 release [HTML 5]
# Swap out code to use html5lib tokenizer and tree-builder
! Allow turning off of FixNesting and required attribute insertion
5.1 release [It's All About Trust] (floating)
# Implement untrusted, dangerous elements/attributes
# Implement IDREF support (harder than it seems, since you cannot have
IDREFs to non-existent IDs)
- Implement <area> (client and server side image maps are blocking
on IDREF support)
# Frameset XHTML 1.0 and HTML 4.01 doctypes
- Figure out how to simultaneously set %CSS.Trusted and %HTML.Trusted (?)
5.2 release [Error'ed]
# Error logging for filtering/cleanup procedures
# Additional support for poorly written HTML
- Microsoft Word HTML cleaning (i.e. MsoNormal, but research essential!)
- Friendly strict handling of <address> (block -> <br>)
- XSS-attempt detection--certain errors are flagged XSS-like
- Append something to duplicate IDs so they're still usable (impl. note: the
dupe detector would also need to detect the suffix as well)
6.0 release [Beyond HTML]
# Legit token based CSS parsing (will require revamping almost every
AttrDef class). Probably will use CSSTidy
# More control over allowed CSS properties using a modularization
# IRI support (this includes IDN)
- Standardize token armor for all areas of processing
7.0 release [To XML and Beyond]
- Extended HTML capabilities based on namespacing and tag transforms (COMPLEX)
- Hooks for adding custom processors to custom namespaced tags and
attributes, offer default implementation
- Lots of documentation and samples
Ongoing
- More refactoring to take advantage of PHP5's facilities
- Refactor unit tests into lots of test methods
- Plugins for major CMSes (COMPLEX)
- phpBB
- Also, a FAQ for extension writers with HTML Purifier
AutoFormat
- Smileys
- Syntax highlighting (with GeSHi) with <pre> and possibly <?php
- Look at http://drupal.org/project/Modules/category/63 for ideas
Neat feature related
! Support exporting configuration, so users can easily tweak settings
in the demo, and then copy-paste into their own setup
- Advanced URI filtering schemes (see docs/proposal-new-directives.txt)
- Allow scoped="scoped" attribute in <style> tags; may be troublesome
because regular CSS has no way of uniquely identifying nodes, so we'd
have to generate IDs
- Explain how to use HTML Purifier in non-PHP languages / create
a simple command line stub (or complicated?)
- Fixes for Firefox's inability to handle COL alignment props (Bug 915)
- Automatically add non-breaking spaces to empty table cells when
empty-cells:show is applied to have compatibility with Internet Explorer
- Table of Contents generation (XHTML Compiler might be reusable). May also
be out-of-band information.
- Full set of color keywords. Also, a way to add onto them without
finalizing the configuration object.
- Write a var_export and memcached DefinitionCache - Denis
- Built-in support for target="_blank" on all external links
- Convert RTL/LTR override characters to <bdo> tags, or vice versa on demand.
Also, enable disabling of directionality
? Externalize inline CSS to promote clean HTML, proposed by Sander Tekelenburg
? Remove redundant tags, ex. <u><u>Underlined</u></u>. Implementation notes:
1. Analyzing which tags to remove duplicants
2. Ensure attributes are merged into the parent tag
3. Extend the tag exclusion system to specify whether or not the
contents should be dropped or not (currently, there's code that could do
something like this if it didn't drop the inner text too.)
? Make AutoParagraph also support paragraph-izing double <br> tags, and not
just double newlines. This is kind of tough to do in the current framework,
though, and might be reasonably approximated by search replacing double <br>s
with newlines before running it through HTML Purifier.
Maintenance related (slightly boring)
# CHMOD install script for PEAR installs
! Factor out command line parser into its own class, and unit test it
- Reduce size of internal data-structures (esp. HTMLDefinition)
- Allow merging configurations. Thus,
a -> b -> default
c -> d -> default
becomes
a -> b -> c -> d -> default
Maybe allow more fine-grained tuning of this behavior. Alternatively,
encourage people to use short plist depths before building them up.
- Time PHPT tests
ChildDef related (very boring)
- Abstract ChildDef_BlockQuote to work with all elements that only
allow blocks in them, required or optional
- Implement lenient <ruby> child validation
Wontfix
- Non-lossy smart alternate character encoding transformations (unless
patch provided)
- Pretty-printing HTML: users can use Tidy on the output on entire page
- Native content compression, whitespace stripping: use gzip if this is
really important
vim: et sw=4 sts=4

View file

@ -1,8 +0,0 @@
HTML Purifier 4.4.0 is a minor security release addressing a security
vulnerability associated with some optional functionality. It also
contains an accumulation of new features and bugfixes over half a year.
New configuration options include %HTML.TargetBlank,
%HTML.AllowedComments, %HTML.AllowedCommentsRegexp, %HTML.SafeIframe,
%URI.SafeIframeRegexp, %Core.EnableIDNA (requires PEAR Net_IDNA2 module and
doesn't work for PHP 5.0.5). We also now support the 'scope' attribute on
tables.

View file

@ -1,20 +0,0 @@
WYSIWYG - What You See Is What You Get
HTML Purifier: A Pretty Good Fit for TinyMCE and FCKeditor
Javascript-based WYSIWYG editors, simply stated, are quite amazing. But I've
always been wary about using them due to security issues: they handle the
client-side magic, but once you've been served a piping hot load of unfiltered
HTML, what should be done then? In some situations, you can serve it uncleaned,
since you only offer these facilities to trusted(?) authors.
Unfortunantely, for blog comments and anonymous input, BBCode, Textile and
other markup languages still reign supreme. Put simply: filtering HTML is
hard work, and these WYSIWYG authors don't offer anything to alleviate that
trouble. Therein lies the solution:
HTML Purifier is perfect for filtering pure-HTML input from WYSIWYG editors.
Enough said.
vim: et sw=4 sts=4

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

View file

@ -1,101 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16.000000px"
height="16.000000px"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.42.2"
sodipodi:docbase="C:\DOCUME~1\Edward\MYDOCU~1\MYWEBS~1\HTMLPU~1\art"
sodipodi:docname="ICON-1~1.SVG"
inkscape:export-filename="C:\Documents and Settings\Edward\My Documents\My Webs\htmlpurifier\art\icon.png"
inkscape:export-xdpi="90.000000"
inkscape:export-ydpi="90.000000">
<defs
id="defs4">
<linearGradient
id="linearGradient5003">
<stop
style="stop-color:#537ddd;stop-opacity:1.0000000;"
offset="0.00000000"
id="stop5005" />
<stop
style="stop-color:#000000;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop5007" />
</linearGradient>
<linearGradient
id="linearGradient4993">
<stop
style="stop-color:#183577;stop-opacity:1.0000000;"
offset="0.00000000"
id="stop4995" />
<stop
id="stop5001"
offset="0.58142859"
style="stop-color:#8b9fbb;stop-opacity:1.0000000;" />
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop4997" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="23.255956"
inkscape:cx="3.2274095"
inkscape:cy="4.1487021"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
showguides="false"
gridspacingy="0.50000000cm"
gridspacingx="0.50000000cm"
gridoriginy="0.00000000cm"
gridoriginx="0.00000000cm"
gridtolerance="0.10000000cm"
gridempspacing="2"
inkscape:grid-points="true"
inkscape:grid-bbox="false"
inkscape:window-width="975"
inkscape:window-height="759"
inkscape:window-x="130"
inkscape:window-y="129" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0000004px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
d="M 6.1949060,157.57756 L 6.1949060,157.57756 z "
id="path1319" />
<path
style="fill:#224db0;fill-opacity:1.0000000;fill-rule:evenodd;stroke:none;stroke-width:6.0000000;stroke-linecap:butt;stroke-linejoin:round;marker-start:none;stroke-miterlimit:4.0000000;stroke-dasharray:none;stroke-opacity:1.0000000"
d="M 0.58257145,1.2121863 C 0.63548185,3.4711463 0.61139575,5.1777365 1.0905516,7.3958765 C 1.2484712,8.3223265 2.8202544,8.4670465 3.5807376,8.5653065 C 4.0690207,8.6283965 4.0902492,8.5661465 4.0906878,9.1995265 C 4.1064337,11.195036 4.0317991,11.792303 4.0906878,13.786273 C 4.0906878,15.786203 4.0909380,15.786453 6.0908601,15.786453 C 9.0907431,15.786453 10.414747,15.786053 12.414669,15.786053 C 14.414592,15.786053 14.414842,15.785813 14.414842,13.785893 C 14.418166,10.552283 14.404522,7.8374163 14.421897,4.6040763 C 14.625008,2.9294663 14.978320,2.5231063 15.830433,1.1499263 C 15.040843,1.1499263 14.943078,1.1493063 14.129102,1.1493063 C 8.8912931,1.1493063 5.8203807,1.2121863 0.58257145,1.2121863 z M 2.0905126,2.4028663 C 2.8330809,2.4028663 3.3476197,2.4028663 4.0901879,2.4028663 C 4.0901879,4.8586963 4.0906878,4.8408265 4.0906878,7.2966665 C 3.2248799,7.2967665 2.2374444,7.5239665 2.1488437,6.3255665 C 1.8765344,4.2270765 1.8837837,4.4962263 2.0905126,2.4028663 z M 5.4346466,6.5656265 L 6.8695071,6.5656265 L 6.8696331,13.558223 L 9.8657791,11.557663 L 9.8656551,6.5656265 L 13.070633,6.5656265 L 13.070633,13.786523 C 13.070633,14.786503 13.070633,14.786503 12.070671,14.786503 L 6.4158330,14.786503 C 5.5388453,14.786503 5.4347719,14.786723 5.4347719,13.786523 L 5.4346466,6.5656265 z "
id="path1325"
sodipodi:nodetypes="ccsccsscccsccccccccccccccccc" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 615 B

View file

@ -1,101 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16.000000px"
height="16.000000px"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.42.2"
sodipodi:docbase="C:\DOCUME~1\Edward\MYDOCU~1\MYWEBS~1\HTMLPU~1\art"
sodipodi:docname="icon-32x32.svg"
inkscape:export-filename="C:\Documents and Settings\Edward\My Documents\My Webs\htmlpurifier\art\icon-16x16.png"
inkscape:export-xdpi="90.000000"
inkscape:export-ydpi="90.000000">
<defs
id="defs4">
<linearGradient
id="linearGradient5003">
<stop
style="stop-color:#537ddd;stop-opacity:1.0000000;"
offset="0.00000000"
id="stop5005" />
<stop
style="stop-color:#000000;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop5007" />
</linearGradient>
<linearGradient
id="linearGradient4993">
<stop
style="stop-color:#183577;stop-opacity:1.0000000;"
offset="0.00000000"
id="stop4995" />
<stop
id="stop5001"
offset="0.58142859"
style="stop-color:#8b9fbb;stop-opacity:1.0000000;" />
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop4997" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="23.255956"
inkscape:cx="3.2274095"
inkscape:cy="4.1487021"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
showguides="false"
gridspacingy="0.50000000cm"
gridspacingx="0.50000000cm"
gridoriginy="0.00000000cm"
gridoriginx="0.00000000cm"
gridtolerance="0.10000000cm"
gridempspacing="2"
inkscape:grid-points="true"
inkscape:grid-bbox="false"
inkscape:window-width="975"
inkscape:window-height="759"
inkscape:window-x="130"
inkscape:window-y="129" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0000004px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
d="M 6.1949060,157.57756 L 6.1949060,157.57756 z "
id="path1319" />
<path
style="fill:#224db0;fill-opacity:1.0000000;fill-rule:evenodd;stroke:none;stroke-width:6.0000000;stroke-linecap:butt;stroke-linejoin:round;marker-start:none;stroke-miterlimit:4.0000000;stroke-dasharray:none;stroke-opacity:1.0000000"
d="M 0.58257145,1.2121863 C 0.63548185,3.4711463 0.61139575,5.1777365 1.0905516,7.3958765 C 1.2484712,8.3223265 2.8202544,8.4670465 3.5807376,8.5653065 C 4.0690207,8.6283965 4.0902492,8.5661465 4.0906878,9.1995265 C 4.1064337,11.195036 4.0317991,11.792303 4.0906878,13.786273 C 4.0906878,15.786203 4.0909380,15.786453 6.0908601,15.786453 C 9.0907431,15.786453 10.414747,15.786053 12.414669,15.786053 C 14.414592,15.786053 14.414842,15.785813 14.414842,13.785893 C 14.418166,10.552283 14.404522,7.8374163 14.421897,4.6040763 C 14.625008,2.9294663 14.978320,2.5231063 15.830433,1.1499263 C 15.040843,1.1499263 14.943078,1.1493063 14.129102,1.1493063 C 8.8912931,1.1493063 5.8203807,1.2121863 0.58257145,1.2121863 z M 2.0905126,2.4028663 C 2.8330809,2.4028663 3.3476197,2.4028663 4.0901879,2.4028663 C 4.0901879,4.8586963 4.0906878,4.8408265 4.0906878,7.2966665 C 3.2248799,7.2967665 2.2374444,7.5239665 2.1488437,6.3255665 C 1.8765344,4.2270765 1.8837837,4.4962263 2.0905126,2.4028663 z M 5.0906487,6.5656265 L 6.8695071,6.5656265 L 6.8696331,13.558223 L 9.8657791,11.557663 L 9.8656551,6.5656265 L 13.414631,6.5656265 L 13.414631,13.786523 C 13.414631,14.786503 13.414631,14.786503 12.414669,14.786503 L 6.0718351,14.786503 C 5.1948474,14.786503 5.0907740,14.786723 5.0907740,13.786523 L 5.0906487,6.5656265 z "
id="path1325"
sodipodi:nodetypes="ccsccsscccsccccccccccccccccc" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -1,119 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="82.000000mm"
height="82.000000mm"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.42.2"
sodipodi:docbase="C:\Documents and Settings\Edward\My Documents\My Webs\htmlpurifier\art"
sodipodi:docname="logo-bold-large.svg">
<defs
id="defs4">
<linearGradient
id="linearGradient5003">
<stop
style="stop-color:#537ddd;stop-opacity:1.0000000;"
offset="0.00000000"
id="stop5005" />
<stop
style="stop-color:#000000;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop5007" />
</linearGradient>
<linearGradient
id="linearGradient4993">
<stop
style="stop-color:#183577;stop-opacity:1.0000000;"
offset="0.00000000"
id="stop4995" />
<stop
id="stop5001"
offset="0.58142859"
style="stop-color:#8b9fbb;stop-opacity:1.0000000;" />
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop4997" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4993"
id="linearGradient4999"
x1="283.46457"
y1="141.72675"
x2="11.135608"
y2="141.72675"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(2.000000,4.000000)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5003"
id="linearGradient5009"
x1="2.9621078"
y1="141.72675"
x2="283.46457"
y2="141.72675"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(2.000000,4.000000)" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.0000000"
inkscape:cx="100.23897"
inkscape:cy="178.03397"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
showguides="false"
gridspacingy="0.50000000cm"
gridspacingx="0.50000000cm"
gridoriginy="0.00000000cm"
gridoriginx="0.00000000cm"
gridtolerance="0.10000000cm"
gridempspacing="2"
inkscape:grid-points="true"
inkscape:grid-bbox="false"
inkscape:window-width="975"
inkscape:window-height="759"
inkscape:window-x="139"
inkscape:window-y="88" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
d="M 19.726130,9.6194746 L 19.726130,9.6194746 z "
id="path1319" />
<path
style="fill:url(#linearGradient4999);fill-opacity:1.0000000;fill-rule:evenodd;stroke:url(#linearGradient5009);stroke-width:10.000000;stroke-linecap:butt;stroke-linejoin:round;marker-start:none;stroke-miterlimit:4.0000000;stroke-dasharray:none;stroke-opacity:1.0000000"
d="M 4.9621078,5.1031050 C 5.8995325,45.125639 5.4727947,85.709799 13.962107,125.00936 C 16.760003,141.42321 35.988453,143.98728 49.462107,145.72811 C 58.113128,146.84585 67.112800,145.74318 67.120572,156.96457 C 67.399545,192.31975 66.077225,216.69948 67.120572,252.02707 C 67.120572,287.46015 67.125004,287.46457 102.55807,287.46457 C 155.70768,287.46457 179.16536,287.45768 214.59843,287.45768 C 250.03151,287.45768 250.03593,287.45325 250.03593,252.02018 C 250.09483,194.72943 249.85310,122.48395 250.16093,65.197704 C 253.75952,35.528496 270.36749,28.328596 285.46457,4.0000020 C 271.47521,4.0000020 259.39483,3.9889299 244.97343,3.9889297 C 152.17399,3.9889293 97.761552,5.1031060 4.9621078,5.1031050 z M 31.678643,26.198667 C 44.834892,26.198667 53.955464,26.198667 67.111714,26.198667 C 67.111713,69.709084 67.120572,79.741005 67.120572,123.25143 C 51.780853,123.25317 34.281868,127.27859 32.712107,106.04622 C 27.887543,68.866763 28.015982,63.286945 31.678643,26.198667 z M 84.837103,110.29921 L 102.55585,110.29921 L 102.55807,247.98656 L 155.64148,212.54217 L 155.63926,110.29921 L 232.31496,110.29921 L 232.31496,252.03150 C 232.31496,269.74803 232.31496,269.74803 214.59843,269.74803 L 102.22100,269.74803 C 86.683215,269.74803 84.839322,269.75212 84.839322,252.03150 L 84.837103,110.29921 z "
id="path1325"
sodipodi:nodetypes="ccsccsscccsccccccccccccccccc" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

View file

@ -1 +0,0 @@
Deny from all

View file

@ -1,16 +0,0 @@
<?php
chdir(dirname(__FILE__));
//require_once '../library/HTMLPurifier.path.php';
shell_exec('php ../maintenance/generate-schema-cache.php');
require_once '../library/HTMLPurifier.path.php';
require_once 'HTMLPurifier.includes.php';
$begin = xdebug_memory_usage();
$schema = HTMLPurifier_ConfigSchema::makeFromSerial();
echo xdebug_memory_usage() - $begin;
// vim: et sw=4 sts=4

View file

@ -1,158 +0,0 @@
<?php
require_once '../library/HTMLPurifier.auto.php';
@include_once '../test-settings.php';
// PEAR
require_once 'Benchmark/Timer.php'; // to do the timing
require_once 'Text/Password.php'; // for generating random input
$LEXERS = array();
$RUNS = isset($GLOBALS['HTMLPurifierTest']['Runs'])
? $GLOBALS['HTMLPurifierTest']['Runs'] : 2;
require_once 'HTMLPurifier/Lexer/DirectLex.php';
$LEXERS['DirectLex'] = new HTMLPurifier_Lexer_DirectLex();
if (version_compare(PHP_VERSION, '5', '>=')) {
require_once 'HTMLPurifier/Lexer/DOMLex.php';
$LEXERS['DOMLex'] = new HTMLPurifier_Lexer_DOMLex();
}
// custom class to aid unit testing
class RowTimer extends Benchmark_Timer
{
var $name;
function RowTimer($name, $auto = false) {
$this->name = htmlentities($name);
$this->Benchmark_Timer($auto);
}
function getOutput() {
$total = $this->TimeElapsed();
$result = $this->getProfiling();
$dashes = '';
$out = '<tr>';
$out .= "<td>{$this->name}</td>";
$standard = false;
foreach ($result as $k => $v) {
if ($v['name'] == 'Start' || $v['name'] == 'Stop') continue;
//$perc = (($v['diff'] * 100) / $total);
//$tperc = (($v['total'] * 100) / $total);
//$out .= '<td align="right">' . $v['diff'] . '</td>';
if ($standard == false) $standard = $v['diff'];
$perc = $v['diff'] * 100 / $standard;
$bad_run = ($v['diff'] < 0);
$out .= '<td align="right"'.
($bad_run ? ' style="color:#AAA;"' : '').
'>' . number_format($perc, 2, '.', '') .
'%</td><td>'.number_format($v['diff'],4,'.','').'</td>';
}
$out .= '</tr>';
return $out;
}
}
function print_lexers() {
global $LEXERS;
$first = true;
foreach ($LEXERS as $key => $value) {
if (!$first) echo ' / ';
echo htmlspecialchars($key);
$first = false;
}
}
function do_benchmark($name, $document) {
global $LEXERS, $RUNS;
$config = HTMLPurifier_Config::createDefault();
$context = new HTMLPurifier_Context();
$timer = new RowTimer($name);
$timer->start();
foreach($LEXERS as $key => $lexer) {
for ($i=0; $i<$RUNS; $i++) $tokens = $lexer->tokenizeHTML($document, $config, $context);
$timer->setMarker($key);
}
$timer->stop();
$timer->display();
}
?>
<html>
<head>
<title>Benchmark: <?php print_lexers(); ?></title>
</head>
<body>
<h1>Benchmark: <?php print_lexers(); ?></h1>
<table border="1">
<tr><th>Case</th><?php
foreach ($LEXERS as $key => $value) {
echo '<th colspan="2">' . htmlspecialchars($key) . '</th>';
}
?></tr>
<?php
// ************************************************************************** //
// sample of html pages
$dir = 'samples/Lexer';
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
if (strpos($filename, '.html') !== strlen($filename) - 5) continue;
$document = file_get_contents($dir . '/' . $filename);
do_benchmark("File: $filename", $document);
}
// crashers, caused infinite loops before
$snippets = array();
$snippets[] = '<a href="foo>';
$snippets[] = '<a "=>';
foreach ($snippets as $snippet) {
do_benchmark($snippet, $snippet);
}
// random input
$random = Text_Password::create(80, 'unpronounceable', 'qwerty <>="\'');
do_benchmark('Random input', $random);
?></table>
<?php
echo '<div>Random input was: ' .
'<span colspan="4" style="font-family:monospace;">' .
htmlspecialchars($random) . '</span></div>';
?>
</body></html>
<?php
// vim: et sw=4 sts=4

View file

@ -1,21 +0,0 @@
<?php
ini_set('xdebug.trace_format', 1);
ini_set('xdebug.show_mem_delta', true);
if (file_exists('Trace.xt')) {
echo "Previous trace Trace.xt must be removed before this script can be run.";
exit;
}
xdebug_start_trace(dirname(__FILE__) . '/Trace');
require_once '../library/HTMLPurifier.auto.php';
$purifier = new HTMLPurifier();
$data = $purifier->purify(file_get_contents('samples/Lexer/4.html'));
xdebug_stop_trace();
echo "Trace finished.";
// vim: et sw=4 sts=4

View file

@ -1,56 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Main Page - Huaxia Taiji Club</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" media="screen, projection" href="/screen.css" />
<link rel="stylesheet" type="text/css" media="print" href="/print.css" />
</head>
<body>
<div id="translation"><a href="/ch/Main_Page">&#20013;&#25991;</a></div>
<div id="heading"><a href="/en/Main_Page" title="English Main Page">Huaxia Taiji Club</a>
<a class="heading_ch" href="/ch/Main_Page" title="&#20013;&#25991;&#20027;&#39029;">&#21326;&#22799;&#22826;&#26497;&#20465;&#20048;&#37096;</a></div>
<ul id="menu">
<li><a href="/en/Main_Page" class="active">Main Page</a></li><li><a href="/en/About">About</a></li><li><a href="/en/News">News</a></li><li><a href="/en/Events">Events</a></li><li><a href="/en/Digest">Digest</a></li><li><a href="/en/Taiji_and_I">Taiji and I</a></li><li><a href="/en/Downloads">Downloads</a></li><li><a href="/en/Registration">Registration</a></li><li><a href="/en/Contact">Contact</a></li> <li><a href="http://www.taijiclub.org/gallery2/main.php">Gallery</a></li>
<li><a href="http://www.taijiclub.org/forums/index.php">Forums</a></li>
</ul>
<div id="content">
<h1 id="title">Main Page</h1><h2>Taiji (Tai Chi) </h2>
<div id="sidebar">
<h3>Recent News</h3>
<ul>
<li>Zou Xiaojun was elected as the new club vice president </li>
<li>HX Edison Taiji Club <a href="http://www.taijiclub.org/downloads/Taiji_club_regulation_.pdf">by-law</a> effective 3/28/2006</li>
<li>A new email account for our club: HXEdisontaijiclub@yahoo.com</li>
<li>Workshop conducted by <a href="http://www.taijiclub.org/ch/Digest/LiDeyin">?????</a> Li Deyin is set on June 4, 2006 at Clarion Hotel in Edison from 9:30am-12pm; <a href="http://www.taijiclub.org/en/Registration">Registration</a></li>
</ul>
</div>
<p><i>Taiji</i> is an ancient Chinese tradition of movement systems that is associated with philosophy, physiology, psychology, geometry and dynamics. It is the slowest form of martial arts and is meant to improve the internal spirit. It is soothing to the soul and extremely invigorating. </p>
<p>The founder of Taiji was Zhang Sanfeng (Chang San-feng), who was a monk of the Wu Dang (Wu Tang) Monastery and lived in the period from 1391 to 1459. His exercises stressed suppleness and elasticity as opposed to the hardness and force of other martial art styles. Several centuries old, Taiji was originally developed as a form of self-defense, emphasizing strength, balance, flexibility and speed. Tai Chi also differs from other martial arts in that it is based on the Taoist religion and aims to avoid aggressive forces. </p>
<p>Modern Taiji includes many forms &mdash; Quan, Sword and Fan. Impacting the mind and body of the practitioners, Taiji is practiced as a meditative exercise made up of a series of forms, or choreographed motions, requiring slow, gentle movement of the arms, legs and torso. Taiji practitioners learn to center their attention on their breathing and body movements so that the exercise strengthens their overall mental and physical awareness. In a sense, Taiji is similar to yoga in that it is also a form of moving meditation, with the goal of achieving stillness through the motion and awareness of breath. To perform Taiji, practitioners have to empty their mind of thoughts and worries in order to achieve harmony. It is a great aid for reducing stress and improving the quality of life. </p>
<p>In China and in communities all over the world, Taiji is practiced by young and old in the early morning hours. It's a great way to bring a new and fresh day!</p>
<p>Check out our <a href="/gallery2/main.php">gallery</a>.</p>
<div style="text-align:center;"><a href="http://www.taijiclub.org/gallery2/v/2006/group1b.jpg.html?g2_imageViewsIndex=1"><img src="/gallery2/d/1836-2/group1b.jpg" /></a></div>
<div style="text-align:center;">Click on photo to see HR version</div></div>
</body>
</html>
<!-- vim: et sw=4 sts=4
-->

View file

@ -1,20 +0,0 @@
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Google</title><style><!--
body,td,a,p,.h{font-family:arial,sans-serif;}
.h{font-size: 20px;}
.q{color:#0000cc;}
//-->
</style>
<script>
<!--
function sf(){document.f.q.focus();}
function rwt(el,ct,cd,sg){var e = window.encodeURIComponent ? encodeURIComponent : escape;el.href="/url?sa=t&ct="+e(ct)+"&cd="+e(cd)+"&url="+e(el.href).replace(/\+/g,"%2B")+"&ei=fHNBRJDEG4HSaLONmIoP"+sg;el.onmousedown="";return true;}
// -->
</script>
</head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onLoad=sf() topmargin=3 marginheight=3><center><table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td align=right nowrap><font size=-1><b>edwardzyang@gmail.com</b>&nbsp;|&nbsp;<a href="/url?sa=p&pref=ig&pval=2&q=http://www.google.com/ig%3Fhl%3Den" onmousedown="return rwt(this,'pro','hppphou:def','&sig2=hDbTpsWIp9YG37a23n6krQ')">Personalized Home</a>&nbsp;|&nbsp;<a href="/searchhistory/?hl=en">Search History</a>&nbsp;|&nbsp;<a href="https://www.google.com/accounts/ManageAccount">My Account</a>&nbsp;|&nbsp;<a href="http://www.google.com/accounts/Logout?continue=http://www.google.com/">Sign out</a></font></td></tr><tr height=4><td><img alt="" width=1 height=1></td></tr></table><img src="/intl/en/images/logo.gif" width=276 height=110 alt="Google"><br><br>
<form action=/search name=f><script><!--
function qs(el) {if (window.RegExp && window.encodeURIComponent) {var ue=el.href;var qe=encodeURIComponent(document.f.q.value);if(ue.indexOf("q=")!=-1){el.href=ue.replace(new RegExp("q=[^&$]*"),"q="+qe);}else{el.href=ue+"&q="+qe;}}return 1;}
// -->
</script><table border=0 cellspacing=0 cellpadding=4><tr><td nowrap><font size=-1><b>Web</b>&nbsp;&nbsp;&nbsp;&nbsp;<a id=1a class=q href="/imghp?hl=en&tab=wi" onClick="return qs(this);">Images</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=2a class=q href="http://groups.google.com/grphp?hl=en&tab=wg" onClick="return qs(this);">Groups</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=4a class=q href="http://news.google.com/nwshp?hl=en&tab=wn" onClick="return qs(this);">News</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=5a class=q href="http://froogle.google.com/frghp?hl=en&tab=wf" onClick="return qs(this);">Froogle</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=8a class=q href="/lochp?hl=en&tab=wl" onClick="return qs(this);">Local</a>&nbsp;&nbsp;&nbsp;&nbsp;<b><a href="/intl/en/options/" class=q>more&nbsp;&raquo;</a></b></font></td></tr></table><table cellspacing=0 cellpadding=0><tr><td width=25%>&nbsp;</td><td align=center><input type=hidden name=hl value=en><input maxlength=2048 size=55 name=q value="" title="Google Search"><br><input type=submit value="Google Search" name=btnG><input type=submit value="I'm Feeling Lucky" name=btnI></td><td valign=top nowrap width=25%><font size=-2>&nbsp;&nbsp;<a href=/advanced_search?hl=en>Advanced Search</a><br>&nbsp;&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&nbsp;<a href=/language_tools?hl=en>Language Tools</a></font></td></tr></table></form><br><br><font size=-1><a href="/ads/">Advertising&nbsp;Programs</a> - <a href=/services/>Business Solutions</a> - <a href=/about.html>About Google</a></font><p><font size=-2>&copy;2006 Google</font></p></center></body></html>
<!-- vim: et sw=4 sts=4
-->

View file

@ -1,131 +0,0 @@
<html>
<head>
<title>Anime Digi-Lib Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<div id="tb">
<form name="lycos_search" method="get" target="_new" style="margin: 0px"
action="http://r.hotbot.com/r/memberpgs_lycos_searchbox_af/http://www.angelfire.lycos.com/cgi-bin/search/pursuit">
<table id="tbtable" cellpadding="0" cellspacing="0" border="0" width="100%" style="border: 1px solid black;">
<tr style="background-color: #dcf7ff">
<td colspan="3">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>&nbsp;Search:</td>
<td><input type="radio" name="cat" value="lycos" checked></td>
<td nowrap="nowrap">The Web</td>
<td><input type="radio" name="cat" value="angelfire"></td>
<td nowrap="nowrap">Angelfire</td>
<td nowrap="nowrap">&nbsp;&nbsp;&nbsp;<img src="http://af.lygo.com/d/toolbar/planeticon.gif"></td><td nowrap="nowrap">&nbsp;<a href="http://r.lycos.com/r/tlbr_planet/http://planet.lycos.com" target="_new">Planet</a></td>
</tr>
</table>
<td nowrap="nowrap"><a href="http://lt.angelfire.com/af_toolbar/edit/_h_/www.angelfire.lycos.com/build/index.tmpl" target="_top">
<span id="build">Edit your Site</span></a>&nbsp;</td>
<td><img src="http://af.lygo.com/d/toolbar/dir.gif" alt="show site directory" border="0" height="10" hspace="3" width="8"></td>
<td nowrap="nowrap"><a href="http://lt.angelfire.com/af_toolbar/browse/_h_/www.angelfire.lycos.com/directory/index.tmpl" target="_top">Browse Sites</a>&nbsp;</td>
<td><a href="http://lt.angelfire.com/af_toolbar/angelfire/_h_/www.angelfire.lycos.com" target="_top"><img src="http://af.lygo.com/d/toolbar/aflogo_top.gif" alt="hosted by angelfire" border="0" height="26" width="143"></a></td>
</tr>
<tr style="background-color: #dcf7ff">
<td nowrap="nowrap" valign="middle">&nbsp;<input size="30" style="font-size: 10px; background-color: #fff;" type="text" name="query" id="searchbox"></td>
<td style="background: #fff url(http://af.lygo.com/d/toolbar/bg.gif) repeat-x; text-align: center;" colspan="3" align="center">
<a href="http://clk.atdmt.com/VON/go/lycsnvon0710000019von/direct/01/"><img src="/sys/free_logo_xxxx_157x20.gif" height="20" width="157" border="0" alt="Vonage"></a><img src="http://view.atdmt.com/VON/view/lycsnvon0710000019von/direct/01/"></td>
<span style="font-size: 11px;">
<span style="color:#00f; font-weight:bold;">&#171;</span>
<span id="top100">
<a href="javascript:void top100('prev')" target="_top">Previous</a> |
<a href="http://lt.angelfire.com/af_toolbar/top100/_h_/www.angelfire.lycos.com/cgi-bin/top100/pagelist?start=1" target="_top">Top 100</a> |
<a href="javascript:void top100('next')" target="_top">Next</a>
</span>
<span style="color: #00f; font-weight: bold;">&#187;</span>
</span>
</td>
<td valign="top" style="background: #fff url(http://af.lygo.com/d/toolbar/bg.gif) repeat-x;"><a href="http://lt.angelfire.com/af_toolbar/angelfire/_h_/www.angelfire.lycos.com" target="_top"><img src="http://af.lygo.com/d/toolbar/aflogo_bot.gif" alt="hosted by angelfire" border="0" height="22" width="143"></a></td>
</tr>
</table>
</form>
</div>
<table border="0" cellpadding="0" cellspacing="0" width="728"><tr><td>
<script type="text/javascript">
if (objAdMgr.isSlotAvailable("leaderboard")) {
objAdMgr.renderSlot("leaderboard")
}
</script>
<noscript>
<a href="http://network.realmedia.com/RealMedia/ads/click_nx.ads/lycosangelfire/ros/728x90/wp/ss/a/491169@Top1?x"><img border="0" src="http://network.realmedia.com/RealMedia/ads/adstream_nx.ads/lycosangelfire/ros/728x90/wp/ss/a/491169@Top1" alt="leaderboard ad" /></a>
</noscript>
</td></tr>
</table>
<table width="86%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td height="388" width="19%" bgcolor="#FFCCFF" valign="top">
<p>May 1, 2000</p>
<p><b>Pop Culture</b> </p>
<p>by. H. Finkelstein</p>
</td>
<td height="388" width="52%" valign="top">
<p>Welcome to the <b>Anime Digi-Lib</b>, a virtual index to anime on the
internet. This site strives to house a comprehensive index to both personal
and commercial websites and provides reviews to these sites. We hope to
be a gateway for people who've never imagined they'd ever be interested
in Japanese Animation. </p>
<table width="99%" border="1" cellspacing="0" cellpadding="2" height="320" name="Searchnservices">
<tr>
<td height="263" valign="top" width="58%">
<p>&nbsp; </p>
<p>&nbsp;</p>
<FORM ACTION="/cgi-bin/script_library/site_search/search" METHOD="GET">
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<td colspan="2">Search term: <INPUT NAME="search_term"><br></td>
</tr>
<tr>
<td colspan="2" align="center">Case-sensitive -
<INPUT TYPE="checkbox" NAME="case_sensitive">yes<br></td>
</tr>
<tr>
<td align="right"><INPUT TYPE="radio" NAME="search_type" VALUE="exact" CHECKED>exact</td>
<td><INPUT TYPE="radio" NAME="search_type" VALUE="fuzzy">fuzzy<br></td>
</tr>
<tr>
<td colspan="2" align="center"><INPUT TYPE="hidden" NAME="display" VALUE="#FF0000"><INPUT TYPE="submit"></td>
</tr>
</table>
</form>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td><font face="verdana,geneva" color="#000011" size="1">What is better, subtitled or dubbed anime?</font></td></tr>
<tr><td><input type="radio" name="rd" value="1"><font face="verdana" size="2" color="#000011">Subtitled</font></td></tr>
<tr><td align="middle"><font face="verdana" size="1"><a href="http://pub.alxnet.com/poll?id=2079873&q=view">Current results</a></font></td></tr>
</table></td></tr>
<tr>
<td><font face="verdana" size="1"><a href="http://www.alxnet.com/services/poll/">Free
Web Polls</a></font></td>
</tr>
</table></form>
<!-- Alxnet.com -- web poll code ends -->
</td>
</tr>
</table>
</body>
</html>
<!-- vim: et sw=4 sts=4
-->

View file

@ -1,543 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Tai Chi Chuan,Yang Pan-hou,Yang Chien-hou,Yang style Tai Chi Chuan,Yang Lu-ch'an,Wu/Hao style T'ai Chi Ch'uan,Wu Ch'uan-yü,Hao Wei-chen,Yang Shou-chung,Wu style T'ai Chi Ch'uan,Wu Chien-ch'üan" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="copyright" href="http://www.gnu.org/copyleft/fdl.html" />
<title>Tai Chi Chuan - Wikipedia, the free encyclopedia</title>
<style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "/skins-1.5/monobook/main.css?9"; /*]]>*/</style>
<link rel="stylesheet" type="text/css" media="print" href="/skins-1.5/common/commonPrint.css" />
<!--[if lt IE 5.5000]><style type="text/css">@import "/skins-1.5/monobook/IE50Fixes.css";</style><![endif]-->
<!--[if IE 5.5000]><style type="text/css">@import "/skins-1.5/monobook/IE55Fixes.css";</style><![endif]-->
<!--[if IE 6]><style type="text/css">@import "/skins-1.5/monobook/IE60Fixes.css";</style><![endif]-->
<!--[if IE 7]><style type="text/css">@import "/skins-1.5/monobook/IE70Fixes.css?1";</style><![endif]-->
<!--[if lt IE 7]><script type="text/javascript" src="/skins-1.5/common/IEFixes.js"></script>
<meta http-equiv="imagetoolbar" content="no" /><![endif]-->
<script type="text/javascript">var skin = 'monobook';var stylepath = '/skins-1.5';</script>
<script type="text/javascript" src="/skins-1.5/common/wikibits.js?1"><!-- wikibits js --></script>
<script type="text/javascript" src="/w/index.php?title=-&amp;action=raw&amp;smaxage=0&amp;gen=js"><!-- site js --></script>
<style type="text/css">/*<![CDATA[*/
@import "/w/index.php?title=MediaWiki:Common.css&action=raw&ctype=text/css&smaxage=2678400";
@import "/w/index.php?title=MediaWiki:Monobook.css&action=raw&ctype=text/css&smaxage=2678400";
@import "/w/index.php?title=-&action=raw&gen=css&maxage=2678400&ts=20060721225848";
@import "/w/index.php?title=User:Edward_Z._Yang/monobook.css&action=raw&ctype=text/css";
/*]]>*/</style>
<script type="text/javascript" src="/w/index.php?title=User:Edward_Z._Yang/monobook.js&amp;action=raw&amp;ctype=text/javascript&amp;dontcountme=s"></script>
<!-- Head Scripts -->
</head>
<body class="ns-0 ltr">
<div id="globalWrapper">
<div id="column-content">
<div id="content">
<a name="top" id="top"></a>
<div id="siteNotice"><div id="wikimania2006" style="text-align:right; font-size:80%"><a href="http://wm06reg.wikimedia.org/" class="external text" title="http://wm06reg.wikimedia.org/">Registration</a> for <a href="http://wikimania2006.wikimedia.org" class="external text" title="http://wikimania2006.wikimedia.org">Wikimania 2006</a> is open.&nbsp;&nbsp;&nbsp;</div>
</div> <h1 class="firstHeading">Tai Chi Chuan</h1>
<div id="bodyContent">
<h3 id="siteSub">From Wikipedia, the free encyclopedia</h3>
<div id="contentSub"></div>
<div id="jump-to-nav">Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a></div> <!-- start content -->
<table border="1" cellpadding="2" cellspacing="0" align="right">
<tr>
<th colspan="2" bgcolor="#FFCCCC"><big>???</big></th>
</tr>
<tr>
<td colspan="2">
<div class="center">
<div class="thumb tnone">
<div style="width:182px;"><a href="/wiki/Image:Yang_Ch%27eng-fu_circa_1918.jpg" class="internal" title="Yang Chengfu in a posture from the Tai Chi solo form known as Single Whip, circa 1918"><img src="http://upload.wikimedia.org/wikipedia/en/thumb/d/d1/Yang_Ch%27eng-fu_circa_1918.jpg/180px-Yang_Ch%27eng-fu_circa_1918.jpg" alt="Yang Chengfu in a posture from the Tai Chi solo form known as Single Whip, circa 1918" width="180" height="255" longdesc="/wiki/Image:Yang_Ch%27eng-fu_circa_1918.jpg" /></a>
<div class="thumbcaption">
<div class="magnify" style="float:right"><a href="/wiki/Image:Yang_Ch%27eng-fu_circa_1918.jpg" class="internal" title="Enlarge"><img src="/skins-1.5/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>
<b><a href="/wiki/Yang_Chengfu" title="Yang Chengfu">Yang Chengfu</a> in a posture from the Tai Chi solo form known as <i>Single Whip</i>, circa <a href="/wiki/1918" title="1918">1918</a></b></div>
</div>
</div>
</div>
</td>
</tr>
<tr>
<th colspan="2"><a href="/wiki/Chinese_language" title="Chinese language">Chinese</a> Name</th>
</tr>
<tr>
<td><a href="/wiki/Hanyu_Pinyin" title="Hanyu Pinyin">Hanyu Pinyin</a></td>
<td>Tàijíquán</td>
</tr>
<tr>
<td><a href="/wiki/Wade-Giles" title="Wade-Giles">Wade-Giles</a></td>
<td>T'ai<sup>4</sup> Chi<sup>2</sup> Ch'üan<sup>2</sup></td>
</tr>
<tr>
<td><a href="/wiki/Simplified_Chinese" title="Simplified Chinese">Simplified Chinese</a></td>
<td>???</td>
</tr>
<tr>
<td><a href="/wiki/Traditional_Chinese" title="Traditional Chinese">Traditional Chinese</a></td>
<td><a href="http://en.wiktionary.org/wiki/%E5%A4%AA" class="extiw" title="wiktionary:?">?</a><a href="http://en.wiktionary.org/wiki/%E6%A5%B5" class="extiw" title="wiktionary:?">?</a><a href="http://en.wiktionary.org/wiki/%E6%8B%B3" class="extiw" title="wiktionary:?">?</a></td>
</tr>
<tr>
<td><a href="/wiki/Cantonese_%28linguistics%29" title="Cantonese (linguistics)">Cantonese</a></td>
<td>taai3 gik6 kyun4</td>
</tr>
<tr>
<td><a href="/wiki/Hiragana" title="Hiragana">Japanese Hiragana</a></td>
<td>???????</td>
</tr>
<tr>
<td><a href="/wiki/Korean_%28language%29" title="Korean (language)">Korean</a></td>
<td>???</td>
</tr>
<tr>
<td><a href="/wiki/Vietnamese_%28language%29" title="Vietnamese (language)">Vietnamese</a></td>
<td>Thái C?c Quy?n</td>
</tr>
</table>
<p><b>Tai Chi Chuan</b>, <b>T'ai Chi Ch'üan</b> or <b>Taijiquan</b> (<a href="/wiki/Traditional_Chinese_character" title="Traditional Chinese character">Traditional Chinese</a>: ???; <a href="/wiki/Simplified_Chinese_character" title="Simplified Chinese character">Simplified Chinese</a>: ???; <a href="/wiki/Pinyin" title="Pinyin">pinyin</a>: Tàijíquán; literally "supreme ultimate fist"), commonly known as <b>Tai Chi</b>, <b>T'ai Chi</b>, or <b><a href="/wiki/Taiji" title="Taiji">Taiji</a></b>, is an <a href="/wiki/Neijia" title="Neijia">internal</a> <a href="/wiki/Chinese_martial_arts" title="Chinese martial arts">Chinese martial art</a>. There are different styles of T'ai Chi Ch'üan, although most agree they are all based on the system originally taught by the <a href="/wiki/Chen" title="Chen">Chen</a> family to the <a href="/wiki/Yang" title="Yang">Yang</a> family starting in <a href="/wiki/1820" title="1820">1820</a>. It is often promoted and practiced as a <a href="/wiki/Martial_arts_therapy" title="Martial arts therapy">martial arts therapy</a> for the purposes of <a href="/wiki/Health" title="Health">health</a> and <a href="/wiki/Longevity" title="Longevity">longevity</a>, (some <a href="/wiki/Tai_Chi_Chuan#Citations_to_medical_research" title="Tai Chi Chuan">recent medical studies</a> support its effectiveness). T'ai Chi Ch'üan is considered a <i>soft</i> style martial art, an art applied with as complete a relaxation or "softness" in the musculature as possible, to distinguish its theory and application from that of the <i>hard</i> martial art styles which use a degree of tension in the muscles.</p>
<p>Variations of T'ai Chi Ch'üan's basic training forms are well known as the slow motion routines that groups of people practice every morning in parks across China and other parts of the world. Traditional T'ai Chi training is intended to teach awareness of one's own balance and what affects it, awareness of the same in others, an appreciation of the practical value in one's ability to moderate extremes of behavior and attitude at both mental and physical levels, and how this applies to effective self-defense principles.</p>
<table id="toc" class="toc" summary="Contents">
<tr>
<td>
<div id="toctitle">
<h2>Contents</h2>
</div>
<ul>
<li class="toclevel-1"><a href="#Overview"><span class="tocnumber">1</span> <span class="toctext">Overview</span></a></li>
<li class="toclevel-1"><a href="#Training_and_techniques"><span class="tocnumber">2</span> <span class="toctext">Training and techniques</span></a></li>
<li class="toclevel-1"><a href="#Styles_and_history"><span class="tocnumber">3</span> <span class="toctext">Styles and history</span></a>
<ul>
<li class="toclevel-2"><a href="#Family_tree"><span class="tocnumber">3.1</span> <span class="toctext">Family tree</span></a></li>
<li class="toclevel-2"><a href="#Notes_to_Family_tree_table"><span class="tocnumber">3.2</span> <span class="toctext">Notes to Family tree table</span></a></li>
</ul>
</li>
<li class="toclevel-1"><a href="#Modern_T.27ai_Chi"><span class="tocnumber">4</span> <span class="toctext">Modern T'ai Chi</span></a>
<ul>
<li class="toclevel-2"><a href="#Modern_forms"><span class="tocnumber">4.1</span> <span class="toctext">Modern forms</span></a></li>
</ul>
</li>
<li class="toclevel-1"><a href="#Health_benefits"><span class="tocnumber">5</span> <span class="toctext">Health benefits</span></a>
<ul>
<li class="toclevel-2"><a href="#Citations_to_medical_research"><span class="tocnumber">5.1</span> <span class="toctext">Citations to medical research</span></a></li>
</ul>
</li>
<li class="toclevel-1"><a href="#See_also"><span class="tocnumber">6</span> <span class="toctext">See also</span></a></li>
<li class="toclevel-1"><a href="#External_links"><span class="tocnumber">7</span> <span class="toctext">External links</span></a></li>
</ul>
</td>
</tr>
</table>
<p><script type="text/javascript">
//<![CDATA[
if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); }
//]]>
</script></p>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=1" title="Edit section: Overview">edit</a>]</div>
<p><a name="Overview" id="Overview"></a></p>
<h2>Overview</h2>
<p>Historically, T'ai Chi Ch'üan has been regarded as a martial art, and its traditional practitioners still teach it as one. Even so, it has developed a worldwide following among many thousands of people with little or no interest in martial training for its aforementioned benefits to health and <a href="/wiki/Preventive_medicine" title="Preventive medicine">health maintenance</a>. Some call it a form of moving <a href="/wiki/Meditation" title="Meditation">meditation</a>, and T'ai Chi theory and practice evolved in agreement with many of the principles of <a href="/wiki/Traditional_Chinese_medicine" title="Traditional Chinese medicine">traditional Chinese medicine</a>. Besides general health benefits and <a href="/wiki/Stress_management" title="Stress management">stress management</a> attributed to beginning and intermediate level T'ai Chi training, many therapeutic interventions along the lines of traditional Chinese medicine are taught to advanced T'ai Chi students.</p>
<p>T'ai Chi Ch'üan as physical training is characterized by its requirement for the use of leverage through the joints based on coordination in relaxation rather than muscular tension in order to neutralize or initiate physical attacks. The slow, repetitive work involved in that process is said to gently increase and open the internal circulation (<a href="/wiki/Breath" title="Breath">breath</a>, body heat, <a href="/wiki/Blood" title="Blood">blood</a>, <a href="/wiki/Lymph" title="Lymph">lymph</a>, <a href="/wiki/Peristalsis" title="Peristalsis">peristalsis</a>, etc.). Over time, proponents say, this enhancement becomes a lasting effect, a direct reversal of the constricting physical effects of stress on the human body. This reversal allows much more of the students' native energy to be available to them, which they may then apply more effectively to the rest of their lives; families, careers, spiritual or creative pursuits, hobbies, etc.</p>
<p>The study of T'ai Chi Ch'üan involves three primary subjects:</p>
<ul>
<li><b>Health</b> - an unhealthy or otherwise uncomfortable person will find it difficult to meditate to a state of calmness or to use T'ai Chi as a martial art. T'ai Chi's health training therefore concentrates on relieving the physical effects of stress on the body and mind.</li>
<li><b>Meditation</b> - the focus meditation and subsequent calmness cultivated by the meditative aspect of T'ai Chi is seen as necessary to maintain optimum health (in the sense of effectively maintaining stress relief or <a href="/wiki/Homeostasis" title="Homeostasis">homeostasis</a>) and in order to use it as a soft style martial art.</li>
<li><b>Martial art</b> - the ability to competently use T'ai Chi as a martial art is said to be proof that the health and meditation aspects are working according to the dictates of the theory of T'ai Chi Ch'üan.</li>
</ul>
<p>In its traditional form (many modern variations exist which ignore at least one of the above requirements) every aspect of its training has to conform with all three of the aforementioned categories.</p>
<p>The <a href="/wiki/Mandarin_%28linguistics%29" title="Mandarin (linguistics)">Mandarin</a> term "T'ai Chi Ch'üan" translates as "Supreme Ultimate Boxing" or "Boundless Fist". T'ai Chi training involves learning solo routines, known as <i>forms</i>, and two person routines, known as <i><a href="/wiki/Pushing_hands" title="Pushing hands">pushing hands</a></i>, as well as <i><a href="/wiki/Acupressure" title="Acupressure">acupressure</a></i>-related manipulations taught by traditional schools. T'ai Chi Ch'üan is seen by many of its schools as a variety of <a href="/wiki/Taoism" title="Taoism">Taoism</a>, and it does seemingly incorporate many Taoist principles into its practice (see below). It is an art form said to date back many centuries (although not reliably documented under that name before 1850), with precursor disciplines dating back thousands of years. The explanation given by the traditional T'ai Chi family schools for why so many of their previous generations have dedicated their lives to the study and preservation of the art is that the discipline it seems to give its students to dramatically improve the effects of stress in their lives, with a few years of hard work, should hold a useful purpose for people living in a stressful world. They say that once the T'ai Chi principles have been understood and internalized into the bodily framework the practitioner will have an immediately accessible "toolkit" thereby to improve and then maintain their health, to provide a meditative focus, and that can work as an effective and subtle martial art for self-defense.</p>
<p>Teachers say the study of T'ai Chi Ch'üan is, more than anything else, about challenging one's ability to change oneself appropriately in response to outside forces. These principles are taught using the examples of <a href="/wiki/Physics" title="Physics">physics</a> as experienced by two (or more) bodies in <a href="/wiki/Combat" title="Combat">combat</a>. In order to be able to protect oneself or someone else by using change, it is necessary to understand what the consequences are of changing appropriately, changing inappropriately and not changing at all in response to an attack. Students, by this theory, will appreciate the full benefits of the entire art in the fastest way through physical training of the martial art aspect.</p>
<p><a href="/wiki/Wu_Chien-ch%27uan" title="Wu Chien-ch'uan">Wu Chien-ch'üan</a>, co-founder of the Wu family style, described the name <i>T'ai Chi Ch'üan</i> this way at the beginning of the <a href="/wiki/20th_century" title="20th century">20th century</a>:</p>
<dl>
<dd>"Various people have offered different explanations for the name <i>T'ai Chi Ch'uan</i>. Some have said: 'In terms of self-cultivation, one must train from a state of movement towards a state of stillness. <i>T'ai Chi</i> comes about through the balance of <i><a href="/wiki/Yin" title="Yin">yin</a></i> and <i><a href="/wiki/Yang" title="Yang">yang</a></i>. In terms of the art of attack and defense then, in the context of the <a href="/wiki/I_Ching" title="I Ching">changes</a> of full and empty, one is constantly internally latent, not outwardly expressive, as if the <i>yin</i> and <i>yang</i> of <i>T'ai Chi</i> have not yet divided apart.'</dd>
<dd>Others say: 'Every movement of <i>T'ai Chi Ch'uan</i> is based on circles, just like the shape of a <a href="/wiki/Taijitu" title="Taijitu"><i>T'ai Chi</i> symbol</a>. Therefore, it is called <i>T'ai Chi Ch'uan</i>.' Both explanations are quite reasonable, especially the second, which is more complete."</dd>
</dl>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=2" title="Edit section: Training and techniques">edit</a>]</div>
<p><a name="Training_and_techniques" id="Training_and_techniques"></a></p>
<h2>Training and techniques</h2>
<div class="thumb tright">
<div style="width:182px;"><a href="/wiki/Image:Yin_yang.svg" class="internal" title="The T'ai Chi Symbol or T'ai Chi T'u (Taijitu)"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/17/Yin_yang.svg/180px-Yin_yang.svg.png" alt="The T'ai Chi Symbol or T'ai Chi T'u (Taijitu)" width="180" height="180" longdesc="/wiki/Image:Yin_yang.svg" /></a>
<div class="thumbcaption">
<div class="magnify" style="float:right"><a href="/wiki/Image:Yin_yang.svg" class="internal" title="Enlarge"><img src="/skins-1.5/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>
<b>The T'ai Chi Symbol or T'ai Chi T'u (Taijitu)</b></div>
</div>
</div>
<p>As the name <i>T'ai Chi Ch'üan</i> is held to be derived from the T'ai Chi symbol, the <i>taijitu</i> or <i>t'ai chi t'u</i> (???, <a href="/wiki/Pinyin" title="Pinyin">pinyin</a> tàijítú), commonly known in the West as the "<a href="/wiki/Yin-yang" title="Yin-yang">yin-yang</a>" diagram, T'ai Chi Ch'üan techniques are said therefore to physically and energetically balance <i>yin</i> (receptive) and <i>yang</i> (active) principles: "From ultimate softness comes ultimate hardness."</p>
<p>The core training involves two primary features: the first being the solo form or <i>ch'üan</i>, a slow sequence of movements which emphasize a straight spine, relaxed breathing and a natural range of motion; the second being different styles of <i>pushing hands</i> or <i>t'ui shou</i> (??) for training "stickiness" and sensitivity in the reflexes through various motions from the forms in concert with a training partner in order to learn leverage, timing, coordination and positioning when interacting with another. Pushing hands is seen as necessary not only for training the self-defense skills of a soft style such as T'ai Chi by demonstrating the forms' movement principles experientially, but also it is said to improve upon the level of conditioning provided by practice of the solo forms by increasing the workload on students while they practice those movement principles.</p>
<p>The solo form should take the students through a complete, natural, range of motion over their centre of gravity. Accurate, repeated practice of the solo routine is said to retrain posture, encourage circulation throughout the students' bodies, maintain flexibility through their joints and further familiarize students with the martial application sequences implied by the forms. The major traditional styles of T'ai Chi have forms which differ somewhat cosmetically, but there are also many obvious similarities which point to their common origin. The solo forms, empty-hand and <a href="/wiki/Weapon" title="Weapon">weapon</a>, are catalogues of movements that are practised individually in pushing hands and martial application scenarios to prepare students for self-defence training. In most traditional schools different variations of the solo forms can be practiced; fast/slow, small circle/large circle, square/round (which are different expressions of leverage through the joints), low sitting/high sitting (the degree to which weight-bearing knees are kept bent throughout the form), for example.</p>
<p>In a fight, if one uses hardness to resist violent force then both sides are certain to be injured, at least to some degree. Such injury, according to T'ai Chi theory, is a natural consequence of meeting brute force with brute force. The collision of two like forces, yang with yang, is known as "double-weighted" in T'ai Chi terminology. Instead, students are taught not to fight or resist an incoming force, but to meet it in softness and "stick" to it, following its motion while remaining in physical contact until the incoming force of attack exhausts itself or can be safely redirected, the result of meeting yang with yin. Done correctly, achieving this yin/yang or yang/yin balance in combat (and, by extension, other areas of one's life) is known as being "single-weighted" and is a primary goal of T'ai Chi Ch'üan training. <a href="/wiki/Lao_Tzu" title="Lao Tzu">Lao Tzu</a> provided the <a href="/wiki/Archetype" title="Archetype">archetype</a> for this in the <a href="/wiki/Tao_Te_Ching" title="Tao Te Ching">Tao Te Ching</a> when he wrote, "The soft and the pliable will defeat the hard and strong." This soft "neutralization" of an attack can be accomplished very quickly in an actual fight by an adept practitioner. A T'ai Chi student has to be well conditioned by many years of disciplined training; stable, sensitive and elastic mentally and physically in order to realize this ability, however.</p>
<p>Other training exercises include:</p>
<ul>
<li>Weapons training and <a href="/wiki/Fencing" title="Fencing">fencing</a> applications employing the straight <i><a href="/wiki/Sword" title="Sword">sword</a></i> known as the <i>jian</i> or <i>chien</i> or <i>gim</i> (<a href="/wiki/Jian" title="Jian">jiàn</a> ?), a heavier curved <i>sabre</i>, sometimes called a <i>broadsword</i> or <i>tao</i> (<a href="/wiki/Dao_%28saber%29" title="Dao (saber)">dao</a> ?, which is actually considered a big <i><a href="/wiki/Knife" title="Knife">knife</a></i>), folding <i><a href="/wiki/Tessen" title="Tessen">fan</a></i>, <i>staff</i> (?), 7 foot (2 m) <i><a href="/wiki/Qiang_%28spear%29" title="Qiang (spear)">spear</a></i> and 13 foot (4 m) <i><a href="/wiki/Lance" title="Lance">lance</a></i> (both called qiang ?). More exotic weapons still used by some traditional styles are the large <i>Da Dao</i> or <i>Ta Tao</i> (??) sabre, <i><a href="/wiki/Ji_%28halberd%29" title="Ji (halberd)">halberd</a></i> (ji ?), <i>cane</i>, <i>rope-dart</i>, <i><a href="/wiki/Three_sectional_staff" title="Three sectional staff">three sectional staff</a></i>, <i><a href="/wiki/Lasso" title="Lasso">lasso</a></i>, <i><a href="/wiki/Whip" title="Whip">whip</a></i>, <i><a href="/wiki/Chain_whip" title="Chain whip">chain whip</a></i> and <i>steel whip</i>.</li>
<li>Two-person tournament sparring (as part of push hands competitions and/or <i><a href="/wiki/San_shou" title="San shou">san shou</a></i> ??);</li>
<li>Breathing exercises; <i><a href="/wiki/Nei_kung" title="Nei kung">nei kung</a></i> (?? nèigong) or, more commonly, <i><a href="/wiki/Ch%27i_kung" title="Ch'i kung">ch'i kung</a></i> (?? qìgong) to develop <b><a href="/wiki/Ch%27i" title="Ch'i">ch'i</a></b> (? qì) or "breath energy" in coordination with physical movement and <a href="/wiki/Zhan_zhuang" title="Zhan zhuang">post standing</a> or combinations of the two. These were formerly taught only to disciples as a separate, complementary training system. In the last 50 years they have become more well known to the general public.</li>
</ul>
<p>T'ai Chi's martial aspect relies on sensitivity to the opponent's movements and centre of gravity dictating appropriate responses. Effectively affecting or "capturing" the opponent's centre of gravity immediately upon contact is trained as the primary goal of the martial T'ai Chi student, and from there all other technique can follow with seeming effortlessness. The alert calmness required to achieve the necessary sensitivity is acquired over thousands of hours of first <i>yin</i> (slow, repetitive, meditative, low impact) and then later adding <i>yang</i> ("realistic," active, fast, high impact) martial training; forms, pushing hands and sparring. T'ai Chi Ch'üan trains in three basic ranges, close, medium and long, and then everything in between. Pushes and open hand strikes are more common than punches, and kicks are usually to the legs and lower torso, never higher than the hip in most styles. The fingers, fists, palms, sides of the hands, wrists, forearms, elbows, shoulders, back, hips, knees and feet are commonly used to strike, with strikes to the eyes, throat, heart, groin and other acupressure points trained by advanced students. There is an extensive repertoire of joint traps, locks and breaks (<a href="/wiki/Chin_na" title="Chin na">chin na</a>), particularly applied to lock up or break an opponent's elbows, wrists, fingers, ankles, back or neck. Most T'ai Chi teachers expect their students to thoroughly learn defensive or neutralizing skills first, and a student will have to demonstrate proficiency with them before offensive skills will be extensively trained. There is also an emphasis in the traditional schools on kind-heartedness. One is expected to show mercy to one's opponents, as instanced by a poem preserved in some of the T'ai Chi families said to be derived from the <a href="/wiki/Shaolin" title="Shaolin">Shaolin</a> temple:</p>
<dl>
<dd>"I would rather maim than kill</dd>
<dd>Hurt than maim</dd>
<dd>Intimidate than hurt</dd>
<dd>Avoid than intimidate."</dd>
</dl>
<div class="thumb tright">
<div style="width:352px;"><a href="/wiki/Image:Martial_arts_-_Fragrant_Hills.JPG" class="internal" title="An outdoor Chen style class in Beijing"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Martial_arts_-_Fragrant_Hills.JPG/350px-Martial_arts_-_Fragrant_Hills.JPG" alt="An outdoor Chen style class in Beijing" width="350" height="233" longdesc="/wiki/Image:Martial_arts_-_Fragrant_Hills.JPG" /></a>
<div class="thumbcaption">
<div class="magnify" style="float:right"><a href="/wiki/Image:Martial_arts_-_Fragrant_Hills.JPG" class="internal" title="Enlarge"><img src="/skins-1.5/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>
An outdoor Chen style class in Beijing</div>
</div>
</div>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=3" title="Edit section: Styles and history">edit</a>]</div>
<p><a name="Styles_and_history" id="Styles_and_history"></a></p>
<h2>Styles and history</h2>
<p>There are five major styles of T'ai Chi Ch'üan, each named after the Chinese family that teaches (or taught) it:</p>
<ul>
<li><b><a href="/wiki/Chen_style_Tai_Chi_Chuan" title="Chen style Tai Chi Chuan">Chen style</a></b> (??) and its close cousin <b><a href="/w/index.php?title=Zhaobao_style_T%27ai_Chi_Ch%27uan&amp;action=edit" class="new" title="Zhaobao style T'ai Chi Ch'uan">Zhao Bao Style</a></b> (?????)</li>
<li><b><a href="/wiki/Yang_style_T%27ai_Chi_Ch%27uan" title="Yang style T'ai Chi Ch'uan">Yang style</a></b> (??)</li>
<li><b><a href="/wiki/Wu/Hao_style_T%27ai_Chi_Ch%27uan" title="Wu/Hao style T'ai Chi Ch'uan">Wu or Wu/Hao style of Wu Yu-hsiang</a></b> (??)</li>
<li><b><a href="/wiki/Wu_style_T%27ai_Chi_Ch%27uan" title="Wu style T'ai Chi Ch'uan">Wu style of Wu Ch'uan-yü and Wu Chien-ch'uan</a></b> (??)</li>
<li><b><a href="/wiki/Sun_style_T%27ai_Chi_Ch%27uan" title="Sun style T'ai Chi Ch'uan">Sun style</a></b> (??)</li>
</ul>
<p>The order of seniority is as listed above. The order of popularity is Yang, Wu, Chen, Sun, and Wu/Hao. The first five major family styles share much underlying theory, but differ in their approaches to training.</p>
<p>In the modern world there are now dozens of new styles, hybrid styles and offshoots of the main styles, but the five family schools are the groups recognised by the international community as being orthodox. For example, there are <i>several</i> groups teaching what they call <a href="/wiki/Wudang_Tai_Chi_Chuan" title="Wudang Tai Chi Chuan">Wu Tang style T'ai Chi Ch'üan (??????)</a>. The best known modern style going by the name <i>Wu Tang</i> has gained some publicity internationally, especially in the <a href="/wiki/United_Kingdom" title="United Kingdom">UK</a> and <a href="/wiki/Europe" title="Europe">Europe</a>, but was originally taught by a senior student of the Wu (?) style.</p>
<p>The designation <i><a href="/wiki/Wudangquan" title="Wudangquan">Wu Tang Ch'üan</a></i> is also used to broadly distinguish <i>internal</i> or <i>nei chia</i> martial arts (said to be a specialty of the <a href="/wiki/Monasteries" title="Monasteries">monasteries</a> at <a href="/wiki/Wudangshan" title="Wudangshan">Wu Tang Shan</a>) from what are known as the <i>external</i> or <i>wei chia</i> styles based on <i><a href="/w/index.php?title=Shaolinquan_kung_fu&amp;action=edit" class="new" title="Shaolinquan kung fu">Shaolinquan kung fu</a></i>, although that distinction is sometimes disputed by individual schools. In this broad sense, among many T'ai Chi schools <i>all</i> styles of T'ai Chi (as well as related arts such as <a href="/wiki/Bagua_zhang" title="Bagua zhang">Pa Kua Chang</a> and <a href="/wiki/Hsing_Yi" title="Hsing Yi">Hsing-i Ch'üan</a>) are therefore considered to be "Wu Tang style" martial arts. The schools that designate themselves "Wu Tang style" relative to the family styles mentioned above mostly claim to teach an "original style" they say was formulated by a Taoist monk called <a href="/wiki/Zhang_Sanfeng" title="Zhang Sanfeng">Zhang Sanfeng</a> and taught by him in the Taoist monasteries at Wu Tang Shan. Some consider that what is practised under that name today may be a modern back-formation based on stories and popular veneration of Zhang Sanfeng (see below) as well as the martial fame of the Wu Tang monastery (there are many other martial art styles historically associated with Wu Tang besides T'ai Chi).</p>
<p>When tracing T'ai Chi Ch'üan's formative influences to <a href="/wiki/Taoist" title="Taoist">Taoist</a> and <a href="/wiki/Buddhist" title="Buddhist">Buddhist</a> monasteries, one has little more to go on than legendary tales from a modern historical perspective, but T'ai Chi Ch'üan's practical connection to and dependence upon the theories of <a href="/wiki/Song_dynasty" title="Song dynasty">Sung dynasty</a> <a href="/wiki/Neo-Confucianism" title="Neo-Confucianism">Neo-Confucianism</a> (a conscious synthesis of Taoist, Buddhist and <a href="/wiki/Confucian" title="Confucian">Confucian</a> traditions, esp. the teachings of <a href="/wiki/Mencius" title="Mencius">Mencius</a>) is readily apparent to its practitioners. The philosophical and political landscape of that time in Chinese history is fairly well documented, even if the origin of the art later to become known as T'ai Chi Ch'üan in it is not. T'ai Chi Ch'üan's theories and practice are therefore believed by some schools to have been formulated by the Taoist monk <a href="/wiki/Zhang_Sanfeng" title="Zhang Sanfeng">Zhang Sanfeng</a> in the 12th century, a time frame fitting well with when the principles of the Neo-Confucian school were making themselves felt in Chinese intellectual life. Therefore the didactic story is told that Zhang Sanfeng as a young man studied <a href="/wiki/Tao_Yin" title="Tao Yin">Tao Yin</a> (??, <a href="/wiki/Pinyin" title="Pinyin">Pinyin</a> daoyin) breathing exercises from his Taoist teachers and martial arts at the Buddhist Shaolin monastery, eventually combining the martial forms and breathing exercises to formulate the soft or internal principles we associate with T'ai Chi Ch'üan and related martial arts. Its subsequent fame attributed to his teaching, Wu Tang monastery was known thereafter as an important martial center for many centuries, its many styles of internal <a href="/wiki/Kung_fu" title="Kung fu">kung fu</a> preserved and refined at various Taoist temples.</p>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=4" title="Edit section: Family tree">edit</a>]</div>
<p><a name="Family_tree" id="Family_tree"></a></p>
<h3>Family tree</h3>
<p>This family tree is not comprehensive.</p>
<pre>
<b>LEGENDARY FIGURES</b>
|
<a href="/wiki/Zhang_Sanfeng" title="Zhang Sanfeng">Zhang Sanfeng</a>*
circa 12th century
<a href="/wiki/Nei_chia" title="Nei chia">NEI CHIA</a>
|
<a href="/w/index.php?title=Wang_Zongyue&amp;action=edit" class="new" title="Wang Zongyue">Wang Zongyue</a>*
T'AI CHI CH'ÜAN
|
<b>THE 5 MAJOR CLASSICAL FAMILY STYLES</b>
|
Chen Wangting
1600-1680 9th generation Chen
<a href="/wiki/Chen_style_Tai_Chi_Chuan" title="Chen style Tai Chi Chuan">CHEN STYLE</a>
|
+-------------------------------------------------------------------+
| |
<a href="/w/index.php?title=Chen_Changxing&amp;action=edit" class="new" title="Chen Changxing">Chen Changxing</a> <a href="/w/index.php?title=Chen_Youben&amp;action=edit" class="new" title="Chen Youben">Chen Youben</a>
1771-1853 14th generation Chen circa 1800s 14th generation Chen
Chen Old Frame Chen New Frame
| |
<a href="/wiki/Yang_Lu-ch%27an" title="Yang Lu-ch'an">Yang Lu-ch'an</a> <a href="/w/index.php?title=Chen_Qingping&amp;action=edit" class="new" title="Chen Qingping">Chen Qingping</a>
1799-1872 1795-1868
<a href="/wiki/Yang_style_Tai_Chi_Chuan" title="Yang style Tai Chi Chuan">YANG STYLE</a> Chen Small Frame, Zhao Bao Frame
| |
+---------------------------------+-----------------------------+ |
| | | |
<a href="/wiki/Yang_Pan-hou" title="Yang Pan-hou">Yang Pan-hou</a> <a href="/wiki/Yang_Chien-hou" title="Yang Chien-hou">Yang Chien-hou</a> <a href="/w/index.php?title=Wu_Yu-hsiang&amp;action=edit" class="new" title="Wu Yu-hsiang">Wu Yu-hsiang</a>
1837-1892 1839-1917 1812-1880
Yang Small Frame | <a href="/wiki/Wu/Hao_style_T%27ai_Chi_Ch%27uan" title="Wu/Hao style T'ai Chi Ch'uan">WU/HAO STYLE</a>
| +-----------------+ |
| | | |
<a href="/wiki/Wu_Ch%27uan-y%C3%BC" title="Wu Ch'uan-yü">Wu Ch'uan-yü</a> <a href="/wiki/Yang_Shao-hou" title="Yang Shao-hou">Yang Shao-hou</a> <a href="/wiki/Yang_Ch%27eng-fu" title="Yang Ch'eng-fu">Yang Ch'eng-fu</a> <a href="/w/index.php?title=Li_I-y%C3%BC&amp;action=edit" class="new" title="Li I-yü">Li I-yü</a>
1834-1902 1862-1930 1883-1936 1832-1892
| Yang Small Frame <a href="/wiki/103_form_Yang_family_T%27ai_Chi_Ch%27uan" title="103 form Yang family T'ai Chi Ch'uan">Yang Big Frame</a> |
<a href="/wiki/Wu_Chien-ch%27%C3%BCan" title="Wu Chien-ch'üan">Wu Chien-ch'üan</a> | <a href="/wiki/Hao_Wei-chen" title="Hao Wei-chen">Hao Wei-chen</a>
1870-1942 <a href="/wiki/Yang_Shou-chung" title="Yang Shou-chung">Yang Shou-chung</a> 1849-1920
<a href="/wiki/Wu_style_T%27ai_Chi_Ch%27uan" title="Wu style T'ai Chi Ch'uan">WU STYLE</a> 1910-1985 |
<a href="/wiki/108_form_Wu_family_T%27ai_Chi_Ch%27uan" title="108 form Wu family T'ai Chi Ch'uan">108 Form</a> |
| <a href="/wiki/Sun_Lu-t%27ang" title="Sun Lu-t'ang">Sun Lu-t'ang</a>
<a href="/wiki/Wu_Kung-i" title="Wu Kung-i">Wu Kung-i</a> 1861-1932
1900-1970 <a href="/wiki/Sun_style_T%27ai_Chi_Ch%27uan" title="Sun style T'ai Chi Ch'uan">SUN STYLE</a>
| |
<a href="/w/index.php?title=Wu_Ta-kuei&amp;action=edit" class="new" title="Wu Ta-kuei">Wu Ta-kuei</a> <a href="/w/index.php?title=Sun_Hsing-i&amp;action=edit" class="new" title="Sun Hsing-i">Sun Hsing-i</a>
1923-1970 1891-1929
<b>MODERN FORMS</b>
from Yang Ch`eng-fu
|
|
|
+--------------+
| |
<a href="/wiki/Cheng_Man-ch%27ing" title="Cheng Man-ch'ing">Cheng Man-ch'ing</a> |
1901-1975 |
Short (37) Form |
|
Chinese Sports Commission
1956
Beijing <a href="/wiki/24_Form" title="24 Form">24 Form</a>
.
.
1989
<a href="/wiki/42_Form_%28Competition_Form%29_T%27ai_Chi_Ch%27uan" title="42 Form (Competition Form) T'ai Chi Ch'uan">42 Competition Form</a>
(<a href="/wiki/Wushu" title="Wushu">Wushu</a> competition form combined from Sun, Wu, Chen, and Yang styles)
</pre>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=5" title="Edit section: Notes to Family tree table">edit</a>]</div>
<p><a name="Notes_to_Family_tree_table" id="Notes_to_Family_tree_table"></a></p>
<h3>Notes to Family tree table</h3>
<p>Names denoted by an asterisk are legendary or semilegendary figures in the lineage, which means their involvement in the lineage, while accepted by most of the major schools, isn't independently verifiable from known historical records.</p>
<p>The Cheng Man-ch'ing and <a href="/w/index.php?title=Chinese_Sports_Commission&amp;action=edit" class="new" title="Chinese Sports Commission">Chinese Sports Commission</a> short forms are said to be derived from Yang family forms, but neither are recognized as Yang family T'ai Chi Ch'üan by current Yang family teachers. The Chen, Yang and Wu families are now promoting their own shortened demonstration forms for competitive purposes.</p>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=6" title="Edit section: Modern T'ai Chi">edit</a>]</div>
<p><a name="Modern_T.27ai_Chi" id="Modern_T.27ai_Chi"></a></p>
<h2>Modern T'ai Chi</h2>
<div class="thumb tright">
<div style="width:352px;"><a href="/wiki/Image:Taichi_shanghai_bund_2005.jpg" class="internal" title="Yang style in Shanghai"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/Taichi_shanghai_bund_2005.jpg/350px-Taichi_shanghai_bund_2005.jpg" alt="Yang style in Shanghai" width="350" height="263" longdesc="/wiki/Image:Taichi_shanghai_bund_2005.jpg" /></a>
<div class="thumbcaption">
<div class="magnify" style="float:right"><a href="/wiki/Image:Taichi_shanghai_bund_2005.jpg" class="internal" title="Enlarge"><img src="/skins-1.5/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>
Yang style in Shanghai</div>
</div>
</div>
<p>T'ai Chi has become very popular in the last twenty years or so, as the <a href="/wiki/Baby_boomers" title="Baby boomers">baby boomers</a> age and T'ai Chi's reputation for ameliorating the effects of aging becomes more well-known. Hospitals, clinics, community and senior centers are all hosting T'ai Chi classes in communities around the world. As a result of this popularity, there has been some divergence between those who say they practice T'ai Chi primarily for fighting, those who practice it for its <a href="/wiki/Aesthetic" title="Aesthetic">aesthetic</a> appeal (as in the shortened, modern, theatrical "Taijiquan" forms of <a href="/wiki/Wushu" title="Wushu">wushu</a>, see below), and those who are more interested in its benefits to physical and mental health. The wushu aspect is primarily for show; the forms taught for those purposes are designed to earn points in competition and are mostly unconcerned with either health maintenance or martial ability. More traditional stylists still see the two aspects of health and martial arts as equally necessary pieces of the puzzle, the <i>yin</i> and <i>yang</i> of T'ai Chi Ch'üan. The T'ai Chi "family" schools therefore still present their teachings in a martial art context even though the majority of their students nowadays profess that they are primarily interested in training for the claimed health benefits.</p>
<p>Along with <a href="/wiki/Yoga" title="Yoga">Yoga</a>, it is one of the fastest growing fitness and health maintenance activities, in terms of numbers of students enrolling in classes. Since there is no universal certification process and most Westerners haven't seen very much T'ai Chi and don't know what to look for, practically anyone can learn or even make up a few moves and call themselves a teacher. This is especially prevalent in the <a href="/wiki/New_Age" title="New Age">New Age</a> community. Relatively few of these teachers even know that there are martial applications to the T'ai Chi forms. Those who do know that it is a martial art usually don't teach martially themselves. If they do teach self-defense, it is often a mixture of motions which the teachers think look like T'ai Chi Ch'üan with some other system. This is especially evident in schools located outside of China. While this phenomenon may have made some external aspects of T'ai Chi available for a wider audience, the traditional T'ai Chi family schools see the martial focus as a fundamental part of their training, both for health <i>and</i> self-defense purposes. They claim that while the students may not need to practice martial applications themselves to derive a benefit from T'ai Chi training, they assert that T'ai Chi teachers at least should know the martial applications to ensure that the movements they teach are done correctly and safely by their students. Also, working on the ability to protect oneself from physical attack (one of the most stressful things that can happen to a person) certainly falls under the category of complete "health maintenance." For these reasons they claim that a school not teaching those aspects somewhere in their syllabus cannot be said to be actually teaching the art itself, and will be much less likely to be able to reproduce the full health benefits that made T'ai Chi's reputation in the first place.</p>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=7" title="Edit section: Modern forms">edit</a>]</div>
<p><a name="Modern_forms" id="Modern_forms"></a></p>
<h3>Modern forms</h3>
<div class="thumb tright">
<div style="width:352px;"><a href="/wiki/Image:Tai_Chi_fans.jpg" class="internal" title="Women practicing non-martial T'ai Chi in Chinatown (New York City, New York, USA)."><img src="http://upload.wikimedia.org/wikipedia/en/thumb/a/ad/Tai_Chi_fans.jpg/350px-Tai_Chi_fans.jpg" alt="Women practicing non-martial T'ai Chi in Chinatown (New York City, New York, USA)." width="350" height="201" longdesc="/wiki/Image:Tai_Chi_fans.jpg" /></a>
<div class="thumbcaption">
<div class="magnify" style="float:right"><a href="/wiki/Image:Tai_Chi_fans.jpg" class="internal" title="Enlarge"><img src="/skins-1.5/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>
Women practicing non-martial T'ai Chi in <a href="/wiki/Chinatown_%28Manhattan%29" title="Chinatown (Manhattan)">Chinatown</a> (<a href="/wiki/New_York_City" title="New York City">New York City</a>, <a href="/wiki/New_York" title="New York">New York</a>, <a href="/wiki/USA" title="USA">USA</a>).</div>
</div>
</div>
<p>In order to standardize T'ai Chi Ch'üan for wushu tournament judging, and because many of the family T'ai Chi Ch'üan teachers had either moved out of China or had been forced to stop teaching after the <a href="/wiki/Chinese_Civil_War" title="Chinese Civil War">Communist regime was established</a> in <a href="/wiki/1949" title="1949">1949</a>, the government sponsored Chinese Sports Committee brought together four of their wushu teachers to truncate the Yang family hand form to <a href="/wiki/24_Form_%28Simplified_Form%29_T%27ai_Chi_Ch%27uan" title="24 Form (Simplified Form) T'ai Chi Ch'uan">24 postures</a> in <a href="/wiki/1956" title="1956">1956</a>. They wanted to somehow retain the look of T'ai Chi Ch'üan but make an easy to remember routine that was less difficult to teach and much less difficult to learn than longer (generally 88 to 108 posture) classical solo hand forms. In <a href="/wiki/1976" title="1976">1976</a>, they developed a slightly longer form also for the purposes of demonstration that still didn't involve the complete memory, balance and coordination requirements of the traditional forms. This was a combination form, the <i>Combined 48 Forms</i> that were created by three wushu coaches headed by Professor Men Hui Feng. The combined forms were created based on simplifying and combining some features of the classical forms from four of the original styles; Ch'en, Yang, Wu, and Sun. Even though shorter modern forms don't have the conditioning benefits of the classical forms, the idea was to take what they felt were distinctive cosmetic features of these styles and to express them in a shorter time for purposes of competition.</p>
<p>As T'ai Chi again became popular on the Mainland, competitive forms were developed to be completed within a 6 minute time limit. In the late <a href="/wiki/1980s" title="1980s">1980s</a>, the Chinese Sports Committee standardized many different competition forms. It had developed sets said to represent the four major styles as well as combined forms. These five sets of forms were created by different teams, and later approved by a committee of wushu coaches in China. All sets of forms thus created were named after their style, e.g., the Ch'en Style National Competition Form is the <i>56 Forms</i>, and so on. The combined forms are <i>The 42 Form</i> or simply the <i>Competition Form</i>, as it is known in China. In the 11th <a href="/wiki/Asian_Games" title="Asian Games">Asian Games</a> of <a href="/wiki/1990" title="1990">1990</a>, wushu was included as an item for competition for the first time with the 42 Form being chosen to represent T'ai Chi. The International Wushu Federation (<a href="/w/index.php?title=IWUF&amp;action=edit" class="new" title="IWUF">IWUF</a>) has applied for wushu to be part of the <a href="/wiki/Olympic_games" title="Olympic games">Olympic games</a>. If accepted, it is likely that T'ai Chi and wushu will be represented as demonstration events in <a href="/wiki/2008" title="2008">2008</a>.</p>
<p>Representatives of the original T'ai Chi families do not teach the forms developed by the Chinese Sports Committee. T'ai Chi Ch'üan has historically been seen by them as a martial art, not a sport, with competitions mostly entered as a hobby or to promote one's school publicly, but with little bearing on measuring actual accomplishment in the art. Their criticisms of modern forms include that the modern, "government" routines have no standardized, internally consistent training requirements. Also, that people studying competition forms rarely train pushing hands or other power generation trainings vital to learning the martial applications of T'ai Chi Ch'üan and thereby lack the <a href="/wiki/Quality_control" title="Quality control">quality control</a> traditional teachers maintain is essential for achieving the full benefits from both the health and the martial aspect of traditional T'ai Chi training.</p>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=8" title="Edit section: Health benefits">edit</a>]</div>
<p><a name="Health_benefits" id="Health_benefits"></a></p>
<h2>Health benefits</h2>
<p>Researchers have found that long-term T'ai Chi practice had favorable effects on the promotion of balance control, flexibility and cardiovascular fitness and reduced the risk of falls in elders. The studies also reported reduced pain, stress and anxiety in healthy subjects. Other studies have indicated improved cardiovascular and respiratory function in healthy subjects as well as those who had undergone coronary artery bypass surgery. Patients also benefited from T'ai Chi who suffered from heart failure, high blood pressure, heart attacks, arthritis and multiple sclerosis.</p>
<p>T'ai Chi has also been shown to reduce the symptoms of young Attention Deficit and Hyperactivity Disorder (<a href="/wiki/ADHD" title="ADHD">ADHD</a>) sufferers. T'ai Chi's gentle, low impact, movements surprisingly burn more calories than surfing and nearly as many as downhill skiing. T'ai Chi also boosts aspects of the immune system's function very significantly, and has been shown to reduce the incidence of anxiety, depression, and overall mood disturbance. (See research citations listed below.)</p>
<p>A pilot study has found evidence that T'ai Chi and related qigong helps reduce the severity of <a href="/wiki/Diabetes" title="Diabetes">diabetes</a>.<a href="http://www.abc.net.au/pm/content/2005/s1535304.htm" class="external autonumber" title="http://www.abc.net.au/pm/content/2005/s1535304.htm">[1]</a></p>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=9" title="Edit section: Citations to medical research">edit</a>]</div>
<p><a name="Citations_to_medical_research" id="Citations_to_medical_research"></a></p>
<h3>Citations to medical research</h3>
<ul>
<li>Wolf SL, Sattin RW, Kutner M. Intense T'ai Chi exercise training and fall occurrences in older, transitionally frail adults: a randomized, controlled trial. J Am Geriatr Soc. 2003 Dec; 51(12): 1693-701. <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&amp;db=pubmed&amp;dopt=Abstract&amp;list_uids=14687346" class="external" title="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&amp;db=pubmed&amp;dopt=Abstract&amp;list_uids=14687346">PMID 14687346</a></li>
<li>Wang C, Collet JP, Lau J. The effect of Tai Chi on health outcomes in patients with chronic conditions: a <a href="/wiki/Systematic_review" title="Systematic review">systematic review</a>. Arch Intern Med. 2004 Mar 8;164(5):493-501. <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&amp;db=pubmed&amp;dopt=Abstract&amp;list_uids=15006825" class="external" title="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&amp;db=pubmed&amp;dopt=Abstract&amp;list_uids=15006825">PMID 15006825</a></li>
<li>Search a listing of articles relating to the FICSIT trials and T'ai Chi <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Select+from+History&amp;db=pubmed&amp;query_key=3" class="external autonumber" title="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Select+from+History&amp;db=pubmed&amp;query_key=3">[2]</a></li>
<li>Hernandez-Reif, M., Field, T.M., &amp; Thimas, E. (2001). Attention deficit hyperactivity disorder: benefits from Tai Chi. Journal of Bodywork &amp; Movement Therapies, 5(2):120-3, 2001 Apr, 5(23 ref), 120-123</li>
<li>Calorie Burning Chart <a href="http://www.nutristrategy.com/activitylist3.htm" class="external autonumber" title="http://www.nutristrategy.com/activitylist3.htm">[3]</a></li>
<li>Tai Chi boosts T-Cell counts in immune system <a href="http://www.acupuncturetoday.com/archives2003/nov/11taichi.html" class="external autonumber" title="http://www.acupuncturetoday.com/archives2003/nov/11taichi.html">[4]</a></li>
<li>Tai Chi, depression, anxiety, and mood disturbance (American Psychological Association) Journal of Psychosomatic Research, 1989 Vol 33 (2) 197-206</li>
<li>A comprehensive listing of Tai Chi medical research links <a href="http://www.worldtaichiday.org/WTCQDHlthBenft.html" class="external autonumber" title="http://www.worldtaichiday.org/WTCQDHlthBenft.html">[5]</a></li>
<li>References to medical publications <a href="http://www.worldtaichiday.org/HeadlineNews.html" class="external autonumber" title="http://www.worldtaichiday.org/HeadlineNews.html">[6]</a></li>
<li><a href="http://www.abc.net.au/pm/content/2005/s1535304.htm" class="external text" title="http://www.abc.net.au/pm/content/2005/s1535304.htm">Tai Chi a promising remedy for diabetes</a>, <i>Australian Broadcasting Corporation</i>, 20 December, 2005 - Pilot study of Qigong and tai chi in diabetes sufferers.</li>
<li>Health Research Articles on "Tai Chi as Health Therapy" for many issues, i.e. ADHD, Cardiac Health &amp; Rehabilitation, Diabetes, High Blood Pressure, Menopause, Bone Loss, Weight Loss, etc.<a href="http://www.worldtaichiday.org/LIBRARYArticles/LIBRARYTaiChiArticlesMenu.html" class="external autonumber" title="http://www.worldtaichiday.org/LIBRARYArticles/LIBRARYTaiChiArticlesMenu.html">[7]</a></li>
</ul>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=10" title="Edit section: See also">edit</a>]</div>
<p><a name="See_also" id="See_also"></a></p>
<h2>See also</h2>
<ul>
<li><a href="/wiki/Jing_%28TCM%29" title="Jing (TCM)">Jing</a></li>
<li><a href="/wiki/List_of_Tai_Chi_Chuan_forms" title="List of Tai Chi Chuan forms">List of Tai Chi Chuan forms</a></li>
<li><a href="/wiki/Nei_Jin" title="Nei Jin">nei chin</a></li>
<li><a href="/wiki/Silk_reeling" title="Silk reeling">Silk reeling</a></li>
<li><a href="/wiki/World_Tai_Chi_and_Qigong_Day" title="World Tai Chi and Qigong Day">World Tai Chi and Qigong Day</a></li>
</ul>
<div class="editsection" style="float:right;margin-left:5px;">[<a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit&amp;section=11" title="Edit section: External links">edit</a>]</div>
<p><a name="External_links" id="External_links"></a></p>
<h2>External links</h2>
<ul>
<li><a href="http://www.chenxiaowang.com/" class="external text" title="http://www.chenxiaowang.com/">A Chen Family Website</a></li>
<li><a href="http://www.yangfamilytaichi.com/" class="external text" title="http://www.yangfamilytaichi.com/">Yang Family Website</a></li>
<li><a href="http://www.wustyle.com/" class="external text" title="http://www.wustyle.com/">Wu Chien-ch'üan Family Website</a></li>
<li><a href="http://www.fushengyuan-taichi.com.au/" class="external text" title="http://www.fushengyuan-taichi.com.au/">Fu Family Website</a></li>
<li><a href="http://www.itcca.org/" class="external text" title="http://www.itcca.org/">Yang family disciple's website (ITCCA)</a></li>
<li><a href="http://www.dongtaichi.com/" class="external text" title="http://www.dongtaichi.com/">Dong T'ai Chi</a></li>
<li><a href="http://www.leefamilystyle.com/" class="external text" title="http://www.leefamilystyle.com/">UK website for Li style, popular in Europe</a></li>
<li><a href="http://www.chen-taiji.com/mambo/" class="external text" title="http://www.chen-taiji.com/mambo/">The World of Taijiquan</a></li>
<li><a href="http://www.scheele.org/lee/tcclinks.html" class="external text" title="http://www.scheele.org/lee/tcclinks.html">Lee Scheele's Links to T'ai Chi Ch'uan Web Sites</a></li>
<li><a href="http://news.bbc.co.uk/1/hi/health/3543907.stm" class="external text" title="http://news.bbc.co.uk/1/hi/health/3543907.stm">BBC article</a></li>
<li><a href="http://www.acupuncturetoday.com/archives2004/jul/07taichi.html" class="external text" title="http://www.acupuncturetoday.com/archives2004/jul/07taichi.html">Tai Chi: Good for the Mind, Good for the Body</a></li>
<li><a href="http://www.taichiunion.com/" class="external text" title="http://www.taichiunion.com/">Tai Chi Chuan Union for Great Britian: The largest collective of independent Tai Chi Chuan Instructors in the British Isles</a></li>
</ul>
<!-- Saved in parser cache with key enwiki:pcache:idhash:30690-0!0!0!1!!en!2 and timestamp 20060722121412 -->
<div class="printfooter">
Retrieved from "<a href="http://en.wikipedia.org/wiki/Tai_Chi_Chuan">http://en.wikipedia.org/wiki/Tai_Chi_Chuan</a>"</div>
<div id="catlinks"><p class='catlinks'><a href="/w/index.php?title=Special:Categories&amp;article=Tai_Chi_Chuan" title="Special:Categories">Categories</a>: <span dir='ltr'><a href="/wiki/Category:Chinese_martial_arts" title="Category:Chinese martial arts">Chinese martial arts</a></span> | <span dir='ltr'><a href="/wiki/Category:T%27ai_Chi_Ch%27uan" title="Category:T'ai Chi Ch'uan">T'ai Chi Ch'uan</a></span> | <span dir='ltr'><a href="/wiki/Category:Taoism" title="Category:Taoism">Taoism</a></span> | <span dir='ltr'><a href="/wiki/Category:Meditation" title="Category:Meditation">Meditation</a></span> | <span dir='ltr'><a href="/wiki/Category:Mind-body_interventions" title="Category:Mind-body interventions">Mind-body interventions</a></span> | <span dir='ltr'><a href="/wiki/Category:Traditional_Chinese_medicine" title="Category:Traditional Chinese medicine">Traditional Chinese medicine</a></span></p></div> <!-- end content -->
<div class="visualClear"></div>
</div>
</div>
</div>
<div id="column-one">
<div id="p-cactions" class="portlet">
<h5>Views</h5>
<ul>
<li id="ca-nstab-main" class="selected"><a href="/wiki/Tai_Chi_Chuan">Article</a></li>
<li id="ca-talk"><a href="/wiki/Talk:Tai_Chi_Chuan">Discussion</a></li>
<li id="ca-edit"><a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=edit">Edit this page</a></li>
<li id="ca-history"><a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=history">History</a></li>
<li id="ca-protect"><a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=protect">Protect</a></li>
<li id="ca-delete"><a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=delete">Delete</a></li>
<li id="ca-move"><a href="/w/index.php?title=Special:Movepage&amp;target=Tai_Chi_Chuan">Move</a></li>
<li id="ca-unwatch"><a href="/w/index.php?title=Tai_Chi_Chuan&amp;action=unwatch">Unwatch</a></li>
</ul>
</div>
<div class="portlet" id="p-personal">
<h5>Personal tools</h5>
<div class="pBody">
<ul>
<li id="pt-userpage"><a href="/wiki/User:Edward_Z._Yang">Edward Z. Yang</a></li>
<li id="pt-mytalk"><a href="/wiki/User_talk:Edward_Z._Yang">My talk</a></li>
<li id="pt-preferences"><a href="/wiki/Special:Preferences">My preferences</a></li>
<li id="pt-watchlist"><a href="/wiki/Special:Watchlist">My watchlist</a></li>
<li id="pt-mycontris"><a href="/wiki/Special:Contributions/Edward_Z._Yang">My contributions</a></li>
<li id="pt-logout"><a href="/w/index.php?title=Special:Userlogout&amp;returnto=Tai_Chi_Chuan">Log out</a></li>
</ul>
</div>
</div>
<div class="portlet" id="p-logo">
<a style="background-image: url(/images/wiki-en.png);" href="/wiki/Main_Page" title="Main Page"></a>
</div>
<script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
<div class='portlet' id='p-navigation'>
<h5>Navigation</h5>
<div class='pBody'>
<ul>
<li id="n-mainpage"><a href="/wiki/Main_Page">Main Page</a></li>
<li id="n-portal"><a href="/wiki/Wikipedia:Community_Portal">Community Portal</a></li>
<li id="n-Featured-articles"><a href="/wiki/Wikipedia:Featured_articles">Featured articles</a></li>
<li id="n-currentevents"><a href="/wiki/Portal:Current_events">Current events</a></li>
<li id="n-recentchanges"><a href="/wiki/Special:Recentchanges">Recent changes</a></li>
<li id="n-randompage"><a href="/wiki/Special:Random">Random article</a></li>
<li id="n-help"><a href="/wiki/Help:Contents">Help</a></li>
<li id="n-contact"><a href="/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li>
<li id="n-sitesupport"><a href="http://wikimediafoundation.org/wiki/Fundraising#Donation_methods">Donations</a></li>
</ul>
</div>
</div>
<div id="p-search" class="portlet">
<h5><label for="searchInput">Search</label></h5>
<div id="searchBody" class="pBody">
<form action="/wiki/Special:Search" id="searchform"><div>
<input id="searchInput" name="search" type="text" accesskey="f" value="" />
<input type='submit' name="go" class="searchButton" id="searchGoButton" value="Go" />&nbsp;
<input type='submit' name="fulltext" class="searchButton" value="Search" />
</div></form>
</div>
</div>
<div class="portlet" id="p-tb">
<h5>Toolbox</h5>
<div class="pBody">
<ul>
<li id="t-whatlinkshere"><a href="/w/index.php?title=Special:Whatlinkshere&amp;target=Tai_Chi_Chuan">What links here</a></li>
<li id="t-recentchangeslinked"><a href="/w/index.php?title=Special:Recentchangeslinked&amp;target=Tai_Chi_Chuan">Related changes</a></li>
<li id="t-upload"><a href="/wiki/Special:Upload">Upload file</a></li>
<li id="t-specialpages"><a href="/wiki/Special:Specialpages">Special pages</a></li>
<li id="t-print"><a href="/w/index.php?title=Tai_Chi_Chuan&amp;printable=yes">Printable version</a></li> <li id="t-permalink"><a href="/w/index.php?title=Tai_Chi_Chuan&amp;oldid=65197836">Permanent link</a></li><li id="t-cite"><a href="/w/index.php?title=Special:Cite&amp;page=Tai_Chi_Chuan&amp;id=65197836">Cite this article</a></li> </ul>
</div>
</div>
<div id="p-lang" class="portlet">
<h5>In other languages</h5>
<div class="pBody">
<ul>
<li class="interwiki-br"><a href="http://br.wikipedia.org/wiki/Taichichuan">Brezhoneg</a></li>
<li class="interwiki-ca"><a href="http://ca.wikipedia.org/wiki/Tai_txi_txuan">Català</a></li>
<li class="interwiki-cs"><a href="http://cs.wikipedia.org/wiki/Tchaj-%C5%A5i">Cesky</a></li>
<li class="interwiki-da"><a href="http://da.wikipedia.org/wiki/Tai_Chi">Dansk</a></li>
<li class="interwiki-de"><a href="http://de.wikipedia.org/wiki/Taijiquan">Deutsch</a></li>
<li class="interwiki-et"><a href="http://et.wikipedia.org/wiki/Taijiquan">Eesti</a></li>
<li class="interwiki-el"><a href="http://el.wikipedia.org/wiki/%CE%A4%CE%AC%CE%B9_%CE%A4%CE%B6%CE%AF_%CE%A3%CE%BF%CF%85%CE%AC%CE%BD">????????</a></li>
<li class="interwiki-es"><a href="http://es.wikipedia.org/wiki/Tai_Chi_Chuan">Español</a></li>
<li class="interwiki-eo"><a href="http://eo.wikipedia.org/wiki/Taj%C4%9Di%C4%89uano">Esperanto</a></li>
<li class="interwiki-fr"><a href="http://fr.wikipedia.org/wiki/Tai-chi-chuan">Français</a></li>
<li class="interwiki-it"><a href="http://it.wikipedia.org/wiki/Taijiquan">Italiano</a></li>
<li class="interwiki-he"><a href="http://he.wikipedia.org/wiki/%D7%98%D7%90%D7%99_%D7%A6%27%D7%99">?????</a></li>
<li class="interwiki-hu"><a href="http://hu.wikipedia.org/wiki/Taijiquan">Magyar</a></li>
<li class="interwiki-nl"><a href="http://nl.wikipedia.org/wiki/Tai_Chi">Nederlands</a></li>
<li class="interwiki-ja"><a href="http://ja.wikipedia.org/wiki/%E5%A4%AA%E6%A5%B5%E6%8B%B3">???</a></li>
<li class="interwiki-pl"><a href="http://pl.wikipedia.org/wiki/Taijiquan">Polski</a></li>
<li class="interwiki-pt"><a href="http://pt.wikipedia.org/wiki/Tai_Chi_Chuan">Português</a></li>
<li class="interwiki-ro"><a href="http://ro.wikipedia.org/wiki/Taijiquan">Româna</a></li>
<li class="interwiki-ru"><a href="http://ru.wikipedia.org/wiki/%D0%A2%D0%B0%D0%B9%D1%86%D0%B7%D0%B8%D1%86%D1%8E%D0%B0%D0%BD%D1%8C">???????</a></li>
<li class="interwiki-fi"><a href="http://fi.wikipedia.org/wiki/Taijiquan">Suomi</a></li>
<li class="interwiki-sv"><a href="http://sv.wikipedia.org/wiki/Taijiquan">Svenska</a></li>
<li class="interwiki-th"><a href="http://th.wikipedia.org/wiki/%E0%B9%84%E0%B8%97%E0%B9%88%E0%B9%80%E0%B8%81%E0%B9%8A%E0%B8%81">???</a></li>
<li class="interwiki-tr"><a href="http://tr.wikipedia.org/wiki/Tai-Chi_Chuan">Türkçe</a></li>
<li class="interwiki-zh"><a href="http://zh.wikipedia.org/wiki/%E5%A4%AA%E6%9E%81%E6%8B%B3">??</a></li>
</ul>
</div>
</div>
</div><!-- end of the left (by default at least) column -->
<div class="visualClear"></div>
<div id="footer">
<div id="f-poweredbyico"><a href="http://www.mediawiki.org/"><img src="/skins-1.5/common/images/poweredby_mediawiki_88x31.png" alt="MediaWiki" /></a></div>
<div id="f-copyrightico"><a href="http://wikimediafoundation.org/"><img src="/images/wikimedia-button.png" border="0" alt="Wikimedia Foundation"/></a></div>
<ul id="f-list">
<li id="lastmod"> This page was last modified 03:15, July 22, 2006.</li>
<li id="copyright">All text is available under the terms of the <a class='internal' href="/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License" title="Wikipedia:Text of the GNU Free Documentation License">GNU Free Documentation License</a>. (See <b><a class='internal' href="/wiki/Wikipedia:Copyrights" title="Wikipedia:Copyrights">Copyrights</a></b> for details.) <br /> Wikipedia&reg; is a registered trademark of the Wikimedia Foundation, Inc.<br /></li>
<li id="privacy"><a href="http://wikimediafoundation.org/wiki/Privacy_policy" title="wikimedia:Privacy policy">Privacy policy</a></li>
<li id="about"><a href="/wiki/Wikipedia:About" title="Wikipedia:About">About Wikipedia</a></li>
<li id="disclaimer"><a href="/wiki/Wikipedia:General_disclaimer" title="Wikipedia:General disclaimer">Disclaimers</a></li>
</ul>
</div>
<script type="text/javascript"> if (window.runOnloadHook) runOnloadHook();</script>
</div>
<!-- Served by srv25 in 0.089 secs. -->
</body></html>
<!-- vim: et sw=4 sts=4
-->

View file

@ -1,7 +0,0 @@
Disclaimer:
The HTML used in these samples are taken from random websites. I claim
no copyright over these and assert that I may use them like this under
fair use.
vim: et sw=4 sts=4

View file

@ -1,64 +0,0 @@
<?php
/**
* Generates XML and HTML documents describing configuration.
* @note PHP 5.2+ only!
*/
/*
TODO:
- make XML format richer
- extend XSLT transformation (see the corresponding XSLT file)
- allow generation of packaged docs that can be easily moved
- multipage documentation
- determine how to multilingualize
- add blurbs to ToC
*/
if (version_compare(PHP_VERSION, '5.2', '<')) exit('PHP 5.2+ required.');
error_reporting(E_ALL | E_STRICT);
// load dual-libraries
require_once dirname(__FILE__) . '/../extras/HTMLPurifierExtras.auto.php';
require_once dirname(__FILE__) . '/../library/HTMLPurifier.auto.php';
// setup HTML Purifier singleton
HTMLPurifier::getInstance(array(
'AutoFormat.PurifierLinkify' => true
));
$builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
$interchange = new HTMLPurifier_ConfigSchema_Interchange();
$builder->buildDir($interchange);
$loader = dirname(__FILE__) . '/../config-schema.php';
if (file_exists($loader)) include $loader;
$interchange->validate();
$style = 'plain'; // use $_GET in the future, careful to validate!
$configdoc_xml = dirname(__FILE__) . '/configdoc.xml';
$xml_builder = new HTMLPurifier_ConfigSchema_Builder_Xml();
$xml_builder->openURI($configdoc_xml);
$xml_builder->build($interchange);
unset($xml_builder); // free handle
$xslt = new ConfigDoc_HTMLXSLTProcessor();
$xslt->importStylesheet(dirname(__FILE__) . "/styles/$style.xsl");
$output = $xslt->transformToHTML($configdoc_xml);
if (!$output) {
echo "Error in generating files\n";
exit(1);
}
// write out
file_put_contents(dirname(__FILE__) . "/$style.html", $output);
if (php_sapi_name() != 'cli') {
// output (instant feedback if it's a browser)
echo $output;
} else {
echo "Files generated successfully.\n";
}
// vim: et sw=4 sts=4

View file

@ -1,44 +0,0 @@
body {margin:0;padding:0;}
#content {
margin:1em auto;
max-width: 47em;
width: expression(document.body.clientWidth >
85 * parseInt(document.body.currentStyle.fontSize) ?
"54em": "auto");
}
table {border-collapse:collapse;}
table td, table th {padding:0.2em;}
table.constraints {margin:0 0 1em;}
table.constraints th {
text-align:right;padding-left:0.4em;padding-right:0.4em;background:#EEE;
width:8em;vertical-align:top;}
table.constraints td {padding-right:0.4em; padding-left: 1em;}
table.constraints td ul {padding:0; margin:0; list-style:none;}
table.constraints td pre {margin:0;}
#tocContainer {position:relative;}
#toc {list-style-type:none; font-weight:bold; font-size:1em; margin-bottom:1em;}
#toc li {position:relative; line-height: 1.2em;}
#toc .col-2 {margin-left:50%;}
#toc .col-l {float:left;}
#toc ul {list-style-type:disc; font-weight:normal; padding-bottom:1.2em;}
.description p {margin-top:0;margin-bottom:1em;}
#library, h1 {text-align:center; font-family:Garamond, serif;
font-variant:small-caps;}
#library {font-size:1em;}
h1 {margin-top:0;}
h2 {border-bottom:1px solid #CCC; font-family:sans-serif; font-weight:normal;
font-size:1.3em; clear:both;}
h3 {font-family:sans-serif; font-size:1.1em; font-weight:bold; }
h4 {font-family:sans-serif; font-size:0.9em; font-weight:bold; }
.deprecated {color: #CCC;}
.deprecated table.constraints th {background:#FFF;}
.deprecated-notice {color: #000; text-align:center; margin-bottom: 1em;}
/* vim: et sw=4 sts=4 */

View file

@ -1,253 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version = "1.0"
xmlns = "http://www.w3.org/1999/xhtml"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
>
<xsl:output
method = "xml"
encoding = "UTF-8"
doctype-public = "-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
indent = "no"
media-type = "text/html"
/>
<xsl:param name="css" select="'styles/plain.css'"/>
<xsl:param name="title" select="'Configuration Documentation'"/>
<xsl:variable name="typeLookup" select="document('../types.xml')/types" />
<xsl:variable name="usageLookup" select="document('../usage.xml')/usage" />
<!-- Twiddle this variable to get the columns as even as possible -->
<xsl:variable name="maxNumberAdjust" select="2" />
<xsl:template match="/">
<html lang="en" xml:lang="en">
<head>
<title><xsl:value-of select="$title" /> - <xsl:value-of select="/configdoc/title" /></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="{$css}" />
</head>
<body>
<div id="content">
<div id="library"><xsl:value-of select="/configdoc/title" /></div>
<h1><xsl:value-of select="$title" /></h1>
<div id="tocContainer">
<h2>Table of Contents</h2>
<ul id="toc">
<xsl:apply-templates mode="toc">
<xsl:with-param name="overflowNumber" select="round(count(/configdoc/namespace) div 2) + $maxNumberAdjust" />
</xsl:apply-templates>
</ul>
</div>
<div id="typesContainer">
<h2>Types</h2>
<xsl:apply-templates select="$typeLookup" mode="types" />
</div>
<xsl:apply-templates />
</div>
</body>
</html>
</xsl:template>
<xsl:template match="type" mode="types">
<div class="type-block">
<xsl:attribute name="id">type-<xsl:value-of select="@id" /></xsl:attribute>
<h3><code><xsl:value-of select="@id" /></code>: <xsl:value-of select="@name" /></h3>
<div class="type-description">
<xsl:copy-of xmlns:xhtml="http://www.w3.org/1999/xhtml" select="xhtml:div/node()" />
</div>
</div>
</xsl:template>
<xsl:template match="title" mode="toc" />
<xsl:template match="namespace" mode="toc">
<xsl:param name="overflowNumber" />
<xsl:variable name="number"><xsl:number level="single" /></xsl:variable>
<xsl:variable name="directiveNumber"><xsl:number level="any" count="directive" /></xsl:variable>
<xsl:if test="count(directive)&gt;0">
<li>
<!-- BEGIN multicolumn code -->
<xsl:if test="$number &gt;= $overflowNumber">
<xsl:attribute name="class">col-2</xsl:attribute>
</xsl:if>
<xsl:if test="$number = $overflowNumber">
<xsl:attribute name="style">margin-top:-<xsl:value-of select="($number * 2 + $directiveNumber - 3) * 1.2" />em</xsl:attribute>
</xsl:if>
<!-- END multicolumn code -->
<a href="#{@id}"><xsl:value-of select="name" /></a>
<ul>
<xsl:apply-templates select="directive" mode="toc">
<xsl:with-param name="overflowNumber" select="$overflowNumber" />
</xsl:apply-templates>
</ul>
<xsl:if test="$number + 1 = $overflowNumber">
<div class="col-l" />
</xsl:if>
</li>
</xsl:if>
</xsl:template>
<xsl:template match="directive" mode="toc">
<xsl:variable name="number">
<xsl:number level="any" count="directive|namespace" />
</xsl:variable>
<xsl:if test="not(deprecated)">
<li>
<a href="#{@id}"><xsl:value-of select="name" /></a>
</li>
</xsl:if>
</xsl:template>
<xsl:template match="title" />
<xsl:template match="namespace">
<div class="namespace">
<xsl:apply-templates />
<xsl:if test="count(directive)=0">
<p>No configuration directives defined for this namespace.</p>
</xsl:if>
</div>
</xsl:template>
<xsl:template match="namespace/name">
<h2 id="{../@id}"><xsl:value-of select="." /></h2>
</xsl:template>
<xsl:template match="namespace/description">
<div class="description">
<xsl:copy-of xmlns:xhtml="http://www.w3.org/1999/xhtml" select="xhtml:div/node()" />
</div>
</xsl:template>
<xsl:template match="directive">
<div>
<xsl:attribute name="class"><!--
-->directive<!--
--><xsl:if test="deprecated"> deprecated</xsl:if><!--
--></xsl:attribute>
<xsl:apply-templates>
<xsl:with-param name="id" select="@id" />
</xsl:apply-templates>
</div>
</xsl:template>
<xsl:template match="directive/name">
<xsl:param name="id" />
<xsl:apply-templates select="../aliases/alias" mode="anchor" />
<h3 id="{$id}"><xsl:value-of select="$id" /></h3>
</xsl:template>
<xsl:template match="alias" mode="anchor">
<a id="{.}"></a>
</xsl:template>
<!-- Do not pass through -->
<xsl:template match="alias"></xsl:template>
<xsl:template match="directive/constraints">
<xsl:param name="id" />
<table class="constraints">
<xsl:apply-templates />
<xsl:if test="../aliases/alias">
<xsl:apply-templates select="../aliases" mode="constraints" />
</xsl:if>
<xsl:apply-templates select="$usageLookup/directive[@id=$id]" />
</table>
</xsl:template>
<xsl:template match="directive/aliases" mode="constraints">
<tr>
<th>Aliases</th>
<td>
<xsl:for-each select="alias">
<xsl:if test="position()&gt;1">, </xsl:if>
<xsl:value-of select="." />
</xsl:for-each>
</td>
</tr>
</xsl:template>
<xsl:template match="directive/description">
<div class="description">
<xsl:copy-of xmlns:xhtml="http://www.w3.org/1999/xhtml" select="xhtml:div/node()" />
</div>
</xsl:template>
<xsl:template match="directive/deprecated">
<div class="deprecated-notice">
<strong>Warning:</strong>
This directive was deprecated in version <xsl:value-of select="version" />.
<a href="#{use}">%<xsl:value-of select="use" /></a> should be used instead.
</div>
</xsl:template>
<xsl:template match="usage/directive">
<tr>
<th>Used in</th>
<td>
<ul>
<xsl:apply-templates />
</ul>
</td>
</tr>
</xsl:template>
<xsl:template match="usage/directive/file">
<li>
<em><xsl:value-of select="@name" /></em> on line<xsl:if test="count(line)&gt;1">s</xsl:if>
<xsl:text> </xsl:text>
<xsl:for-each select="line">
<xsl:if test="position()&gt;1">, </xsl:if>
<xsl:value-of select="." />
</xsl:for-each>
</li>
</xsl:template>
<xsl:template match="constraints/version">
<tr>
<th>Version added</th>
<td><xsl:value-of select="." /></td>
</tr>
</xsl:template>
<xsl:template match="constraints/type">
<tr>
<th>Type</th>
<td>
<xsl:variable name="type" select="text()" />
<xsl:attribute name="class">type type-<xsl:value-of select="$type" /></xsl:attribute>
<a>
<xsl:attribute name="href">#type-<xsl:value-of select="$type" /></xsl:attribute>
<xsl:value-of select="$typeLookup/type[@id=$type]/@name" />
<xsl:if test="@allow-null='yes'">
(or null)
</xsl:if>
</a>
</td>
</tr>
</xsl:template>
<xsl:template match="constraints/allowed">
<tr>
<th>Allowed values</th>
<td>
<xsl:for-each select="value"><!--
--><xsl:if test="position()&gt;1">, </xsl:if>
&quot;<xsl:value-of select="." />&quot;<!--
--></xsl:for-each>
</td>
</tr>
</xsl:template>
<xsl:template match="constraints/default">
<tr>
<th>Default</th>
<td><pre><xsl:value-of select="." xml:space="preserve" /></pre></td>
</tr>
</xsl:template>
<xsl:template match="constraints/external">
<tr>
<th>External deps</th>
<td>
<ul>
<xsl:apply-templates />
</ul>
</td>
</tr>
</xsl:template>
<xsl:template match="constraints/external/project">
<li><xsl:value-of select="." /></li>
</xsl:template>
</xsl:stylesheet>
<!-- vim: et sw=4 sts=4
-->

View file

@ -1,69 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<types>
<type id="string" name="String"><div xmlns="http://www.w3.org/1999/xhtml">
A <a
href="http://docs.php.net/manual/en/language.types.string.php">sequence
of characters</a>.
</div></type>
<type id="istring" name="Case-insensitive string"><div xmlns="http://www.w3.org/1999/xhtml">
A series of case-insensitive characters. Internally, upper-case
ASCII characters will be converted to lower-case.
</div></type>
<type id="text" name="Text"><div xmlns="http://www.w3.org/1999/xhtml">
A series of characters that may contain newlines. Text tends to
indicate human-oriented text, as opposed to a machine format.
</div></type>
<type id="itext" name="Case-insensitive text"><div xmlns="http://www.w3.org/1999/xhtml">
A series of case-insensitive characters that may contain newlines.
</div></type>
<type id="int" name="Integer"><div xmlns="http://www.w3.org/1999/xhtml">
An <a
href="http://docs.php.net/manual/en/language.types.integer.php">
integer</a>. You are alternatively permitted to pass a string of
digits instead, which will be cast to an integer using
<code>(int)</code>.
</div></type>
<type id="float" name="Float"><div xmlns="http://www.w3.org/1999/xhtml">
A <a href="http://docs.php.net/manual/en/language.types.float.php">
floating point number</a>. You are alternatively permitted to
pass a numeric string (as defined by <code>is_numeric()</code>),
which will be cast to a float using <code>(float)</code>.
</div></type>
<type id="bool" name="Boolean"><div xmlns="http://www.w3.org/1999/xhtml">
A <a
href="http://docs.php.net/manual/en/language.types.boolean.php">boolean</a>.
You are alternatively permitted to pass an integer <code>0</code> or
<code>1</code> (other integers are not permitted) or a string
<code>"on"</code>, <code>"true"</code> or <code>"1"</code> for
<code>true</code>, and <code>"off"</code>, <code>"false"</code> or
<code>"0"</code> for <code>false</code>.
</div></type>
<type id="lookup" name="Lookup array"><div xmlns="http://www.w3.org/1999/xhtml">
An array whose values are <code>true</code>, e.g. <code>array('key'
=> true, 'key2' => true)</code>. You are alternatively permitted
to pass an array list of the keys <code>array('key', 'key2')</code>
or a comma-separated string of keys <code>"key, key2"</code>. If
you pass an array list of values, ensure that your values are
strictly numerically indexed: <code>array('key1', 2 =>
'key2')</code> will not do what you expect and emits a warning.
</div></type>
<type id="list" name="Array list"><div xmlns="http://www.w3.org/1999/xhtml">
An array which has consecutive integer indexes, e.g.
<code>array('val1', 'val2')</code>. You are alternatively permitted
to pass a comma-separated string of keys <code>"val1, val2"</code>.
If your array is not in this form, <code>array_values</code> is run
on the array and a warning is emitted.
</div></type>
<type id="hash" name="Associative array"><div xmlns="http://www.w3.org/1999/xhtml">
An array which is a mapping of keys to values, e.g.
<code>array('key1' => 'val1', 'key2' => 'val2')</code>. You are
alternatively permitted to pass a comma-separated string of
key-colon-value strings, e.g. <code>"key1: val1, key2: val2"</code>.
</div></type>
<type id="mixed" name="Mixed"><div xmlns="http://www.w3.org/1999/xhtml">
An arbitrary PHP value of any type.
</div></type>
</types>
<!-- vim: et sw=4 sts=4
-->

View file

@ -1,534 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<usage>
<directive id="Core.CollectErrors">
<file name="HTMLPurifier.php">
<line>131</line>
</file>
<file name="HTMLPurifier/Lexer.php">
<line>81</line>
<line>284</line>
</file>
<file name="HTMLPurifier/Lexer/DirectLex.php">
<line>53</line>
<line>73</line>
<line>348</line>
</file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>50</line>
</file>
</directive>
<directive id="CSS.MaxImgLength">
<file name="HTMLPurifier/CSSDefinition.php">
<line>157</line>
</file>
</directive>
<directive id="CSS.Proprietary">
<file name="HTMLPurifier/CSSDefinition.php">
<line>214</line>
</file>
</directive>
<directive id="CSS.AllowTricky">
<file name="HTMLPurifier/CSSDefinition.php">
<line>218</line>
</file>
</directive>
<directive id="CSS.Trusted">
<file name="HTMLPurifier/CSSDefinition.php">
<line>222</line>
</file>
</directive>
<directive id="CSS.AllowImportant">
<file name="HTMLPurifier/CSSDefinition.php">
<line>226</line>
</file>
</directive>
<directive id="CSS.AllowedProperties">
<file name="HTMLPurifier/CSSDefinition.php">
<line>296</line>
</file>
</directive>
<directive id="CSS.ForbiddenProperties">
<file name="HTMLPurifier/CSSDefinition.php">
<line>310</line>
</file>
</directive>
<directive id="Cache.DefinitionImpl">
<file name="HTMLPurifier/DefinitionCacheFactory.php">
<line>49</line>
</file>
</directive>
<directive id="HTML.Doctype">
<file name="HTMLPurifier/DoctypeRegistry.php">
<line>83</line>
</file>
</directive>
<directive id="HTML.CustomDoctype">
<file name="HTMLPurifier/DoctypeRegistry.php">
<line>85</line>
</file>
</directive>
<directive id="HTML.XHTML">
<file name="HTMLPurifier/DoctypeRegistry.php">
<line>88</line>
</file>
</directive>
<directive id="HTML.Strict">
<file name="HTMLPurifier/DoctypeRegistry.php">
<line>93</line>
</file>
</directive>
<directive id="Core.Encoding">
<file name="HTMLPurifier/Encoder.php">
<line>337</line>
<line>367</line>
</file>
</directive>
<directive id="Test.ForceNoIconv">
<file name="HTMLPurifier/Encoder.php">
<line>341</line>
<line>374</line>
</file>
</directive>
<directive id="Core.EscapeNonASCIICharacters">
<file name="HTMLPurifier/Encoder.php">
<line>368</line>
</file>
</directive>
<directive id="Output.CommentScriptContents">
<file name="HTMLPurifier/Generator.php">
<line>61</line>
</file>
</directive>
<directive id="Output.FixInnerHTML">
<file name="HTMLPurifier/Generator.php">
<line>62</line>
</file>
</directive>
<directive id="Output.SortAttr">
<file name="HTMLPurifier/Generator.php">
<line>63</line>
</file>
</directive>
<directive id="Output.FlashCompat">
<file name="HTMLPurifier/Generator.php">
<line>64</line>
</file>
</directive>
<directive id="Output.TidyFormat">
<file name="HTMLPurifier/Generator.php">
<line>93</line>
</file>
</directive>
<directive id="Core.NormalizeNewlines">
<file name="HTMLPurifier/Generator.php">
<line>107</line>
</file>
<file name="HTMLPurifier/Lexer.php">
<line>266</line>
</file>
</directive>
<directive id="Output.Newline">
<file name="HTMLPurifier/Generator.php">
<line>108</line>
</file>
</directive>
<directive id="HTML.BlockWrapper">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>222</line>
</file>
</directive>
<directive id="HTML.Parent">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>230</line>
</file>
</directive>
<directive id="HTML.AllowedElements">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>247</line>
</file>
</directive>
<directive id="HTML.AllowedAttributes">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>248</line>
</file>
</directive>
<directive id="HTML.Allowed">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>251</line>
</file>
</directive>
<directive id="HTML.ForbiddenElements">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>342</line>
</file>
</directive>
<directive id="HTML.ForbiddenAttributes">
<file name="HTMLPurifier/HTMLDefinition.php">
<line>343</line>
</file>
</directive>
<directive id="HTML.Trusted">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>204</line>
</file>
<file name="HTMLPurifier/Lexer.php">
<line>271</line>
</file>
<file name="HTMLPurifier/HTMLModule/Image.php">
<line>27</line>
</file>
<file name="HTMLPurifier/Lexer/DirectLex.php">
<line>36</line>
</file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>23</line>
</file>
</directive>
<directive id="HTML.AllowedModules">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>211</line>
</file>
</directive>
<directive id="HTML.CoreModules">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>212</line>
</file>
</directive>
<directive id="HTML.Proprietary">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>222</line>
</file>
</directive>
<directive id="HTML.SafeObject">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>225</line>
</file>
</directive>
<directive id="HTML.SafeEmbed">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>228</line>
</file>
</directive>
<directive id="HTML.Nofollow">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>231</line>
</file>
</directive>
<directive id="HTML.TargetBlank">
<file name="HTMLPurifier/HTMLModuleManager.php">
<line>234</line>
</file>
</directive>
<directive id="Attr.IDBlacklist">
<file name="HTMLPurifier/IDAccumulator.php">
<line>26</line>
</file>
</directive>
<directive id="Core.Language">
<file name="HTMLPurifier/LanguageFactory.php">
<line>88</line>
</file>
</directive>
<directive id="Core.LexerImpl">
<file name="HTMLPurifier/Lexer.php">
<line>76</line>
</file>
</directive>
<directive id="Core.MaintainLineNumbers">
<file name="HTMLPurifier/Lexer.php">
<line>80</line>
</file>
<file name="HTMLPurifier/Lexer/DirectLex.php">
<line>48</line>
</file>
</directive>
<directive id="Core.ConvertDocumentToFragment">
<file name="HTMLPurifier/Lexer.php">
<line>282</line>
</file>
</directive>
<directive id="Core.RemoveProcessingInstructions">
<file name="HTMLPurifier/Lexer.php">
<line>303</line>
</file>
</directive>
<directive id="URI.">
<file name="HTMLPurifier/URIDefinition.php">
<line>59</line>
</file>
<file name="HTMLPurifier/URIFilter/Munge.php">
<line>12</line>
</file>
</directive>
<directive id="URI.Host">
<file name="HTMLPurifier/URIDefinition.php">
<line>69</line>
</file>
<file name="HTMLPurifier/URIScheme.php">
<line>81</line>
</file>
</directive>
<directive id="URI.Base">
<file name="HTMLPurifier/URIDefinition.php">
<line>70</line>
</file>
</directive>
<directive id="URI.DefaultScheme">
<file name="HTMLPurifier/URIDefinition.php">
<line>77</line>
</file>
</directive>
<directive id="URI.AllowedSchemes">
<file name="HTMLPurifier/URISchemeRegistry.php">
<line>41</line>
</file>
</directive>
<directive id="URI.OverrideAllowedSchemes">
<file name="HTMLPurifier/URISchemeRegistry.php">
<line>42</line>
</file>
</directive>
<directive id="URI.Disable">
<file name="HTMLPurifier/AttrDef/URI.php">
<line>28</line>
</file>
</directive>
<directive id="Core.ColorKeywords">
<file name="HTMLPurifier/AttrDef/CSS/Color.php">
<line>12</line>
</file>
<file name="HTMLPurifier/AttrDef/HTML/Color.php">
<line>12</line>
</file>
</directive>
<directive id="CSS.AllowedFonts">
<file name="HTMLPurifier/AttrDef/CSS/FontFamily.php">
<line>50</line>
</file>
</directive>
<directive id="Attr.AllowedClasses">
<file name="HTMLPurifier/AttrDef/HTML/Class.php">
<line>18</line>
</file>
</directive>
<directive id="Attr.ForbiddenClasses">
<file name="HTMLPurifier/AttrDef/HTML/Class.php">
<line>19</line>
</file>
</directive>
<directive id="Attr.AllowedFrameTargets">
<file name="HTMLPurifier/AttrDef/HTML/FrameTarget.php">
<line>15</line>
</file>
</directive>
<directive id="Attr.EnableID">
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>30</line>
</file>
</directive>
<directive id="Attr.IDPrefix">
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>36</line>
</file>
</directive>
<directive id="Attr.IDPrefixLocal">
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>38</line>
<line>41</line>
</file>
</directive>
<directive id="Attr.IDBlacklistRegexp">
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>64</line>
</file>
</directive>
<directive id="Attr.">
<file name="HTMLPurifier/AttrDef/HTML/LinkTypes.php">
<line>30</line>
</file>
</directive>
<directive id="Core.EnableIDNA">
<file name="HTMLPurifier/AttrDef/URI/Host.php">
<line>67</line>
</file>
</directive>
<directive id="Attr.DefaultTextDir">
<file name="HTMLPurifier/AttrTransform/BdoDir.php">
<line>13</line>
</file>
</directive>
<directive id="Core.RemoveInvalidImg">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>18</line>
</file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>20</line>
</file>
</directive>
<directive id="Attr.DefaultInvalidImage">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>19</line>
</file>
</directive>
<directive id="Attr.DefaultImageAlt">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>25</line>
</file>
</directive>
<directive id="Attr.DefaultInvalidImageAlt">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>33</line>
</file>
</directive>
<directive id="HTML.Attr.Name.UseCDATA">
<file name="HTMLPurifier/AttrTransform/Name.php">
<line>11</line>
</file>
<file name="HTMLPurifier/HTMLModule/Name.php">
<line>13</line>
</file>
</directive>
<directive id="HTML.FlashAllowFullScreen">
<file name="HTMLPurifier/AttrTransform/SafeParam.php">
<line>38</line>
</file>
</directive>
<directive id="Core.EscapeInvalidChildren">
<file name="HTMLPurifier/ChildDef/Required.php">
<line>62</line>
</file>
</directive>
<directive id="Cache.SerializerPath">
<file name="HTMLPurifier/DefinitionCache/Serializer.php">
<line>91</line>
</file>
</directive>
<directive id="Cache.SerializerPermissions">
<file name="HTMLPurifier/DefinitionCache/Serializer.php">
<line>107</line>
<line>124</line>
</file>
</directive>
<directive id="Filter.ExtractStyleBlocks.TidyImpl">
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
<line>54</line>
</file>
</directive>
<directive id="Filter.ExtractStyleBlocks.Scope">
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
<line>78</line>
</file>
</directive>
<directive id="Filter.ExtractStyleBlocks.Escaping">
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
<line>276</line>
</file>
</directive>
<directive id="HTML.SafeIframe">
<file name="HTMLPurifier/HTMLModule/Iframe.php">
<line>17</line>
</file>
<file name="HTMLPurifier/URIFilter/SafeIframe.php">
<line>23</line>
</file>
</directive>
<directive id="HTML.MaxImgLength">
<file name="HTMLPurifier/HTMLModule/Image.php">
<line>14</line>
</file>
<file name="HTMLPurifier/HTMLModule/SafeEmbed.php">
<line>13</line>
</file>
<file name="HTMLPurifier/HTMLModule/SafeObject.php">
<line>19</line>
</file>
</directive>
<directive id="HTML.TidyLevel">
<file name="HTMLPurifier/HTMLModule/Tidy.php">
<line>45</line>
</file>
</directive>
<directive id="HTML.TidyAdd">
<file name="HTMLPurifier/HTMLModule/Tidy.php">
<line>49</line>
</file>
</directive>
<directive id="HTML.TidyRemove">
<file name="HTMLPurifier/HTMLModule/Tidy.php">
<line>50</line>
</file>
</directive>
<directive id="AutoFormat.PurifierLinkify.DocURL">
<file name="HTMLPurifier/Injector/PurifierLinkify.php">
<line>15</line>
</file>
</directive>
<directive id="AutoFormat.RemoveEmpty.RemoveNbsp">
<file name="HTMLPurifier/Injector/RemoveEmpty.php">
<line>12</line>
</file>
</directive>
<directive id="AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions">
<file name="HTMLPurifier/Injector/RemoveEmpty.php">
<line>13</line>
</file>
</directive>
<directive id="Core.AggressivelyFixLt">
<file name="HTMLPurifier/Lexer/DOMLex.php">
<line>44</line>
</file>
</directive>
<directive id="Core.DirectLexLineNumberSyncInterval">
<file name="HTMLPurifier/Lexer/DirectLex.php">
<line>70</line>
</file>
</directive>
<directive id="Core.EscapeInvalidTags">
<file name="HTMLPurifier/Strategy/MakeWellFormed.php">
<line>53</line>
</file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>19</line>
</file>
</directive>
<directive id="HTML.AllowedComments">
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>24</line>
</file>
</directive>
<directive id="HTML.AllowedCommentsRegexp">
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>25</line>
</file>
</directive>
<directive id="Core.RemoveScriptContents">
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>28</line>
</file>
</directive>
<directive id="Core.HiddenElements">
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>29</line>
</file>
</directive>
<directive id="URI.HostBlacklist">
<file name="HTMLPurifier/URIFilter/HostBlacklist.php">
<line>12</line>
</file>
</directive>
<directive id="URI.MungeResources">
<file name="HTMLPurifier/URIFilter/Munge.php">
<line>14</line>
</file>
</directive>
<directive id="URI.MungeSecretKey">
<file name="HTMLPurifier/URIFilter/Munge.php">
<line>15</line>
</file>
</directive>
<directive id="URI.SafeIframeRegexp">
<file name="HTMLPurifier/URIFilter/SafeIframe.php">
<line>18</line>
</file>
</directive>
</usage>

View file

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Specification for HTML Purifier's advanced API for defining custom filtering behavior." />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Advanced API - HTML Purifier</title>
</head><body>
<h1>Advanced API</h1>
<div id="filing">Filed under Development</div>
<div id="index">Return to the <a href="index.html">index</a>.</div>
<div id="home"><a href="http://htmlpurifier.org/">HTML Purifier</a> End-User Documentation</div>
<p>
Please see <a href="enduser-customize.html">Customize!</a>
</p>
</body></html>
<!-- vim: et sw=4 sts=4
-->

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