library/core/class.statistics.php
public function Sign(&$Request, $Modify = FALSE) {

      // Fail if no ID is present
      $VanillaID = GetValue('VanillaID', $Request, FALSE);
      if (empty($VanillaID))
         return FALSE;
      
      if ($VanillaID != Gdn::InstallationID()) return FALSE;

      // We're going to work on a copy for now
      $SignatureArray = $Request;

      // Build the request time
      $RequestTime = Gdn_Statistics::Time();
      // Get the secret key
      $RequestSecret = Gdn::InstallationSecret();

      // Remove the hash from the request data before checking or building the signature
      unset($SignatureArray['SecurityHash']);

      // Add the real secret and request time
      $SignatureArray['Secret'] = $RequestSecret;
      $SignatureArray['RequestTime'] = $RequestTime;

      $SignData = array_intersect_key($SignatureArray, array_fill_keys(array(
         'VanillaID',
         'Secret',
         'RequestTime',
         'TimeSlot'
      ), NULL));

      // ksort the array to preserve a known order
      $SignData = array_change_key_case($SignData, CASE_LOWER);
      ksort($SignData);

      // Calculate the hash
      $RealHash = sha1(http_build_query($SignData));

      if ($Modify) {
         $Request['RequestTime'] = $RequestTime;
         $Request['SecurityHash'] = $RealHash;
         ksort($Request);
      }

      return $RealHash;
   }
public function Sign(&$Request, $Modify = FALSE) {

      // Fail if no ID is present
      $VanillaID = GetValue('VanillaID', $Request, FALSE);
      if (empty($VanillaID))
         return FALSE;
      
      if ($VanillaID != Gdn::InstallationID()) return FALSE;

      // We're going to work on a copy for now
      $SignatureArray = $Request;

      // Build the request time
      $RequestTime = Gdn_Statistics::Time();
      // Get the secret key
      $RequestSecret = Gdn::InstallationSecret();

      // Remove the hash from the request data before checking or building the signature
      unset($SignatureArray['SecurityHash']);

      // Add the real secret and request time
      $SignatureArray['Secret'] = $RequestSecret;
      $SignatureArray['RequestTime'] = $RequestTime;

      $SignData = array_intersect_key($SignatureArray, array_fill_keys(array(
         'VanillaID',
         'Secret',
         'RequestTime',
         'TimeSlot'
      ), NULL));

      // ksort the array to preserve a known order
      $SignData = array_change_key_case($SignData, CASE_LOWER);
      ksort($SignData);

      // Calculate the hash
      $RealHash = sha1(http_build_query($SignData));

      if ($Modify) {
         $Request['RequestTime'] = $RequestTime;
         $Request['SecurityHash'] = $RealHash;
         ksort($Request);
      }

      return $RealHash;
   }
public function Sign ( & $ Request , $ Modify = FALSE ) { // Fail if no ID is present $ VanillaID = GetValue ( 'VanillaID' , $ Request , FALSE ) ; if ( empty ( $ VanillaID ) ) return FALSE ; if ( $ VanillaID != Gdn :: InstallationID ( ) ) return FALSE ; // We're going to work on a copy for now $ SignatureArray = $ Request ; // Build the request time $ RequestTime = Gdn_Statistics :: Time ( ) ; // Get the secret key $ RequestSecret = Gdn :: InstallationSecret ( ) ; // Remove the hash from the request data before checking or building the signature unset ( $ SignatureArray [ 'SecurityHash' ] ) ; // Add the real secret and request time $ SignatureArray [ 'Secret' ] = $ RequestSecret ; $ SignatureArray [ 'RequestTime' ] = $ RequestTime ; $ SignData = array_intersect_key ( $ SignatureArray , array_fill_keys ( array ( 'VanillaID' , 'Secret' , 'RequestTime' , 'TimeSlot' ) , NULL ) ) ; // ksort the array to preserve a known order $ SignData = array_change_key_case ( $ SignData , CASE_LOWER ) ; ksort ( $ SignData ) ; // Calculate the hash $ RealHash = sha1 ( http_build_query ( $ SignData ) ) ; if ( $ Modify ) { $ Request [ 'RequestTime' ] = $ RequestTime ; $ Request [ 'SecurityHash' ] = $ RealHash ; ksort ( $ Request ) ; } return $ RealHash ; }
Sign a request or response

Uses the known site secret to sign the given request or response. The
request/response is passed in by reference so that it can be augmented
with the signature.

@param array $Request The request array to be signed
@param boolean $Modify Optional whether or not to modify the request in place (default false)
Sign a request or response