Exemplo n.º 1
0
 public function pathChmod()
 {
     $info_list = json_decode($this->in['list'], true);
     $mod = octdec('0' . $this->in['mod']);
     $success = 0;
     $error = 0;
     foreach ($info_list as $val) {
         $path = _DIR($val['path']);
         if (chmod_path($path, $mod)) {
             $success++;
         } else {
             $error++;
         }
     }
     $state = $error == 0 ? true : false;
     $info = $success . ' success,' . $error . ' error';
     if (count($info_list) == 1 && $error == 0) {
         $info = $this->L['success'];
     }
     show_json($info, $state);
 }
 public function mkdir()
 {
     $new = rtrim($this->path, '/');
     $this->_pathAllow($new);
     if (mkdir($new, 0777)) {
         chmod_path($new, 0777);
         show_json($this->L['create_success']);
     } else {
         show_json($this->L['create_error'], false);
     }
 }
Exemplo n.º 3
0
/**
 * 修改文件、文件夹权限
 * @param  $path 文件(夹)目录
 * @return :string
 */
function chmod_path($path, $mod)
{
    //$mod = 0777;//
    if (!isset($mod)) {
        $mod = 0777;
    }
    if (!is_dir($path)) {
        return @chmod($path, $mod);
    }
    if (!($dh = opendir($path))) {
        return false;
    }
    while (($file = readdir($dh)) !== false) {
        if ($file != "." && $file != "..") {
            $fullpath = $path . '/' . $file;
            chmod($fullpath, $mod);
            return chmod_path($fullpath, $mod);
        }
    }
    closedir($dh);
    return chmod($path, $mod);
}
Exemplo n.º 4
0
 public function mkdir()
 {
     if ($_SERVER['HTTP_REFERER'] != $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]) {
         if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
             $new = rtrim($this->path, '/');
             $this->_pathAllow($new);
             if (mkdir($new, 0777)) {
                 chmod_path($new, 0777);
                 show_json($this->L['create_success']);
             } else {
                 show_json($this->L['create_error'], false);
             }
         }
     } else {
         header('Location: 403.php');
     }
 }