コード例 #1
0
ファイル: launcher.php プロジェクト: NikDiamond/NikLauncher
function GetListFiles($folder, &$all_files)
{
    $fp = opendir($folder);
    while ($cv_file = readdir($fp)) {
        if (is_file($folder . "/" . $cv_file)) {
            $all_files[] = $folder . "/" . $cv_file;
        } elseif ($cv_file != "." && $cv_file != ".." && is_dir($folder . "/" . $cv_file)) {
            GetListFiles($folder . "/" . $cv_file, $all_files);
        }
    }
    closedir($fp);
}
コード例 #2
0
ファイル: core.php プロジェクト: KasaiDot/xdwc
        // if list file exists on the local system, use it right away
        return $listFileLocal;
    } else {
        $localTarget = XDWCTEMP . md5($listFile) . '.txt';
        if (CheckFile($localTarget) && time() - filemtime($localTarget) < LISTFILECACHEPERIOD) {
            // cache hit: cached list file exists locally and is still valid
            return $localTarget;
        } else {
            return FetchRemoteListFile($listFile, $localTarget);
        }
    }
}
// main code
$query = GetQuery();
// get the regular expression to search for
$listFiles = GetListFiles();
// get an array of list files
// get requested packs
$packs = array();
foreach ($listFiles as $listFile) {
    if ($listFile = PrepareListFile($listFile)) {
        $handle = fopen($listFile, 'r');
        if (fgets($handle) !== false && fgets($handle) !== false && ($line = fgets($handle)) !== false && preg_match("/\\/MSG (.+?) /", $line, $match)) {
            $botName = $match[1];
            while (($line = fgets($handle)) !== false && preg_match("/^#(\\d+) +(\\d+)x +\\[ *(.+?)\\] +(.+)\$/", $line, $match)) {
                // ...and is another pack
                if ($query === null || preg_match($query, $match[4])) {
                    // ...or if the file name matches what's being searched for
                    array_push($packs, new Pack($botName, $match[1], $match[2], $match[3], $match[4]));
                    // create Pack object and add it to pack array
                }