Dwhistler Posted May 7, 2009 Share Posted May 7, 2009 HI.... I got problem with this script... <?php //set this to true to rotate link offer or false to show fake website $go=false; //fake website $site='http://www.example.com'; $sites=explode("\n",file_get_contents('sites.txt')); $redirect = $sites[array_rand($sites)]; $aff_link = "$redirect"; if($go==true||$_REQUEST['trkid']==12){ if($_REQUEST['trkid']!=12){ echo '<meta http-equiv="refresh" content="0;url=track.php?trkid=12">'; }else{ $referer = $_SERVER['HTTP_REFERER']; if($referer == "" || strpos($referer,$_SERVER['HTTP_HOST'])) { echo '<meta http-equiv="refresh" content="0;url='.$aff_link.'">'; }else{ echo '<meta http-equiv="refresh" content="0;url='.$site.'">'; } } }else{ echo '<meta http-equiv="refresh" content="0;url='.$site.'">'; } ?> basically the script work fine... but it will double meta refresh the pages that listed in sites.txt I just need the function of the script to go true or false working and redirect randomly picked site listed in sites.txt please anyone could help? Thanks! ??? Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/ Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 Well, then put exit after an echo will stop that regardless of what the rest of your code does. Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-828516 Share on other sites More sharing options...
Zhadus Posted May 7, 2009 Share Posted May 7, 2009 Try this: <?php //set this to true to rotate link offer or false to show fake website $go = false; //fake website $site = 'http://www.example.com'; $sites = explode("\n",file_get_contents('sites.txt')); $aff_link = $sites[array_rand($sites)]; if (($go === true) || ($_REQUEST['trkid'] == 12)) { if ($_REQUEST['trkid'] != 12 ) { echo '<meta http-equiv="refresh" content="0;url=track.php?trkid=12">'; } else { $referer = $_SERVER['HTTP_REFERER']; if (($referer == "") || (strpos($referer,$_SERVER['HTTP_HOST']))) { echo '<meta http-equiv="refresh" content="0;url='.$aff_link.'">'; } else { echo '<meta http-equiv="refresh" content="0;url='.$site.'">'; } } } else { echo '<meta http-equiv="refresh" content="0;url='.$site.'">'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-828538 Share on other sites More sharing options...
GingerRobot Posted May 7, 2009 Share Posted May 7, 2009 Using the value of HTTP_REFERER to show different content isn't a great idea. It can be spoofed to get around your checks - indeed using any information which came from the user can be altered. But worse, is doing this means potentially legitimate users will suffer - some firewalls prevent the referer from being send and browsers can be configured not to send it. Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-828619 Share on other sites More sharing options...
Dwhistler Posted May 8, 2009 Author Share Posted May 8, 2009 Try this: <?php //set this to true to rotate link offer or false to show fake website $go = false; //fake website $site = 'http://www.example.com'; $sites = explode("\n",file_get_contents('sites.txt')); $aff_link = $sites[array_rand($sites)]; if (($go === true) || ($_REQUEST['trkid'] == 12)) { if ($_REQUEST['trkid'] != 12 ) { echo '<meta http-equiv="refresh" content="0;url=track.php?trkid=12">'; } else { $referer = $_SERVER['HTTP_REFERER']; if (($referer == "") || (strpos($referer,$_SERVER['HTTP_HOST']))) { echo '<meta http-equiv="refresh" content="0;url='.$aff_link.'">'; } else { echo '<meta http-equiv="refresh" content="0;url='.$site.'">'; } } } else { echo '<meta http-equiv="refresh" content="0;url='.$site.'">'; } ?> Is this code will disable the double meta refresh and show the referrer from the site listed in sites.txt? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-829146 Share on other sites More sharing options...
Dwhistler Posted May 8, 2009 Author Share Posted May 8, 2009 Using the value of HTTP_REFERER to show different content isn't a great idea. It can be spoofed to get around your checks - indeed using any information which came from the user can be altered. But worse, is doing this means potentially legitimate users will suffer - some firewalls prevent the referer from being send and browsers can be configured not to send it. Is there any better way to done this? ??? Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-829262 Share on other sites More sharing options...
RichardRotterdam Posted May 8, 2009 Share Posted May 8, 2009 why not use header instead Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-829272 Share on other sites More sharing options...
GingerRobot Posted May 8, 2009 Share Posted May 8, 2009 Using the value of HTTP_REFERER to show different content isn't a great idea. It can be spoofed to get around your checks - indeed using any information which came from the user can be altered. But worse, is doing this means potentially legitimate users will suffer - some firewalls prevent the referer from being send and browsers can be configured not to send it. Is there any better way to done this? ??? Well what exactly are you trying to achieve? Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-829282 Share on other sites More sharing options...
Dwhistler Posted May 8, 2009 Author Share Posted May 8, 2009 Using the value of HTTP_REFERER to show different content isn't a great idea. It can be spoofed to get around your checks - indeed using any information which came from the user can be altered. But worse, is doing this means potentially legitimate users will suffer - some firewalls prevent the referer from being send and browsers can be configured not to send it. Is there any better way to done this? ??? Well what exactly are you trying to achieve? I want the script function (go true or false and randomly picking site to load based on the sites.txt) to work without the double meta refresh. but i really don't know how to do it when it set to go=true it will randomly pick site to load from sites.txt and double meta refresh. I don' want the script to double meta refresh when it pick site to load from sites.txt echo '<meta http-equiv="refresh" content="0;url=track.php?trkid=12">'; }else{ $referer = $_SERVER['HTTP_REFERER']; if($referer == "" || strpos($referer,$_SERVER['HTTP_HOST'])) { echo '<meta http-equiv="refresh" content="0;url='.$aff_link.'">'; }else{ echo '<meta http-equiv="refresh" content="0;url='.$site.'">'; } } }else{ echo '<meta http-equiv="refresh" content="0;url='.$site.'">'; } ?> I am sorry for my bad english as Thanks for helping me.... appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-829375 Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Well, then put exit after an echo will stop that regardless of what the rest of your code does. Does that not work? Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-829410 Share on other sites More sharing options...
Dwhistler Posted May 8, 2009 Author Share Posted May 8, 2009 Well, then put exit after an echo will stop that regardless of what the rest of your code does. Does that not work? I don't know how I am a total noob on programming Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-829585 Share on other sites More sharing options...
premiso Posted May 8, 2009 Share Posted May 8, 2009 <?php //set this to true to rotate link offer or false to show fake website $go = false; //fake website $site = 'http://www.example.com'; $redirect = $site; $sites = explode("\n",file_get_contents('sites.txt')); $aff_link = $sites[array_rand($sites)]; if (($go === true) || ($_REQUEST['trkid'] == 12)) { if ($_REQUEST['trkid'] != 12 ) { $redirect = "track.php?trkid=12"; } else { $referer = $_SERVER['HTTP_REFERER']; if (($referer == "") || (strpos($referer,$_SERVER['HTTP_HOST']))) { $redirect = $aff_link; } } } echo '<meta http-equiv="refresh" content="0;url='.$redirect.'">'; exit; ?> Give that code a try and see if it works right for you. Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-829599 Share on other sites More sharing options...
Dwhistler Posted May 9, 2009 Author Share Posted May 9, 2009 <?php //set this to true to rotate link offer or false to show fake website $go = false; //fake website $site = 'http://www.example.com'; $redirect = $site; $sites = explode("\n",file_get_contents('sites.txt')); $aff_link = $sites[array_rand($sites)]; if (($go === true) || ($_REQUEST['trkid'] == 12)) { if ($_REQUEST['trkid'] != 12 ) { $redirect = "track.php?trkid=12"; } else { $referer = $_SERVER['HTTP_REFERER']; if (($referer == "") || (strpos($referer,$_SERVER['HTTP_HOST']))) { $redirect = $aff_link; } } } echo '<meta http-equiv="refresh" content="0;url='.$redirect.'">'; exit; ?> Give that code a try and see if it works right for you. Thanks a lot! It works! ;D Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/157237-solved-need-help-here-guru/#findComment-830172 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.