QuickGallery PHP restriction?

tyharo195

New Member
Messages
14
Reaction score
0
Points
1
I'm trying to use QuickGallery but each time I load the index page I get the following errors:
Code:
Warning: opendir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/tyharote:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/tyharote/public_html/cphoto/gallery/index.php on line 65

Warning: opendir(/): failed to open dir: Operation not permitted in /home/tyharote/public_html/cphoto/gallery/index.php on line 65

Warning: readdir() expects parameter 1 to be resource, boolean given in /home/tyharote/public_html/cphoto/gallery/index.php on line 66

The code for this sections is here (lines 62 - 74):
Code:
 <?php
          $imgdir = $gallery . '/';
          $allowed_types = array('png','jpg','jpeg','gif');
          $dimg = opendir($imgdir);
          while($imgfile = readdir($dimg))
          {
            if( in_array(strtolower(substr($imgfile,-3)),$allowed_types) OR
              in_array(strtolower(substr($imgfile,-4)),$allowed_types) )
            {$a_img[] = $imgfile;}
          }
           $totimg = count($a_img);
           for($x=0; $x < $totimg; $x++){ echo "<a href='" . $imgdir . $a_img[$x] . "' rel='gallery'><img src='thumb.php?file=$imgdir".$a_img[$x]."' /></a>"; }
        ?>

The QuickGallery code can be found here and I havent modified or added the base code.
https://github.com/mojeda/QuickGallery

Any help is appreciated, I'd really like to get this php gallery working it been bugging me for the last few days.
 

descalzo

Grim Squeaker
Community Support
Messages
9,375
Reaction score
327
Points
83
You have $gallery set to the empty string -- at least that is what the Error Message is saying.
 

tyharo195

New Member
Messages
14
Reaction score
0
Points
1
$imgdir = $gallery . '/'; is supposed to point towards the directory where the photos are stored I believe. The index.php file is located in another folder called gallery, a dricetory one level down from the rest of the site, where the folders with the images are located. I googled the first error and apparently its a php security error but I'm not a master at php. I can submit the code for to php pages if it will help and the error can be viewed here : http://tyharotest.x10host.com/cphoto/gallery/
the links on the side work but the images preview wont show, if you click an image it will display though.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,375
Reaction score
327
Points
83
$imgdir = $gallery . '/'; is supposed to point towards the directory where the photos are stored

Correct. But if $gallery == "", then you get $imgdir == "/" which is WRONG.

$gallery should be something like "/home/yourCPanelUserName/public_html/wheretheimagesare"

Try posting everything above what you have already posted.
 

tyharo195

New Member
Messages
14
Reaction score
0
Points
1
Alright now we are getting some where, I changed the code to the following:
Code:
$imgdir = $gallery . '/home/tyharote/public_html/cphoto/gallery';
but now I'am getting these errors when i click on a folder link in the gallery, its as though its reading the path backwards. FYI 'fake' is the name of the directory clicked on which is holding some photos:
Code:
Warning: opendir(fake/home/tyharote/public_html/cphoto/gallery): failed to open dir: No such file or directory in /home/tyharote/public_html/cphoto/gallery/index.php on line 65

Warning: readdir() expects parameter 1 to be resource, boolean given in /home/tyharote/public_html/cphoto/gallery/index.php on line 66
 
Last edited:

tyharo195

New Member
Messages
14
Reaction score
0
Points
1
Thanks for helping me out so far descalzo! Ok so I fixed the errors by changing the code to:
Code:
$imgdir =  '/home/tyharote/public_html/cphoto/gallery/' . $gallery . '/';
But the image previews aren't working and the images wont load when clicked anymore, all you get is an error saying "The requested content cannot be loaded. please try again later". When I hover over the possible image link the path listed is correct but the image just wont load.
Here is the complete php section, hopefully it will help:
Code:
  <?php
          $imgdir =  '/home/tyharote/public_html/cphoto/gallery/' . $gallery . '/';
          $allowed_types = array('png','jpg','jpeg','gif');
          $dimg = opendir($imgdir);
          while($imgfile = readdir($dimg))
          {
            if( in_array(strtolower(substr($imgfile,-3)),$allowed_types) OR
              in_array(strtolower(substr($imgfile,-4)),$allowed_types) )
            {$a_img[] = $imgfile;}
          }
           $totimg = count($a_img);
           for($x=0; $x < $totimg; $x++){ echo "<a href='" . $imgdir . $a_img[$x] . "' rel='gallery'><img src='thumb.php?file=$imgdir".$a_img[$x]."' /></a>"; }
        ?>
 
Top