Beispiel #1
0
function file_lists($filepath, $subdir = 1, $ex = '', $isdir = 0, $md5 = 0, $enforcement = 0)
{
    static $file_list = array();
    if ($enforcement) {
        $file_list = array();
    }
    $flags = $isdir ? GLOB_ONLYDIR : 0;
    $list = glob($filepath . '*' . (!empty($ex) && empty($subdir) ? '.' . $ex : ''), $flags);
    if (!empty($ex)) {
        $ex_num = strlen($ex);
    }
    foreach ($list as $k => $v) {
        $v = str_replace('\\', '/', $v);
        $v1 = str_replace(IA_ROOT . '/', '', $v);
        if ($subdir && is_dir($v)) {
            file_lists($v . '/', $subdir, $ex, $isdir, $md5);
            continue;
        }
        if (!empty($ex) && strtolower(substr($v, -$ex_num, $ex_num)) == $ex) {
            if ($md5) {
                $file_list[$v1] = md5_file($v);
            } else {
                $file_list[] = $v1;
            }
            continue;
        } elseif (!empty($ex) && strtolower(substr($v, -$ex_num, $ex_num)) != $ex) {
            unset($list[$k]);
            continue;
        }
    }
    return $file_list;
}
Beispiel #2
0
 }
 if ($op == 'count') {
     load()->func('file');
     set_time_limit(0);
     $files = array();
     $config = iunserializer(cache_read('scan:config'));
     if (empty($config)) {
         message('获取扫描配置失败', url('system/tools/scan'), 'error');
     }
     $config['file_type'] = explode('|', $config['file_type']);
     $list_arr = array();
     foreach ($config['dir'] as $v) {
         if (is_dir($v)) {
             if (!empty($config['file_type'])) {
                 foreach ($config['file_type'] as $k) {
                     $list_arr = array_merge($list_arr, file_lists($v . '/', 1, $k, 0, 1, 1));
                 }
             }
         } else {
             $list_arr = array_merge($list_arr, array(str_replace(IA_ROOT . '/', '', $v) => md5_file($v)));
         }
     }
     unset($list_arr['data/config.php']);
     $list_arr = iserializer($list_arr);
     cache_write('scan:file', $list_arr);
     message("文件统计完成,进行特征函数过滤。。。", url('system/tools/scan', array('op' => 'filter_func')), 'success');
 }
 if ($op == 'filter_func') {
     @set_time_limit(0);
     $config = iunserializer(cache_read('scan:config'));
     $file = iunserializer(cache_read('scan:file'));