protected function saveUploadedFile() { $file = new Gpf_Db_File(); $file->set('filename', $this->name); $file->set('filesize', $this->size); $file->set('filetype', $this->type); $file->save(); $dir = new Gpf_Io_File($this->getZipFolderUrl().$file->getFileId().'/'); if ($dir->isExists()) { $dir->delete(); } $dir->mkdir(); $tmpZip = new Gpf_Io_File($this->getZipFolderUrl().$file->getFileId().'/'.$file->getFileId().".zip"); $dir->copy(new Gpf_Io_File($this->tmpName),$tmpZip); $archive = new PclZip($this->getZipFolderUrl().$file->getFileId().'/'.$file->getFileId().".zip"); $err = $archive->extract($this->getZipFolderUrl().$file->getFileId().'/'); if ($err <= 0) { throw new Gpf_Exception("code: ".$err); } $tmpZip->delete(); return $file; }
/** * @service theme write * * @return Gpf_Rpc_Action */ public function save(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $newThemeId = str_replace(' ', '_', $form->getFieldValue('name')); $srcTheme = new Gpf_Desktop_Theme($form->getFieldValue('Id') , $form->getFieldValue('panelName')); $srcPath = $srcTheme->getThemePath(); $targetPath = new Gpf_Io_File($srcPath->getParent().$newThemeId); try{ $targetPath->mkdir(); $srcPath->recursiveCopy($targetPath); $newTheme = new Gpf_Desktop_Theme($newThemeId , $form->getFieldValue('panelName')); $newTheme->load(); $newTheme->setName($form->getFieldValue('name')); $newTheme->setAuthor($form->getFieldValue('author')); $newTheme->setUrl($form->getFieldValue('url')); $newTheme->setDescription($form->getFieldValue('description')); $newTheme->setBuiltIn(false); $newTheme->save(); }catch(Gpf_Exception $ex){ $form->setErrorMessage($ex->getMessage()); } $form->setField('themeId', $newThemeId); return $form; }
public function onActivate() { $zipDir = new Gpf_Io_File(Gpf_Paths::getInstance()->getFullAccountPath().Pap_Features_ZipBanner_Unziper::ZIP_DIR); if ($zipDir->isExists() === false) { $zipDir->mkdir(); } $cacheZipDir = new Gpf_Io_File(Gpf_Paths::getInstance()->getCacheAccountDirectory().'zip/'); if ($cacheZipDir->isExists() === false) { $cacheZipDir->mkdir(); } }
private function copyFilesToCacheZipFolder($unpackedZipFolderPath, $cacheZipFolderPath) { $unpackedZipFolder = new Gpf_Io_File($unpackedZipFolderPath); $cacheZipFolder = new Gpf_Io_File($cacheZipFolderPath); if ($cacheZipFolder->isExists()) { $cacheZipFolder->emptyFiles(true); $cacheZipFolder->rmdir(); } $cacheZipFolder->mkdir(); $unpackedZipFolder->recursiveCopy($cacheZipFolder); }
public function insert() { parent::insert(); $file = new Gpf_Io_File(Gpf_Paths::getInstance()->getAccountDirectoryPath() . Pap_Features_SiteReplication_Replicator::SITES_DIR . $this->getId()); $file->mkdir(); }
private function checkAccountsWritable() { $requirement = new Gpf_Install_Requirement(); $requirement->setPositiveName($this->_('Configuration directory is writable')); $requirement->setNegativeName($this->_('Configuration directory has to be writable')); $accountDirectory = Gpf_Paths::getInstance()->getAccountsPath(); $result = @is_dir($accountDirectory) && is_writable($accountDirectory); if ($result) { $this->deleteIfExistsTestFilesAndDir($accountDirectory); $testFile = new Gpf_Io_File($accountDirectory . 'check'); $subTestFile = new Gpf_Io_File($accountDirectory . 'check/subcheck'); try { $testFile->open('w'); $testFile->close(); $testFile->delete(); } catch (Exception $e) { $result = false; $requirement->setNegativeName($this->_('Could not create file inside %s directory', $accountDirectory)); } try { $testFile->mkdir(); $testFile->rmdir(); } catch (Exception $e) { $result = false; $requirement->setNegativeName($this->_('Could not create directory inside %s directory', $accountDirectory)); } try { $testFile->mkdir(); $subTestFile->open('w'); $subTestFile->close(); $subTestFile->delete(); $subTestFile->mkdir(); $subTestFile->rmdir(); $testFile->rmdir(); } catch (Exception $e) { $result = false; $requirement->setNegativeName($this->_('Could not create file or directory inside %s subdirectory. Probably safe mode is not properly configured.', $accountDirectory)); } } $requirement->setResult($result); $description = $this->_('Please make directory %s and all subdirectories writable by webserver.', $accountDirectory); if (stripos(PHP_OS, 'win') === false) { $description .= $this->_('On unix-like systems you can type "chmod -R 777 %s".', $accountDirectory); } $description .= $this->_('On any system you can set write permissions using your favourite FTP client.'); $requirement->setFixDescription($description); $this->addRequirement($requirement); }
private function checkCompilePanelDirectory() { $baseCompileDir = Gpf_Templates_Smarty::getCompileDir(); $panelDir = new Gpf_Io_File($baseCompileDir . $this->panel . '/'); if (!$panelDir->isExists()) { $panelDir->mkdir(true); } }
public function recursiveCopy(Gpf_Io_File $target, $mode = null) { if ($this->isDirectory()) { $dir = new Gpf_Io_DirectoryIterator($this, '', false, true); foreach ($dir as $fullFileName => $fileName) { $file = new Gpf_Io_File($fullFileName); $targetDir = new Gpf_Io_File($target->getFileName() . '/' . $fileName); $targetDir->mkdir(); $file->recursiveCopy($targetDir); } $dir = new Gpf_Io_DirectoryIterator($this, '', false); foreach ($dir as $fullFileName => $fileName) { $srcFile = new Gpf_Io_File($fullFileName); $dstFile = new Gpf_Io_File($target->getFileName() . '/' . $fileName); $this->copy($srcFile, $dstFile); } } else { throw new Gpf_Exception($this->_('%s is not directory!', $this->fileName)); } return true; }
protected function createDirectory(Gpf_Io_File $directory) { if ($directory->isExists() && !$directory->isWritable()) { throw new Gpf_Exception($this->_('Directory %s is not writable by web server user. Please remove it or set write permissions.', $directory->getFileName())); } if (!$directory->isExists()) { $directory->mkdir(true); } }
private static function getTempInAccountsDir() { $tempDir = new Gpf_Io_File(Gpf_Paths::getInstance()->getFullBaseServerPath() . Gpf_Paths::ACCOUNTS_DIR . 'TMP'); if ($tempDir->isDirectory() && $tempDir->isWritable()) { return $tempDir->getFileName(); } try { $tempDir->mkdir(); return $tempDir->getFileName(); } catch (Gpf_Exception $e) { return self::INSTALL_STREAM . '://:'; } }