Skip to content

Instantly share code, notes, and snippets.

@treffynnon
Created February 4, 2010 15:19
Show Gist options
  • Save treffynnon/294731 to your computer and use it in GitHub Desktop.
Save treffynnon/294731 to your computer and use it in GitHub Desktop.
PHP: Detecting a valid request via a pass key set in a header
<?php
if('my-agent' !== $_SERVER['HTTP_USER_AGENT'] or
$_SERVER['SERVER_ADDR'] !== $_SERVER['REMOTE_ADDR'] or
!isset($_SERVER['HTTP_TASK_KEY']) or
empty($_SERVER['HTTP_TASK_KEY']) or
'my-secret-key' !== $_SERVER['HTTP_TASK_KEY']) {
print 'You do not have permission to execute this script!';
exit();
}
print 'Executing operation.';
//insert your processing script here
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment