中药方大全小图标
您当前的位置:首页 > 其他 > 网站日记

帝国cms有哪些函数?如何察看?

提示: 阅读权限:公开  来源:网络  作者: 未知

天气好热,不干点事情更是难熬,计划把帝国cms 的系统函数全部搜集到一起。以下为工作笔记。

第一步:遍历目录e,把所有的php文件都保存到一个数组中

帝国cms 的函数集中在目录e下,所以只要遍历整个目录就可以了。代码如下:

<?php
 function read_all_dir ( $dir )
    {
        $result = array();
        $handle = opendir($dir);
        if ( $handle )
        {
            while ( ( $file = readdir ( $handle ) ) !== false )
            {
                if ( $file != '.' && $file != '..')
                {
                    $cur_path = $dir . DIRECTORY_SEPARATOR . $file;
                    if ( is_dir ( $cur_path ) )
                    {
                        $result = array_merge($result,read_all_dir ( $cur_path ));
                    }
                    else
                    {
                        $kzhm=strtolower(pathinfo($cur_path, PATHINFO_EXTENSION));		
                        if($kzhm=='php')$result[] = $cur_path;
                    }
                }
            }
            closedir($handle);
        }
        return $result;
    }
print_r(read_all_dir(ECMS_PATH.'e/action/'));
?>


测试了下,还行,就是碰见中文文件名就翻车了,我的php和mysql都用的utf系统,但是不幸的是,我用的xinxp,他的文件是gbk系统的。看来还需要转码了。

思路是,先判断下路径,如果路径里含有gbk编码,就转成utf8。代码为:

$bm=mb_detect_encoding($cur_path, array('ASCII','UTF-8','GB2312','GBK','BIG5'));
		            if($bm=='EUC-CN')$cur_path=iconv('GB2312', 'UTF-8', $cur_path);


这代码一加中文拿下,我测试了下,我的e目录下居然有845个php文件。而且这只是第一步,下一步还要逐个文件分析,我总是担心脚本会超时。那就干脆,最前边加一句:

set_time_limit(0);

第二步,打开某个php文件,读取函数名称。但是无法判断是js函数还是php函数,下暴雨了还凉快,不玩了,直接给出完整的代码吧。

<?php
define('EmpireCMSAdmin', '1');
 define('InEmpireCMS', '1');
 require("../../class/connect.php");
 require("../../class/db_sql.php");
 require("../../class/functions.php");
// require('../../data/dbcache/class.php'); 
 //验证用户
 $link=db_connect();
 $empire=new mysqlquery();
 $lur=is_login();
 
 set_time_limit(0);

//输出格式化后的文件路径
function qpath($path) {
	$path = str_replace(ECMS_PATH, '', $path);
	$path ='/'.$path;
	$path = str_replace(DIRECTORY_SEPARATOR, '/', $path); //过滤win下的路径
	$path = str_replace('//', '/', $path); //过滤双斜杠
	return $path;
}

//输出格式化后的文件真实路径
function hpath($path,$qzh=0) {
	if(!$qzh)$path = ECMS_PATH . $path;
	$path = str_replace("", '/', $path); 
	$path = str_replace('//', '/', $path); 
	$path = str_replace('/',DIRECTORY_SEPARATOR, $path);
	return $path;
}

//获取所有php文件
function get_all_php ( $dir )
    {
        $result = array();
        $dir=rtrim($dir,DIRECTORY_SEPARATOR);
        $handle = opendir($dir);
        if ( $handle )
        {
            while ( ( $file = readdir ( $handle ) ) !== false )
            {
                if ( $file != '.' && $file != '..')
                {
                    $cur_path = $dir . DIRECTORY_SEPARATOR . $file;
                    $bm=mb_detect_encoding($cur_path, array('ASCII','UTF-8','GB2312','GBK','BIG5'));
		            if($bm=='EUC-CN')$cur_path=iconv('GB2312', 'UTF-8', $cur_path);
                    if ( is_dir ( $cur_path ) )
                    {
                        $result = array_merge($result,get_all_php ( $cur_path ));
                    }
                    else
                    {
                        $kzhm=strtolower(pathinfo($cur_path, PATHINFO_EXTENSION));		
                        if($kzhm=='php')$result[] = $cur_path;
                    }
                }
            }
            closedir($handle);
        }
        return $result;
    }
$dir='/e/';
$dir=hpath($dir);
$phpfiles=get_all_php($dir);
$funs=array();
foreach($phpfiles as $filename){
    $lines=@file($filename);
    for($i=0;$i<count($lines);$i++){
        $line=trim($lines[$i]);
        if(substr($line,0,9)=='function '){
            $funName=strstr(substr($line,9,-1),'(',true);
            $lines[$i-1]=trim($lines[$i-1]);
            if(substr($lines[$i-1],0,2)<>'//')$lines[$i-1]='没有注释,有可能是js函数';
            $bm=mb_detect_encoding($lines[$i-1], array('ASCII','UTF-8','GB2312','GBK','BIG5'));
		    if($bm=='EUC-CN')$lines[$i-1]=iconv('GB2312', 'UTF-8', $lines[$i-1]);
            if(stripos($lines[$i-1],'script')==false)$funs[$funName]=qpath($filename)."#".$lines[$i-1];//.$lines[$i-1];
        }
    }
    
}
ksort($funs);
// $result=json_encode(($funs));

$str='';
foreach($funs as $key=>$value){
    $xxkey=strtolower($key);
    $str.=<<<jhc
,'{$xxkey}' => '{$value}'

jhc;
}
$str=ltrim($str,',');
$str=<<<jhc
<?php
return array(
{$str});
jhc;


file_put_contents('data/fundata.php', $str);
echo 'ok!';
?>


tags: 帝国cms 帝国
返回顶部
推荐资讯
视频:田纪钧讲关节不痛的秘密、膝关节拉筋法
视频:田纪钧讲关节不
白露到了,你还好吗?
白露到了,你还好吗?
尿疗与断食
尿疗与断食
给风疹反复发作女孩的药方(组图)
给风疹反复发作女孩的
相关文章
栏目更新
栏目热门
  1. 帝国cms全站搜索的分页格式如何修改-流程
  2. libreoffice7的命令大全
  3. 帝国cms插件之标题生成标题图片
  4. 帝国cms插件安装模板
  5. useragent两千条,爬虫专用
  6. 帝国cms插件如何兼容gbk和utf8
  7. 帝国cms插件之迅搜
  8. 帝国cms用户上传文件名的命名规则及修改方
  9. 帝国cms7.2函数大全
  10. 帝国cms代码片段备忘录