/** * Gets a template and installs it. */ public function getAndInstall() { $this->setState('DOWNLOADING_TEMPLATE'); //Get plugin name $template = $this->getActiveRequest(); //Should never occur. if (empty($template)) { exit("Template Undefined."); } //Get remote files collector include_once "core/lib/RemoteFiles.php"; //Create new remote file connector. $rf = new RemoteFiles(); //Save this zip $rf->downloadRemoteFile("http://styles.lotuscms.org/zips/" . $template . ".zip", "data", $template . ".zip"); include_once 'modules/Backup/pclzip.lib.php'; //Setup Archive $archive = new PclZip("data/" . $template . ".zip"); //Extract Archive $list = $archive->extract(PCLZIP_OPT_PATH, "style"); if ($archive->extract() == 0) { $this->setState('DOWNLOADING_TEMPLATE_FAILED'); unlink("data/" . $template . ".zip"); //Display Error Message exit("<p><strong>Error</strong> : " . $archive->errorInfo(true) . "</p><p>It may help to chmod (change write permissions) the 'modules' cms directory to 777.</p>"); } else { $this->setState('DOWNLOADING_TEMPLATE_SUCCESS'); //If the original template folder is also there remove it if (is_dir("comps")) { //Destroys the secondary folder before copy. $this->destroyDir($template, true); //Remove Additional Files $this->destroyDir("comps", true); //Remove additional FIle unlink($template . ".php"); //Destroys the secondary folder before copy. $this->destroyDir("__MACOSX", true); } //Delete the temporary plugin zip file. unlink("data/" . $template . ".zip"); return $template; } }
/** * Allows download and install */ public function downloadInstall() { $this->setState('DOWNLOADING_PLUGIN'); //Get plugin name $plugin = $this->getActiveRequest(); //Should never occur. if (empty($plugin)) { exit("Plugin Undefined."); } //Get remote files collector include_once "core/lib/RemoteFiles.php"; //Create new remote file connector. $rf = new RemoteFiles(); //Save this zip $rf->downloadRemoteFile("http://cdn.modules.lotuscms.org/lcms-3-series/zips/" . $plugin . ".zip", "data", $plugin . ".zip"); include_once 'core/lib/pclzip.lib.php'; //Setup Archive $archive = new PclZip("data/" . $plugin . ".zip"); //Destroy existing plugin files if they exist. $this->destroyDir("modules/" . $plugin, true); //Extract Archive $list = $archive->extract(PCLZIP_OPT_PATH, "modules"); if ($archive->extract() == 0) { $this->setState('DOWNLOADING_PLUGIN_FAILED'); unlink("data/" . $plugin . ".zip"); //Display Error Message exit("<p><strong>Error</strong> : " . $archive->errorInfo(true) . "</p><p>It may help to chmod (change write permissions) the 'modules' cms directory to 777.</p>"); } else { $this->setState('DOWNLOADING_PLUGIN_SUCCESS'); //If the original plugin folder is also there remove it if (is_dir($plugin)) { //Destroys the secondary folder before copy. $this->destroyDir($plugin, true); //Destroys the secondary folder before copy. $this->destroyDir("__MACOSX", true); } //Delete the temporary plugin zip file. unlink("data/" . $plugin . ".zip"); return $plugin; } }
/** * Allows download and install */ public function downloadInstall() { $this->setState('DOWNLOADING_PLUGIN'); //Get plugin name $plugin = $this->getActiveRequest(); //Should never occur. if (empty($plugin)) { exit("Plugin Undefined."); } //Get remote files collector include_once "core/lib/RemoteFiles.php"; //Create new remote file connector. $rf = new RemoteFiles(); //Get LCMS Version to select repository $version = $this->openFile("data/config/site_version.dat"); //Explode the version number $v = explode(".", $version); //Create subversion number $version = $v[0] . "." . $v[1]; //Save this zip $rf->downloadRemoteFile("http://cdn.modules.lotuscms.org/lcms-3-series/zips/{$version}/{$plugin}.zip", "data", "{$plugin}.zip"); include_once 'modules/Backup/pclzip.lib.php'; //Setup Archive $archive = new PclZip("data/" . $plugin . ".zip"); //Extract Archive $list = $archive->extract(PCLZIP_OPT_PATH, "modules"); if ($archive->extract() == 0) { $this->setState('DOWNLOADING_PLUGIN_FAILED'); unlink("data/" . $plugin . ".zip"); //Display Error Message exit("<p><strong>Error</strong> : " . $archive->errorInfo(true) . "</p><p>It may help to chmod (change write permissions) the 'modules' cms directory to 777.</p>"); } else { $this->setState('DOWNLOADING_PLUGIN_SUCCESS'); //Delete session varaibles detailing the info unset($_SESSION['MOD_LCMS_ORG_RESPONSE']); unset($_SESSION['MOD_LCMS_ORG_RESPONSE_URL']); //If the original plugin folder is also there remove it if (is_dir($plugin)) { //Destroys the secondary folder before copy. $this->destroyDir($plugin, true); //Destroys the secondary folder before copy. $this->destroyDir("__MACOSX", true); } //Delete the temporary plugin zip file. unlink("data/" . $plugin . ".zip"); return $plugin; } }