mirror of
https://github.com/jimeh/zynapse.git
synced 2026-02-18 23:06:38 +00:00
fixed the sql-inject issue properly :P
This commit is contained in:
8
vendor/zynapse/active_record.php
vendored
8
vendor/zynapse/active_record.php
vendored
@@ -613,14 +613,12 @@ class ActiveRecord {
|
|||||||
$cond = array();
|
$cond = array();
|
||||||
foreach( $conditions as $key => $value ) {
|
foreach( $conditions as $key => $value ) {
|
||||||
if ( !preg_match('/^[0-9]+$/', $key) && !is_array($value) ) {
|
if ( !preg_match('/^[0-9]+$/', $key) && !is_array($value) ) {
|
||||||
$cond[] = '`'.$key."` = '".$value."'";
|
$cond[] = '`'.$key."` = ".$this->sql_quote($value);
|
||||||
} elseif ( !is_array($value) && preg_match('/^[0-9]+$/', $value) ) {
|
} elseif ( !is_array($value) && preg_match('/^[0-9]+$/', $value) ) {
|
||||||
$cond[] = '`'.$this->_primary_key."` = '".$value."'";
|
$cond[] = '`'.$this->_primary_key."` = '".$value."'";
|
||||||
} elseif(is_array($value)) {
|
} elseif(is_array($value)) {
|
||||||
$cond[] = '`'.$key."` IN (".implode(",",$this->sql_quote($value)).")";
|
$cond[] = '`'.$key."` IN (".implode(",",$this->sql_quote($value)).")";
|
||||||
} else {
|
}
|
||||||
$cond[] = $this->sql_quote($value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$operator = ( !empty($options['operator']) ) ? $options['operator'] : 'AND' ;
|
$operator = ( !empty($options['operator']) ) ? $options['operator'] : 'AND' ;
|
||||||
return ' WHERE '.implode(' '.$operator.' ', $cond);
|
return ' WHERE '.implode(' '.$operator.' ', $cond);
|
||||||
@@ -871,7 +869,7 @@ class ActiveRecord {
|
|||||||
if ( ($field == 'integer' || $field == 'decimal') && preg_match('/^[0-9\-\.]+$/', $input) ) {
|
if ( ($field == 'integer' || $field == 'decimal') && preg_match('/^[0-9\-\.]+$/', $input) ) {
|
||||||
return $input;
|
return $input;
|
||||||
} else {
|
} else {
|
||||||
return "'".addslashes(urldecode($input))."'";
|
return "'".addslashes($input)."'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user