rendsonn Posted September 26, 2010 Share Posted September 26, 2010 I'm having trouble with a role in a wordpress site that I made I think the script was that I installed another version, so I some adjustments in it, among those changes have modified this function if (@$_GET['src'] && !@$PHPTHUMB_CONFIG['allow_local_http_src'] && eregi('^http://'.@$_SERVER['HTTP_HOST'].'(.+)', @$_GET['src'], $matches)) { $phpThumb->ErrorImage('It is MUCH better to specify the "src" parameter as "'.$matches[1].'" instead of "'.$matches[0].'".'."\n\n".'If you really must do it this way, enable "allow_local_http_src" in phpThumb.config.php'); } for this: (@$_GET['src'] && !@$PHPTHUMB_CONFIG['allow_local_http_src'] && preg_match('^http://'.@$_SERVER['HTTP_HOST'].'(.+)', @$_GET['src'], $matches)) { $phpThumb->ErrorImage('It is MUCH better to specify the "src" parameter as "'.$matches[1].'" instead of "'.$matches[0].'".'."\n\n".'If you really must do it this way, enable "allow_local_http_src" in phpThumb.config.php'); } It was supposed to make some images appear as thumbnails on the home page my site, but they do not appear and I got the following error: Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /home/pontocom/public_html/wp-content/themes/Comfy/scripts/phpThumb/phpThumb.php on line 160 Is there some way that I can take to fix this error? Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 26, 2010 Share Posted September 26, 2010 use ('/^http://'.@$_SERVER['HTTP_HOST'].'(.+)/', because you started your regexp with ^ it expect it to end the pattern with ^ that's why people mostly use / pattern / or ~ pattern ~ Quote Link to comment Share on other sites More sharing options...
rwwd Posted September 26, 2010 Share Posted September 26, 2010 Why do people do this:@$_GET['src'] I never quite understand why people do this, why suppress errors? Surely you want to know EVERYTHING that could be erroneous with your code... The only exception I know to this 'rule' is some of the XML functions, that even php.net documentation state, that in order to get it to functional you will need to use the @ symbol to get the desired functionality. Secondly: Word of advice (though using older versions should be ok) If you put error_reporting(E_ALL|E_DEPRECATED); on in the file you are working on, you should get a notice to say that ereg_ functions are now deprecated, this means that, should you come to migrate servers in the future, some of the functionality of you code won't or wouldn't perform as desired. [EDIT] Then I re read the first post and wish I had pressed preview instead of post! Read some preg stuff from the manual Rw Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 26, 2010 Share Posted September 26, 2010 I think his problem stemmed from the fact that he just got rid of the eregi() and is replacing it with preg_match(). I agree with universally and summarily ripping all the error suppression '@'s out of all code, however. Quote Link to comment Share on other sites More sharing options...
rendsonn Posted September 26, 2010 Author Share Posted September 26, 2010 use ('/^http://'.@$_SERVER['HTTP_HOST'].'(.+)/', because you started your regexp with ^ it expect it to end the pattern with ^ that's why people mostly use / pattern / or ~ pattern ~ I get this: Warning: preg_match() [function.preg-match]: Unknown modifier '/' in I'll read the manual and see if I can find another way to insert this script, anything I post here again Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 26, 2010 Share Posted September 26, 2010 You need to escape the slashes in the pattern now that someone decided you should use slashes as a delimiter. Otherwise, to help keep it readable, change the delimiters to tilde ~ (or some other non-alphanumeric character that doesn't appear in the pattern). Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 26, 2010 Share Posted September 26, 2010 bad advice. never mind. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.