protected function loadData() { $manager = UpdateManager::instance(); $this->vars['inMaintenance'] = MaintenanceSettings::get('is_enabled'); $this->vars['showUpdates'] = $this->controller->user->hasAccess('system.manage_updates'); $this->vars['updates'] = $manager->check(); }
/** * Execute the console command. * @return void */ public function fire() { $pluginManager = PluginManager::instance(); $pluginName = $this->argument('name'); $pluginName = $pluginManager->normalizeIdentifier($pluginName); if (!$pluginManager->hasPlugin($pluginName)) { return $this->error(sprintf('Unable to find a registered plugin called "%s"', $pluginName)); } if (!$this->confirmToProceed(sprintf('This will DELETE "%s" from the filesystem and database.', $pluginName))) { return; } /* * Rollback plugin */ $manager = UpdateManager::instance()->resetNotes(); $manager->rollbackPlugin($pluginName); foreach ($manager->getNotes() as $note) { $this->output->writeln($note); } /* * Delete from file system */ if ($pluginPath = $pluginManager->getPluginPath($pluginName)) { File::deleteDirectory($pluginPath); $this->output->writeln(sprintf('<info>Deleted: %s</info>', $pluginName)); } }
/** * Perform test case set up * * @deprecated use pluginTestSetUp method */ public final function setUp() { /* * Create application instance */ parent::setUp(); /* * Reboot October Singletons' dependencies */ \System\Classes\PluginManager::instance()->bindContainerObjects(); \System\Classes\UpdateManager::instance()->bindContainerObjects(); /* * If test maker wants to create functional test, migrate october and given plugins */ if (count($this->refreshPlugins) > 0) { foreach ($this->refreshPlugins as $pluginCode) { $this->refreshPlugin($pluginCode); } } /* * If test maker wants october environment for some reason, migrate october */ if (count($this->refreshPlugins) === 0 && $this->requiresOctoberMigration) { $this->migrateOctober(); } /* * Prevent mailer from actually sending emails */ Mail::pretend(true); $this->pluginTestSetUp(); }
/** * Initiate the reset process. * * If an exception is thrown, the site will remain * locked until the lockfile is manually deleted. * * @return void * @throws \Krisawzm\DemoManager\Classes\DemoManagerException */ public function resetEverything() { if ($this->locked()) { throw new DemoManagerException('Lock file exists. You may have to remove it.'); } // Lock site. if (!$this->locked(true)) { throw new DemoManagerException('Error making lockfile.'); } // Clear cache. Artisan::call('cache:clear'); // Set up an UpdateManager. $updateManager = UpdateManager::instance(); // Uninstall database. $updateManager->uninstall(); // Remove old themes. if (!$this->removeOldThemes()) { throw new DemoManagerException('Error removing old themes.'); } // Update database. $updateManager->update(); // Update the admin user. if (!$this->updateAdminUser()) { throw new DemoManagerException('Error updating admin user.'); } // Run any custom provisioners. if (!$this->runProvisioners()) { throw new DemoManagerException('Error running provisioners.'); } // Unlock site. $this->locked(false); }
/** * Perform test case set up. * @return void */ public function setUp() { /* * Create application instance */ parent::setUp(); /* * Rebind Laravel container in October Singletons */ UpdateManager::instance()->bindContainerObjects(); PluginManager::instance()->bindContainerObjects(); /* * Ensure system is up to date */ $this->runOctoberUpCommand(); /* * Detect plugin from test and autoload it */ $this->pluginTestCaseLoadedPlugins = []; $pluginCode = $this->guessPluginCodeFromTest(); if ($pluginCode !== false) { $this->runPluginRefreshCommand($pluginCode, false); } /* * Disable mailer */ Mail::pretend(); }
public function signin_onSubmit() { $rules = ['login' => 'required|min:2|max:32', 'password' => 'required|min:2']; $validation = Validator::make(post(), $rules); if ($validation->fails()) { throw new ValidationException($validation); } // Authenticate user $user = BackendAuth::authenticate(['login' => post('login'), 'password' => post('password')], true); // Load version updates UpdateManager::instance()->update(); // Log the sign in event AccessLog::add($user); // User cannot access the dashboard if (!$user->hasAccess('backend.access_dashboard')) { $true = function () { return true; }; if ($first = array_first(BackendMenu::listMainMenuItems(), $true)) { return Redirect::intended($first->url); } } // Redirect to the intended page after successful sign in return Redirect::intended(Backend::url('backend')); }
/** * Execute the console command. */ public function fire() { $this->output->writeln('<info>Updating October...</info>'); $manager = UpdateManager::instance()->resetNotes(); $forceUpdate = $this->option('force'); /* * Check for disabilities */ $disableCore = $disablePlugins = $disableThemes = false; if ($this->option('plugins')) { $disableCore = true; $disableThemes = true; } if ($this->option('core')) { $disablePlugins = true; $disableThemes = true; } if (Config::get('cms.disableCoreUpdates', false)) { $disableCore = true; } /* * Perform update */ $updateList = $manager->requestUpdateList($forceUpdate); $updates = (int) array_get($updateList, 'update', 0); if ($updates == 0) { $this->output->writeln('<info>No new updates found</info>'); return; } else { $this->output->writeln(sprintf('<info>Found %s new %s!</info>', $updates, Str::plural('update', $updates))); } $coreHash = $disableCore ? null : array_get($updateList, 'core.hash'); $coreBuild = array_get($updateList, 'core.build'); if ($coreHash) { $this->output->writeln('<info>Downloading application files</info>'); $manager->downloadCore($coreHash); } $plugins = $disablePlugins ? [] : array_get($updateList, 'plugins'); foreach ($plugins as $code => $plugin) { $pluginName = array_get($plugin, 'name'); $pluginHash = array_get($plugin, 'hash'); $this->output->writeln(sprintf('<info>Downloading plugin: %s</info>', $pluginName)); $manager->downloadPlugin($code, $pluginHash); } if ($coreHash) { $this->output->writeln('<info>Unpacking application files</info>'); $manager->extractCore($coreHash, $coreBuild); } foreach ($plugins as $code => $plugin) { $pluginName = array_get($plugin, 'name'); $pluginHash = array_get($plugin, 'hash'); $this->output->writeln(sprintf('<info>Unpacking plugin: %s</info>', $pluginName)); $manager->extractPlugin($code, $pluginHash); } /* * Run migrations */ $this->call('october:up'); }
/** * Execute the console command. */ public function fire() { $manager = UpdateManager::instance()->resetNotes()->update(); $this->output->writeln('<info>Migrating application and plugins...</info>'); foreach ($manager->getNotes() as $note) { $this->output->writeln($note); } }
/** * Execute the console command. */ public function fire() { if ($this->confirm('Destroy all database tables? [yes|no]')) { $manager = UpdateManager::instance()->resetNotes()->uninstall(); foreach ($manager->getNotes() as $note) { $this->output->writeln($note); } } }
/** * Execute the console command. */ public function fire() { if (!$this->confirmToProceed('This will DESTROY all database tables.')) { return; } $manager = UpdateManager::instance()->resetNotes()->uninstall(); foreach ($manager->getNotes() as $note) { $this->output->writeln($note); } }
protected function loadData() { $manager = UpdateManager::instance(); $this->vars['canUpdate'] = BackendAuth::getUser()->hasAccess('system.manage_updates'); $this->vars['updates'] = $manager->check(); $this->vars['warnings'] = $this->getSystemWarnings(); $this->vars['coreBuild'] = Parameter::get('system::core.build'); $this->vars['eventLog'] = EventLog::count(); $this->vars['requestLog'] = RequestLog::count(); $this->vars['appBirthday'] = PluginVersion::orderBy('created_at')->pluck('created_at'); }
/** * Execute the console command. * @return void */ public function fire() { $themeName = $this->argument('name'); $argDirName = $this->argument('dirName'); if ($argDirName && $themeName == $argDirName) { $argDirName = null; } if ($argDirName) { if (!preg_match('/^[a-z0-9\\_\\-]+$/i', $argDirName)) { return $this->error('Invalid destination directory name.'); } if (Theme::exists($argDirName)) { return $this->error(sprintf('A theme named %s already exists.', $argDirName)); } } try { $themeManager = ThemeManager::instance(); $updateManager = UpdateManager::instance(); $themeDetails = $updateManager->requestThemeDetails($themeName); if ($themeManager->isInstalled($themeDetails['code'])) { return $this->error(sprintf('The theme %s is already installed.', $themeDetails['code'])); } if (Theme::exists($themeDetails['code'])) { return $this->error(sprintf('A theme named %s already exists.', $themeDetails['code'])); } $fields = ['Name', 'Description', 'Author', 'URL', '']; $this->info(sprintf(implode(': %s' . PHP_EOL, $fields), $themeDetails['code'], $themeDetails['description'], $themeDetails['author'], $themeDetails['product_url'])); if (!$this->confirm('Do you wish to continue? [Y|n]', true)) { return; } $this->info('Downloading theme...'); $updateManager->downloadTheme($themeDetails['code'], $themeDetails['hash']); $this->info('Extracting theme...'); $updateManager->extractTheme($themeDetails['code'], $themeDetails['hash']); $dirName = $this->themeCodeToDir($themeDetails['code']); if ($argDirName) { /* * Move downloaded theme to a new directory. * Basically we're renaming it. */ File::move(themes_path() . '/' . $dirName, themes_path() . '/' . $argDirName); /* * Let's make sure to unflag the 'old' theme as * installed so it can be re-installed later. */ $themeManager->setUninstalled($themeDetails['code']); $dirName = $argDirName; } $this->info(sprintf('The theme %s has been installed. (now %s)', $themeDetails['code'], $dirName)); } catch (Exception $ex) { $this->error($ex->getMessage()); } }
public function signin_onSubmit() { $rules = ['login' => 'required|min:2|max:32', 'password' => 'required|min:2']; $validation = Validator::make(post(), $rules); if ($validation->fails()) { throw new ValidationException($validation); } // Authenticate user $user = BackendAuth::authenticate(['login' => post('login'), 'password' => post('password')], true); // Load version updates UpdateManager::instance()->update(); // Log the sign in event AccessLog::add($user); // Redirect to the intended page after successful sign in return Backend::redirectIntended('backend'); }
/** * Execute the console command. * @return void */ public function fire() { $pluginName = $this->argument('name'); $pluginName = PluginManager::instance()->normalizeIdentifier($pluginName); $manager = UpdateManager::instance()->resetNotes(); $manager->rollbackPlugin($pluginName); foreach ($manager->getNotes() as $note) { $this->output->writeln($note); } $manager->resetNotes(); $this->output->writeln('<info>Reinstalling plugin...</info>'); $manager->updatePlugin($pluginName); foreach ($manager->getNotes() as $note) { $this->output->writeln($note); } }
protected function loadData() { $manager = UpdateManager::instance(); $manager->requestUpdateList(); $this->vars['inMaintenance'] = MaintenanceSetting::get('is_enabled'); $this->vars['updates'] = DB::table('system_parameters')->where('item', 'count')->pluck('value'); $this->vars['plugins'] = DB::table('system_plugin_versions')->count(); $count = 0; if ($themes = opendir('themes')) { while (false !== ($theme = readdir($themes))) { if ($theme != '.' && $theme != '..' && !File::isFile($theme)) { $count++; } } closedir($themes); } $this->vars['themes'] = $count; }
/** * Execute the console command. * @return void */ public function fire() { $pluginName = $this->argument('name'); $pluginName = PluginManager::instance()->normalizeIdentifier($pluginName); if (!PluginManager::instance()->exists($pluginName)) { throw new \InvalidArgumentException(sprintf('Plugin "%s" not found.', $pluginName)); } $manager = UpdateManager::instance()->resetNotes(); $manager->rollbackPlugin($pluginName); foreach ($manager->getNotes() as $note) { $this->output->writeln($note); } $manager->resetNotes(); $this->output->writeln('<info>Reinstalling plugin...</info>'); $manager->updatePlugin($pluginName); foreach ($manager->getNotes() as $note) { $this->output->writeln($note); } }
/** * Execute the console command. */ public function fire() { $themeManager = ThemeManager::instance(); $updateManager = UpdateManager::instance(); foreach (Theme::all() as $theme) { $flag = $theme->isActiveTheme() ? '[*] ' : '[-] '; $themeId = $theme->getId(); $themeName = $themeManager->findByDirName($themeId) ?: $themeId; $this->info($flag . $themeName); } if ($this->option('include-marketplace')) { // @todo List everything in the marketplace - not just popular. $popularThemes = $updateManager->requestPopularProducts('theme'); foreach ($popularThemes as $popularTheme) { if (!$themeManager->isInstalled($popularTheme['code'])) { $this->info('[ ] ' . $popularTheme['code']); } } } $this->info(PHP_EOL . "[*] Active [-] Installed [ ] Not installed"); }
/** * Execute the console command. * @return void */ public function fire() { $pluginName = $this->argument('name'); $manager = UpdateManager::instance()->resetNotes(); $pluginDetails = $manager->requestPluginDetails($pluginName); $code = array_get($pluginDetails, 'code'); $hash = array_get($pluginDetails, 'hash'); $this->output->writeln(sprintf('<info>Downloading plugin: %s</info>', $code)); $manager->downloadPlugin($code, $hash); $this->output->writeln(sprintf('<info>Unpacking plugin: %s</info>', $code)); $manager->extractPlugin($code, $hash); /* * Migrate plugin */ $this->output->writeln(sprintf('<info>Migrating plugin...</info>', $code)); PluginManager::instance()->loadPlugins(); $manager->updatePlugin($code); foreach ($manager->getNotes() as $note) { $this->output->writeln($note); } }
/** * Execute the console command. * @return void */ public function fire() { if ($this->confirm('Are you sure you want to uninstall this plugin? [yes|no]')) { $pluginName = $this->argument('name'); $pluginName = PluginManager::instance()->normalizeIdentifier($pluginName); /* * Rollback plugin */ $manager = UpdateManager::instance()->resetNotes(); $manager->rollbackPlugin($pluginName); foreach ($manager->getNotes() as $note) { $this->output->writeln($note); } /* * Delete from file system */ if ($pluginPath = PluginManager::instance()->getPluginPath($pluginName)) { File::deleteDirectory($pluginPath); $this->output->writeln(sprintf('<info>Deleted: %s</info>', $pluginName)); } } }
/** * Execute the console command. */ public function fire() { $this->output->writeln('<info>Updating October...</info>'); $manager = UpdateManager::instance()->resetNotes(); $updateList = $manager->requestUpdateList(); $updates = (int) array_get($updateList, 'update', 0); if ($updates == 0) { $this->output->writeln('<info>No new updates found</info>'); return; } else { $this->output->writeln(sprintf('<info>Found %s new %s!</info>', $updates, Str::plural('update', $updates))); } $coreHash = array_get($updateList, 'core.hash'); $coreBuild = array_get($updateList, 'core.build'); $this->output->writeln('<info>Downloading application files</info>'); $manager->downloadCore($coreHash); $plugins = array_get($updateList, 'plugins'); foreach ($plugins as $code => $plugin) { $pluginName = array_get($plugin, 'name'); $pluginHash = array_get($plugin, 'hash'); $this->output->writeln(sprintf('<info>Downloading plugin: %s</info>', $pluginName)); $manager->downloadPlugin($code, $pluginHash); } $this->output->writeln('<info>Unpacking application files</info>'); $manager->extractCore($coreHash, $coreBuild); foreach ($plugins as $code => $plugin) { $pluginName = array_get($plugin, 'name'); $pluginHash = array_get($plugin, 'hash'); $this->output->writeln(sprintf('<info>Unpacking plugin: %s</info>', $pluginName)); $manager->extractPlugin($code, $pluginHash); } /* * Run migrations */ $this->call('october:up'); }
/** * Rebuilds plugin database migrations. * @return void */ public function onRefreshPlugins() { if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) { $manager = UpdateManager::instance(); foreach ($checkedIds as $objectId) { if (!($object = PluginVersion::find($objectId))) { continue; } /* * Refresh plugin */ $pluginCode = $object->code; $manager->rollbackPlugin($pluginCode); $manager->updatePlugin($pluginCode); } Flash::success(Lang::get('system::lang.plugins.refresh_success')); } return $this->listRefresh('manage'); }
protected function forcePluginRegistration() { PluginManager::instance()->loadPlugins(); UpdateManager::instance()->update(); }
public function index() { # CHECK SETTINGS ARE DEFINED $this->checkSettings(['google_client_id', 'google_client_secret']); # CREATE GOOGLE CLIENT $client = new Google_Client(); $client->setClientId(Settings::get('google_client_id')); $client->setClientSecret(Settings::get('google_client_secret')); $client->setRedirectUri(Backend::url('martin/ssologin/google')); $client->setScopes('email'); # HANDLE LOGOUTS if (Input::has('logout')) { Session::forget('access_token'); return; } # AUTHENTICATE GOOGLE USER if (Input::has('code')) { $client->authenticate(Input::get('code')); Session::put('access_token', $client->getAccessToken()); } # SET ACCESS TOKEN OR GET A NEW ONE if (Session::has('access_token')) { $client->setAccessToken(Session::get('access_token')); } else { $authUrl = $client->createAuthUrl(); // Redirect::to() doesn't work here. Send header manually. header("Location: {$authUrl}"); exit; } # PARSE USER DETAILS if ($client->getAccessToken()) { Session::put('access_token', $client->getAccessToken()); $token_data = $client->verifyIdToken(); } # FORGET ACCESS TOKEN Session::forget('access_token'); # CHECK MAIL EXISTS if (!isset($token_data['email'])) { # RECORD FAILED LOGIN $log = new Log(); $log->provider = 'Google'; $log->result = 'failed'; $log->email = $email; $log->ip = Request::getClientIp(); $log->save(); Flash::error(trans('martin.ssologin::lang.errors.google.invalid_user')); return Backend::redirect('backend/auth/signin'); } # FIND USER BY EMAIL $email = $token_data['email']; $user = User::where('email', $email)->first(); # IF NO USER, GET BACK TO LOGIN SCREEN if (!$user) { # RECORD FAILED LOGIN $log = new Log(); $log->provider = 'Google'; $log->result = 'failed'; $log->email = $email; $log->ip = Request::getClientIp(); $log->save(); Flash::error(trans('martin.ssologin::lang.errors.google.invalid_user')); return Backend::redirect('backend/auth/signin'); } # LOGIN USER ON BACKEND BackendAuth::login($user, true); # RECORD SUCCESSFUL LOGIN $log = new Log(); $log->provider = 'Google'; $log->result = 'successful'; $log->user_id = $user->id; $log->email = $email; $log->ip = Request::getClientIp(); $log->save(); // Load version updates UpdateManager::instance()->update(); // Log the sign in event AccessLog::add($user); // Redirect to the intended page after successful sign in return Backend::redirectIntended('backend'); }
public function onGetPopularThemes() { $installed = $this->getInstalledThemes(); $popular = UpdateManager::instance()->requestPopularProducts('theme'); $popular = $this->filterPopularProducts($popular, $installed); return ['result' => $popular]; }
protected function getInstalledThemes() { $history = Parameters::get('system::theme.history', []); $manager = UpdateManager::instance(); $installed = $manager->requestProductDetails(array_keys($history), 'theme'); /* * Splice in the directory names */ foreach ($installed as $key => $data) { $code = array_get($data, 'code'); $installed[$key]['dirName'] = array_get($history, $code, $code); } return $installed; }
/** * Tears down a plugin's database tables and rebuilds them. * @param string $id Plugin code/namespace * @return void */ public function refreshPlugin($id) { $manager = UpdateManager::instance(); $manager->rollbackPlugin($id); $manager->updatePlugin($id); }
protected function setupMigrateDatabase() { $this->line('Migrating application and plugins...'); try { Db::purge(); UpdateManager::instance()->resetNotes()->update(); } catch (Exception $ex) { $this->error($ex->getMessage()); $this->setupDatabaseConfig(); $this->setupMigrateDatabase(); } }
protected function loadData() { $manager = UpdateManager::instance(); $this->vars['updates'] = $manager->check(); }