Reply
preg_match help
Old 05-29-2008, 07:40 PM preg_match help
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
This is what I have:
PHP Code:
preg_match('/^http:\/\/:[www.]?arenlor.com\/index2.php$/i',$_SERVER['HTTP_REFERER']) 
I know referer can be faked or disabled but this isn't anything more than a fun feature on my one page actually so it's not needed. Anyway I think the issue is with the [www.]? part or it may be with the colon, not sure.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
When You Register, These Ads Go Away!
Old 05-30-2008, 03:10 PM Re: preg_match help
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 984
Name: Jeremy Miller
Location: Reno, NV
Check out this change:
PHP Code:
<?php
$_SERVER
['HTTP_REFERER'] = 'http://www.arenlor.com/index2.php';
$_SERVER['HTTP_REFERER'] = 'http://arenlor.com/index2.php';
if (
preg_match('/^http:\/\/(?:www.)?arenlor.com\/index2.php$/i',$_SERVER['HTTP_REFERER'])) {
  echo 
'Referrer Match';
}
?>
There were 2 issues:
1) You had an extra colon in there.
2) Brackets are used to list allowed characters, not to denote a section (that's not the right word, but hopefully you get what I mean). Use parenthesis to denote a section. Adding ?: after the first parenthesis means that it doesn't capture the match -- it's optional for your usage here.

Hope that helps
__________________
Jeremy Miller - TeraTask Technologies, LLC
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 05-31-2008, 01:12 AM Re: preg_match help
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
Thanks, that solved it, not sure what the first two lines are though.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 05-31-2008, 01:14 AM Re: preg_match help
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 984
Name: Jeremy Miller
Location: Reno, NV
That's me sticking in test data. You wouldn't use it on a live site.
__________________
Jeremy Miller - TeraTask Technologies, LLC
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 05-31-2008, 01:50 AM Re: preg_match help
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
I never knew you could manipulate $_SERVER like that.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 05-31-2008, 02:06 AM Re: preg_match help
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 984
Name: Jeremy Miller
Location: Reno, NV
You can do that with any of the global variables.
__________________
Jeremy Miller - TeraTask Technologies, LLC
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 05-31-2008, 02:12 AM Re: preg_match help
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
That's pretty sweet.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Reply     « Reply to preg_match help
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13419 seconds with 12 queries