Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Redirect-Script
- *
- * Aufgabe:
- * - Umgebungsdaten ermitteln
- * -- Cookie gesetzt?
- * -- Cookie übergeben?
- */
- // definierte Werte die per se für mich gelten und von der Generator-Routine gesetzt werden
- define('CustomerID', '323');
- define('TagID', '891');
- define('COOKIE_NAME', 'axd');
- if (!defined('COOKIE_DOMAIN')) {
- define('COOKIE_DOMAIN', '.theadex.com');
- }
- define('TS_DMPSTART', 1378591200);
- function _schemaExplode($a) {
- $ud = array();
- while (list($k,$v) = each($a)) {
- if (strpos($v, ':') > 0) {
- list($Sub, $Time) = explode(":", $v);
- $ud[$Sub] = $Time;
- }
- }
- return $ud;
- }
- function _schemaImplode($a) {
- $ud = array();
- while (list($k, $time) = each($a)) {
- $ud[] = $k.':'.$time;
- }
- return $ud;
- }
- /**
- * Converts a timestamp to adex-days
- *
- * @param integer $timestamp
- *
- * @return integer
- */
- function toAdexDays($timestamp) {
- return floor(($timestamp - TS_DMPSTART) / (60*60*24));
- }
- /**
- * Converts from adex days to a unix timestamp
- *
- * @param integer $AdexDays
- *
- * @return integer
- */
- function fromAdexDays($AdexDays) {
- return floor(TS_DMPSTART + ($AdexDays * 60*60*24));
- }
- /**
- * Speichert zeitbezogene Zustandsdaten in einem Cookie - getrennt nach $key; separiert per | und :
- * @param string $key SubIdentifier
- * @param integer $days Gültigkeitsdauer
- *
- * @return boolean
- */
- function stateInformationOlderThan($key, $days, $setState = false) {
- $now = toAdexDays(time());
- $expected = $now + $days;
- $Cookie = 'tis';
- $SubParts = array();
- if (isset($_COOKIE[$Cookie])) {
- // nach schema zerhacken
- $parts = explode("|", $_COOKIE[$Cookie]);
- $SubParts = _schemaExplode($parts);
- if (isset($SubParts[$key]) && $SubParts[$key] * 1 > $now) {
- return false;
- }
- }
- if ($setState) {
- $SubParts[$key] = $expected;
- $implode = array();
- $implode = _schemaImplode($SubParts);
- setcookie($Cookie, join("|", $implode), fromAdexDays($now + 3000), '/', COOKIE_DOMAIN, false, false);
- $_COOKIE[$Cookie] = join("|", $implode);
- }
- return true;
- }
- if (isset($_SERVER['QUERY_STRING'])) {
- define("QS", substr($_SERVER['QUERY_STRING'], 0, 1) == '?' ? substr($_SERVER['QUERY_STRING'], 1) : $_SERVER['QUERY_STRING']);
- } else {
- define("QS", "");
- }
- if (isset($_GET['c']) && trim($_GET['c']) !== '') {
- define('COOKIE', $_GET['c']);
- } elseif (!empty($_COOKIE[COOKIE_NAME])) {
- define('COOKIE', $_COOKIE[COOKIE_NAME]);
- } else {
- // kein Cookie, kein redirect
- ?>
- <html><head></head><body></body></html>
- <?php
- exit;
- }
- $SSLon = false;
- if (!empty($_SERVER['HTTPS'])) {
- $SSLon = true;
- }
- if(isset($_SERVER['HTTP_X_PROTO']) && $_SERVER['HTTP_X_PROTO'] == 'SSL') {
- $SSLon = true;
- }
- header('P3P:CP="CAO PSA OUR"');
- ob_start();
- if (!$SSLon) {
- # no SSL
- ?>
- <html>
- <body>
- <?php if (stateInformationOlderThan("EP2",7)) { ?>
- <img width='1' height='1' src='http://c1.adform.net/serving/cookie/match/?party=1010&adx_id=323' />
- <?php } ?>
- <?php if (stateInformationOlderThan("EP14",7)) { ?>
- <img width='1' height='1' src='http://dsp.adfarm1.adition.com/cookie/?redirect=http%3A%2F%2Fdmp.theadex.com%2Fd%2F323%2Fi%2F2.gif%3Fc%3D<?= COOKIE ?>%26axd_pid%3D14%26axd_fuid%3D%25%25COOKIE%25%25' />
- <?php } ?>
- </body>
- </html>
- <?php
- } else {
- # SSL
- ?>
- <html>
- <body>
- <?php if (stateInformationOlderThan("EP2",7)) { ?>
- <img width='1' height='1' src='https://c1.adform.net/serving/cookie/match/?party=1010&adx_id=323' />
- <?php } ?>
- <?php if (stateInformationOlderThan("EP14",7)) { ?>
- <img width='1' height='1' src='https://dsp.adfarm1.adition.com/cookie/?redirect=https%3A%2F%2Fdmp.theadex.com%2Fd%2F323%2Fi%2F2.gif%3Fc%3D<?= COOKIE ?>%26axd_pid%3D14%26axd_fuid%3D%25%25COOKIE%25%25' />
- <?php } ?>
- </body>
- </html>
- <?php
- }
- ob_end_flush();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement