public function action($name, $data, $action, $item = false) { $c = CMS::$current_controller; $item_id = $item ? $item->id() : 0; if (isset($_GET['filename'])) { $filename = $_GET['filename']; $filename = str_replace('..', '', $filename); $path = CMS::temp_dir() . '/' . $filename; } if ($action == 'temp') { if (!IO_FS::exists($path)) { return false; } Core::load('Net.HTTP'); return Net_HTTP::Download($path, false); } if ($action == 'delete') { if (IO_FS::exists($path)) { IO_FS::rm($path); } return 'ok'; } if ($action == 'info') { if ($filename == 'none') { return 'ok'; } return $this->render($name, $data, 'info-ajax.phtml', array('file_path' => $path, 'file_url' => $c->field_action_url($name, 'temp', $item, array('filename' => str_replace('/', '', $filename))), 'name' => $name)); } if ($action == 'upload') { return $this->action_upload($name, $data, $action, $item); } return false; }
public function action($name, $data, $action, $item) { $file = $this->uploaded_path($item[$name]); if ($action == 'delete') { @IO_FS::rm($file); $item[$name] = ''; CMS::$current_controller->field_callback_update_item($item); return 'ok'; } if ($action == 'download') { $path = $this->uploaded_path($file); return Net_HTTP::Download($path); } return false; }
public function action($name, $data, $action, $item = false) { $code = $this->request('code'); $dir = $this->dir_path($item, $code, $name, $data); if ($action == 'delete') { return $this->action_delete($name, $data, $action, $item); } if ($action == 'download') { $file = $this->request('file'); $path = "{$dir}/{$file}"; if (!IO_FS::exists($path)) { return false; } Core::load('Net.HTTP'); return Net_HTTP::Download($path, false); } if ($action == 'reload') { $t = $this->create_template($name, $data, 'files'); return $t->with(array('type_object' => $this, 'c' => CMS::$current_controller, 'name' => $name, 'data' => $data, 'item' => $item))->render(); } if ($action == 'upload') { return $this->action_upload($name, $data, $action, $item); } return false; }
public static function download($file, $cache = false) { return Net_HTTP::Download($file, $cache); }
public function action($name, $data, $action, $item = false) { $c = CMS::$current_controller; $item_id = $item ? $item->id() : 0; if (isset($_GET['filename'])) { $filename = $_GET['filename']; if (!$this->is_valid($filename) && $filename != 'none') { return false; } $filename = str_replace('..', '', $filename); $path = CMS::temp_dir() . '/' . $filename; } if ($action == 'right' || $action == 'left') { $oldpath = $path; if ($filename == 'none' && !empty($item_id) && isset($item[$name]) && trim($item[$name]) != '') { $oldpath = $this->value_to_path($item[$name]); } $code = $this->temp_code(); $newfile = "file-{$code}-{$name}." . $this->extension($oldpath); $newpath = CMS::temp_dir() . '/' . $newfile; if (!IO_FS::exists($oldpath)) { return CMS::lang()->_common->file_not_found . ': ' . $oldpath; } Events::call('admin.change'); Core::load('CMS.Images'); } if ($action == 'right') { CMS_Images::Image($oldpath)->turn_right()->save($newpath); if (IO_FS::exists($path)) { IO_FS::rm($path); } return "!{$newfile}"; } if ($action == 'left') { CMS_Images::Image($oldpath)->turn_left()->save($newpath); if (IO_FS::exists($path)) { IO_FS::rm($path); } return "!{$newfile}"; } if ($action == 'temp') { if (!IO_FS::exists($path)) { return false; } Core::load('Net.HTTP'); return Net_HTTP::Download($path, false); } if ($action == 'delete') { //AJAX way /*if ($filename=='none'&&$item_id>0&&isset($item[$name])&&trim($item[$name])!='') { $path = $this->value_to_path($item[$name]); $item[$name] = ''; $item->update(); }*/ if (IO_FS::exists($path)) { IO_FS::rm($path); } Events::call('admin.change'); return 'ok'; } if ($action == 'info') { if ($filename == 'none') { return 'ok'; } $data['__item'] = $item; return $this->render($name, $data, 'info-ajax.phtml', array('image_path' => $path, 'name' => $name, 'image_url' => $c->field_action_url($name, 'temp', $item, array('filename' => str_replace('/', '', $filename))), 'name' => $name)); } if ($action == 'preview') { $size = 100; if (isset($data['admin_preview_size'])) { $size = $data['admin_preview_size']; } if (!IO_FS::exists($path)) { return false; } Core::load('CMS.Images'); $image = CMS_Images::Image($path)->fit($size, $size); $image->out(); die; } if ($action == 'upload') { $r = $this->action_upload($name, $data, $action, $item); // $this->preset->preset_on_upload($this->container($name, $data, $item)); return $r; } return false; }
/** * @param string $file */ protected function download_file($file) { return Net_HTTP::Download($file); }
public function run(WS_Environment $env) { if (isset($_SERVER['REQUEST_URI']) && ($uri = $_SERVER['REQUEST_URI'])) { if (strpos($uri, '/component-static/') === 0) { $uri = substr($uri, 18); if ($m = Core_regexps::match_with_results('{^([^/]+)/(.+(css|js|gif|jpg|png))/(\\d+)/$}', $uri)) { $component = $m[1]; $file = $m[2]; $path = CMS::component_dir($component, $file); if (IO_FS::exists($path)) { Core::load('WS.Adapters'); $adapter = WS_Adapters::apache(); $adapter->process_response(Net_HTTP::Download($path, true)); exit; } } } } return $this->application->run($env); }