/**
  * Display the update dashboard
  *
  * @return  void
  */
 public function displayTask()
 {
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     $source = Component::params('com_update')->get('git_repository_source', null);
     $this->view->repositoryVersion = json_decode(Cli::version());
     $this->view->repositoryVersion = $this->view->repositoryVersion[0];
     $this->view->repositoryMechanism = json_decode(Cli::mechanism());
     $this->view->repositoryMechanism = $this->view->repositoryMechanism[0];
     $this->view->databaseMechanism = Config::get('dbtype');
     $this->view->databaseVersion = \App::get('db')->getVersion();
     $this->view->status = json_decode(Cli::status());
     $this->view->upcoming = json_decode(Cli::update(true, false, $source));
     $this->view->migration = json_decode(Cli::migration());
     if (!isset($this->view->repositoryMechanism)) {
         $this->view->message = 'Please ensure that the component is properly configured';
         $this->view->setLayout('error');
     } elseif ($this->view->repositoryMechanism != 'GIT') {
         $this->view->message = 'The CMS update component currently only supports repositories managed via GIT';
         $this->view->setLayout('error');
     }
     // Output the HTML
     $this->view->display();
 }
 /**
  * Perform rollback
  *
  * @return  void
  */
 public function migrateTask()
 {
     $file = Request::getVar('file', null);
     $response = Cli::migration(false, true, $file);
     $response = json_decode($response);
     $message = 'Migration complete!';
     $type = 'success';
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $message, $type);
 }
Exemple #3
0
 /**
  * Perform rollback
  *
  * @param   string  $message  The message to display upon rollback completion
  * @param   string  $type     The message type to use
  * @return  void
  */
 public function rollbackTask($message = 'Rollback complete!', $type = 'success')
 {
     $response = Cli::rollback();
     $response = json_decode($response);
     $response = $response[0];
     if (!empty($response)) {
         $type = 'error';
         $message = ucfirst($response);
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $message, $type);
 }
 /**
  * Display system information
  *
  * @apiMethod GET
  * @apiUri    /system/info
  * @apiParameter {
  * 		"name":          "values",
  * 		"description":   "Amount of data to return",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       "all",
  * 		"allowedValues": "all, short"
  * }
  * @return    void
  */
 public function infoTask()
 {
     $values = Request::getVar('values', 'all');
     $response = new stdClass();
     /*$ip = Request::ip();
     		$ips = explode(',', $this->config->get('whitelist', '127.0.0.1'));
     		$ips = array_map('trim', $ips);
     		if (!in_array($ip, $ips))
     		{
     			$this->setMessage($response);
     			return;
     		}
     
     		if (isset($_SERVER['SERVER_SOFTWARE']))
     		{
     			$sf = $_SERVER['SERVER_SOFTWARE'];
     		}
     		else
     		{
     			$sf = getenv('SERVER_SOFTWARE');
     		}*/
     //$commit = shell_exec("git log -1 --pretty=format:'%H - %s (%ad)' --abbrev-commit");
     //shell_exec("git log -1 --pretty=format:'%h - %s (%ci)' --abbrev-commit git merge-base local-dev dev");
     // System
     $response->system = array('cms' => App::version(), 'php' => php_uname(), 'dbversion' => App::get('db')->getVersion(), 'dbcollation' => App::get('db')->getCollation(), 'phpversion' => phpversion(), 'server' => $sf, 'last_update' => null, 'last_core_update' => null, 'environment' => Config::get('application_env', 'production'));
     require_once PATH_CORE . DS . 'components' . DS . 'com_update' . DS . 'helpers' . DS . 'cli.php';
     $source = Component::params('com_update')->get('git_repository_source', null);
     //$response->system['repositoryVersion']   = json_decode(Cli::version());
     //$response->system['repositoryVersion']   = $response->system['repositoryVersion'][0];
     //$response->system['repositoryMechanism'] = json_decode(Cli::mechanism());
     //$response->system['repositoryMechanism'] = $response->system['repositoryMechanism'][0];
     //$response->system['status']    = json_decode(Cli::status());
     $response->system['status'] = count(json_decode(Cli::status())) > 0 ? 'dirty' : 'clean';
     $response->system['upcoming'] = json_decode(Cli::update(true, false, $source));
     $response->system['migration'] = json_decode(Cli::migration());
     // Get the last update
     $rows = json_decode(Cli::log(1, 0, '', false, true, false, null));
     if ($rows) {
         $props = get_object_vars($rows);
         foreach ($props as $key => $item) {
             $response->system['last_update'] = $item;
         }
     }
     // Get last core update
     $rows = json_decode(Cli::log(1, 0, 'Merge remote-tracking', false, true, false, null));
     if ($rows) {
         $props = get_object_vars($rows);
         foreach ($props as $key => $item) {
             $response->system['last_update_core'] = $item;
         }
     }
     if (strstr($values, ',') || $values != 'all' && $values != 'short') {
         $keys = explode(',', $values);
         $keys = array_map('trim', $keys);
         $keys = array_map('strtolower', $keys);
         $data = array();
         foreach ($keys as $key) {
             $data[$key] = $response->system[$key];
         }
         $response->system = $data;
     }
     $results = Event::trigger('hubzero.onSystemOverview', array($values));
     if ($results) {
         $response->overview = array();
         foreach ($results as $result) {
             if ($result) {
                 $response->overview[] = $result;
             }
         }
     }
     $this->send($response);
 }