public function delete($var) { if (is_string($var)) { $var = $this->load($var); } $path = $this->path($var->name()); if ($var->is_dir()) { CMS::rmdir($path); } else { IO_FS::rm($path); } }
public function remove($file, $name, $data, $item) { $dir = $this->dir_path($item, null, $name, $data); return IO_FS::rm($dir . '/' . $file); }
public function delfile($parms) { $id = (int) $parms['id']; $file = $_GET['file']; @IO_FS::rm($file); Events::call('admin.change'); return $this->redirect_to($this->make_uri('attaches', $id)); }
public function change($id, $data, $item) { if (is_object($item)) { $item->id = $id; } $file = $_FILES['value']; $name = trim($file['name']); $tmp_name = trim($file['tmp_name']); if ($tmp_name != '') { $dir = "./" . Core::option('files_name') . "/vars/{$id}"; CMS::mkdirs($dir, 0775); foreach (IO_FS::Dir($dir) as $f) { @IO_FS::rm($f->path); } $name = CMS::translit(mb_strtolower($name)); $name = preg_replace('{\\s+}', '_', $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}"); chmod("{$dir}/{$name}", 0775); $rc = CMS::vars()->on_change_call($id, $value, $data); if (is_string($rc)) { $item->valuesrc = $data['valuesrc']; return $rc; } $item->value = "{$dir}/{$name}"; $item->update_value(); } }
protected function action_delgallery($id) { $fid = (int) $_GET['file']; $item = $this->load($id); if (!$item) { return $this->page_not_found(); } $files = $item[$this->gallery_field]; if (is_string($files)) { $files = unserialize($files); } if (!is_array($files)) { $files = array(); } @IO_FS::rm($files[$fid]['file_path']); @IO_FS::rm($files[$fid]['preview_path']); unset($files[$fid]); $item[$this->gallery_field] = $files; $this->update($item); Events::call('admin.change', $item); return $this->redirect_to($this->admin_url('gallery', $id)); }
/** * @return boolean */ private function rm_storage_dir() { $rc = true; foreach ($this as $file) { $rc = $rc && IO_FS::rm($file->path); } return $rc && IO_FS::rm($this->full_path); }
public function action_user_mod_delete($name, $data, $action, $item = false, $fields = array()) { $mod = $this->request('mod'); $file_name = $this->request('file_name'); $dir = $this->dir_path($item, $this->request('code'), $name, $data); $path = $dir . '/' . $mod . '/' . $file_name; if (IO_FS::exists($path) && IO_FS::rm($path)) { $mods_info = $this->load_mods_info($dir); if (!empty($mods_info[$file_name][$mod])) { unset($mods_info[$file_name][$mod]); } $this->save_mods_info($dir, $mods_info); return 'ok'; } return 'ok'; }
/** * Удалят значение из кэша * * @param string $key * * @return boolean */ public function delete($key) { Events::call('cache.delete', $key); $res = IO_FS::rm($this->path($key)); if ($this->use_array_cache) { if (isset($this->values[$key])) { unset($this->values[$key]); } if (isset($this->timestamps[$key])) { unset($this->timestamps[$key]); } } return $res; }
public function remove_existed_file($item, $name, $file = false) { $oldfile = isset($item->{$name}) ? trim($item->{$name}) : ''; $oldpath = $this->uploaded_path($oldfile); if ($oldpath && $oldfile != $file) { IO_FS::rm($oldpath); } return; }
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']); } }
public function delete_all() { $this->clear_query_cache(); return (bool) IO_FS::rm($this->base_path()); }
public function remove() { $path = $this->path(); $default_image_path = $this->default_image_path(); if (IO_FS::exists($path) && (!$default_image_path || $path != $default_image_path)) { IO_FS::rm($path); parent::set(''); return true; } return false; }
/** * Формирует один фаил с заголовками и параметрами * * @param $container * @param int $index */ protected function head($container, $index) { $values = array(); $headers = Mail_Message::Head(); foreach ($container as $k => $v) { if (array_search($k, Mail_List::option('headers'), true) !== false) { $headers->field($k, $v); } else { $values[] = sprintf("-%s: %s", $k, MIME::encode_qp($v, null)); } } $path = sprintf('%s/%s.%06d', Mail_List::option('root') . '/recipients', $this->id, $index); IO_FS::rm($path); $f = IO_FS::File($path); $f->open('w')->write($headers->encode() . (count($values) ? implode("\n", $values) . "\n" : ''))->close(); $f->chmod(0664); }
/** * @return DB_ORM_Assets_Collection */ public function sync() { if ($this->path !== null) { IO_FS::mkdir($this->path_for(''), 0777, true); foreach ($this->removed as $name) { IO_FS::rm($this->path_for($name)); } foreach ($this->added as $name => $file) { $stored = $file->copy_to($this->path_for($name)); $stored->chmod(0666); } } return $this; }
protected function onpage_to_file($type = 'js') { $enable = $this->use_onpage_to_file[$type]; if ($enable) { $content = $this[$type]; $request = WS::env()->request; $path = 'onpage' . '/' . trim($request->path, '/.'); $method = "{$type}_path"; $dir = '.' . Templates_HTML::$method($path); $name = md5($content); // $name = md5($request->query); $file = $dir . '/' . $name . '.' . $type; if (!is_file($file)) { IO_FS::rm($dir); IO_FS::mkdir($dir); file_put_contents($file, $content); } $this->use_file(array('name' => trim($file, '.'), 'weight' => 100000)); $this[$type] = ''; } return $this; }
public function set($value) { if (IO_FS::exists($value)) { $ext = ''; if ($m = Core_Regexps::match_with_results('{\\.([^\\.]+)$}', $value)) { $ext = strtolower(trim($m[1])); } $filename = $this->type->uploaded_file_name($this->name, $this->data, $this->item, $ext); $dir = $this->type->uploaded_file_dir($this->name, $this->data, $this->item); if ($dir) { if (!IO_FS::exists($dir)) { CMS::mkdirs($dir); } $_dir = preg_replace('{^\\./}', '', $dir); copy($value, "{$dir}/{$filename}"); IO_FS::rm($uploaded); $value = "{$_dir}/{$filename}"; return parent::set($value); } } return $this; }