issue 2109 Fixed a problem in_array function

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10832 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2012-07-05 00:16:31 +00:00
parent e1ae5aab97
commit 1a7a68efea
18 changed files with 52 additions and 30 deletions

View file

@ -362,7 +362,8 @@ class Context {
function checkSSO() {
// pass if it's not GET request or XE is not yet installed
if($this->db_info->use_sso != 'Y' || isCrawler()) return true;
if(Context::getRequestMethod()!='GET' || !Context::isInstalled() || in_array(Context::get('act'),array('rss','atom'))) return true;
$checkActList = array('rss'=>1, 'atom'=>1);
if(Context::getRequestMethod()!='GET' || !Context::isInstalled() || isset($checkActList[Context::get('act')])) return true;
// pass if default URL is not set
$default_url = trim($this->db_info->default_url);
@ -630,8 +631,8 @@ class Context {
function setResponseMethod($method='HTML') {
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
$methods = array('HTML','XMLRPC','JSON');
$self->response_method = in_array($method, $methods)?$method:$methods[0];
$methods = array('HTML'=>1, 'XMLRPC'=>1, 'JSON'=>1);
$self->response_method = isset($methods[$method]) ? $method : 'HTML';
}
/*
@ -644,9 +645,9 @@ class Context {
if($self->response_method) return $self->response_method;
$method = $self->getRequestMethod();
$methods = array('HTML','XMLRPC','JSON');
$methods = array('HTML'=>1, 'XMLRPC'=>1, 'JSON'=>1);
return in_array($method, $methods)?$method:$methods[0];
return isset($methods[$method]) ? $method : 'HTML';
}
/**
@ -891,7 +892,8 @@ class Context {
$key = $get_vars['key'];
$srl = $get_vars['document_srl'];
$is_feed = in_array($act, array('rss', 'atom', 'api'));
$tmpArray = array('rss'=>1, 'atom'=>1, 'api'=>1);
$is_feed = isset($tmpArray[$act]);
$target_map = array(
'vid'=>$vid,

View file

@ -422,7 +422,8 @@
$id = $id_args[1];
} elseif(count($id_args) == 3) {
$target = $id_args[0];
if(!in_array($target, array('addons','widgets'))){
$typeList = array('addons'=>1, 'widgets'=>1);
if(!isset($typeList[$target])){
$this->actDBClassFinish();
return;
}

View file

@ -440,6 +440,7 @@
$unique_list = array();
$index_list = array();
$typeList = array('number'=>1, 'text'=>1);
foreach($columns as $column) {
$name = $column->attrs->name;
$type = $column->attrs->type;
@ -454,7 +455,7 @@
$column_schema[] = sprintf('[%s] %s%s %s %s %s',
$name,
$this->column_type[$type],
!in_array($type,array('number','text'))&&$size?'('.$size.')':'',
!isset($typeList[$type])&&$size?'('.$size.')':'',
isset($default)?"default '".$default."'":'',
$notnull?'not null':'null',
$auto_increment?'identity(1,1)':''

View file

@ -125,7 +125,11 @@
// 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; }
if(!in_array(gettype($this->_value), array('string', 'integer'))) {$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;}

View file

@ -15,7 +15,8 @@
*/
function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = ""){
parent::Condition($column_name, $argument, $operation, $pipe);
if(in_array($operation, array('in', 'notin', 'not_in'))){
$tmpArray = array('in'=>1, 'notin'=>1, 'not_in'=>1);
if(isset($tmpArray[$operation])){
if(is_array($argument)) $argument = implode($argument, ',');
$this->_value = '('. $argument .')';
}

View file

@ -37,9 +37,10 @@
$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(in_array($index_hint_type, array('USE', 'FORCE')))
if(isset($indexTypeList[$index_hint_type]))
$index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
}
if($index_hint_string != ''){

View file

@ -109,8 +109,8 @@
$file->cdnVersion = $cdnVersion;
}
$availableExtension = array('css', 'js');
if (!in_array($file->fileExtension, $availableExtension)) return;
$availableExtension = array('css'=>1, 'js'=>1);
if (!isset($availableExtension[$file->fileExtension])) return;
$file->targetIe = $args[2];
$file->index = (int)$args[3];

View file

@ -430,7 +430,8 @@
$procResult = $oModule->proc();
if(!$oModule->stop_proc && !in_array(Context::getRequestMethod(),array('XMLRPC','JSON')))
$methodList = array('XMLRPC'=>1, 'JSON'=>1);
if(!$oModule->stop_proc && !isset($methodList[Context::getRequestMethod()]))
{
$error = $oModule->getError();
$message = $oModule->getMessage();
@ -522,7 +523,8 @@
if(!$output->toBool()) $this->error = $output->getMessage();
// Use message view object, if HTML call
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$methodList = array('XMLRPC'=>1, 'JSON'=>1);
if(!isset($methodList[Context::getRequestMethod()])) {
if($_SESSION['XE_VALIDATOR_RETURN_URL'])
{
@ -634,8 +636,8 @@
$kind = strtolower($kind);
$type = strtolower($type);
$kinds = explode(' ', 'svc admin');
if(!in_array($kind, $kinds)) $kind = $kinds[0];
$kinds = array('svc'=>1, 'admin'=>1);
if(!isset($kinds[$kind])) $kind = 'svc';
$key = $module.'.'.($kind!='admin'?'':'admin').'.'.$type;

View file

@ -104,7 +104,8 @@
**/
function getMessageType(){
$type = $this->get('message_type');
if (!in_array($type, array('error', 'info', 'update'))){
$typeList = array('error'=>1, 'info'=>1, 'update'=>1);
if (!isset($typeList[$type])){
$type = $this->getError()?'error':'info';
}
return $type;

View file

@ -351,7 +351,7 @@ class TemplateHandler {
$nodes = preg_split($split_regex, $buff, -1, PREG_SPLIT_DELIM_CAPTURE);
// list of self closing tags
$self_closing = explode(',', 'area,base,basefont,br,hr,input,img,link,meta,param,frame,col');
$self_closing = array('area'=>1,'base'=>1,'basefont'=>1,'br'=>1,'hr'=>1,'input'=>1,'img'=>1,'link'=>1,'meta'=>1,'param'=>1,'frame'=>1,'col'=>1);
for($idx=1,$node_len=count($nodes); $idx < $node_len; $idx+=2) {
if(!($node=$nodes[$idx])) continue;
@ -392,7 +392,7 @@ class TemplateHandler {
// find closing tag
$close_php = '<?php '.str_repeat('}', $closing).' ?>';
if($node{1} == '!' || substr($node,-2,1) == '/' || in_array($tag, $self_closing)) { // self closing tag
if($node{1} == '!' || substr($node,-2,1) == '/' || isset($self_closing[$tag])) { // self closing tag
$nodes[$idx+1] = $close_php.$nodes[$idx+1];
} else {
$depth = 1;

View file

@ -87,9 +87,10 @@
// extracts the supported lanuage when xml:lang is used
if(count($matches[1]) && $supported_lang = array_unique($matches[1])) {
$tmpLangList = array_flip($supported_lang);
// if lang of the first log-in user doesn't exist, apply en by default if exists. Otherwise apply the first lang.
if(!in_array($this->lang, $supported_lang)) {
if(in_array('en', $supported_lang)) {
if(!isset($tmpLangList[$this->lang])) {
if(isset($tmpLangList['en'])) {
$this->lang = 'en';
} else {
$this->lang = array_shift($supported_lang);

View file

@ -35,7 +35,8 @@
$id = $id_args[1];
} elseif(count($id_args)==3) {
$target = $id_args[0];
if(!in_array($target, array('modules','addons','widgets'))) return;
$typeList = array('modules'=>1, 'addons'=>1, 'widgets'=>1);
if(!isset($typeList[$target])) return;
$module = $id_args[1];
$id = $id_args[2];
}
@ -52,6 +53,7 @@
if(!$tables) return;
if(!is_array($tables)) $tables = array($tables);
$joinList = array('left join'=>1, 'left outer join'=>1, 'right join'=>1, 'right outer join'=>1);
foreach($tables as $key => $val) {
// 테이블과 alias의 이름을 구함
@ -61,7 +63,7 @@
$output->tables[$alias] = $table_name;
if(in_array($val->attrs->type,array('left join','left outer join','right join','right outer join')) && count($val->conditions)){
if(isset($joinList[$val->attrs->type]) && count($val->conditions)){
$output->left_tables[$alias] = $val->attrs->type;
$left_conditions[$alias] = $val->conditions;
}

View file

@ -40,7 +40,8 @@
$id = $id_args[1];
} elseif (count($id_args) == 3) {
$target = $id_args[0];
if (!in_array($target, array('modules', 'addons', 'widgets')))
$targetList = array('modules'=>1, 'addons'=>1, 'widgets'=>1);
if (!isset($targetList[$target]))
return;
$module = $id_args[1];
$id = $id_args[2];

View file

@ -130,7 +130,8 @@ class Argument {
if (!isset($value))
return null;
if (in_array($column_type, array('date', 'varchar', 'char', 'text', 'bigtext'))) {
$columnTypeList = array('date'=>1, 'varchar'=>1, 'char'=>1, 'text'=>1, 'bigtext'=>1);
if (isset($columnTypeList[$column_type])) {
if (!is_array($value))
$value = $this->_escapeStringValue($value);
else {

View file

@ -21,7 +21,8 @@
* @return void
*/
function ConditionArgument($name, $value, $operation){
if(isset($value) && in_array($operation, array('in', 'notin','not_in', 'between')) && !is_array($value) && $value != ''){
$operationList = array('in'=>1, 'notin'=>1, 'not_in'=>1, 'between'=>1);
if(isset($value) && isset($operationList[$operation]) && !is_array($value) && $value != ''){
$value = str_replace(' ', '', $value);
$value = str_replace('\'', '', $value);
$value = explode(',', $value);

View file

@ -70,7 +70,8 @@
}
else {
if(isset($condition->attrs->default)){
if(in_array($this->operation, array('in', 'between', 'not in'))){
$operationList = array('in'=>1, 'between'=>1, 'not in'=>1);
if(isset($operationList[$this->operation])){
$default_value = $condition->attrs->default;
if(strpos($default_value, "'") !== false)
$default_value = "\"" . $default_value . "\"";

View file

@ -49,7 +49,8 @@
// Sort order - asc / desc
$this->sort_order = $index->attrs->order;
if(!in_array($this->sort_order, array("asc", "desc"))){
$sortList = array('asc'=>1, 'desc'=>1);
if(!isset($sortList[$this->sort_order])){
$arg = new Xml_Node_();
$arg->attrs = new Xml_Node_();
$arg->attrs->var = $this->sort_order;

View file

@ -75,7 +75,8 @@
}
function isJoinTable(){
if(in_array($this->join_type,array('left join','left outer join','right join','right outer join'))
$joinList = array('left join'=>1, 'left outer join'=>1, 'right join'=>1, 'right outer join'=>1);
if(isset($joinList[$this->join_type])
&& count($this->conditions)) return true;
return false;
}