/** * Stash a value in the user's session, or unstash it if no value was provided to stash. * * Looks for Name and Value POST/GET variables to pass along to Gdn_Session. */ public function Stash() { $this->DeliveryType(DELIVERY_TYPE_BOOL); $this->DeliveryMethod(DELIVERY_METHOD_JSON); $Name = TrueStripSlashes(GetValue('Name', $_POST, '')); $Value = TrueStripSlashes(GetValue('Value', $_POST, '')); $Response = Gdn::Session()->Stash($Name, $Value); if ($Name != '' && $Value == '') { $this->SetJson('Unstash', $Response); } $this->Render(); }
public function UpdateResponse() { // Get the message, response, and transientkey $Messages = TrueStripSlashes(GetValue('Messages', $_POST)); $Response = TrueStripSlashes(GetValue('Response', $_POST)); $TransientKey = GetIncomingValue('TransientKey', ''); // If the key validates $Session = Gdn::Session(); if ($Session->ValidateTransientKey($TransientKey)) { // If messages wasn't empty if ($Messages != '') { // Unserialize them & save them if necessary $Messages = Gdn_Format::Unserialize($Messages); if (is_array($Messages)) { $MessageModel = new MessageModel(); foreach ($Messages as $Message) { // Check to see if it already exists, and if not, add it. if (is_object($Message)) $Message = Gdn_Format::ObjectAsArray($Message); $Content = ArrayValue('Content', $Message, ''); if ($Content != '') { $Data = $MessageModel->GetWhere(array('Content' => $Content)); if ($Data->NumRows() == 0) { $MessageModel->Save(array( 'Content' => $Content, 'AllowDismiss' => ArrayValue('AllowDismiss', $Message, '1'), 'Enabled' => ArrayValue('Enabled', $Message, '1'), 'Application' => ArrayValue('Application', $Message, 'Dashboard'), 'Controller' => ArrayValue('Controller', $Message, 'Settings'), 'Method' => ArrayValue('Method', $Message, ''), 'AssetTarget' => ArrayValue('AssetTarget', $Message, 'Content'), 'CssClass' => ArrayValue('CssClass', $Message, '') )); } } } } } // Save some info to the configuration file $Save = array(); // If the response wasn't empty, save it in the config if ($Response != '') $Save['Garden.RequiredUpdates'] = Gdn_Format::Unserialize($Response); // Record the current update check time in the config. $Save['Garden.UpdateCheckDate'] = time(); SaveToConfig($Save); } }
public function GetHandshake() { $HaveHandshake = $this->CheckCookie(); if ($HaveHandshake) { // Found a handshake cookie, sweet. Get the payload. $Payload = $this->GetCookie(); // Rebuild the real payload $ReconstitutedCookiePayload = Gdn_Format::Unserialize(TrueStripSlashes(array_shift($Payload))); return $ReconstitutedCookiePayload; } return FALSE; }
/** * What the mothership said about update availability. * * @since 2.0.? * @access public */ public function UpdateResponse() { // Get the message, response, and transientkey $Response = TrueStripSlashes(GetValue('Response', $_POST)); $TransientKey = GetIncomingValue('TransientKey', ''); // If the key validates $Session = Gdn::Session(); if ($Session->ValidateTransientKey($TransientKey)) { // Save some info to the configuration file $Save = array(); // If the response wasn't empty, save it in the config if ($Response != '') { $Save['Garden.RequiredUpdates'] = @json_decode($Response); } // Record the current update check time in the config. $Save['Garden.UpdateCheckDate'] = time(); SaveToConfig($Save); } }
public function GetHandshake() { $HaveHandshake = Gdn_CookieIdentity::CheckCookie($this->_CookieName); if ($HaveHandshake) { // Found a handshake cookie, sweet. Get the payload. $Payload = Gdn_CookieIdentity::GetCookiePayload($this->_CookieName); // Shift the 'userid' and 'expiration' off the front. These were made-up anyway :D array_shift($Payload); array_shift($Payload); // Rebuild the real payload $ReconstitutedCookiePayload = Gdn_Format::Unserialize(TrueStripSlashes(array_shift($Payload))); return $ReconstitutedCookiePayload; } return FALSE; }