Пример #1
0
 function do_mkdir()
 {
     iACP::MP('FILE.MKDIR') or iPHP::json(array('code' => 0, 'msg' => '您没有相关权限!'));
     $name = $_POST['name'];
     strstr($name, '.') !== false && iPHP::json(array('code' => 0, 'msg' => '您输入的目录名称有问题!'));
     strstr($name, '..') !== false && iPHP::json(array('code' => 0, 'msg' => '您输入的目录名称有问题!'));
     $pwd = trim($_POST['pwd'], '/');
     $dir = iFS::path_join(iPATH, iCMS::$config['FS']['dir']);
     $dir = iFS::path_join($dir, $pwd);
     $dir = iFS::path_join($dir, $name);
     file_exists($dir) && iPHP::json(array('code' => 0, 'msg' => '您输入的目录名称已存在,请重新输入!'));
     if (iFS::mkdir($dir)) {
         iPHP::json(array('code' => 1, 'msg' => '创建成功!'));
     }
     iPHP::json(array('code' => 0, 'msg' => '创建失败,请检查目录权限!!'));
 }
Пример #2
0
 public static function folder($dir = '', $type = NULL)
 {
     $dir = trim($dir, '/');
     $sDir = $dir;
     $_GET['dir'] && ($gDir = trim($_GET['dir'], '/'));
     // print_r('$dir='.$dir.'<br />');
     // print_r('$gDir='.$gDir.'<br />');
     //$gDir && $dir = $gDir;
     //strstr($dir,'.')!==false  && self::alert('What are you doing?','',1000000);
     //strstr($dir,'..')!==false && self::alert('What are you doing?','',1000000);
     $sDir_PATH = iFS::path_join(iPATH, $sDir);
     $iDir_PATH = iFS::path_join($sDir_PATH, $gDir);
     // print_r('$sDir_PATH='.$sDir_PATH."\n");
     // print_r('$iDir_PATH='.$iDir_PATH."\n");
     strpos($iDir_PATH, $sDir_PATH) === false && self::_error(array('code' => 0, 'state' => 'DIR_Error'));
     if (!is_dir($iDir_PATH)) {
         return false;
     }
     $url = buildurl(false, 'dir');
     if ($handle = opendir($iDir_PATH)) {
         while (false !== ($rs = readdir($handle))) {
             // print_r('$rs='.$rs."\n");
             $filepath = iFS::path_join($iDir_PATH, $rs);
             $filepath = rtrim($filepath, '/');
             //              print_r('$filepath='.$filepath."\n");
             $sFileType = @filetype($filepath);
             //              print_r('$sFileType='.$sFileType."\n");
             // var_dump($sDir_PATH,$filepath);
             $path = str_replace($sDir_PATH, '', $filepath);
             $path = ltrim($path, '/');
             if ($sFileType == "dir" && !in_array($rs, array('.', '..', 'admincp'))) {
                 $dirArray[] = array('path' => $path, 'name' => $rs, 'url' => $url . urlencode($path));
             }
             if ($sFileType == "file" && !in_array($rs, array('..', '.iPHP'))) {
                 $filext = iFS::get_ext($rs);
                 $fileinfo = array('path' => $path, 'dir' => dirname($path), 'url' => iFS::fp($path, '+http'), 'name' => $rs, 'modified' => get_date(filemtime($filepath), "Y-m-d H:i:s"), 'md5' => md5_file($filepath), 'ext' => $filext, 'size' => iFS::sizeUnit(filesize($filepath)));
                 if ($type) {
                     in_array(strtolower($filext), $type) && ($fileArray[] = $fileinfo);
                 } else {
                     $fileArray[] = $fileinfo;
                 }
             }
         }
     }
     $a['DirArray'] = (array) $dirArray;
     $a['FileArray'] = (array) $fileArray;
     $a['pwd'] = str_replace($sDir_PATH, '', $iDir_PATH);
     $a['pwd'] = trim($a['pwd'], '/');
     $pos = strripos($a['pwd'], '/');
     $a['parent'] = ltrim(substr($a['pwd'], 0, $pos), '/');
     $a['URI'] = $url;
     // var_dump($a);
     //      exit;
     return $a;
 }