當前位置: 首頁>>代碼示例>>PHP>>正文


PHP rchmod函數代碼示例

本文整理匯總了PHP中rchmod函數的典型用法代碼示例。如果您正苦於以下問題:PHP rchmod函數的具體用法?PHP rchmod怎麽用?PHP rchmod使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了rchmod函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: action

 public function action()
 {
     $mode = $_POST['new_mode'];
     $rec_option = $_POST['is_recursive'];
     $valid_options = array('none', 'files', 'folders', 'both');
     $chmod_perm = is_dir($path) ? $chmod_dirs : $chmod_files;
     // check perm
     if ($chmod_perm === FALSE) {
         $fileORfolder = is_dir($path) ? 'folders' : 'files';
         $response = "Changing" . $fileORfolder . "permissions are not allowed.";
         $this->r = array($response, 403);
         return;
     }
     // check mode
     if (!preg_match("/^[0-7]{3}\$/", $mode)) {
         $this->r = array('The supplied permission mode is incorrect.', 400);
         return;
     }
     // check recursive option
     if (!in_array($rec_option, $valid_options)) {
         $this->r = array("wrong option", 400);
         return;
     }
     // check if server disabled chmod
     if (is_function_callable('chmod') === FALSE) {
         $this->r = array('The chmod function has been disabled by the server.', 'chmod', 403);
         return;
     }
     $mode = "0" . $mode;
     $mode = octdec($mode);
     rchmod($path, $mode, $rec_option);
 }
開發者ID:Kingtreemonkey,項目名稱:FileManager,代碼行數:32,代碼來源:Chmod.php

示例2: rchmod

function rchmod($source, $mode, $rec_option = "none", $is_rec = FALSE)
{
    if ($rec_option == "none") {
        chmod($source, $mode);
    } else {
        if ($is_rec === FALSE) {
            chmod($source, $mode);
        }
        $files = scandir($source);
        foreach ($files as $file) {
            if ($file != "." && $file != "..") {
                if (is_dir($source . DIRECTORY_SEPARATOR . $file)) {
                    if ($rec_option == "folders" || $rec_option == "both") {
                        chmod($source . DIRECTORY_SEPARATOR . $file, $mode);
                    }
                    rchmod($source . DIRECTORY_SEPARATOR . $file, $mode, $rec_option, TRUE);
                } else {
                    if ($rec_option == "files" || $rec_option == "both") {
                        chmod($source . DIRECTORY_SEPARATOR . $file, $mode);
                    }
                }
            }
        }
    }
}
開發者ID:Vatia13,項目名稱:funtime,代碼行數:25,代碼來源:utils.php

示例3: response

         response(trans('File_Permission_Wrong_Mode'), 400)->send();
         exit;
     }
     // check recursive option
     if (!in_array($rec_option, $valid_options)) {
         response("wrong option", 400)->send();
         exit;
     }
     // check if server disabled chmod
     if (is_function_callable('chmod') === FALSE) {
         response(sprintf(trans('Function_Disabled'), 'chmod'), 403)->send();
         exit;
     }
     $mode = "0" . $mode;
     $mode = octdec($mode);
     rchmod($path, $mode, $rec_option);
     break;
 case 'save_text_file':
     $content = $_POST['new_content'];
     // $content = htmlspecialchars($content); not needed
     // $content = stripslashes($content);
     // no file
     if (!file_exists($path)) {
         response(trans('File_Not_Found'), 404)->send();
         exit;
     }
     // not writable or edit not allowed
     if (!is_writable($path) || $edit_text_files === FALSE) {
         response(sprintf(trans('File_Open_Edit_Not_Allowed'), strtolower(trans('Edit'))), 403)->send();
         exit;
     }
開發者ID:ilhammalik,項目名稱:yii2-starter,代碼行數:31,代碼來源:execute.php

示例4: changePermissions

 public function changePermissions()
 {
     $this->log('<comment>~ Changing permissions</comment>');
     rchmod(storage_path(), 0777, 0777);
     rchmod(base_path('bootstrap/cache'), 0777, 0777);
     if ($this->post('db_type') == 'sqlite') {
         $db_name = $this->post('db_name', '');
         rchmod($this->baseDirectory . DIRECTORY_SEPARATOR . $db_name, 0777, 0777);
     }
     $this->log('<info>[ + ] Changing permissions [OK]</info>');
 }
開發者ID:zedx,項目名稱:core,代碼行數:11,代碼來源:Installer.php

示例5: rchmod

 /**
  * Recursive chmod.
  *
  * @param string $path
  * @param int    $filePerm
  * @param int    $dirPerm
  *
  * @return bool
  */
 function rchmod($path, $filePerm = 0644, $dirPerm = 0755)
 {
     if (!file_exists($path)) {
         return false;
     }
     if (is_file($path)) {
         chmod($path, $filePerm);
     } elseif (is_dir($path)) {
         $foldersAndFiles = scandir($path);
         $entries = array_slice($foldersAndFiles, 2);
         foreach ($entries as $entry) {
             rchmod($path . DIRECTORY_SEPARATOR . $entry, $filePerm, $dirPerm);
         }
         chmod($path, $dirPerm);
     }
     return true;
 }
開發者ID:zedx,項目名稱:core,代碼行數:26,代碼來源:helpers.php

示例6: rchmod

function rchmod($path, $filemode, $dirmode)
{
    if (is_dir($path)) {
        if (!chmod($path, $dirmode)) {
            return false;
        }
        $objects = scandir($path);
        if (is_array($objects)) {
            foreach ($objects as $file) {
                if ($file != '.' && $file != '..') {
                    if (!rchmod($path . '/' . $file, $filemode, $dirmode)) {
                        return false;
                    }
                }
            }
        }
        return true;
    } elseif (is_link($path)) {
        return true;
    } elseif (is_file($path)) {
        return chmod($path, $filemode);
    }
    return false;
}
開發者ID:LNDDYL,項目名稱:filemanager,代碼行數:24,代碼來源:filemanager.php


注:本文中的rchmod函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。