本文整理汇总了PHP中CMS::chmod_file方法的典型用法代码示例。如果您正苦于以下问题:PHP CMS::chmod_file方法的具体用法?PHP CMS::chmod_file怎么用?PHP CMS::chmod_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMS
的用法示例。
在下文中一共展示了CMS::chmod_file方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: on_execute
public function on_execute(DB_Cursor $cursor)
{
self::$cnt++;
if ($cursor->execution_time < self::$time_filter) {
return;
}
if (!self::check_filters()) {
return;
}
$dir = IO_FS::Path(self::$log_file)->dirname;
IO_FS::mkdir($dir);
$fh = fopen(self::$log_file, 'a');
fwrite($fh, $this->create_string($cursor) . "\n");
fclose($fh);
CMS::chmod_file(self::$log_file);
}
示例2: modified_image
static function modified_image($path, $mods)
{
if (is_string($mods)) {
$mods = self::parse_modifiers($mods);
}
$ext = false;
$name = false;
if ($m = Core_Regexps::match_with_results('{(.+)\\.(jpe?g|gif|png|bmp)$}i', $path)) {
$name = $m[1];
$ext = strtolower($m[2]);
}
if (!$ext || !IO_FS::exists($path)) {
$path = '../tao/files/images/admin.gif';
$ext = 'gif';
$name = 'error';
}
$name = preg_replace('{^\\.\\./}', 'up/', $name);
$name = ltrim($name, '.');
$name = ltrim($name, '/');
$stat = IO_FS::Stat($path);
$mtime = $stat->mtime->timestamp;
$name .= "-{$stat->size}-{$mtime}-";
$name .= md5(serialize($mods));
$cache = self::$cache_dir . "/{$name}.{$ext}";
if (IO_FS::exists('./' . $cache)) {
return '/' . $cache;
}
$dir = preg_replace('{/([^/]+)$}', '', $cache);
if (!IO_FS::exists($dir)) {
IO_FS::mkdir($dir);
}
$image = self::Image($path);
$image->modify($mods);
$image->save('./' . $cache);
CMS::chmod_file('./' . $cache);
return '/' . $cache;
}
示例3: chmod_file
protected function chmod_file($name)
{
CMS::chmod_file($name);
}
示例4: addfile
public function addfile($parms)
{
$id = (int) $parms['id'];
$file = $_FILES['up'];
$name = trim($file['name']);
$tmp_name = trim($file['tmp_name']);
if ($tmp_name != '') {
$dir = "./" . Core::option('files_name') . "/vars/{$id}";
CMS::mkdirs($dir);
$name = strtolower($name);
$name = trim(preg_replace('{[^a-z0-9_\\.\\-]}', '', $name));
if ($name == '') {
$name = 'noname';
}
if ($name[0] == '.') {
$name = "noname.{$name}";
}
move_uploaded_file($tmp_name, "{$dir}/{$name}");
CMS::chmod_file("{$dir}/{$name}");
Events::call('admin.change');
}
return $this->redirect_to($this->make_uri('attaches', $id));
}
示例5: create_module_file
protected function create_module_file($module, $content)
{
list($file, $dir) = $this->module_paths($module);
if (!IO_FS::exists($dir)) {
CMS::mkdirs($dir);
CMS::chmod_dir($dir);
}
if (IO_FS::exists($file)) {
//return "{$file} уже существует!";
}
$content = preg_replace('{^<}', '<', $content);
file_put_contents($file, $content);
CMS::chmod_file($file);
return false;
}
示例6: upload_file
protected function upload_file($fobject, $name, $data, $action, $item)
{
$file = $fobject->file_array;
$filename = $this->real_uploaded_filename($name, $data, $file);
$code = $this->request('code');
$dir = $this->dir_path($item, $code, $name, $data);
if (!empty($file['error'])) {
return $this->upload_error_message($file['error']);
} else {
if (!isset($file['tmp_name']) || empty($file['tmp_name']) || $file['tmp_name'] == 'none') {
throw new Exception(CMS::lang()->_common->no_file_uploaded);
//TODO: Exception class
} else {
$old = $file['tmp_name'];
$new = "{$dir}/{$filename}";
$valid = $this->upload_validate($name, $data, $file, $new);
if ($valid !== true) {
throw new Exception($valid);
}
$eres = Events::call('cms.fields.upload', $name, $data, $file, $new);
if (!is_null($eres) && $eres !== true) {
return $eres;
}
$eres = Events::call("cms.fields.{$name}.upload", $data, $file, $new);
if (!is_null($eres) && $eres !== true) {
return $eres;
}
if (!is_dir($dir)) {
CMS::mkdirs($dir);
}
CMS::copy($old, $new);
CMS::chmod_file($new);
return $this->upload_return($name, $data, $new, $dir, $filename);
}
}
}
示例7: save_info_file
public function save_info_file()
{
$title = $this['title'];
$version = $this['version'];
$content = "component {$title}\nversion {$version}\n";
foreach ($this->hashes as $file => $hash) {
$content .= "hash {$hash} {$file}\n";
}
file_put_contents($this->info_path(), $content);
CMS::chmod_file($this->info_path());
}
示例8: set
public function set($file)
{
if (!IO_FS::exists($file)) {
return $this;
}
$private = isset($this->data['private']) && $this->data['private'];
$dir = $this->type->uploaded_file_dir($this->data, $this->item, $private);
$filename = $this->type->uploaded_file_name($this->get_file_info($file), $this->data, $this->item, $this->name);
if (!$dir) {
return $this;
}
if (!IO_FS::exists($dir)) {
CMS::mkdirs($dir);
}
$_dir = preg_replace('{^\\./}', '', $dir);
copy($file, "{$dir}/{$filename}");
CMS::chmod_file("{$dir}/{$filename}");
$this->remove($file);
$file = "{$_dir}/{$filename}";
return parent::set($file);
}
示例9: process_uploads
protected function process_uploads($item)
{
if (!isset($_FILES[$this->form->name])) {
return;
}
$dir = CMS::temp_dir();
$files = $_FILES[$this->form->name];
foreach ($files['tmp_name'] as $field => $path) {
$t = time();
$path = trim($path);
if ($path == '') {
continue;
}
$original_name = $files['name'][$field];
$original_name_we = $original_name;
$ext = '';
$dotext = '';
if ($m = Core_Regexps::match_with_results('{^(.*)\\.([a-z0-9_]+)$}i', $original_name)) {
$original_name_we = strtolower($m[1]);
$ext = $m[2];
$dotext = ".{$ext}";
}
$uplname = "uploaded-{$field}-{$t}{$dotext}";
$uplpath = "{$dir}/{$uplname}";
move_uploaded_file($path, $uplpath);
CMS::chmod_file($uplpath);
$this->uploaded_files[$field] = array('original_name' => $original_name, 'original_name_we' => $original_name_we, 'ext' => $ext, 'dotext' => $dotext, 'uplname' => $uplname, 'uplpath' => $uplpath, 'size' => $files['size'][$field], 'type' => $files['type'][$field]);
}
$uploads_extra = array('old_item' => $this->item_before_assign, 'id' => $this->item_id($item), 'homedir' => $this->item_homedir($item), 'private_homedir' => $this->item_homedir($item, true), 'controller' => $this, 'form' => $this->form, 'form_fields' => $this->filtered_form_fields);
foreach ($this->filtered_form_fields as $field => $parms) {
$type = CMS_Fields::type($parms);
$type->process_uploads($field, $parms, $this->uploaded_files, $item, $uploads_extra);
}
foreach ($this->uploaded_files as $fdata) {
IO_FS::rm($fdata['uplpath']);
}
}
示例10: log
/**
* @param string $name
* @param string $text
*/
static function log($name, $text)
{
if (!IO_FS::exists(self::$logs_path)) {
self::mkdirs(self::$logs_path);
self::chmod_dir(self::$logs_path);
}
$filename = self::$logs_path . '/' . $name . '.log';
$text = trim($text);
$f = fopen($filename, "a");
$t = date('Y-m-d G:i:s');
$ip = self::ip();
fputs($f, "{$t} [{$ip}] {$text}\n");
fclose($f);
CMS::chmod_file($filename);
}
示例11: process_inserted
public function process_inserted($name, $data, $item)
{
$item_id = $item->id();
$value = trim($item[$name]);
if ($value != '') {
if ($value[0] == '#') {
$uploaded = trim(substr($value, 1));
$value = '';
if ($uploaded != '') {
$uploaded = str_replace('..', '', $uploaded);
$filename = $uploaded;
$uploaded = CMS::temp_dir() . '/' . $uploaded;
if (IO_FS::exists($uploaded)) {
$ext = '';
if ($m = Core_Regexps::match_with_results('{\\.([^\\.]+)$}', $uploaded)) {
$ext = trim($m[1]);
}
$filename = $this->uploaded_file_name($name, $data, $item, $ext, $filename);
$dir = $this->uploaded_file_dir($name, $data, $item);
if ($dir) {
if (!IO_FS::exists($dir)) {
CMS::mkdirs($dir);
}
$_dir = preg_replace('{^\\./}', '', $dir);
copy($uploaded, "{$dir}/{$filename}");
CMS::chmod_file("{$dir}/{$filename}");
IO_FS::rm($uploaded);
$value = "{$_dir}/{$filename}";
}
}
}
}
}
$item[$name] = $value;
if (!empty($value) && method_exists($item, 'clear_cache')) {
$item->clear_cache(false);
}
$this->preset->preset_on_upload($this->container($name, $data, $item));
return true;
}
示例12: save_info
public function save_info($file, $info)
{
$s = '';
foreach ($info as $field => $value) {
if (is_array($value)) {
$value = serialize($value);
}
if ($value == trim($value) && Core_Regexps::match('{^[a-zа-я0-9\\. ]*$}i', $value)) {
$s .= "{$field}={$value}\n";
} else {
$v = base64_encode($value);
$s .= "{$field}: {$v}\n";
}
}
file_put_contents($file, $s);
CMS::chmod_file($file);
}