Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Warning: Unknown modifier 't' in...

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Warning: Unknown modifier 't' in...

Postby jstrellner » Thu May 22, 2003 10:16 pm

Can anyone help with this, I can't figure this out for anything. I've searched google, checked my PHP books, but nothing.

Code: Select all
if (preg_match ("/User-agent: \*\nDisallow: $parsedurl[path]\n/i", $finalrobotfile)) {
   print "robots file found, can not index this page.";
}


The problem is is that I can't get preg_match to allow me to have the $parsedurl[path] string.

If I remove the string it will work without error, but once I add the string back in I get the error. I have to have the string because that part of the code will change everytime that the script is executed.

Does anyone have any ideas?

Thanks,
jstrellner
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Nov 05, 2002 11:05 pm
Location: Las Vegas, NV

Re: Warning: Unknown modifier 't' in...

Postby WiZARD » Fri May 23, 2003 4:13 am

hi!
as i understand you want to determinate user's info like browser, from what page his come and e.t.c. correct?
Try use GLOBAL PHP array.
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby jstrellner » Fri May 23, 2003 10:18 am

No, I know how to get a users information. What I am doing is opening a robots.txt file. Then I am checking to see if they specify all robots with User-agent: * the I am checking to see if the file that I want to check is specifically forbiden.

Code: Select all
User-agent: *
Disallow: /cgi-bin/
Disallow: /errors/
Disallow: /ftp/
Disallow: /logs/
Disallow: /webmail/
Disallow: /test1.php


The other thing that I have to figure out is how to make it so that any number of characters can be between the two strings.

I have changed the way I check it to make it sort of work.

Code: Select all
if ((preg_match("/(User-agent: \*\n)|(User-agent: \TestBotName\n)/i", $finalrobotfile)) AND (preg_match("/Disallow: \/test1.php/i", $finalrobotfile))) {
   print "robots file found, can not index this page.";
}


The above code will work (almost) perfectly. The reason it almost works perfectly is that I have to hardcode the "test1.php", I cant use a variable to put the file name in there.
jstrellner
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Nov 05, 2002 11:05 pm
Location: Las Vegas, NV

Postby jstrellner » Fri May 23, 2003 11:03 am

Nevermind I figured it out. Instead of using preg_match I used a while loop when I opened the file and I looped through each line to see if it matched correctly.

This worked well and I can now more accuratly tell if the robots.txt file is excluding spidering.

Thanks for your help.
jstrellner
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Nov 05, 2002 11:05 pm
Location: Las Vegas, NV


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.