Rusnak PHP Scripts Support Forums

Full Version: Remote hosted themes error and workaround
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I noticed today that with my remotely hosted themes, mybb was failing to pick up the image lang directory correctly, thus showing the alt text for all the lang images.

Workaround
Open global.php

find
PHP Code:
// If a language directory for the current language exists within the theme - we use it
if(!empty($mybb->user['language']) && is_dir($theme['imgdir'].'/'.$mybb->user['language'])) 

REPLACE with

PHP Code:
//Custom function to enable remote hosted themes to work correctly
function url_exists($url) {
    
$hdrs = @get_headers($url);
    return 
is_array($hdrs) ? preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/',$hdrs[0]) : false;


// If a language directory for the current language exists within the theme - we use it

if(!empty($mybb->user['language']) && is_dir($theme['imgdir'].'/'.$mybb->user['language'])) 

FIND

PHP Code:
if(is_dir($theme['imgdir'].'/'.$mybb->settings['bblanguage'])) 

REPLACE with

PHP Code:
//if(is_dir($theme['imgdir'].'/'.$mybb->settings['bblanguage']))

if(if(url_exists($theme['imgdir'].'/'.$mybb->settings['bblanguage'].'/newreply.gif') OR is_dir($theme['imgdir'].'/'.$mybb->settings['bblanguage']))) 

That should solve your problem Smile

Credits: Some guy on php.net for the url_exists() function. ME for the rest!
Nice! Smile
Cheers! If anyone has any troubles with this not working, feel free to post and I'll check it out.
Nice fix. Hopefully everyone with this issue comes and pick's up this code. Cool
Ok I found today that my fix for remote themes would break the local themes so i've updated my fix in the first post to work with both. Sorry about that!
Reference URL's