danjapro Posted March 20, 2012 Share Posted March 20, 2012 I have this javascript here, I am trying to gather the zip and referrer and aaa_redir_url from the URL, which I have them being called as a variable. But if there is not zip in url, to then redirect to set location. I need a little assistance with this. here is how I am calling my variable that I need to pass <script type="text/javascript"> var tqsRedirectChecker = new TQSRedirectChecker({ aaa_redir_url: http://aaa.com/memberdeals, //need to repoint this, if the users does not have zip and devicecd timeWindow: 1800000, //milliseconds zip: "<?php if (isset($_REQUEST["zip"])):echo $_REQUEST["zip"]; endif; ?>", referrer: "<?php if (isset($_REQUEST["referrer"])):echo $_REQUEST["referrer"]; endif; ?>", }); tqsRedirectChecker.validateTqs(); </script> Here I am trying to perform the redirect, per the zip and reffer and then if it is not loaded in url go to aaa_redir_url, but if there is a zip and reffer in url go to a set url, that. If there is a way to make it into a cookie and then pass it, will be greate if not, just above request will be gratefully appreciated: var TQSRedirectChecker = function(config) { // This object expects a configuration JS object with all of the following parameters var allowed_clubs_array = config.allowed_clubs_array; var invalid_club_url = config.invalid_club_url; var invalid_ts_url = config.invalid_ts_url; var aaa_redir_url = config.aaa_redir_url; var timeWindow = config.timeWindow; var zip = config.zip; var referrer = config.referrer; var recipient_id = config.recipient_id; var ets = config.ets; var club = config.club; // Get the current system time var systemTime = new Date(); // Initialize the encoding / decoding key using the following map: // // 1 <-> E // 2 <-> A // 3 <-> C // 4 <-> B // 5 <-> D // 6 <-> F var key = new String("EACBDF"); // * // * PUBLIC METHOD to run the TQS Check // * this.validateTqs = function(){ // Checks to see if the request is a redirect from TQS. If // so, then it validates the credentials. If the request fails // validation, the request will be redirected to the "I'm sorry" // page. if( isEmailClickThru() ){ alert("Recipient ID: "+recipient_id); return; } if( !isTqsRedirect() ){ //alert("Not TQS...sending to aaa.com/MemberDeals"); window.location = aaa_redir_url; return; } else { alert(referrer + " | " + ets + " | " + club + " | " + timeWindow); } if( !isValidClub() ){ alert("invalid club"); window.location = invalid_club_url; return; } if( !isValidTqsTime() ){ alert("invalid time"); window.location = invalid_ts_url; return; } } // private method to check whether or not the incoming request is a referral from the partner redirect system. var isEmailClickThru = function(){ var isEmailClick = false; if( recipient_id != undefined && recipient_id != null && recipient_id != "" ){ isEmailClick = true; } return isEmailClick; }; // private method to check whether or not the incoming request is a referral from the partner redirect system. var isTqsRedirect = function(){ var isTqsRedir = false; if( referrer != undefined && referrer != null ){ if(referrer == "aaa" || referrer == "caa"){ isTqsRedir = true; } } return isTqsRedir; }; // private method to see if the time parameter is within the window var isValidTqsTime = function(){ var isWithinTime = false; var etsTime, etsTimeDecoded; if( ets != undefined && ets != null ){ etsTime = ets; if( !(etsTime == null) && !(etsTime == undefined) && !(etsTime == "")){ etsTimeDecoded = decodeTime(etsTime); if(etsTimeDecoded > (getGMTTime(systemTime) - timeWindow) && etsTimeDecoded < (getGMTTime(systemTime) + timeWindow) ){ isWithinTime = true; } } } return isWithinTime; }; // Private method to validate whether a club code is participating in the program var isValidClub = function(){ var isClubAllowed = false; if( club != undefined && club != null ){ for(var i=0;i<allowed_clubs_array.length;i++){ if(allowed_clubs_array[i]==club){ isClubAllowed = true; break; } } } return isClubAllowed; }; Quote Link to comment https://forums.phpfreaks.com/topic/259364-trying-to-redirect-with-cookie-or-with-zip-from-url/ Share on other sites More sharing options...
danjapro Posted March 21, 2012 Author Share Posted March 21, 2012 Can anyone, help me with this. Take a look, it simplfied process, that I am not quit sure I understand how to implement with the code we have already.. Quote Link to comment https://forums.phpfreaks.com/topic/259364-trying-to-redirect-with-cookie-or-with-zip-from-url/#findComment-1329817 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.