array('Auth', 'Submit', 'Username', 'Password', 'ContentId', 'Email'))); if($Submit) { ErrLog("AuthRequest: ($ContentId, $Email, Auth: '$Auth')---------------"); AuthRequest($Username, $Password, $Email, $Auth) ; $TotTime = sprintf( "%0.2f", microtime_diff($start_time, microtime())); ErrLog("Total Time: $TotTime\n"); exit; } $DownloadMsg = "After you pay for the items in your shopping cart at CCBill.com, please login to download your videos"; //----------------------------------------------------------------- // //----------------------------------------------------------------- function GetShoppingCartFile($CustId) { if(isset($_COOKIE[$CustId])) { return $_COOKIE[$CustId]; } else { ErrLog("Failed to get cookie in GetShoppingCartFile(CustId: '$CustId')"); return false; } } // ------------------------------------------------------------------ // // ------------------------------------------------------------------ function AuthRequest($Username, $Password, $Email, $Auth) { global $DIAG, $Server, $RcvrUrl, $Domain, $ClientAccountId, $CustId, $CustAuthCode; // $GoBack = "history.go(-1)"; // $GoBack = "history.back()"; ErrLog("AuthRequest('$Username', '$Password', '$Email', '$Auth'"); $ShoppingCartFileName = ""; $PurchasedDir = "logs/purchased"; if($Auth) $ShoppingCartFileName = $Auth; else $ShoppingCartFileName = GetShoppingCartFile($CustId); // Make sure we are not trying to read a file that aint' there if($ShoppingCartFileName) { if(is_readable("$PurchasedDir/$ShoppingCartFileName")) { $UserData = GetContentItems("$PurchasedDir/$ShoppingCartFileName"); ErrLog("GetContentItems('$PurchasedDir/$ShoppingCartFileName')"); } else ErrLog("Unable to read file: '$PurchasedDir/$ShoppingCartFileName'"); } $Msg = "Action=" .urlencode("Login"); $Msg .= "&ClientAccountId=" .urlencode($ClientAccountId); $Msg .= "&Server=" .urlencode($Server); $Msg .= "&Username=" .urlencode($Username); $Msg .= "&Password=" .urlencode($Password); $Msg .= "&UserData=" .urlencode($UserData); $Msg .= "&UserIp=" .urlencode($_SERVER['REMOTE_ADDR']); $Msg .= "&Email=" .urlencode(strtolower($Email)); // Record part of the posting, but not enough to give prying eyes anything important ErrLog("Posting Message: $Msg"); ErrLog("SendMsgToRcvr($Msg, $Domain, $RcvrUrl"); // // Process return message from server // //************** THE APOS TEST // ORIGIANL $Ret = urldecode(SendMsgToRcvr($Msg, $Domain, $RcvrUrl)); //*************** // DO NOT urldecode this $Ret = SendMsgToRcvr($Msg, $Domain, $RcvrUrl); //*************** ErrLog("Ret:\n$Ret"); $Ret = parse_response($Ret); ErrLog("Return Code From Phantom Cart Server: " .$Ret[0]); if(!strstr($Ret[0], "200")) { $Subject = "PhantomCart - Possible Failure - Important"; $Msg .= "An Authorization request failed: $ClientAccountId\n$Email\n$Username\n$UserData\nReturn Code From Phantom Cart Server: " .$Ret[0]; // SendEmail($Subject, $Msg); ErrLog("ERROR: A authorization request failed: $Username, $UserData, $Email"); // // The following lines were commented out because even if the PhantomFlicks server is is down, we should deliver the content to the customer. // //$Error = "System Error. Please wait a few minutes then try again"; //include "c_msg1.html"; //exit; } $Ret = $Ret[2]; //print "$Ret
"; if(stristr($Ret, "B A D")) { list($junk, $Error) = explode("::", $Ret); ErrLog("ERROR: $Error Email: '$Email'"); //$Error = "Login failed"; removed when I put in the Brute force attack stuff $GoBack = "history.back()"; $Err2 = ""; include "c_msg1.html"; exit; } else { ErrLog("Authorization Approved==>$Ret"); //list($Good, $AuthCookieVal, $UserData) = explode("::", $Ret); list($Good, $AuthCookieVal, $UserData) = explode("::", urldecode($Ret)); if(trim($Good) != "GOOD") { ErrLog("ERROR: Authentication system error. Server returns: '$Ret' Email: '$Email' Ret: $Ret" . GetPlaceInFile(__FILE__, __LINE__)); print "System Error: Contact webmaster
"; exit; } else { // // Empty the cart. Why? If shopping car cookie has not expired for some returning customers who want to make another purchase, // The origianl shopping cart items(that they already purchased) will still show up, thus the customer gets charged a second time. // EmptyCart(); // Authorization cookie expires at end of session $ServerName = preg_replace("/www\./", "", $_SERVER['SERVER_NAME']); if(!setcookie($CustAuthCode, $AuthCookieVal, 0, "/", ".$ServerName")) { ErrLog("Error: AuthCode not set in cookie: CustAuthCode: '$CustAuthCode' AuthCookieVal: '$AuthCookieVal' UserData: '$UserData' Email: '$Email'"); } ErrLog("SUCCESS: Auth Cookie: '$AuthCookieVal' UserData: '$UserData' Email: '$Email'"); // // Perpare message window // $DownloadMsg = ""; $Error = ""; $Error .= "Click on links below to view/download your purchase(s).


"; //************** THE APOS TEST //$Error .= urldecode($UserData); $Error .= ($UserData); //************** THE APOS TEST $GoBack = "history.back()"; $Err2 = ""; include "c_msg1.html"; exit; } } } //----------------------------------------------------------------- // //----------------------------------------------------------------- function EmptyCart() { global $CartDir, $ShoppingCartFile, $ShoppingCartName; // EmptyCart() CartDir: 'logs/carts', ShoppingCartFile: '', ShoppingCartName: 'VodShoppingCart' ErrLog("EmptyCart() CartDir: '$CartDir', ShoppingCartFile: '$ShoppingCartFile', ShoppingCartName: '$ShoppingCartName'"); $ServerName = preg_replace("/www\./", "", $_SERVER['SERVER_NAME']); setcookie($ShoppingCartName, "", 0, "/", ".$ServerName"); //@unlink("$CartDir/$ShoppingCartFile"); } //------------------------------------------------------------- // //------------------------------------------------------------- function GetItemsFromShoppingCartFile($ShoppingCartFile) { global $CartDir, $MsgWindow; if(!file_exists("$CartDir/$ShoppingCartFile")) { $Msg1 = "Error 001 - Shopping cart empty
"; print "$Msg1"; //include $MsgWindow; exit; } $ShoppingCartItems = file("$CartDir/$ShoppingCartFile"); $ItemPrice = $SubTotal = 0; foreach($ShoppingCartItems as $ContentId) { $ContentId = trim($ContentId); $ItemPrice = GetPriceByContentId($ContentId); $SubTotal = $SubTotal + $ItemPrice; } return $SubTotal; } //----------------------------------------------------------------- // //----------------------------------------------------------------- function ShoppingCartFile() { global $CookieLife; if(isset($_COOKIE[$CustId])) { return $_COOKIE[$CustId]; } else { $CustIdCookie = GenerateRandomCustId(32); $ServerName = preg_replace("/www\./", "", $_SERVER['SERVER_NAME']); setcookie($CustId, $CustIdCookie, time()+ $CookieLife, "/", ".$ServerName"); return $CustIdCookie; } } ?> <? echo $HeaderMsg?>



Thank you for your purchase!

Login to your account

E-mail address 
Username 
Password 
*** SAVE FILES TO YOUR HARD DRIVE ***
 *** READ ME FIRST ***