예제 #1
0
 /**
  * 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();
 }
예제 #2
0
 /**
  * Perform update
  *
  * @return     void
  */
 public function updateTask()
 {
     $env = Config::get('application_env', 'production');
     $source = Component::params('com_update')->get('git_repository_source', null);
     $autoPushRef = Component::params('com_update')->get('git_auto_push_ref', null);
     $allowNonFf = $env == 'production' ? false : true;
     $response = Cli::update(false, $allowNonFf, $source, $autoPushRef);
     $response = json_decode($response);
     $response = $response[0];
     $message = 'Update complete!';
     $type = 'success';
     if (!empty($response) && stripos($response, 'fix conflicts and then commit the result') === false) {
         $type = 'error';
         $message = ucfirst($response);
     } else {
         // Also check status again to make sure it's clean (merge conflicts will show up here)
         $status = json_decode(Cli::status());
         if (!empty($status)) {
             foreach ($status as $type => $files) {
                 // If anything is left over besides untracked files, something went wrong
                 if ($type != 'untracked' && !empty($files)) {
                     $type = 'error';
                     $message = 'Update failed. Rolling back changes.';
                     $this->rollbackTask($message, $type);
                     break;
                 }
             }
         }
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $message, $type);
 }
예제 #3
0
 /**
  * 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);
 }