function notifications_check_signature in Notifications 6.4
Same name and namespace in other branches
- 7 notifications.module \notifications_check_signature()
Check signature
Parameters
$params: Optional array of path elements. If not specified the current URL will be used
$query: Query string array, will be taken from request if empty
$prefix: When using the path this must match the first part of it, which is not used in the signature
4 calls to notifications_check_signature()
- notifications_anonymous_destination_page in notifications_anonymous/
notifications_anonymous.pages.inc - Page callback. Manage anonymous destinations.
- notifications_anonymous_subscription_page in notifications_anonymous/
notifications_anonymous.pages.inc - Page callback. Manage anonymous subscriptions.
- notifications_page_check_signature in ./
notifications.pages.inc - Check current URL is signed
- notifications_subscription_edit_page in ./
notifications.pages.inc - Edit subscription page that can be accessed with signed link
File
- ./
notifications.module, line 287 - Notifications module
Code
function notifications_check_signature($params = NULL, $query = array(), $prefix = 'notifications') {
// If not parameters passed, get them from path, discard the first one that must match $prefix
if (!$params) {
if (arg(0) == $prefix) {
$params = arg();
array_shift($params);
}
$query = $query ? $query : $_GET;
}
// Check timestamp < 7 days
if (!empty($query['timestamp']) && time() - 24 * 7 * 3600 > (int) $query['timestamp']) {
drupal_set_message(t('This link has expired. Please get a new one or contact the site administrator.'), 'error');
return FALSE;
}
if (!empty($_GET['signature'])) {
unset($query['signature']);
unset($query['q']);
if ($_GET['signature'] === _notifications_signature($params, $query)) {
return TRUE;
}
else {
drupal_set_message(t('This link is not valid anymore. Please get a new one or contact the site administrator.'), 'error');
return FALSE;
}
}
}