Page 1 of 1

Regex question..

Posted: Mon Oct 18, 2004 1:11 pm
by Gonik
hello ppl... I have a regex problem.

Let's say i want to match a specific string from the HTTP_REFERER var. I use this code:

Code: Select all

<?php
if(preg_match("/^(http:\/\/)www\.domain\.com\/new\/site\/disp/i", getenv("HTTP_REFERER")) {
// code to allow download goes here
}
?>
The pages that the above regex must match are:
so i want one regex to match all... But it doesn't work :( any suggestions?

Thanx in advance,
Nick :)

Hmmm

Posted: Mon Oct 18, 2004 1:20 pm
by neophyte
Code a switch for each of the four possible scenarios.....?

Posted: Mon Oct 18, 2004 1:30 pm
by Christopher
Maybe:

Code: Select all

if(preg_match("/^[htp\:\/]*www\.domain\.com\/new\/site\/disp[a-zA-Z0-9\.]*/i", getenv("HTTP_REFERER")) {
// code to allow download goes here
}

Posted: Mon Oct 18, 2004 1:32 pm
by feyd
Word to the wise: don't bank on the variable being set.

As for your regex...

Code: Select all

preg_match('#^https?://(www\.)?domain\.com/new/site/disp\.(freeware|shareware|gamedemos|freewaregames)\.php$#i', $_SERVER&#1111;'HTTP_REFERER'])
or similar..

Posted: Tue Oct 19, 2004 8:39 am
by Gonik
thanx, i'll try all of them and i'l get back to you