当前位置: 首页>>代码示例>>PHP>>正文


PHP CMS::temp_dir方法代码示例

本文整理汇总了PHP中CMS::temp_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP CMS::temp_dir方法的具体用法?PHP CMS::temp_dir怎么用?PHP CMS::temp_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMS的用法示例。


在下文中一共展示了CMS::temp_dir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: zip_upload

 protected function zip_upload($fobject, $name, $data, $action, $item)
 {
     $res = array();
     $mtype = MIME::type_for_file($fobject->original_name);
     if ($mtype->type == 'application/zip;zip') {
         $zip = new ZipArchive();
         $ro = $zip->open($fobject->path);
         if ($ro === true) {
             $dir = CMS::temp_dir() . '/' . $fobject->name;
             $dir_object = IO_FS::mkdir($dir, null, true);
             if ($dir_object) {
                 $zip->extractTo($dir);
                 $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS));
                 foreach ($objects as $k => $object) {
                     $base = trim($object->getBasename($object->getExtension()), '. ');
                     if ('' !== $base) {
                         $upload = Net_HTTP::Upload($object->getPathname(), $object->getFilename(), array('name' => $object->getFilename(), 'type' => MIME::type_for_file($object->getPathname())->type, 'tmp_name' => $object->getPathname(), 'error' => 0, 'size' => $object->getSize()));
                         $res[] = $this->upload_file($upload, $name, $data, $action, $item);
                     }
                 }
                 $dir_object->rm();
             }
             $zip->close();
         }
     }
     return $res;
 }
开发者ID:techart,项目名称:tao,代码行数:27,代码来源:Gallery.php

示例2: process_uploads

 protected function process_uploads($item)
 {
     $id = $this->item_id($item);
     $uploaded = array();
     $ruploaded = array();
     $udirs = array();
     $tmpdir = CMS::temp_dir();
     foreach ($this->upload_fields as $field => $dir) {
         if (is_string($dir)) {
             $dir = rtrim($dir, '/');
             if ($this->uploads_multi_dir) {
                 $did = floor($id / 100) * 100;
                 $dir .= "/{$did}";
             }
             if (!IO_FS::exists($dir)) {
                 $this->mkdirs($dir);
             }
             $udirs[$field] = $dir;
         }
         if (is_object($this->form[$field])) {
             $path = $this->form[$field]->path;
             $original_name = $this->form[$field]->original_name;
             $ext = '';
             if ($m = Core_Regexps::match_with_results('{(\\.[a-z0-9_]+)$}i', $original_name)) {
                 $ext = strtolower($m[1]);
             }
             $name = $this->upload_destination($id, $field, $ext, $original_name);
             if (is_string($dir) && $dir != '') {
                 $name = "{$dir}/{$name}";
             }
             $name = trim($name);
             move_uploaded_file($path, $name);
             $ncname = $tmpdir . '/upl-' . md5($name) . $ext;
             $ncres = @copy($name, $ncname);
             $type = self::$field_types[$this->form_fields[$field]['type']];
             if ($type) {
                 $r = $type->after_upload($name, $this->form_fields[$field]);
                 if ($r) {
                     $name = $r;
                 }
             }
             $this->chmod_file($name);
             $old = trim($this->item_before_assign->{$field});
             if ($old != '' && $name != $old && IO_FS::exists($old)) {
                 IO_FS::rm($old);
             }
             $item->{$field} = $name;
             $uploaded[$field] = $ncres ? $ncname : $name;
             $ruploaded[$field] = $name;
         }
     }
     foreach ($udirs as $field => $dir) {
         $type = self::$field_types[$this->form_fields[$field]['type']];
         if ($type) {
             $old = trim($this->item_before_assign->{$field});
             $name = rtrim($udirs[$field], '/ ') . '/' . $this->upload_destination($id, $field, '.$$$', 'null.$$$');
             $name = $type->after_all_uploads($field, $this->form_fields[$field], $name, $uploaded, $old);
             if ($name) {
                 $this->chmod_file($name);
                 if ($old != '' && $name != $old && IO_FS::exists($old)) {
                     IO_FS::rm($old);
                 }
                 $item->{$field} = $name;
             }
         }
     }
     foreach ($uploaded as $field => $file) {
         if ($file != $ruploaded[$field]) {
             @unlink($file);
         }
     }
 }
开发者ID:techart,项目名称:tao,代码行数:72,代码来源:AdminTableBase.php

示例3: dir_path

 public function dir_path($item, $code, $name, $data)
 {
     $item_id = $item ? $item->id() : 0;
     $key = "{$name}-{$item_id}-{$code}-{$data['private']}";
     if ($item->mapper) {
         $key .= '-' . reset($item->mapper->options['table']);
     }
     if (isset($this->dir_paths[$key])) {
         return $this->dir_paths[$key];
     }
     $dir = false;
     if (empty($item_id)) {
         $dir = CMS::temp_dir() . "/dir-{$code}";
     } else {
         $dir = $item->homedir(isset($data['private']) && $data['private']);
         if ($dir == '') {
             die;
         }
         if ($dir[0] != '.' && $dir[0] != '/') {
             $dir = "./{$dir}";
         }
     }
     $dir .= "/{$name}";
     return $this->dir_paths[$key] = $dir;
 }
开发者ID:techart,项目名称:tao,代码行数:25,代码来源:Fields.php

示例4: install_temp_dir

 public function install_temp_dir()
 {
     return CMS::temp_dir() . '/stockroom/' . $this->code();
 }
开发者ID:techart,项目名称:tao,代码行数:4,代码来源:Stockroom.php

示例5: 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']);
     }
 }
开发者ID:techart,项目名称:tao,代码行数:37,代码来源:Fields.php

示例6: 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;
 }
开发者ID:techart,项目名称:tao,代码行数:40,代码来源:Image.php


注:本文中的CMS::temp_dir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。