Cześć!
Mam drobny problem ze skryptem galerii. Skrypt nie jest mój,jednak na jego podstawie chcę budować dalsza część skryptu.
Skrypt ma za zadanie wczytać pliki graficzne. I wczytuje je jak należy. Problem zaczyna się gdy chce zmienić ścieżkę odczytu.
Oryginalnie skrypt wczytuje obrazki z katalogu głównego. Jedyna zmiana jaką wprowadziłem w skrypcie to właśnie ścieżka opendir.
Pliki oczywiście wczytuje,ale już nie wyświetla obrazków. Nie potrafię za bardzo sobie z tym poradzić
Jakieś wskazówki?
zawartość pliku galerii
<?php if(isset($_REQUEST['big_image']) and
$_REQUEST['big_image']!=''){?> <?php
$image_title = strtolower($_REQUEST['big_image']);
?>
<?php }?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php if(isset($_REQUEST['big_image']) and
$_REQUEST['big_image']!=''){?> <title>
<?php echo $image_title;?></title>
<?php } else {?>
<title>Quick Photo Gallery</title>
<?php }?>
</head>
<body>
<?php if(isset($_REQUEST['big_image']) and
$_REQUEST['big_image']!=''){?>
<h1 style="text-transform:capitalize;">
<?php echo $image_title;?></h1>
<?php list
($image_width, $image_height) = getimagesize($_REQUEST['big_image']); ?>
<img src="image.php?file=
<?php echo $_REQUEST['big_image'];?>"
class="img-responsive">
<?php }?>
<?php
if(!function_exists('get_file_extension')){
function get_file_extension($filename) {
$exts = split("[/\\.]", $filename) ; $exts = $exts[$n];
return $exts;
}
}
if ($handle = opendir('./generator')) { /* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) { if(get_file_extension
(strtolower($file)) == 'jpg' and
$file!= 'no_image.jpg'){
echo '<div style="border:1px solid #EBEBEB; margin-right:10px; margin-bottom:10px; padding:5px; width:auto; display:block; float:left;"><a href="submitnews.php?big_image='.$file.'"><img border="0" src="image.php?file='.$file.' alt="'.$image_title.'" title="'.$image_title.'"/></a></div>'; }
}
}
?>
<div style="clear:both;">
<p style="margin:0px; padding:3px; background-color:#FAFAFA; border:1px solid #EBEBEB; font-size:10px; font-family:Arial, Helvetica, sans-serif;">Script powered by thewebhelp.com <a style="color:#006699;" href="http://www.thewebhelp.com/php/quick_photo_gallery/">quick photo gallery</a>.</p>
</div>
</body>
</html>
Do działania skryptu wykorzystywany jest tez plik images. Próbowałem tutaj zmienić oryginalne ściezki ale i to nic nie dało,dlatego wrzucam plik oryginalny
<?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?> <?php
$requested_width = $_REQUEST['width'];
$requested_height = $_REQUEST['height'];
list
($original_width, $original_height) = getimagesize($partial_name.'.jpg');} else {
// if the original file is not there then stop everything and show a default thumb
echo '<p>No "file" was defined in url.</p><p>Script powered by thewebhelp.com <a href="http://www.thewebhelp.com/php/quick_photo_gallery/">quick photo gallery</a>.</p>'; }
header("Content-type: image/jpg");
// if original image is bigger than requested then calculate proportions in order to scale it down
if(($original_width>$requested_width || $original_height >$requested_height) and
isset($requested_width) and
isset($requested_height) and
$requested_width!='' and
$requested_height!=''){
$proportions = $original_width/$original_height;
// show the image at the maximum height size but ...
$new_height = $requested_height;
$new_width = round($requested_height*$proportions); // but ... if above calculated width is over the given limit then scal it down according to given width
if(round($requested_height*$proportions)>$requested_width){ $new_width = $requested_width;
$new_height = round($requested_width/$proportions); }
}else {
$new_width = $original_width;
$new_height = $original_height;
// show original file without any resizing "image_cache/20.jpg"
header("Location: image_cache/".$partial_name.".jpg"); }
}
// now that we know the resized file check to see if file already exists "image_cache/20_800x600.jpg" and load it, else create it below
if(file_exists('image_cache/'.$partial_name.'_'.$new_width.'x'.$new_height.'.jpg')){ header("Location: image_cache/".$partial_name."_".$new_width."x".$new_height.".jpg"); }
$file = $partial_name.'.jpg';
// set quality to 100
$quality= 100;
}
// get width and height of original image
$original_width = $imagedata[0];
$original_height = $imagedata[1];
// if orignal image is smaller than 550px then do NOT increase its size to 550
if($original_width<$new_width){
$new_width = $original_width;
}
// calculating width or height if one was not defined
// leave this one first
$new_width = $original_width;
$new_height = $original_height;
}
$new_height = $new_width*($original_height/$original_width);
}
$new_width = $new_height*($original_width/$original_height);
}
$smaller_image = imagecreatetruecolor($new_width, $new_height);
$original_image = imagecreatefromjpeg($file);
imagecopyresampled($smaller_image, $original_image, 0, 0, 0, 0, $new_width, $new_height, $imagedata[0], $imagedata[1]);
// save the image
if($new_width>140 and $new_height>100){
imagejpeg($smaller_image,'image_cache/'.$partial_name.'_'.$new_width.'x'.$new_height.'.jpg',$quality);
} else {
imagejpeg($smaller_image,'image_cache/'.$partial_name.'_'.$new_width.'x'.$new_height.'.jpg',$quality);
}
// make the image 644 (0644)
chmod('image_cache/'.$partial_name.'_'.$new_width.'x'.$new_height.'.jpg',0644);
imagedestroy($original_image);
imagedestroy($smaller_image);
imagedestroy($watermarked_image);
// read the new image
header('Location: image_cache/'.$partial_name.'_'.$new_width.'x'.$new_height.'.jpg'); ?>