Search Results for 'code'
-
Search Results
-
Topic: A question about icons
Topic: PHP Warning: parse_url
In the php_errorlog, there is a common warning, “PHP Warning: parse_url(…..”. This warning is caused within the bb_get_path function in bb-includes/functions.bb-core.php. The common cause of this issue is due to urls being passed to this function in the following format:
/bb-login.php?re=http://example.com/tags.php?tag=sometag
Due to the http:// within the query string, parse_url will fail and log an error. The way to get around this is to pre-pend the website address and http:// to the beginning of the url, such as:
http://example.com/bb-login.php?re=http://example.com/tags.php?tag=sometag
This format is valid with the parse_url function. To change your code to use this format, change the bb_get_path function in bb-includes/functions.bb-core.php to the following:
function bb_get_path( $level = 1, $base = false, $request = false ) {
if ( !$request )
$request = $_SERVER;
if ( is_string($request) )
{
// parse_url throws a warning for a url that has http:// as a query parameter and doesn’t start with http://
$pos = strpos($url, “http://”);
// Check if we found http:// in the string and it’s not at the beginning, and the url starts with a forward slash
if ($pos !== false && $pos > 0 && substr($request,0,1) == “/”)
{
// We got here, so it’s not at the beginning and is in the url. Add in the domain to the beginning
$oldRequest = $request; // Use a new variable since some PHP versions don’t like re-assigning
$request = “http://”.$_SERVER[“HTTP_HOST”].$oldRequest;
}
$request = parse_url($request);
}
if ( !is_array($request) || !isset($request) )
return ”;
$path = rtrim($request, ” tnrx0B/”);
if ( !$base )
$base = rtrim(bb_get_option(‘path’), ” tnrx0B/”);
$path = preg_replace(‘|’ . preg_quote($base, ‘|’) . ‘/?|’,”,$path,1);
if ( !$path )
return ”;
if ( strpos($path, ‘/’) === false )
return ”;
$url = explode(‘/’,$path);
if ( !isset($url[$level]) )
return ”;
return urldecode($url[$level]);
}
Doing this will get rid of the common error in your error log, and prevent site issues.
Note: This will need to be changed if your site is using SSL, such as https://
Topic: bbRating FF issue
Topic: BB Seo Tools Bugs
There’s some conflicts in the bb seo tools plugin with human test. This is the error:
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /web/htdocs/www.alegria.it/home/forum/my-plugins/bb-seo-tools.php on line 178
Glad you figured it out. Just to clarify, what I mean was you need to pass the proper topic ID depending on what you are doing. In this case, you are using get_topic_id(), which will get the current topic ID being worked on based on the global topic object. In other cases, you may be within a loop of topics, in which case you would need to use something along the lines of $topic->topic_id, depending on your topic object name. This will start to make more sense as you progress within php and bbPress. Until then, don’t be afraid to ask questions for help, everyone has to learn somehow.
.
