Jump to content

PHP script photo gallery HELP


yoda87

Recommended Posts

Hi all, i've set this script for my gallery, it works, it display me the name of the albums, but when i click to see the pictures inside, the page is blank, and also don't appear the "Back to the albums" link, i can't find the error in the code...  :confused:

 

<html> 
<head> 
<script type="text/javascript" src="../lightbox2.05/js/lightbox.js">
</script> 
</head> 
<body>   
<?php  
$page = $_SERVER['PHP_SELF'];  
//settings 
$column = 5;  
//directories 
$base = "carrelli_noleggio"; 
$thumbs = "thumbs";  
// get album 
$get_album = $_GET['album'];  
//if no album selected 
if (!$get_album) {     
echo "<b>Select an album:</b><p />";  
//find each album and display as links 
$handle = opendir($base);     
while (($file = readdir($handle))!==FALSE)     
{ 
if (is_dir($base."/".$file) && $file != "." && $file != ".." && $file != $thumbs)        
{             
echo "<a href='$page?album=$file'>$file</a><br />";         
}     }     
closedir($handle); } 
else {     
//check if album exist, and additional security checks     
if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\") !=NULL)     {     
echo "Album doesn't exist.";     } 
else {    
$x = 0;     
echo "<b>$get_album</b><p />";     
$handle = opendir($base."/".$get_album); 
while (($file = readdir($handle)) !== FALSE)     
{         
if ($file != "." && $file != "..")        
{         
echo "<table style='display:inline;'><tr><td><a href='$base/$get_album/$files' ref='lightbox'<img src='$base/$thumbs/$file' height='100' width'100'></a></td></tr></table>"; 
$x++; 
if ($x==$column)         
{ 
echo"<br />";             
$x = 0;         
}     
  }   
    }     
closedir($handle);          
echo "<p /><a href='$page>Back to albums</a>";  } } 
?> 
</body>
</html>

Link to comment
Share on other sites

From what I can see I think you've gone wrong with the quotes. The colour shows that most of that is a string rather than the code.

I see, but frist i use doble " and after single ', I do not know how to do otherwise...

Link to comment
Share on other sites

The \ in this line is escaping the quote, you need to add another quote!

if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\") !=NULL)  

 

Add quote:

if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\"") !=NULL) 
Link to comment
Share on other sites

Ok, here's my mistake, the original code i wrote was ...

if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\\") !=NULL)     {   

with two \\ , anyway there's other error, because don't work

Link to comment
Share on other sites

The backslashes escape quotes. Try adding an extra quote

 

if (!is_dir($base."/".$get_album) || strstr($get_album,".") !=NULL || strstr($get_album,"/") !=NULL || strstr($get_album,"\\"") !=NULL)

 

Dreamweaver sign it as an error  :wtf:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.