public function processCleanUp() { $configs = OW::getConfig()->getValues('cacheextreme'); //clean template cache if ($configs['template_cache']) { OW_ViewRenderer::getInstance()->clearCompiledTpl(); } //clean db backend cache if ($configs['backend_cache']) { OW::getCacheManager()->clean(array(), OW_CacheManager::CLEAN_ALL); } //clean themes static contents cache if ($configs['theme_static']) { OW::getThemeManager()->getThemeService()->processAllThemes(); } //clean plugins static contents cache if ($configs['plugin_static']) { $pluginService = BOL_PluginService::getInstance(); $activePlugins = $pluginService->findActivePlugins(); /* @var $pluginDto BOL_Plugin */ foreach ($activePlugins as $pluginDto) { $pluginStaticDir = OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'static' . DS; if (file_exists($pluginStaticDir)) { $staticDir = OW_DIR_STATIC_PLUGIN . $pluginDto->getModule() . DS; if (file_exists($staticDir)) { UTIL_File::removeDir($staticDir); } mkdir($staticDir); chmod($staticDir, 0777); UTIL_File::copyDir($pluginStaticDir, $staticDir); } } } }
private function cleanImportDir($dir) { $dh = opendir($dir); while ($node = readdir($dh)) { if ($node == '.' || $node == '..') { continue; } if (is_dir($dir . $node)) { UTIL_File::removeDir($dir . $node); continue; } unlink($dir . $node); } }
* Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy * of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ try { $sql = "SHOW COLUMNS FROM `" . OW_DB_PREFIX . "video_clip` LIKE 'plugin';"; $cols = Updater::getDbo()->queryForList($sql); if (!count($cols)) { $sql = "ALTER TABLE `" . OW_DB_PREFIX . "video_clip` ADD `plugin` VARCHAR(255) NULL DEFAULT 'video' ; "; Updater::getDbo()->update($sql); } } catch (Exception $e) { } // refresh static cache $plugin = OW::getPluginManager()->getPlugin('spvideolite'); $staticDir = OW_DIR_STATIC_PLUGIN . $plugin->getModuleName() . DS; $pluginStaticDir = OW_DIR_PLUGIN . $plugin->getModuleName() . DS . 'static' . DS; if (file_exists($staticDir)) { UTIL_File::removeDir($staticDir); } mkdir($staticDir); chmod($staticDir, 0777); UTIL_File::copyDir($pluginStaticDir, $staticDir);
/** * Removes theme static files and theme db content. * * @param integer $themeId * @throws InvalidArgumentException */ public function unlinkTheme($themeId) { $theme = $this->getThemeById($themeId); if (file_exists($this->getStaticDir($theme->getName()))) { @UTIL_File::removeDir($this->getStaticDir($theme->getName())); } $this->deleteThemeContent($theme->getId()); }
/** * Uninstalls plugin. * * @param string $key */ public function uninstall($key) { if (empty($key)) { throw new LogicException(''); } $pluginDto = $this->findPluginByKey(trim($key)); if ($pluginDto === null) { throw new LogicException(''); } // trigger event $event = new OW_Event(OW_EventManager::ON_BEFORE_PLUGIN_UNINSTALL, array('pluginKey' => $pluginDto->getKey())); OW::getEventManager()->trigger($event); include OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'deactivate.php'; // include plugin custom uninstall script include OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'uninstall.php'; // delete plugin work dirs $dirsToRemove = array(OW_DIR_PLUGINFILES . $pluginDto->getModule(), OW_DIR_PLUGIN_USERFILES . $pluginDto->getModule()); if (!defined('OW_PLUGIN_XP')) { $dirsToRemove[] = OW_DIR_STATIC_PLUGIN . $pluginDto->getModule(); } foreach ($dirsToRemove as $dir) { if (file_exists($dir)) { UTIL_File::removeDir($dir); } } // remove plugin configs OW::getConfig()->deletePluginConfigs($pluginDto->getKey()); // delete language prefix $prefixId = BOL_LanguageService::getInstance()->findPrefixId($pluginDto->getKey()); if (!empty($prefixId)) { BOL_LanguageService::getInstance()->deletePrefix($prefixId, true); } //delete authorization stuff BOL_AuthorizationService::getInstance()->deleteGroup($pluginDto->getKey()); // drop plugin tables $tables = OW::getDbo()->queryForColumnList("SHOW TABLES LIKE '" . str_replace('_', '\\_', OW_DB_PREFIX) . $pluginDto->getKey() . "\\_%'"); if (!empty($tables)) { $query = "DROP TABLE "; foreach ($tables as $table) { $query .= "`" . $table . "`,"; } $query = substr($query, 0, -1); OW::getDbo()->query($query); } //remove entry in DB $this->deletePluginById($pluginDto->getId()); }
public function coreUpdate() { $this->checkXP(); if (!(bool) OW::getConfig()->getValue('base', 'update_soft')) { throw new Redirect404Exception(); } $language = OW::getLanguage(); $archivePath = OW_DIR_PLUGINFILES . 'ow' . DS . 'core.zip'; $tempDir = OW_DIR_PLUGINFILES . 'ow' . DS . 'core' . DS; $ftp = $this->getFtpConnection(); $errorMessage = false; OW::getApplication()->setMaintenanceMode(true); $this->pluginService->downloadCore($archivePath); if (!file_exists($archivePath)) { $errorMessage = $language->text('admin', 'core_update_download_error'); } else { mkdir($tempDir); $zip = new ZipArchive(); $zopen = $zip->open($archivePath); if ($zopen === true) { $zip->extractTo($tempDir); $zip->close(); $ftp->uploadDir($tempDir, OW_DIR_ROOT); $ftp->chmod(0777, OW_DIR_STATIC); $ftp->chmod(0777, OW_DIR_STATIC_PLUGIN); } else { $errorMessage = $language->text('admin', 'core_update_unzip_error'); } } if (file_exists($tempDir)) { UTIL_File::removeDir($tempDir); } if (file_exists($archivePath)) { unlink($archivePath); } if ($errorMessage !== false) { OW::getApplication()->setMaintenanceMode(false); OW::getFeedback()->error($errorMessage); $this->redirect(OW::getRouter()->urlFor('ADMIN_CTRL_Index', 'index')); } $this->redirect(OW_URL_HOME . 'ow_updates/index.php'); }
/** * Removes theme static files and theme db content. * * @param integer $themeId * @throws InvalidArgumentException */ public function unlinkTheme($themeId) { $theme = $this->getThemeById($themeId); if (empty($theme)) { throw new InvalidArgumentException("Can't unlink theme with id `" . $themeId . "`, not found!"); } if (file_exists($this->getStaticDir($theme->getKey()))) { UTIL_File::removeDir($this->getStaticDir($theme->getKey())); } $this->deleteThemeContent($theme->getId()); }
public function update(array $params) { $themeDto = $this->getThemeDtoByKeyInParamsArray($params); $language = OW::getLanguage(); $router = OW::getRouter(); if (!empty($_GET["mode"])) { switch (trim($_GET["mode"])) { case "theme_up_to_date": $this->feedback->warning($language->text("admin", "manage_themes_up_to_date_message")); break; case "theme_update_success": $this->feedback->info($language->text("admin", "manage_themes_update_success_message")); break; default: $this->feedback->error($language->text("admin", "manage_themes_update_process_error")); break; } $this->redirect($router->urlForRoute("admin_themes_choose")); } $remoteThemeInfo = (array) $this->storageService->getItemInfoForUpdate($themeDto->getKey(), $themeDto->getDeveloperKey(), $themeDto->getBuild()); if (empty($remoteThemeInfo) || !empty($remoteThemeInfo["error"])) { $this->feedback->error($language->text("admin", "manage_themes_update_process_error")); $this->redirect($router->urlForRoute("admin_themes_choose")); } if (!(bool) $remoteThemeInfo["freeware"] && ($themeDto->getLicenseKey() == null || !$this->storageService->checkLicenseKey($themeDto->getKey(), $themeDto->getDeveloperKey(), $themeDto->getLicenseKey()))) { $this->feedback->error($language->text("admin", "manage_plugins_update_invalid_key_error")); $this->redirect($router->urlForRoute("admin_themes_choose")); } $ftp = $this->getFtpConnection(); try { $archivePath = $this->storageService->downloadItem($themeDto->getKey(), $themeDto->getDeveloperKey(), $themeDto->getLicenseKey()); } catch (Exception $e) { $this->feedback->error($e->getMessage()); $this->redirect($router->urlForRoute("admin_themes_choose")); } if (!file_exists($archivePath)) { $this->feedback->error($language->text("admin", "theme_update_download_error")); $this->redirect($router->urlForRoute("admin_themes_choose")); } $zip = new ZipArchive(); $pluginfilesDir = OW::getPluginManager()->getPlugin("base")->getPluginFilesDir(); $tempDirPath = $pluginfilesDir . UTIL_HtmlTag::generateAutoId("theme_update") . DS; if ($zip->open($archivePath) === true) { $zip->extractTo($tempDirPath); $zip->close(); } else { $this->feedback->error($language->text("admin", "theme_update_download_error")); $this->redirect($router->urlForRoute("admin_themes_choose")); } $result = UTIL_File::findFiles($tempDirPath, array("xml")); $localThemeRootPath = null; foreach ($result as $item) { if (basename($item) == BOL_ThemeService::THEME_XML) { $localThemeRootPath = dirname($item) . DS; } } if ($localThemeRootPath == null) { $this->feedback->error($language->text("admin", "manage_theme_update_extract_error")); $this->redirect($router->urlForRoute("admin_themes_choose")); } $remoteDir = OW_DIR_THEME . $themeDto->getKey(); if (!file_exists($remoteDir)) { $this->feedback->error($language->text("admin", "manage_theme_update_theme_not_found")); $this->redirect($router->urlForRoute("admin_themes_choose")); } $ftp->uploadDir($localThemeRootPath, $remoteDir); UTIL_File::removeDir($localThemeRootPath); $params = array("theme" => $themeDto->getKey(), "back-uri" => urlencode(OW::getRequest()->getRequestUri())); $this->redirect(OW::getRequest()->buildUrlQueryString($this->storageService->getUpdaterUrl(), $params)); }
public function update(array $params) { $this->checkXP(); if (!empty($_GET['mode'])) { switch (trim($_GET['mode'])) { case 'theme_up_to_date': OW::getFeedback()->warning(OW::getLanguage()->text('admin', 'manage_themes_up_to_date_message')); break; case 'theme_update_success': OW::getFeedback()->info(OW::getLanguage()->text('admin', 'manage_themes_update_success_message')); break; default: OW::getFeedback()->error(OW::getLanguage()->text('admin', 'manage_themes_update_process_error')); break; } $this->redirectToAction('chooseTheme'); } $themeDto = $this->getThemeDtoByName($params); $ftp = $this->getFtpConnection(); try { $archivePath = $this->themeService->downloadTheme($themeDto->getName(), $themeDto->getDeveloperKey(), !empty($params['licenseKey']) ? $params['licenseKey'] : null); } catch (Exception $e) { OW::getFeedback()->error($e->getMessage()); $this->redirectToAction('chooseTheme'); } if (!file_exists($archivePath)) { OW::getFeedback()->error(OW::getLanguage()->text('admin', 'theme_update_download_error')); $this->redirectToAction('chooseTheme'); } $zip = new ZipArchive(); $tempDir = OW_DIR_PLUGINFILES . 'ow' . DS . uniqid('theme_update') . DS; if ($zip->open($archivePath) === true) { $zip->extractTo($tempDir); $zip->close(); } else { OW::getFeedback()->error(OW::getLanguage()->text('admin', 'theme_update_download_error')); $this->redirectToAction('chooseTheme'); } if (file_exists($tempDir . 'theme.xml')) { $localDir = $tempDir; } else { $handle = opendir($tempDir); while (($item = readdir($handle)) !== false) { if ($item === '.' || $item === '..') { continue; } $innerDir = $item; } closedir($handle); if (!empty($innerDir) && file_exists($tempDir . $innerDir . DS . 'theme.xml')) { $localDir = $tempDir . $innerDir; } else { OW::getFeedback()->error(OW::getLanguage()->text('admin', 'theme_update_download_error')); $this->redirectToAction('chooseTheme'); } } if (substr($name, -1) === DS) { $name = substr($name, 0, strlen($name) - 1); } $remoteDir = OW_DIR_THEME . $themeDto->getName(); if (!file_exists($remoteDir)) { $ftp->mkDir($remoteDir); } $ftp->uploadDir($localDir, $remoteDir); UTIL_File::removeDir($localDir); $this->redirect(OW::getRequest()->buildUrlQueryString(OW_URL_HOME . 'ow_updates/', array('theme' => $themeDto->getName(), 'back-uri' => urlencode(OW::getRequest()->getRequestUri())))); }
/** * Executes plugin update * * @param array $params */ public function update(array $params) { $pluginDto = $this->getPluginDtoByKeyInParamsArray($params); $language = OW::getLanguage(); $feedback = OW::getFeedback(); $redirectUrl = OW::getRouter()->urlForRoute("admin_plugins_installed"); //TODO remove hardcoded constants // process data returned by update script if (!empty($_GET["mode"])) { switch (trim($_GET["mode"])) { case "plugin_up_to_date": $feedback->warning($language->text("admin", "manage_plugins_up_to_date_message")); break; case "plugin_update_success": OW::getEventManager()->trigger(new OW_Event(OW_EventManager::ON_AFTER_PLUGIN_UPDATE, array('pluginKey' => $pluginDto->getKey()))); $feedback->info($language->text("admin", "manage_plugins_update_success_message")); break; default: $feedback->error($language->text("admin", "manage_plugins_update_process_error")); break; } $this->redirect($redirectUrl); } $remotePluginInfo = (array) $this->storageService->getItemInfoForUpdate($pluginDto->getKey(), $pluginDto->getDeveloperKey(), $pluginDto->getBuild()); if (empty($remotePluginInfo) || !empty($remotePluginInfo["error"])) { $feedback->error($language->text("admin", "manage_plugins_update_process_error")); $this->redirect($redirectUrl); } if (!(bool) $remotePluginInfo["freeware"] && ($pluginDto->getLicenseKey() == null || !$this->storageService->checkLicenseKey($pluginDto->getKey(), $pluginDto->getDeveloperKey(), $pluginDto->getLicenseKey()))) { $feedback->error($language->text("admin", "manage_plugins_update_invalid_key_error")); $this->redirect($redirectUrl); } $ftp = $this->getFtpConnection(); try { $archivePath = $this->storageService->downloadItem($pluginDto->getKey(), $pluginDto->getDeveloperKey(), $pluginDto->getLicenseKey()); } catch (Exception $e) { $feedback->error($e->getMessage()); $this->redirect($redirectUrl); } if (!file_exists($archivePath)) { $feedback->error(OW::getLanguage()->text("admin", "plugin_update_download_error")); $this->redirect($redirectUrl); } $zip = new ZipArchive(); $tempDirPath = OW::getPluginManager()->getPlugin("base")->getPluginFilesDir() . "plugin_update" . UTIL_String::getRandomString(5, UTIL_String::RND_STR_ALPHA_NUMERIC) . DS; mkdir($tempDirPath); if ($zip->open($archivePath) === true) { $zip->extractTo($tempDirPath); $zip->close(); } else { $feedback->error(OW::getLanguage()->text("admin", "plugin_update_download_error")); $this->redirect($redirectUrl); } // locate plugin.xml file to find plugin source root dir $result = UTIL_File::findFiles($tempDirPath, array("xml")); $localPluginRootPath = null; foreach ($result as $item) { if (basename($item) == BOL_PluginService::PLUGIN_INFO_XML) { $localPluginRootPath = dirname($item) . DS; } } if ($localPluginRootPath == null) { $feedback->error($language->text("admin", "manage_plugin_add_extract_error")); $this->redirect($redirectUrl); } try { $plugin = OW::getPluginManager()->getPlugin($pluginDto->getKey()); } catch (InvalidArgumentException $ex) { $feedback->error($language->text("admin", "manage_plugin_update_plugin_not_active_error")); $this->redirect($redirectUrl); } $remoteDirPath = $plugin->getRootDir(); $ftp->uploadDir($localPluginRootPath, $remoteDirPath); UTIL_File::removeDir($localPluginRootPath); $this->pluginService->addPluginDirs($pluginDto); $params = array("plugin" => $pluginDto->getKey(), "back-uri" => urlencode(OW::getRequest()->getRequestUri())); $this->redirect(OW::getRequest()->buildUrlQueryString($this->storageService->getUpdaterUrl(), $params)); }
public function removeDir($dirPath) { UTIL_File::removeDir($dirPath); }
private function installComplete($installPlugins = null) { $storage = INSTALL::getStorage(); $username = $storage->get('admin_username'); $password = $storage->get('admin_password'); $email = $storage->get('admin_email'); $user = BOL_UserService::getInstance()->createUser($username, $password, $email, null, true); $realName = ucfirst($username); BOL_QuestionService::getInstance()->saveQuestionsData(array('realname' => $realName), $user->id); BOL_AuthorizationService::getInstance()->addAdministrator($user->id); OW::getUser()->login($user->id); OW::getConfig()->saveConfig('base', 'site_name', $storage->get('site_title')); OW::getConfig()->saveConfig('base', 'site_tagline', $storage->get('site_tagline')); OW::getConfig()->saveConfig('base', 'site_email', $email); $notInstalledPlugins = array(); if (!empty($installPlugins)) { OW::getPluginManager()->initPlugins(); // Init installed plugins ( base, admin ), to insure that all of their package pointers are added foreach ($installPlugins as $plugin) { try { BOL_PluginService::getInstance()->install($plugin['key']); } catch (LogicException $e) { $notInstalledPlugins[] = $plugin['key']; } } if (!empty($notInstalledPlugins)) { //Some plugins were not installed } } OW::getConfig()->saveConfig('base', 'site_installed', 1); OW::getConfig()->saveConfig('base', 'dev_mode', 1); @UTIL_File::removeDir(OW_DIR_ROOT . "ow_install"); $this->redirect(OW_URL_HOME); }
/** * Uninstalls plugin * * @param string $pluginKey */ public function uninstall($pluginKey) { if (empty($pluginKey)) { throw new LogicException("Empty plugin key provided for uninstall"); } $pluginDto = $this->findPluginByKey(trim($pluginKey)); if ($pluginDto === null) { throw new LogicException("Invalid plugin key - `{$pluginKey}` provided for uninstall!"); } $plugin = new OW_Plugin($pluginDto); // trigger event OW::getEventManager()->trigger(new OW_Event(OW_EventManager::ON_BEFORE_PLUGIN_UNINSTALL, array("pluginKey" => $pluginDto->getKey()))); $this->includeScript($plugin->getRootDir() . BOL_PluginService::SCRIPT_DEACTIVATE); $this->includeScript($plugin->getRootDir() . BOL_PluginService::SCRIPT_UNINSTALL); // delete plugin work dirs $dirsToRemove = array($plugin->getPluginFilesDir(), $plugin->getUserFilesDir(), $plugin->getPublicStaticDir()); foreach ($dirsToRemove as $dir) { if (file_exists($dir)) { UTIL_File::removeDir($dir); } } // remove plugin configs OW::getConfig()->deletePluginConfigs($pluginDto->getKey()); // delete language prefix $prefixId = BOL_LanguageService::getInstance()->findPrefixId($pluginDto->getKey()); if (!empty($prefixId)) { BOL_LanguageService::getInstance()->deletePrefix($prefixId, true); } //delete authorization stuff BOL_AuthorizationService::getInstance()->deleteGroup($pluginDto->getKey()); // drop plugin tables $tables = OW::getDbo()->queryForColumnList("SHOW TABLES LIKE '" . str_replace('_', '\\_', OW_DB_PREFIX) . $pluginDto->getKey() . "\\_%'"); if (!empty($tables)) { $query = "DROP TABLE "; foreach ($tables as $table) { $query .= "`" . $table . "`,"; } $query = substr($query, 0, -1); OW::getDbo()->query($query); } //remove entry in DB $this->deletePluginById($pluginDto->getId()); $this->updatePluginListCache(); // trigger event OW::getEventManager()->trigger(new OW_Event(OW_EventManager::ON_AFTER_PLUGIN_UNINSTALL, array("pluginKey" => $pluginDto->getKey()))); }
/** * Updates platform. */ public function platformUpdate() { if (!(bool) OW::getConfig()->getValue("base", "update_soft")) { throw new Redirect404Exception(); } $language = OW::getLanguage(); $tempDir = OW_DIR_PLUGINFILES . "ow" . DS . "core" . DS; $ftp = $this->getFtpConnection(); $errorMessage = false; OW::getApplication()->setMaintenanceMode(true); $archivePath = $this->storageService->downloadPlatform(); if (!file_exists($archivePath)) { $errorMessage = $language->text("admin", "core_update_download_error"); } else { mkdir($tempDir); $zip = new ZipArchive(); $zopen = $zip->open($archivePath); if ($zopen === true && file_exists($tempDir)) { $zip->extractTo($tempDir); $zip->close(); $ftp->uploadDir($tempDir, OW_DIR_ROOT); $ftp->chmod(0777, OW_DIR_STATIC); $ftp->chmod(0777, OW_DIR_STATIC_PLUGIN); } else { $errorMessage = $language->text("admin", "core_update_unzip_error"); } } if (file_exists($tempDir)) { UTIL_File::removeDir($tempDir); } if (file_exists($archivePath)) { unlink($archivePath); } if ($errorMessage !== false) { OW::getApplication()->setMaintenanceMode(false); OW::getFeedback()->error($errorMessage); $this->redirect(OW::getRouter()->urlFor("ADMIN_CTRL_Index", "index")); } $this->redirect($this->storageService->getUpdaterUrl()); }
<?php Updater::getDbo()->query("CREATE TABLE IF NOT EXISTS `" . OW_DB_PREFIX . "toplink_children` (\n\t\t`id` int(11) NOT NULL auto_increment,\n\t\t`childof` int(11) NOT NULL,\n\t\t`name` varchar(255) NOT NULL,\n\t\t`url` tinytext NOT NULL,\n\t\tPRIMARY KEY(`id`)\n\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); UTIL_File::removeDir(BOL_LanguageService::getImportDirPath() . 'toplink'); Updater::getLanguageService()->importPrefixFromZip(dirname(__FILE__) . DS . 'langs.zip', 'toplink');