/** * Constructs a new Debug-Object. * * The first parameter has to be the file name with extension, but without directory. The second * parameter has to be a valid and existing directory path with trainling directory separator * (make sure the directory is writable). Standard value for this paramteer is null. If the * directory is null or invalid "data/logs/" will be used. If the specified file doesn't exist * it will created. If it is not possible to create a file a NonFatalException will be thrown. * * @param string File for saving the logdata * @param string Valid Directory for saving the logfile or null (directory will be "data/logs/") * @throws NonFatalException */ public function __construct($file, $dir = null) { if ($dir === null || is_dir($dir) === false) { $dir = 'data/logs/'; } $this->file = new File($dir.basename($file)); if ($this->file->create() === false) { throw new NonFatalException('Could not create log file "'.$this->file->relPath().'".'); } if ($this->file->readable() === false || $this->file->writable() === false) { $this->file->setPermissions(666); } $this->logs = array(); $this->benchmarks = array(); $this->temp = array(); }
private function __actionFile() { $FileManager =& $this->_Parent->ExtensionManager->create('filemanager'); $context = $this->_context; array_shift($context); $path = DOCROOT . $FileManager->getStartLocation() . (is_array($context) && !empty($context) ? '/' . implode('/', $context) . '/' : NULL); $permission = $_POST['fields']['file']['permissions']; $content = $_POST['fields']['file']['contents']; $filename = $_POST['fields']['file']['name']; $file = new File($path . '/' . $filename); $file->setContents($content); $file->setPermissions($permission); return $file->isFile(); }
function action() { $FileManager =& $this->_Parent->ExtensionManager->create('filemanager'); $file = new File(DOCROOT . $FileManager->getStartLocation() . $_GET['file']); if (isset($_POST['action']['save'])) { $fields = $_POST['fields']; $file->setName($fields['name']); if (isset($fields['contents'])) { $file->setContents($fields['contents']); } $file->setPermissions($fields['permissions']); $relpath = str_replace(DOCROOT . $FileManager->getStartLocation(), NULL, dirname($_GET['file'])); if ($file->isWritable()) { redirect($FileManager->baseURL() . 'properties/?file=' . rtrim(dirname($_GET['file']), '/') . '/' . $file->name() . '&result=saved'); } else { redirect($FileManager->baseURL() . 'browse/' . $relpath); } } elseif (isset($_POST['action']['delete'])) { General::deleteFile($file->path() . '/' . $file->name()); $relpath = str_replace(DOCROOT . $FileManager->getStartLocation(), NULL, dirname($_GET['file'])); redirect($FileManager->baseURL() . 'browse/' . $relpath); } }