/** * Index action method * * @return void */ public function index() { $config = new Model\Config(); if (!isset($this->sess->updates)) { $this->sess->updates = $config->getUpdates($this->application->config()['updates']); } $this->prepareView('phire/index.phtml'); $this->view->title = 'Dashboard'; $this->view->overview = $config->overview; $this->view->config = $config->config; $this->view->modules = $config->modules; $this->view->phire_update_version = $this->sess->updates->phirecms; $this->send(); }
/** * Update index action method * * @return void */ public function index() { $config = new Model\Config(); $updates = $config->getUpdates(); if (version_compare($updates->phirecms, \Phire\Module::VERSION) < 0) { $this->console->append($this->console->colorize($updates->phirecms . ' is available for update.', Console::BOLD_YELLOW)); $this->console->append(); $this->console->append($this->console->colorize('Please back up all of your files and your database before proceeding.', Console::BOLD_RED)); $this->console->append(); $this->console->send(); $update = null; while (strtolower($update) != 'y' && strtolower($update) != 'n') { $update = $this->console->prompt($this->console->getIndent() . 'Update the system? (Y/N) '); } if (strtolower($update) == 'y') { if (is_writable(__DIR__ . '/../../../../../') && is_writable(__DIR__ . '/../../../../..' . APP_PATH)) { $baseUpdater = new \Phire\BaseUpdater(); $baseUpdater->getUpdate(); clearstatcache(); $updater = new \Phire\Updater(); $updater->runPost(); $this->console->append(); $this->console->append($this->console->colorize('Update completed successfully!', Console::BOLD_CYAN)); $this->console->append($this->console->colorize('You have updated to Phire version ' . \Phire\Module::VERSION . '.', Console::BOLD_CYAN)); $this->console->send(); } else { $this->console->append(); $this->console->append($this->console->colorize('The system folders are not writable. They must be writable to update the system.', Console::BOLD_RED)); $this->console->send(); } } } else { $this->console->append($this->console->colorize('System is up-to-date!', Console::BOLD_GREEN)); $this->console->send(); } }
/** * Update action method * * @return void */ public function update() { $config = new Model\Config(); $updates = $config->getUpdates(); $moduleId = $this->getModuleId(); $module = Table\Modules::findById($moduleId); if (isset($module->id)) { if (isset($updates->modules[$module->folder]) && version_compare($updates->modules[$module->folder], $module->version) < 0) { $this->console->append(); $this->console->append($this->console->colorize('The \'' . $module->folder . '\' module is available for update.', Console::BOLD_YELLOW)); $this->console->append(); $this->console->append($this->console->colorize('Please back up all of your files and your database before proceeding.', Console::BOLD_RED)); $this->console->append(); $this->console->send(); $update = null; while (strtolower($update) != 'y' && strtolower($update) != 'n') { $update = $this->console->prompt($this->console->getIndent() . 'Update the \'' . $module->folder . '\' module? (Y/N) '); } if (strtolower($update) == 'y') { if (is_writable(__DIR__ . '/../../../') && is_writable(__DIR__ . '/../../../' . $module->folder) && is_writable(__DIR__ . '/../../../' . $module->folder . '.zip')) { $updater = new \Phire\Updater($module->folder); $updater->getUpdate($module->folder); clearstatcache(); $updaterClass = $module->prefix . 'Updater'; if (class_exists($updaterClass)) { $updater = new $updaterClass($module->folder); $updater->runPost(); } else { if (file_exists(__DIR__ . '/../../../' . $module->folder . '/src/Updater.php')) { include __DIR__ . '/../../../' . $module->folder . '/src/Updater.php'; if (class_exists($updaterClass)) { $updater = new $updaterClass($module->folder); $updater->runPost(); } } else { $module->updated_on = date('Y-m-d H:i:s'); $module->save(); } } $this->console->append(); $this->console->append($this->console->colorize('Update completed successfully!', Console::BOLD_CYAN)); $this->console->append($this->console->colorize('You have updated \'' . $module->folder . '\' to version ' . $updates->modules[$module->folder] . '.', Console::BOLD_CYAN)); $this->console->send(); } else { $this->console->append(); $this->console->append($this->console->colorize('The module folders are not writable. They must be writable to update the module.', Console::BOLD_RED)); $this->console->send(); } } } else { $this->console->append(); $this->console->append($this->console->colorize('The \'' . $module->folder . '\' module is up-to-date!', Console::BOLD_GREEN)); $this->console->send(); } } }