Esempio n. 1
0
<?php

include './data/array.php';
require_once './lib/functions.php';
if (!isset($argv[1])) {
    printf("\nMissing argument, enter 1-3 to choice task\n");
    return;
}
if ($argv[1] < 1 || $argv[1] > 3) {
    printf("\nWrong argument, enter 1-3 to choice task\n");
    return;
}
switch ($argv[1]) {
    case '1':
        fsearch($array);
        break;
    case '2':
        freplace($array);
        break;
    case '3':
        fexplode($array);
        break;
    default:
        // ???
        printf("\n\nBad argument\n\n");
        break;
}
Esempio n. 2
0
 function filesql_recur()
 {
     return fsearch($this->pwd, $this->drives, 'id, free, track', true);
 }
Esempio n. 3
0
 function fsearch($d)
 {
     global $found;
     global $found_d;
     global $found_f;
     global $search_i_f;
     global $search_i_d;
     global $a;
     if (substr($d, -1) != DIRECTORY_SEPARATOR) {
         $d .= DIRECTORY_SEPARATOR;
     }
     $h = opendir($d);
     while (($f = readdir($h)) !== FALSE) {
         if ($f != "." && $f != "..") {
             $bool = (empty($a["name_regexp"]) and strpos($f, $a["name"]) !== FALSE) || ($a["name_regexp"] and ereg($a["name"], $f));
             if (is_dir($d . $f)) {
                 $search_i_d++;
                 if (empty($a["text"]) and $bool) {
                     $found[] = $d . $f;
                     $found_d++;
                 }
                 if (!is_link($d . $f)) {
                     fsearch($d . $f);
                 }
             } else {
                 $search_i_f++;
                 if ($bool) {
                     if (!empty($a["text"])) {
                         $r = @file_get_contents($d . $f);
                         if ($a["text_wwo"]) {
                             $a["text"] = " " . trim($a["text"]) . " ";
                         }
                         if (!$a["text_cs"]) {
                             $a["text"] = strtolower($a["text"]);
                             $r = strtolower($r);
                         }
                         if ($a["text_regexp"]) {
                             $bool = ereg($a["text"], $r);
                         } else {
                             $bool = strpos(" " . $r, $a["text"], 1);
                         }
                         if ($a["text_not"]) {
                             $bool = !$bool;
                         }
                         if ($bool) {
                             $found[] = $d . $f;
                             $found_f++;
                         }
                     } else {
                         $found[] = $d . $f;
                         $found_f++;
                     }
                 }
             }
         }
     }
     closedir($h);
 }