Issue 581: Can not login after r9685

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9702 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-10-20 15:28:34 +00:00
parent 15bc72057b
commit 9f24618740
3 changed files with 12 additions and 2 deletions

View file

@ -7,7 +7,8 @@
var $is_operation = false; var $is_operation = false;
var $operation = ''; var $operation = '';
var $_is_string = false; var $_is_string = false; ///< Checks if value is plain string or name of XE function (ipaddress, plus, etc).
var $_is_string_from_function = false; //< Checks if value is string resulted from evaluating a piece of PHP code (see $_SERVER[REMOTE_ADDR])
function DefaultValue($column_name, $value){ function DefaultValue($column_name, $value){
$dbParser = &DB::getParser(); $dbParser = &DB::getParser();
@ -23,6 +24,10 @@
return false; return false;
} }
function isStringFromFunction(){
return $this->_is_string_from_function;
}
function isSequence(){ function isSequence(){
return $this->is_sequence; return $this->is_sequence;
} }
@ -58,6 +63,7 @@
switch($func_name) { switch($func_name) {
case 'ipaddress' : case 'ipaddress' :
$val = '$_SERVER[\'REMOTE_ADDR\']'; $val = '$_SERVER[\'REMOTE_ADDR\']';
$this->_is_string_from_function = true;
break; break;
case 'unixtime' : case 'unixtime' :
$val = 'time()'; $val = 'time()';

View file

@ -29,6 +29,9 @@
//else $this->default_value = $dbParser->parseColumnName($column->attrs->default); //else $this->default_value = $dbParser->parseColumnName($column->attrs->default);
else { else {
$this->default_value = $default_value->toString(); $this->default_value = $default_value->toString();
if($default_value->isStringFromFunction()){
$this->default_value = '"\'".' . $this->default_value . '."\'"';
}
if($default_value->isString()){ if($default_value->isString()){
$this->default_value = '"' . $this->default_value . '"'; $this->default_value = '"' . $this->default_value . '"';
} }

View file

@ -68,8 +68,9 @@
$argsString = '$args->session_key = 339321; $args->val = "yuhuu";'; $argsString = '$args->session_key = 339321; $args->val = "yuhuu";';
$expected = 'update `xe_session` as `session` $expected = 'update `xe_session` as `session`
set `member_srl` = 0, `val` = \'yuhuu\' set `member_srl` = 0, `val` = \'yuhuu\'
, `ipaddress` = \''. $_SERVER['REMOTE_ADDR'] .'\'
, `last_update` = ' . date("YmdHis") . ' , `last_update` = ' . date("YmdHis") . '
where `session_key` = \'339321\''; where `session_key` = \'339321\'';
$this->_test($xml_file, $argsString, $expected); $this->_test($xml_file, $argsString, $expected);
} }
} }