예제 #1
0
<?php

include '../tpl/header.php';
include '../lib/html_common.inc';
include '../lib/misc.inc';
$misc = new misc();
try {
    # 取得目錄名稱
    if ($misc->isEmpty($_GET['d'])) {
        throw new Exception('Directory name is empty');
    }
    $dir_name = $_GET['d'];
    # 目錄名稱檢查
    if (!preg_match('/[a-zA-Z0-9]/', $dir_name)) {
        throw new Exception('Invaild directory name.');
    }
    # 取得顯示目錄名稱並檢查
    $disp_dir_name = '.';
    if (!$misc->isEmpty($_GET['dd'])) {
        $disp_dir_name = $_GET['dd'];
        if (!preg_match('/^((\\\\|\\/){1}[a-zA-Z0-9_\\-\\.\\s]+)+$/', $disp_dir_name)) {
            throw new Exception('Invaild display directory name.');
        }
    }
    # 取得目錄檔案內容
    $src_dir_path = $_SERVER["DOCUMENT_ROOT"] . '/dev/file/' . $dir_name;
    $scan_file_list = array();
    recurciveScan($src_dir_path);
    # 顯示目錄檔案內容
    $disp_file_list = array();
    foreach ($scan_file_list['file'] as $file_path) {
예제 #2
0
}
function get_name_count($sFile_Name, $aSearch_File_List)
{
    $aName_Count = array();
    foreach ($aSearch_File_List as $sTmp_Path) {
        $sTmp_Content = file_get_contents($sTmp_Path);
        $iTmp_Count = substr_count($sTmp_Content, $sFile_Name);
        if ($iTmp_Count > 0) {
            $aName_Count[$sTmp_Path] = $iTmp_Count;
        }
    }
    return $aName_Count;
}
try {
    // 取得目錄名稱
    if ($cMisc->isEmpty($_GET['d'])) {
        throw new Exception('Directory name is empty');
    }
    $sDir_Name = $_GET['d'];
    // 目錄名稱檢查
    if (!preg_match('/[a-zA-Z0-9]/', $sDir_Name)) {
        throw new Exception('Invaild directory name.');
    }
    // 取得目錄檔案內容
    $aFile_Name_List = $cFile->recurcive_scan($sDir_Name);
    // 取得要搜尋的檔案
    $aSearch_File_Path = get_search_file($aFile_Name_List);
    // 取得要檢查的檔名
    $aSearch_File_Name = array();
    foreach ($aSearch_File_Path as $sTmp_Name) {
        $aSearch_File_Name[] = basename($sTmp_Name);