11
phppp
Re: CBB forum, big problem
  • 2005/9/14 17:11

  • phppp

  • XOOPS Contributor

  • Posts: 2857

  • Since: 2004/1/25


"/modules/newbb/images/blank.gif" is generated directly by png hack when an image is forbidden/incapable to access.

That's why I suggested to disable png hack.

The reason for forbidding image access could include hotlink protection or some other unknown issues.
I have checked dean_collins' images, all exist.
So, I still suspect it is a hotlink protection problem.

12
dean_collins
Re: CBB forum, big problem

ok thanks for your time and efforts, it'd definately not appreciated.

13
hammondr
Re: CBB forum, big problem
  • 2005/9/15 3:57

  • hammondr

  • Just popping in

  • Posts: 9

  • Since: 2005/9/15


Ok, here is the fix. I don't know what the cause of the problem is, but at least I figured out the solution. :)

edit modules/newbb/include/functions.php

Find the lines:
if(file_exists($imageuri)){
$size=@getimagesize($imageuri);

and modify them to say:
if(file_exists(XOOPS_ROOT_PATH.$imageuri)){
$size=@getimagesize(XOOPS_ROOT_PATH.$imageuri);

I am a 2-day newbie to XOOPS and cbb, but I know this: for some reason, imageuri does not include the full XOOPS path. files_exists is crapping on the bogus path name (like '/modules/newbb/images/blah.gif') when it expects the full unix path.

Maybe someone smarter than me can find out why?

14
dean_collins
Re: CBB forum, big problem

You are an absolute freaking legend....!!!

sensational work.

Working perfectly. Can someone tell me how we get this modified so that this change is implemented in so no one else has to go through this problem.

You're a champion, if you ever think I can repay the favour somehow dont hesitate to ask.

Cheers,
Dean

15
phppp
Re: CBB forum, big problem
  • 2005/9/15 12:59

  • phppp

  • XOOPS Contributor

  • Posts: 2857

  • Since: 2004/1/25


Thanks guys!

Seems that the processing in functions.php::newbb_displayImage() is not fully valid:
$imageuri=str_replace(XOOPS_URL,XOOPS_ROOT_PATH,$image);

I am going to check and make a fix in next release.

16
hammondr
Re: CBB forum, big problem
  • 2005/9/15 13:01

  • hammondr

  • Just popping in

  • Posts: 9

  • Since: 2005/9/15


Update:

mainfile.php (in the XOOPS root) defines the constants XOOPS_URL and XOOPS_ROOT_PATH. Most people probably have a value in XOOPS_URL liks "/xoops/html". However, since I am using a test subdomain, which points directly to my xoops/html directory, my XOOPS_URL is '' (empty string). These problems are happening w/ newbb because XOOPS_URL is ''.

So, the problem is not exactly with the lines I pasted earlier, although that will fix the problem, too. The 'real' problem is the str_replace line just about the lines I pasted here.

The str_replace doesn't work when XOOPS_URL is empty. The newbb module is trying to provide a real pathname to file_exists() and getimagesize(), but the str_replace has no effect. Again, I think this will only cause problems when XOOPS_URL is ''.

Add some logic around your str_replace like this, and see if that works, too.

[in include/functions.php]
Quote:
.
.
.
$image .= '.'.$image_type;

// 2005-09-14: REH: added logic to test for XOOPS_URL. Without it, the str_replace has no effect when
// XOOPS_URL is empty.
if (XOOPS_URL != '') {
$imageuri=str_replace(XOOPS_URL,XOOPS_ROOT_PATH,$image);
} else {
$imageuri= XOOPS_ROOT_PATH.$image;
}

if(file_exists($imageuri)){
$size=@getimagesize($imageuri);
.
.
.


The file also has a snafu like this one. Look for the line:
Quote:
$indeximage_select->setExtra("onchange=\"showImgSelected('img', 'indeximage', '/".$imgdir."/', '', '" . XOOPS_URL . "')\"")


and replace that line with this:
Quote:
// 2005-09-14: REH: added logic to test for XOOPS_URL. Without it, the str_replace has no effect when
// XOOPS_URL is empty.
if (XOOPS_URL != '') {
$indeximage_select->setExtra("onchange=\"showImgSelected('img', 'indeximage', '/".$imgdir."/', '', '" . XOOPS_URL . "')\"")
;
} else {
$indeximage_select->setExtra("onchange=\"showImgSelected('img', 'indeximage', '/".$imgdir."/', '', '../../..')\"");
}


The magic is in that last line. Note: This only works for me since '../../..' gets me back to the XOOPS root from where I have this module installed. your mileage may vary. Hopefully the author can patch the module so we can get rid of my spaghetti code. .

17
hammondr
Re: CBB forum, big problem
  • 2005/9/15 13:06

  • hammondr

  • Just popping in

  • Posts: 9

  • Since: 2005/9/15


Oops ... I forgot to mention the other filename with that last bug. The file that uses the $indeximage_select->setExtra business is admin/admin_cat_manager.php, in the function editCategory().

18
phppp
Re: CBB forum, big problem
  • 2005/9/15 13:07

  • phppp

  • XOOPS Contributor

  • Posts: 2857

  • Since: 2004/1/25


Solution for test:
function newbb_displayImage($image$alt ""$width 0$height =0$style ="margin: 0px;"$sizeMeth='scale')
{
    global 
$xoopsModuleConfig$forumImage;
    static 
$image_type;

    
$user_agent_is_IE5 newbb_isIE5();
    if(!isset(
$image_type)) $image_type = ($xoopsModuleConfig['image_type'] == 'auto')?(($user_agent_is_IE5)?'gif':'png'):$xoopsModuleConfig['image_type'];
    
$image .= '.'.$image_type;
[
b]    $imageuri=preg_replace("/^".preg_quote(XOOPS_URL,"/")."/",XOOPS_ROOT_PATH,$image);
    if(!
preg_match("/^".preg_quote(XOOPS_ROOT_PATH,"/")."/",$imageuri)){
        
$imageuri XOOPS_ROOT_PATH."/".$image;
    }[/
b]
    if(
file_exists($imageuri)){
        
$size=@getimagesize($imageuri);
        if(
is_array($size)){
            
$width=$size[0];
            
$height=$size[1];
        }
    }else{
        
$image=$forumImage['blank'].'.gif';
    }
    
$width .='px';
    
$height .='px';

    
$img_style "width: $width; height:$height$style";
    
$image_url "$image."" style="".$img_style."" alt="".$alt."" align="middle" />";

    return 
$image_url;
}



Thanks for your help.

19
scriptino
Re: CBB forum, big problem
  • 2005/9/23 2:09

  • scriptino

  • Just popping in

  • Posts: 4

  • Since: 2005/9/21


I CONFIRM : IT WORKS!
I had the same problem with my forum and when i used The code below it worked !
Great Work guys!
Thank you
Quote:

phppp wrote:
Solution for test:
function newbb_displayImage($image$alt ""$width 0$height =0$style ="margin: 0px;"$sizeMeth='scale')
{
    global 
$xoopsModuleConfig$forumImage;
    static 
$image_type;

    
$user_agent_is_IE5 newbb_isIE5();
    if(!isset(
$image_type)) $image_type = ($xoopsModuleConfig['image_type'] == 'auto')?(($user_agent_is_IE5)?'gif':'png'):$xoopsModuleConfig['image_type'];
    
$image .= '.'.$image_type;
[
b]    $imageuri=preg_replace("/^".preg_quote(XOOPS_URL,"/")."/",XOOPS_ROOT_PATH,$image);
    if(!
preg_match("/^".preg_quote(XOOPS_ROOT_PATH,"/")."/",$imageuri)){
        
$imageuri XOOPS_ROOT_PATH."/".$image;
    }[/
b]
    if(
file_exists($imageuri)){
        
$size=@getimagesize($imageuri);
        if(
is_array($size)){
            
$width=$size[0];
            
$height=$size[1];
        }
    }else{
        
$image=$forumImage['blank'].'.gif';
    }
    
$width .='px';
    
$height .='px';

    
$img_style "width: $width; height:$height$style";
    
$image_url "$image."" style="".$img_style."" alt="".$alt."" align="middle" />";

    return 
$image_url;
}



Thanks for your help.

Login

Who's Online

322 user(s) are online (218 user(s) are browsing Support Forums)


Members: 0


Guests: 322


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits