Skip to content

Instantly share code, notes, and snippets.

@BrianEmilius
Created May 4, 2017 12:25
Show Gist options
  • Select an option

  • Save BrianEmilius/70fb473cc72414cd451d92a403fc9ece to your computer and use it in GitHub Desktop.

Select an option

Save BrianEmilius/70fb473cc72414cd451d92a403fc9ece to your computer and use it in GitHub Desktop.

Revisions

  1. BrianEmilius created this gist May 4, 2017.
    29 changes: 29 additions & 0 deletions click tracker
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <?php

    require_once 'functions.php';

    if (requestMethodCheck('GET')) {
    $myArray = getRequestArray(INPUT_GET);

    $name = $myArray['name'];
    $origin = $_SERVER['HTTP_REFERER'];
    $ip = $_SERVER['REMOTE_ADDR'];
    $target = $myArray['target'];

    $data = array('action' => 'clicktracking', 'name' => $name, 'origin' => $origin, 'ip' => $ip);
    $data_string = json_encode($data);

    $ch = curl_init('http://localhost/undervisning/reklamer/api.php');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
    );

    $result = curl_exec($ch);

    header("Location: $target");

    }