I have popups which i want to show to one IP address every hour. How do i do this with a simple PHP, or can you redirect me to one. Thanks, Jacob
you can do simple if condition: e.g <?php $ip="1.1.1.1"; if($ip != "1.1.1.1") { // do nothing } else { //pop script here } <?
eli03 is off to the right start but it's not exactly the entire code you'd need. you have a few options. 1) store the ip's in a flat file with the last time visited associated with it 2) do the same but with mysql. 3) use cookies. the third is usually ideal.
<? $cookie=$_COOKIE['time']; if ($cookie!='on') { setcookie('time', 'on', time()+3600); /// insert code for ad here } ?> PHP: not a great coder, but i think that's what you'd want.
Edit: Almost same code as above. Was not there when I first looked at the thread. ---- Try this: <?php if($_COOKIE['pop'] != "333") { setcookie('pop', '333', time()+3600); // sets a cookie for 1 hour. // Pop up code here. } ?> On the first visit the cookie will not be found, Popup comes up. Plus cookie is set. For the next 1 hour, the cookie is found, No popup. After 1 hour cookie expires, popup comes up again. Plus new cookie set. Hope that helps. Bye
Wow, that was the fastest response Its good ill give it a go Thanks guys. P.S check back to see if it worked
I used this code: <?php if($_COOKIE['pop'] != "333") { setcookie('pop', '333', time()+3600); // sets a cookie for 1 hour. // Pop up code here. <script src="http://www.adversal.com/cg.jsp"></script> <script src="http://www.adversal.com/publisherJS.jsp"></script> <script type="text/javascript" language="javascript"> initAdversal("8708bb9d80806013c99bb1910fb0a7cc", true); </script> } ?> Is that right, becase when i try to use it it says "Parse error: syntax error, unexpected '<' in /home/admin/public_html/poxy-0.4/url_form.inc on line 43" Am i coding it wrong?
ahem ... is that exactly how the code looked like? B'coz if it is then try doing it something like <?php if($_COOKIE['pop'] != "333") { setcookie('pop', '333', time()+3600); // sets a cookie for 1 hour. // Pop up code here. echo ' <script src="http://www.adversal.com/cg.jsp"></script> <script src="http://www.adversal.com/publisherJS.jsp"></script> <script type="text/javascript" language="javascript"> initAdversal("8708bb9d80806013c99bb1910fb0a7cc", true); </script>'; } ?> PHP:
Thanks, i repped you both. If i wanted to apply this time for one IP but not another, is that a way to do that? Like combine a IP chooser kind of.
list ip's you don't want in an array. http://us3.php.net/manual/en/ref.array.php define the ips you don't want to trigger it, then use the code below <? $nopop[0] = "xx.xx.xx.xx"; $nopop[1] = "xx.xx.xx.xx"; if (strpos($_SERVER['REMOTE_ADDR'], $nopop) === 0)) { // the cookie code here } ?> PHP:
settings cookies isnt always effective. if it were me, I'd store it in a session. (its easiest if you have already one running)
most users that have cookies turned off are probably the sort of user that has some fairly advanced adblocking software installed too, so it seems kind of moot to me. and it's not like sessions aren't without downfalls either.
And then they a get a popup every time. It isn't that bad after all most proxy sites have a popup every load. I get enough traffic with a popup each load so it doesn't matter. Also i repped disgust