function trackPageView() { $timeStamp = time(); $domainName = $_SERVER["SERVER_NAME"]; if (empty($domainName)) { $domainName = ""; } // Get the referrer from the utmr parameter, this is the referrer to the // page that contains the tracking pixel, not the referrer for tracking // pixel. $documentReferer = $_GET["utmr"]; if (empty($documentReferer) && $documentReferer !== "0") { $documentReferer = "-"; } else { $documentReferer = urldecode($documentReferer); } $documentPath = $_GET["utmp"]; if (empty($documentPath)) { $documentPath = ""; } else { $documentPath = urldecode($documentPath); } $account = $_GET["utmac"]; $userAgent = $_SERVER["HTTP_USER_AGENT"]; if (empty($userAgent)) { $userAgent = ""; } // Try and get visitor cookie from the request. $cookie = $_COOKIE[COOKIE_NAME]; $guidHeader = $_SERVER["HTTP_X_DCMGUID"]; if (empty($guidHeader)) { $guidHeader = $_SERVER["HTTP_X_UP_SUBNO"]; } if (empty($guidHeader)) { $guidHeader = $_SERVER["HTTP_X_JPHONE_UID"]; } if (empty($guidHeader)) { $guidHeader = $_SERVER["HTTP_X_EM_UID"]; } $visitorId = getVisitorId($guidHeader, $account, $userAgent, $cookie); // Always try and add the cookie to the response. setrawcookie(COOKIE_NAME, $visitorId, $timeStamp + COOKIE_USER_PERSISTENCE, COOKIE_PATH); $utmGifLocation = "http://www.google-analytics.com/__utm.gif"; // Construct the gif hit url. $utmUrl = $utmGifLocation . "?" . "utmwv=" . VERSION . "&utmn=" . getRandomNumber() . "&utmhn=" . urlencode($domainName) . "&utmr=" . urlencode($documentReferer) . "&utmp=" . urlencode($documentPath) . "&utmac=" . $account . "&utmcc=__utma%3D999.999.999.999.999.1%3B" . "&utmvid=" . $visitorId . "&utmip=" . getIP($_SERVER["REMOTE_ADDR"]); sendRequestToGoogleAnalytics($utmUrl); // If the debug parameter is on, add a header to the response that contains // the url that was used to contact Google Analytics. if (!empty($_GET["utmdebug"])) { header("X-GA-MOBILE-URL:" . $utmUrl); } // Finally write the gif data to the response. writeGifData(); }
function trackTranItem() { // $GET is non decode get parameter $GET = array(); $get_params = preg_split("/&/", $_SERVER['QUERY_STRING']); foreach ($get_params as $param) { list($key, $val) = preg_split("/=/", $param); $GET[$key] = $val; } $domainName = isset($_SERVER["SERVER_NAME"]) ? urlencode($_SERVER["SERVER_NAME"]) : ''; $account = $GET["utmac"]; $utmtid = isset($GET["utmtid"]) ? $GET["utmtid"] : ''; // order ID $utmt = isset($GET["utmt"]) ? $GET["utmt"] : ''; // tran or item $utmGifLocation = "http://www.google-analytics.com/__utm.gif"; $utmUrl = "{$utmGifLocation}?utmwv=" . VERSION . "&utmn=" . getRandomNumber() . "&utmvid=" . getVisitorId() . "&utmcc=__utma%3D999.999.999.999.999.1%3B" . "&utmhn={$domainName}" . "&utmt={$utmt}" . "&utmtid={$utmtid}" . "&utmac={$account}"; if ('tran' === $utmt) { $utmUrl .= "&utmtst={$GET["utmtst"]}" . "&utmtto={$GET["utmtto"]}" . "&utmttx={$GET["utmttx"]}" . "&utmtsp={$GET["utmtsp"]}" . "&utmtci={$GET["utmtci"]}" . "&utmtrg={$GET["utmtrg"]}" . "&utmtco={$GET["utmtco"]}"; // country } else { if ('item' === $utmt) { $utmUrl .= "&utmipc={$GET["utmipc"]}" . "&utmipn={$GET["utmipn"]}" . "&utmiva={$GET["utmiva"]}" . "&utmipr={$GET["utmipr"]}" . "&utmiqt={$GET["utmiqt"]}"; // Purchase quantity } } sendRequestToGoogleAnalytics($utmUrl); // If the debug parameter is on, add a header to the response that contains // the url that was used to contact Google Analytics. if (!empty($_GET["utmdebug"])) { header("X-GA-MOBILE-URL:" . $utmUrl); } // Finally write the gif data to the response. writeGifData(); }
<?php function getRandomNumber($len = "15") { $better_token = $code = sprintf("%0" . $len . "d", mt_rand(1, str_pad("", $len, "9"))); return $better_token; } function gen_num($len) { $rand = ''; while (!isset($rand[$len - 1])) { $rand .= mt_rand(0, 9); } return substr($rand, 0, $len); } $t1 = time(); for ($i = 0; $i <= 1000; $i++) { $codes[] = gen_num(16); } $t2 = time(); echo $t2 - $t1; echo "<pre>"; print_r($codes); $t1 = time(); for ($i = 0; $i <= 1000; $i++) { $codes1[] = getRandomNumber(16); } $t2 = time(); echo $t2 - $t1; echo "<pre>"; print_r($codes1);
require "functions.php"; banner(); if (!isset($argv[1])) { echo "You must provide the event stub as a parameter.\n\n"; usage(); } if (preg_match('/[^a-zA-Z0-9-_]/', $argv[1])) { echo "Event stub should only have a-z, 0-9, - or _\n\n"; usage(); } echo "Finding a random comment... "; $talkCommentsUri = getTalkCommentsUriFromStub($argv[1]); if (null === $talkCommentsUri) { echo "FAILED.\n\nEvent stub was not found on Joind.in.\n\n"; usage(); } $totalCommentsCount = getTalkComments($talkCommentsUri)->meta->total; if (!$totalCommentsCount) { echo "FAILED.\n\nThere were no comments to pick from.\n\n"; usage(); } $selectedComment = reset(getTalkComments($talkCommentsUri, getRandomNumber($totalCommentsCount))->comments); echo " done!\n\n"; echo str_repeat("-", 30) . "\n"; echo strtoupper($selectedComment->talk_title) . "\n"; echo str_repeat("-", 30) . "\n"; echo " - by " . $selectedComment->user_display_name . "\n"; echo " - rated " . $selectedComment->rating . " out of 5" . "\n"; echo " - on " . (new DateTime($selectedComment->created_date))->format('d/m/Y H:i:s') . "\n"; echo str_repeat("=", 30) . "\n"; echo $selectedComment->comment . "\n\n";
function trackPageView() { global $category, $action, $label, $value; $timeStamp = time(); $domainName = $_SERVER["SERVER_NAME"]; if (empty($domainName)) { $domainName = ""; } // Get the referrer from the utmr parameter, this is the referrer to the // page that contains the tracking pixel, not the referrer for tracking // pixel. $documentReferer = $_GET["utmr"]; if (empty($documentReferer) && $documentReferer !== "0") { $documentReferer = "-"; } else { $documentReferer = urldecode($documentReferer); } $documentPath = $_GET["utmp"]; if (empty($documentPath)) { $documentPath = ""; } else { $documentPath = urldecode($documentPath); } $account = $_GET["utmac"]; $userAgent = $_SERVER["HTTP_USER_AGENT"]; if (empty($userAgent)) { $userAgent = ""; } // Try and get visitor cookie from the request. $cookie = $_COOKIE[COOKIE_NAME]; $visitorId = getVisitorId($_SERVER["HTTP_X_DCMGUID"], $account, $userAgent, $cookie); // Always try and add the cookie to the response. setrawcookie(COOKIE_NAME, $visitorId, $timeStamp + COOKIE_USER_PERSISTENCE, COOKIE_PATH); $utmGifLocation = "http://www.google-analytics.com/__utm.gif"; // Construct the gif hit url. #$group2 = rand(1147483647, 2147483647); #$groupN = time(); #"&utmcc=__utma%3D999.$group2.$groupN.$groupN.$groupN.1%3B" . $category = empty($category) ? "track-category" : $category; $action = empty($action) ? "track-action" : $action; $label = empty($label) ? "track-label" : $label; $value = empty($value) ? 0 : $value; $utmUrl = $utmGifLocation . "?" . "utmwv=" . VERSION . "&utmn=" . getRandomNumber() . "&utmhn=" . urlencode($domainName) . "&utmr=" . urlencode($documentReferer) . "&utmp=" . urlencode($documentPath) . "&utmac=" . $account . "&utmcc=__utma%3D999.999.999.999.999.1%3B" . "&utmvid=" . $visitorId . "&utmt=event" . "&utme=5({$category}*{$action}*{$label})({$value})" . "&utmip=" . getIP($_SERVER["REMOTE_ADDR"]); sendRequestToGoogleAnalytics($utmUrl); // If the debug parameter is on, add a header to the response that contains // the url that was used to contact Google Analytics. if (!empty($_GET["utmdebug"])) { header("X-GA-MOBILE-URL:" . $utmUrl); } // Finally write the gif data to the response. writeGifData(); }
function generateToken($len) { $s = ''; for ($i = 0; $i < $len; $i++) { $case = rand(0, 2); if ($case == 0) { $s .= getRandomNumber(); } elseif ($case == 1) { $s .= getRandomUppercase(); } else { $s .= getRandomLowercase(); } } return $s; }
<?php echo json_encode(getRandomNumber()); function getRandomNumber() { $array = range(1, 8); shuffle($array); return $array; }