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


PHP rex::getDirPerm方法代碼示例

本文整理匯總了PHP中rex::getDirPerm方法的典型用法代碼示例。如果您正苦於以下問題:PHP rex::getDirPerm方法的具體用法?PHP rex::getDirPerm怎麽用?PHP rex::getDirPerm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rex的用法示例。


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

示例1: create

 /**
  * Creates a directory.
  *
  * @param string $dir       Path of the new directory
  * @param bool   $recursive When FALSE, nested directories won't be created
  *
  * @return bool TRUE on success, FALSE on failure
  */
 public static function create($dir, $recursive = true)
 {
     if (is_dir($dir)) {
         return true;
     }
     $parent = dirname($dir);
     if (!is_dir($parent) && (!$recursive || !self::create($parent))) {
         return false;
     }
     if (self::isWritable($parent) && mkdir($dir, rex::getDirPerm())) {
         @chmod($dir, rex::getDirPerm());
         return true;
     }
     return false;
 }
開發者ID:staabm,項目名稱:redaxo,代碼行數:23,代碼來源:dir.php

示例2: enterObject


//.........這裏部分代碼省略.........
         if (rex::isBackend()) {
             $value = explode("_", $value, 2);
             $value = $value[0];
         }
         $search_path = $upload_folder . '/' . $value . '_' . $this->getElement('file_prefix');
         $files = glob(preg_replace('/(\\*|\\?|\\[)/', '[$1]', $search_path) . '*');
         if (count($files) == 1) {
             $value = basename($files[0]);
             if (rex_request("rex_upload_downloadfile") == $value) {
                 $file = $upload_folder . '/' . $value;
                 if (file_exists($file)) {
                     ob_end_clean();
                     $filename = explode("_", basename($file), 2);
                     $filename = $filename[1];
                     header('Content-Description: File Transfer');
                     header('Content-Type: application/octet-stream');
                     header('Content-Disposition: attachment; filename=' . $filename);
                     header('Expires: 0');
                     header('Cache-Control: must-revalidate');
                     header('Pragma: public');
                     header('Content-Length: ' . filesize($file));
                     readfile($file);
                     exit;
                 }
             }
         } else {
             $value = "";
         }
     }
     if ($this->params['send']) {
         if (isset($_FILES[$rfile]) && $_FILES[$rfile]['name'] != '') {
             $FILE['size'] = $_FILES[$rfile]['size'];
             $FILE['name'] = $_FILES[$rfile]['name'];
             $FILE['type'] = $_FILES[$rfile]['type'];
             $FILE['tmp_name'] = $_FILES[$rfile]['tmp_name'];
             $FILE['error'] = $_FILES[$rfile]['error'];
             $FILE['name_normed'] = strtolower(preg_replace('/[^a-zA-Z0-9.\\-\\$\\+]/', '_', $FILE['name']));
             $extensions_array = explode(',', $this->getElement('types'));
             $ext = '.' . pathinfo($FILE['name'], PATHINFO_EXTENSION);
             if (!in_array(strtolower($ext), $extensions_array) && !in_array(strtoupper($ext), $extensions_array)) {
                 $error[] = $err_msgs['type_error'];
                 $value = '';
             } else {
                 $file_normed = $FILE['name_normed'];
                 $file_normed_new = $prefix . $file_normed;
                 if (file_exists($upload_folder . '/' . $file_normed_new)) {
                     for ($cf = 1; $cf < 1000; $cf++) {
                         $file_normed_new = $prefix . $cf . '_' . $file_normed;
                         if (!file_exists($upload_folder . '/' . $file_normed_new)) {
                             break;
                         }
                     }
                 }
                 $value = $file_normed_new;
                 if (!@move_uploaded_file($FILE['tmp_name'], $upload_folder . '/' . $file_normed_new)) {
                     if (!@copy($FILE['tmp_name'], $upload_folder . '/' . $file_normed_new)) {
                         $error[] = 'upload failed: destination folder problem';
                         $value = '';
                     } else {
                         @chmod($upload_folder . '/' . $file_normed_new, rex::getDirPerm());
                     }
                 } else {
                     @chmod($upload_folder . '/' . $file_normed_new, rex::getDirPerm());
                 }
             }
         }
     }
     if (count($error) == 0) {
         switch ($this->getElement('modus')) {
             case 'database':
                 if ($database_filename_field != "") {
                     $this->params['value_pool']['email'][$database_filename_field] = $value;
                     // $FILE['name_normed'];
                     $this->params['value_pool']['sql'][$database_filename_field] = $value;
                     // $FILE['name_normed'];
                 }
                 $value_email = file_get_contents($upload_folder . '/' . $value);
                 $value_sql = $value_email;
                 break;
             case 'upload':
             default:
                 $value_email = $value;
                 $value_sql = $value_email;
                 break;
         }
     }
     $this->setValue($value);
     $this->params['value_pool']['email'][$this->getName()] = $value_email;
     $this->params['value_pool']['sql'][$this->getName()] = $value_sql;
     ## check for required file
     if ($this->params['send'] && $this->getElement('required') == 1 && $this->getValue() == '') {
         $error[] = $err_msgs['empty_error'];
     }
     ## setting up error Message
     if ($this->params['send'] && count($error) > 0) {
         $this->params['warning'][$this->getId()] = $this->params['error_class'];
         $this->params['warning_messages'][$this->getId()] = implode(', ', $error);
     }
     $this->params['form_output'][$this->getId()] = $this->parse('value.upload.tpl.php');
 }
開發者ID:VIEWSION,項目名稱:redaxo_yform,代碼行數:101,代碼來源:upload.php


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