public function Update() { // Check for permission or flood control. // These settings are loaded/saved to the database because we don't want the config file storing non/config information. $Now = time(); $LastTime = Gdn::Get('Garden.Update.LastTimestamp', 0); if ($LastTime + (60 * 60 * 24) > $Now) { // Check for flood control. $Count = Gdn::Get('Garden.Update.Count', 0) + 1; if ($Count > 5) { if (!Gdn::Session()->CheckPermission('Garden.Settings.Manage')) { // We are only allowing an update of 5 times every 24 hours. throw PermissionException(); } } } else { $Count = 1; } Gdn::Set('Garden.Update.LastTimestamp', $Now); Gdn::Set('Garden.Update.Count', $Count); // Run the structure. $UpdateModel = new UpdateModel(); $UpdateModel->RunStructure(); $this->SetData('Success', TRUE); $this->MasterView = 'none'; $this->Render(); }
/** * Run a structure update on the database. * * @since 2.0.? * @access public */ public function Update() { try { // Check for permission or flood control. // These settings are loaded/saved to the database because we don't want the config file storing non/config information. $Now = time(); $LastTime = Gdn::Get('Garden.Update.LastTimestamp', 0); if ($LastTime + 60 * 60 * 24 > $Now) { // Check for flood control. $Count = Gdn::Get('Garden.Update.Count', 0) + 1; if ($Count > 5) { if (!Gdn::Session()->CheckPermission('Garden.Settings.Manage')) { // We are only allowing an update of 5 times every 24 hours. throw PermissionException(); } } } else { $Count = 1; } Gdn::Set('Garden.Update.LastTimestamp', $Now); Gdn::Set('Garden.Update.Count', $Count); } catch (PermissionException $Ex) { return; } catch (Exception $Ex) { } try { // Run the structure. $UpdateModel = new UpdateModel(); $UpdateModel->RunStructure(); $this->SetData('Success', TRUE); } catch (Exception $Ex) { $this->SetData('Success', FALSE); if (Debug()) { throw $Ex; } } if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) { SaveToConfig('Garden.Version', APPLICATION_VERSION); } if ($Target = $this->Request->Get('Target')) { Redirect($Target); } $this->FireEvent('AfterUpdate'); $this->MasterView = 'empty'; $this->CssClass = 'Home'; $this->Render(); }