Two Useful php Functions

29th May 2015

Ensure that the user has access to a page with a query string.

The code below ensures that the user has a specific query string, this can be useful especially if you want to prevent robots crawling your site and potentially triggering a task page (e.g. an import).

The example below works on the assumption that the URL is similar to:

$keya = "369D1131-05F040E089B259E9A9CA7B64";
$keyb = $_GET["k"];

if ($keya == $keyb){
  // your code which you want to run
  // non valid users – redirect to the homepage
  header("Location: http://your-website/");

Convert .NET ticks to php ticks

$tempTicks = $netTicks - 621355968000000000;
$phpTicks = $tempTicks / 10000000;
This website uses cookies to provide the best possible experience. By continuing to use our website you are agreeing to our use of cookies.