【发布时间】:2016-02-08 18:32:13
【问题描述】:
我想获取我所有的 wordpress 插件然后获取所有 gettext 函数参数
例子
die(_e('Error')) ;
die( '<b>'._e('Error').'</b>' ) ;
_e('Error')
我使用的wordpress gettext函数
_e , __
以及如何绕过类似的功能
use_e , get_email , select__
我通过正则表达式创建了这个函数,但它不是很有用
$list_words = array();
function po_fetch_code($dir , $preg = "/_\(('|\")(.*?)('|\")\)/"){
if( is_dir($dir) ){
$list = scandir($dir) ;
foreach($list as $l){
if($l == '.' || $l == '..'){
// Do Nothing
}else{
po_fetch_code($dir.'/'.$l , $preg) ;
}
}
}else{
$ext = strrchr($dir , '.') ;
//if($ext == '.php' || $ext == '.html' || $ext == 'html'){
//$cont = file_get_contents($dir) ;
$list = file($dir) ;
global $list_words ;
foreach($list as $key => $l){
preg_match_all( $preg , $l , $matches );
if(!empty($matches[2])){
foreach($matches[2] as $k=>$m){
//$m = str_replace(array( "\'",'\\' , '"' , "'",'\'' ), '' ,$m) ;
//$m = str_replace('\'s', 's' ,$m) ;
if(!isset($list_words[$m])){
$list_words[$m]['msgid'] = array($m) ;
$list_words[$m]['msgstr'] = array($m) ;
$list_words[$m]['reference'] = array() ;
}
$list_words[$m]['reference'][] = $dir.':'.$key ;
}
}
}
// }
}
}
$dir = 'themes/mytheme/' ;
po_fetch_code($dir , "/__\(('|\")(.*?)('|\")\)/" ) ;
po_fetch_code($dir , "/_e\(('|\")(.*?)('|\")\)/" ) ;
有什么方法可以增强我的功能吗? 谢谢
【问题讨论】:
-
你是说你想用
_e(搜索你的代码库吗? -
是的,还有其他gettext函数__
-
你可以访问命令行/shell界面吗?
-
不,我想用php代码,主机禁用所有命令功能
-
那会很痛苦。在这种情况下,您将需要 PHP 打开所有文件,然后在内容上运行正则表达式。我会尝试看看您是否可以让您的主机允许您使用
grep或为您执行命令..