/** * Parses the $_FILES superglobal for uploaded files. An event is triggered for each file. Handlers * can then decide whether to keep the uploaded file. The action result is filled with the properties * of the $_FILES superglobal storing the corresponding result - whether the respective file was * removed or has been accepted. */ protected function action_main($skipPermsCheck = false) { if (!$skipPermsCheck and !Permissions::has('sys_upload')) { return $this->redirectForbidden(); } $lang = i18n::load('diamondmvc'); $result = array(); $success = true; if (!empty($_FILES)) { foreach ($_FILES as $prop => $file) { // Skip this file if not desired. if (!empty($this->filters) and !in_array($prop, $this->filters)) { continue; } // Attempt to save the file. if (!$this->handleUpload($prop, $file)) { $this->addMessage(str_replace('%name%', $file['name'], $lang->get('ERROR_TITLE', 'ControllerUpload')), $lang->get('ERROR_MESSAGE', 'ControllerUpload'), 'error'); $result[$prop] = false; $success = false; } else { $result[$prop] = true; } } } $this->result = array('success' => $success, 'details' => $result); }
protected function action_plugins() { if (!Permissions::has('sys_access') or !Permissions::has('sys_plugins_view')) { return $this->redirectForbidden(); } }
protected function action_mkdir($base = '', $id = '') { if (!Permissions::has('sys_fs_create')) { return $this->redirectForbidden(); } if (!func_num_args()) { if (!isset($_REQUEST['base']) or !isset($_REQUEST['id'])) { $this->result = array('success' => false, 'msg' => 'Missing arguments'); return false; } else { $base = $_REQUEST['base']; $id = $_REQUEST['id']; } } $path = $this->buildPath($base, $id); if (file_exists($path)) { $this->result = array('success' => false, 'msg' => 'A file with this name already exists!'); return false; } if (!mkdir($path)) { $this->result = array('success' => false, 'msg' => 'I could not create your directory!'); return false; } $this->result = array('success' => true); return true; }