You are here

function _simplenews_statistics_decode in Simplenews Statistics 6.3

Same name and namespace in other branches
  1. 6.2 simplenews_statistics.module \_simplenews_statistics_decode()

Decode a request.

3 calls to _simplenews_statistics_decode()
simplenews_statistics_click in ./simplenews_statistics.module
Gathers the clicks.
simplenews_statistics_cron in ./simplenews_statistics.module
Implements hook_cron().
simplenews_statistics_view in ./simplenews_statistics.module
Gathers the opens.

File

./simplenews_statistics.module, line 245
Main simplenews statistics file.

Code

function _simplenews_statistics_decode($values) {
  $pars = $values['p'];
  $pars_hash = $values['h'];
  if (isset($pars) && isset($pars_hash)) {
    $pars = _simplenews_statistics_decode_parameter($pars);
    $pars_hash = _simplenews_statistics_decode_parameter($pars_hash);
    if (md5($pars) == $pars_hash) {
      require_once drupal_get_path('module', 'simplenews_statistics') . '/includes/rc4.inc';
      $pars = _simplenews_statistics_rc4Decrypt(simplenews_private_key(), $pars);
      parse_str($pars, $stat);
    }
  }
  foreach ($stat as $idx => $stat_param) {
    if ($idx != 'nid' && $idx != 'mail' && $idx != 'url') {
      $idx = str_replace('amp;', '', $idx);
      if (stristr($stat['url'], '?')) {
        $stat['url'] = $stat['url'] . '&' . $idx . '=' . $stat_param;
      }
      else {
        $stat['url'] = $stat['url'] . '?' . $idx . '=' . $stat_param;
      }
    }
  }
  return $stat;
}