【发布时间】:2014-05-30 07:25:09
【问题描述】:
以下问题:With "magic quotes" disabled, why does PHP/WordPress continue to auto-escape my POST data?
在 WordPress 中,即使 magic quotes 关闭,所有超全局变量都会被转义。
所以,按照这个答案:With "magic quotes" disabled, why does PHP/WordPress continue to auto-escape my POST data?
如果我创建一个插件和一个类来访问原始 POST、GET 等,这是一个好的解决方案吗?您认为这种方法有什么缺点和问题吗?
下面是我的插件:
class MyPluginRequest{
public static function getPost( $key ){
global $_REAL_POST;
return isset( $_REAL_POST[ $key ] )? $_REAL_POST[ $key ] : FALSE ;
}
}
// A hack to cope with un-configurable call to wp_magic_quotes
// E.G. Make the original $_POST available through a global $_REAL_POST
global $_REAL_GET, $_REAL_POST, $_REAL_COOKIE, $_REAL_REQUEST;
$_REAL_GET = $_GET;
$_REAL_POST = $_POST;
$_REAL_COOKIE = $_COOKIE;
$_REAL_REQUEST = $_REQUEST;
然后,每当我需要发布的未转义值时,我都会使用 MyPluginRequest::getPost( 'submit' );。
$wpdb->escape 是否期望一个已经神奇的引用值或未转义的值?
【问题讨论】:
标签: php wordpress magic-quotes-gpc