Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Warning: preg_match() [function.preg-match]: Unknown modifier 'n'


labmais

Recommended Posts

Hello new problem at my site

 

It was saying before that function eregi was deprecated, then I changed it to preg_match and now it gives the following error

 

Error: Warning: preg_match() [function.preg-match]: Unknown modifier 'n' in /home/alexband/public_html/noticias/index.php on line 481

Here is the code

if($config_check_referer == TRUE){

  $self = $_SERVER["SCRIPT_NAME"];

  if($self == ""){ $self = $_SERVER["REDIRECT_URL"]; }

  if($self == ""){ $self = "index.php"; }



  if(!preg_match("$self",$HTTP_REFERER) and $HTTP_REFERER != ""){

  	die("<h2>Sorry but your access to this page was denied !</h2><br>try to <a href=\"?action=logout\">logout</a> and then login again<br>To turn off this security check, change \$config_check_referer in index.php to FALSE");

  }

}

 

 

 

Thanks,

Rafael

DarkEden Amateur International

E-commerce?

No external links please.

Link to comment
Share on other sites

Here is a better look of the code

 


471 if($config_check_referer == TRUE){
472
473   $self = $_SERVER["SCRIPT_NAME"];
474
475   if($self == ""){ $self = $_SERVER["REDIRECT_URL"]; }
476
477   if($self == ""){ $self = "index.php"; }
478
479
480
481   if(!preg_match("$self",$HTTP_REFERER) and $HTTP_REFERER != ""){
482
483       die("<h2>Sorry but your access to this page was denied !</h2><br>try to <a href=\"?action=logout\">logout</a> and then login again<br>To turn off this security check, change \$config_check_referer in index.php to FALSE");
484
485   }
486
487}
488

E-commerce?

No external links please.

Link to comment
Share on other sites

481   if(!preg_match("#$self#",$HTTP_REFERER) and $HTTP_REFERER != ""){

I don't think "#" is ever used in the $self string, but if it is, try "@" or "^" or some other character as the search delimiter.

 

I presume that your intent is to match any occurrence of $self in the HTTP_REFERER, rather than an exact match of the entire thing? If not, why not just use == ?

Link to comment
Share on other sites

Hey, it seems worked...I have added those ^ ^ on self and it's apparently working.

 

^$self^

 

 

but I still have another problem...

 

if you can look the website

 

www.AlexBand.com.br

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 137577900 bytes) in /home/alexband/public_html/noticias/inc/functions.inc.phpon line 859

 

and

 

AlexBand News

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 137577900 bytes) in/home/alexband/public_html/noticias/inc/main.mdu on line 55

what should I do?

I talked to my host and they said that I have 64MB memory limit and they can't increase it.

They recomended me to decrease the size of my application...how would I do that?

MrPhill, thank you so much,

Rafael Vidal

E-commerce?

No external links please.

Link to comment
Share on other sites

Something is very wrong with your site. There's no way it should be trying to allocate 137 megabytes, much less in one step. Can you see if your previous fix might be doing something? Perhaps you could temporarily comment out the line and the two following it, just to ensure that isn't the cause. If it still fails (my guess is that it will), we have to look elsewhere.

Link to comment
Share on other sites

MrPhil,

 

the problem is the following.

This site www.alexband.com.br is out dated.

It's my friend website and I think it would be easy to fix the out date problems (eregi deprecated, memory cache, etc), but everytime when I fix a file or a line in a file, I find another problem...so I guess that I'm doing something wrong.

Example, when I changed the eregi into preg_match and the $self into ^$self^ ... apparently it worked, but another problem appeared...

 

What can I do?

Can you help me?

E-commerce?

No external links please.

Link to comment
Share on other sites

Are you creating problems when you try to fix something, or are you just getting further along in the code before the next thing breaks? If you're creating as many bugs as you're fixing, perhaps you need to take some online courses on PHP and related subjects. Otherwise, you just need to keep plugging away at it. These days I'm fully employed and can't take on any outside projects (sorry!). Otherwise I'd be happy to quote a price for updating the site.

 

By the way, if the original code was

eregi("$self",...

you would need to change it to

preg_match("^$self^i",...

The "i" means "ignore case".

Link to comment
Share on other sites

MrPhil,

 

I did what you said, replaced the "$self" for "^$self^i" and it's looking like this. Also it's seems to be working...

 

465 - //----------------------------------

466 - 
467 - // Check Referer
468 - 
469 - //----------------------------------
470 - 
471 - if($config_check_referer == TRUE){
472 - 
473 - $self = $_SERVER["SCRIPT_NAME"];
474 - 
475 - if($self == ""){ $self = $_SERVER["REDIRECT_URL"]; }
476 - 
477 - if($self == ""){ $self = "index.php"; }
478 - 
479 - 
480 - 
481 - if(!preg_match("^$self^i",$HTTP_REFERER) and $HTTP_REFERER != ""){
482 - 
483 - die("<h2>Sorry but your access to this page was denied !</h2><br>try to <a href=\"?action=logout\">logout</a> and then login again<br>To turn off this security check, change \$config_check_referer in index.php to FALSE");
484 - 
485 - }
486 - 
487 - }

 

 

 

 

My main problem now is about this error:

 

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 137577900 bytes) in /home/alexband/public_html/noticias/inc/addnews.mdu on line 432

Almost none of the website functions aren't working because of this thing....

 

 

Thank you

E-commerce?

No external links please.

Link to comment
Share on other sites

Everything seems ok now.

 

I had a file named "comments.txt" at "/www/noticias/data/" and this file was 130MB sized.

 

So I deleted it and recreated another and everything is working again.

 

There is already some minor problems with "deprecated functions", but I guess I can handle now...

 

thanks everybody,

 

Thanks MrPhil.

E-commerce?

No external links please.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...