jbutler Posted April 16, 2009 Share Posted April 16, 2009 Can someone point me in the right direction? I need to create a "speed bump" or one of those annoying messages that pops up when you click on an outbound link that says "Warning, you are about to leave this site, etc...). I know I can do it with Javascript but would rather have a PHP capture the click and go to a page that says basically the same thing. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/154361-how-to-create-speed-bump-or-capture-an-outbound-link/ Share on other sites More sharing options...
kenrbnsn Posted April 16, 2009 Share Posted April 16, 2009 PHP can not do that, since it runs on the server. Ken Quote Link to comment https://forums.phpfreaks.com/topic/154361-how-to-create-speed-bump-or-capture-an-outbound-link/#findComment-811535 Share on other sites More sharing options...
Zane Posted April 16, 2009 Share Posted April 16, 2009 PHP cannot capture clicks. To Javascript this goes Quote Link to comment https://forums.phpfreaks.com/topic/154361-how-to-create-speed-bump-or-capture-an-outbound-link/#findComment-811536 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 U can use a php redirector script instead if yer links were like: http://mysite.com/redir.php?url=xxxx u wud have to use urlencode, to encode the original url. Quote Link to comment https://forums.phpfreaks.com/topic/154361-how-to-create-speed-bump-or-capture-an-outbound-link/#findComment-811545 Share on other sites More sharing options...
jbutler Posted April 16, 2009 Author Share Posted April 16, 2009 U can use a php redirector script instead if yer links were like: http://mysite.com/redir.php?url=xxxx u wud have to use urlencode, to encode the original url. THANKS! This is what I want! I don't know why they moved it to the Java forum when I specifically stated that. Anyway, could you point me in the right direction and give more information? THANKS! again! Quote Link to comment https://forums.phpfreaks.com/topic/154361-how-to-create-speed-bump-or-capture-an-outbound-link/#findComment-811734 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 Okay with some standard coding here, here is redir.php this should work, as an example <html> <head> <title>HTML Redirect Ad Example</title> <?php // Check for a url field, otherwise send to default page $url=(!isset($_GET['url']))?'index.php':urldecode($_GET['url']); // Javascript insertion detection if(preg_match( "/([<>'\"]|'|!|"|%27|%22|%3E|%3C|'|"|>|<|\.js)/i", $url )) $url='http://www.urbandictionary.com/define.php?term=twat'; // Fix up any unprefixed urls if (substr($url, 0, 4) == "www.") $url = "http://" . $url; ?> <meta http-equiv="refresh" content="5;<?php echo $url; ?>"> </head> <body> <?php $ads=array('google','yahoo','msn'); $show=rand(0,count($ads)-1); ?> <h1>Ad for <span style='color: red'><?php echo $ads[$show]; ?></span></h1> </body> </html> to use the code in yer site $redir="redir.php?url=".urlencode("http://www.google.com"); and that should do it Note: Now if some moderator would be kind enough to move this thread back? Good Luck Quote Link to comment https://forums.phpfreaks.com/topic/154361-how-to-create-speed-bump-or-capture-an-outbound-link/#findComment-811845 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.