本文整理汇总了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;
}
示例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');
}