Merge branch 'master' of github.com:gnuboard/g5

This commit is contained in:
whitedot
2014-03-18 15:40:35 +09:00
2 changed files with 22 additions and 10 deletions

View File

@ -69,21 +69,21 @@ if (file_exists($dbconfig_file)) {
if (defined(G5_TIMEZONE)) @mysql_query(" set time_zone = '".G5_TIMEZONE."'");
//==============================================================================
// SQL Injection 등으로 부터 보호를 위해 mysql_real_escape_string() 적용
// SQL Injection 등으로 부터 보호를 위해 sql_escape_string() 적용
//------------------------------------------------------------------------------
// magic_quotes_gpc 에 의한 backslashes 제거
if (get_magic_quotes_gpc()) {
$_POST = array_map_deep('stripslashes', $_POST);
$_GET = array_map_deep('stripslashes', $_GET);
$_COOKIE = array_map_deep('stripslashes', $_COOKIE);
$_REQUEST = array_map_deep('stripslashes', $_REQUEST);
$_POST = array_map_deep('stripslashes', $_POST);
$_GET = array_map_deep('stripslashes', $_GET);
$_COOKIE = array_map_deep('stripslashes', $_COOKIE);
$_REQUEST = array_map_deep('stripslashes', $_REQUEST);
}
// mysql_real_escape_string 적용
$_POST = array_map_deep(G5_ESCAPE_FUNCTION, $_POST);
$_GET = array_map_deep(G5_ESCAPE_FUNCTION, $_GET);
$_COOKIE = array_map_deep(G5_ESCAPE_FUNCTION, $_COOKIE);
$_REQUEST = array_map_deep(G5_ESCAPE_FUNCTION, $_REQUEST);
// sql_escape_string 적용
$_POST = array_map_deep('sql_escape_string', $_POST);
$_GET = array_map_deep('sql_escape_string', $_GET);
$_COOKIE = array_map_deep('sql_escape_string', $_COOKIE);
$_REQUEST = array_map_deep('sql_escape_string', $_REQUEST);
//==============================================================================
// PHP 4.1.0 부터 지원됨

View File

@ -25,6 +25,18 @@ function array_map_deep($fn, $array)
return $array;
}
// SQL Injection 대응 문자열 필터링
function sql_escape_string($str)
{
$pattern = '/(and|or).*(union|select|insert|update|delete|from|where|limit|create|drop).*/i';
$replace = '';
$str = preg_replace($pattern, $replace, $str);
$str = call_user_func(G5_ESCAPE_FUNCTION, $str);
return $str;
}
// 마이크로 타임을 얻어 계산 형식으로 만듦
function get_microtime()
{