PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Tue Sep 18, 2007 3:34 pm
This script needs to be made case insensitive. So if someone clicks to get to my site using the string 'Two' it will not currently match.
Code: Select all
<?php
$lostsouls = array( "one", "two", "three");
list($parameter_string) = array_reverse(explode('?', $_SERVER['HTTP_REFERER']));
$parameters = explode('&', $parameter_string);
foreach($parameters as $parameter) {
list($key, $value) = explode('=', $parameter);
$args = explode('+',$value);
foreach($args as $item){
if(in_array($item,$lostsouls)){header("Location: http://www.example.com/");
}
}
}
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Sep 18, 2007 3:51 pm
What have you tried?
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Tue Sep 18, 2007 3:53 pm
Code: Select all
in_array(trim(mb_strtolower($item)),$lostsouls)
Code: Select all
in_array(trim(strtolower($item)),$lostsouls)
Code: Select all
in_array(strtolower($item),$lostsouls)
Code: Select all
(in_array(strtolower($item),strtolower($lostsouls))
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Tue Sep 18, 2007 4:00 pm
This works fine with Lycos but not with Bearshare...
Code: Select all
<?php
$lostsouls = array( "one", "two", "three");
list($parameter_string) = array_reverse(explode('?', $_SERVER['HTTP_REFERER']));
$parameters = explode('&', $parameter_string);
foreach($parameters as $parameter) {
list($key, $value) = explode('=', $parameter);
$args = explode('+',$value);
foreach($args as $item){
$item = urldecode($item);
$i = explode(' ',$item);
foreach($i as $x){
if (in_array(trim(strtolower($item)),$lostsouls)) {
header("Location: http://www.example.com/");
}
}
}
}
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Sep 18, 2007 4:03 pm
What are the differences between the two?
JAB Creations
DevNet Resident
Posts: 2341 Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:
Post
by JAB Creations » Tue Sep 18, 2007 4:17 pm
Thanks for the replies. Got it working and as always here is the final code...
Code: Select all
<?php
$lostsouls = array( "one", "two", "three");
list($parameter_string) = array_reverse(explode('?', $_SERVER['HTTP_REFERER']));
$parameters = explode('&', $parameter_string);
foreach($parameters as $parameter) {
list($key, $value) = explode('=', $parameter);
$args = explode('+',$value);
foreach($args as $item){
$item = urldecode($item);
$i = explode(' ',$item);
foreach($i as $x){
if (in_array(trim(strtolower($x)),$lostsouls)) {
header("Location: http://www.example.com/");
}
}
}
}
?>