Exemplo n.º 1
0
 /**
  *
  * @param php项目文件夹路径 $dirpath            
  * @return array of phpfiles 
  */
 public static function getPHPfile($dirpath)
 {
     $ret = array();
     if (substr($dirpath, -4) == ".php") {
         $in_charset = mb_detect_encoding($dirpath);
         $dirpath = iconv($in_charset, "UTF-8", $dirpath);
         array_push($ret, $dirpath);
     }
     if (!is_dir($dirpath)) {
         return $ret;
     }
     $dh = opendir($dirpath);
     while (($file = readdir($dh)) != false) {
         // 文件名的全路径 包含文件名
         $filePath = $dirpath . "/" . $file;
         // echo $filePath."<br/>";
         if ($file == "." or $file == "..") {
             continue;
         } elseif (is_dir($filePath)) {
             $files = FileUtils::getPHPfile($filePath);
             foreach ($files as $filePath) {
                 if (!is_null($filePath)) {
                     $in_charset = mb_detect_encoding($filePath);
                     $filePath = iconv($in_charset, "UTF-8", $filePath);
                     array_push($ret, $filePath);
                 }
             }
         } elseif (substr($filePath, -4) == ".php") {
             $in_charset = mb_detect_encoding($filePath);
             $filePath = iconv($in_charset, "UTF-8", $filePath);
             array_push($ret, $filePath);
         }
     }
     closedir($dh);
     return $ret;
 }
Exemplo n.º 2
0
$project_path = str_replace(array('\\', '//'), '/', $project_path);
$scan_path = str_replace(array('\\', '//'), '/', $scan_path);
$fileName = str_replace('/', '_', $scan_path);
$fileName = str_replace(':', '_', $fileName);
$serialPath = CURR_PATH . "/data/resultConetxtSerialData/" . $fileName;
if (!is_file($serialPath)) {
    //创建文件
    $fileHandler = fopen($serialPath, 'w');
    fclose($fileHandler);
}
$results = null;
if (($serial_str = file_get_contents($serialPath)) != '') {
    $results = unserialize($serial_str);
} else {
    //3、初始化模块
    $allFiles = FileUtils::getPHPfile($project_path);
    $mainlFiles = FileUtils::mainFileFinder($scan_path);
    $initModule = new InitModule();
    $initModule->init($project_path, $allFiles);
    //4、循环每个文件  进行分析工作
    if (is_file($project_path)) {
        load_file($project_path);
    } elseif (is_dir($project_path)) {
        $path_list = $mainlFiles;
        foreach ($path_list as $path) {
            try {
                load_file($path);
            } catch (Exception $e) {
                continue;
            }
        }
Exemplo n.º 3
0
 private function getAllSourceFiles()
 {
     return FileUtils::getPHPfile($this->path);
 }