![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Opiekunowie Postów: 3 855 Pomógł: 317 Dołączył: 4.01.2005 Skąd: że ![]() |
Witam. mam skrypt galerii, który działa poprawnie jedynie, gdy umieszczony jest w folderze z grafikami. Jeżeli zagłębiam się - działa (wyświetla grafikę, nie pobiera daty i rozmiaru), ponadto wywala błędy:
Cytat Warning: filemtime() [function.filemtime]: stat failed for vertical.gif in ... galeria.php on line 56 Warning: filesize() [function.filesize]: stat failed for vertical.gif in ... galeria.php on line 57
Przeszukałem Google, również to forum - niby znalazłem sporo materiału, ale nie potrafiłem sobie poradzić... -------------------- Jak poprawnie zadać pytanie | Jak poprawnie zatytułować wątek
Najczęstsze błędy | Błędy E_NOTICE | PHP FAQ | FAQ PHPedia | SQL-Injection | Logowanie i sesje | Hashowanie haseł | Server - od czego zacząć ? | Manual PHP Alternatywne Forum dla Ekspertów Nie pomagam na PW, nie mam GG |
|
|
![]()
Post
#2
|
|
![]() Grupa: Moderatorzy Postów: 15 467 Pomógł: 1451 Dołączył: 25.04.2005 Skąd: Szczebrzeszyn/Rzeszów ![]() |
Wychodzi na to, że problem jest ze ścieżkami.
Pokaż faktyczną strukturę drzewa katalogowego. Poza tym, to nie jest pełny kod. -------------------- ![]() ZCE :: Pisząc PW załączaj LINK DO TEMATU i TYLKO w sprawach moderacji :: jakiś błąd - a TREŚĆ BŁĘDU? :: nie ponaglaj z odpowiedzią via PW! |
|
|
![]()
Post
#3
|
|
![]() Grupa: Opiekunowie Postów: 3 855 Pomógł: 317 Dołączył: 4.01.2005 Skąd: że ![]() |
"problem ze ścieżkami" taką informację już wugooglowałem. Dlaczego więc wyświetlają się grafiki? Cała galeria:
CODE <? // maximum width of images (height will be scaled accordingly) $maxw = 100; // directory to place thumbnail images $thumbdir = "./"; // wyświetla się dobrze // $thumbdir = "./gfx"; // wyświetla się z błędami // number of columns in table $cols = 5; // number of rows in table $rows = 5; // default sorting method ["date","size","name"] $df_sortby = "name"; // default ordering (ascending or descending) ["ASC","DESC"] $df_ascdsc = "ASC"; /* INITIALISATION */ // useful shortcut $url = $_SERVER["PHP_SELF"]."?"; // start point and ordering $start = ( isset($_GET["start"]) ) ? $_GET["start"] : 0; $sortby = ( isset($_GET["sortby"]) ) ? $_GET["sortby"] : $df_sortby; $ascdsc = ( isset($_GET["ascdsc"]) ) ? $_GET["ascdsc"] : $df_ascdsc; // allowed image types $sfxs = array(".jpg",".jpeg",".png",".gif"); // get the current directory path: $curdir = dirname(stripslashes($_SERVER["PATH_TRANSLATED"])); // get folder delimiter for this system: $slash = ( strstr($curdir,"\\") ) ? "\\" : "/"; $curdir = $thumbdir; /* READ DIRECTORY */ // create array to hold filenames and information // $images[n][0] = name // $images[n][1] = date // $images[n][2] = size $images = array(); @ $handle = opendir($curdir); if ( !$handle ) { error("could not open directory!"); exit; } while ( $file = readdir($handle) ) { if ( isValid($file,$sfxs) ) { $tmp = array(); $tmp[0] = $file; /// /// $tmp[1] = filemtime($file); $tmp[2] = filesize($file); array_push($images,$tmp); // do we need to create a thumbnail? if ( !file_exists($thumbdir.$slash.$file) ) { createThumb($file); } } } // now sort the dir: usort($images,"sortme"); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <html> <head> <title>Galeria</title> <style> body, td, input, select { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 0.8em; } a { font-weight: bold; } .img { font-size: 0.7em; border: 1px solid #666666; text-align: center; vertical-align: bottom; padding: 5px 2px 5px 2px; } </style> </head> <body> <? /* CREATE TABLE */ $k = $start; $n = count($images); $ord = "&sortby=".$sortby."&ascdsc=".$ascdsc; if ( $start > 0 ) { $pn = $start - $rows*$cols; $prev = '<a href="'.$url.$ord.'&start='.$pn.'">poprzednia</a>'; } else { $prev = "poprzednia"; } if ( $start + $rows*$cols < $n) { $nn = $start + $rows*$cols; $next = '<a href="'.$url.$ord.'&start='.$nn.'">następna</a>'; } else { $next = "następna"; } if ( $n-$k < $rows*$cols ) { $rows = ceil(($n-$k)/$cols); } ?> <table border="0" align="center" width="<?=$cols*$maxw*1.4?>"> <tr> <td colspan="<?=$cols?>" align="center"> <form name="f" action="<?=$_SERVER["PHP_SELF"]?>" method="GET"> <input name="start" type="hidden" value="<?=$start?>"> sortuj <select name="sortby"> <option value="-1">-- sortuj --</option> <option value="date"<? if ($sortby=="date") echo " SELECTED"?>>data</option> <option value="size"<? if ($sortby=="size") echo " SELECTED"?>>rozmiar</option> <option value="name"<? if ($sortby=="name") echo " SELECTED"?>>nazwa</option> </select> <input name="ascdsc" value="ASC" type="radio"<? if ($ascdsc=="ASC") echo " CHECKED"?>>rosnąco <input name="ascdsc" value="DESC" type="radio"<? if ($ascdsc=="DESC") echo " CHECKED"?>>malejąco <input type="submit" value="sortuj"> </form> </td> </tr> <tr> <td colspan="<?=$cols?>"><hr></td> </tr> <tr> <td colspan="<?=$cols?>"> <table width="100%"> <tr> <td><?=$prev?></td> <td align="right"><?=$next?></td> </tr> </table> </td> </tr> <? for ( $i=0; $i<$rows; $i++ ) { ?> <tr> <? for ( $j=0; $j<$cols; $j++ ) { ?> <td class="img"> <? if ( $k < $n ) { ?> <a href="<?=$images[$k][0]?>" target="blank"> <img src="<?=$thumbdir."/".$images[$k][0]?>" border="0"><br /> <?=$images[$k][0]?> </a><br /> <?=round($images[$k][2]/1024)?>Kb, <?=date("d-m-y",$images[$k][1])?> <? } else { ?> <? } ?> </td> <? $k++; } ?> </tr> <? } ?> <tr> <td colspan="<?=$cols?>"><hr></td> </tr> </table> </body> </html> <? /* USEFUL FUNCTIONS */ function isValid($f,$a) { $t = getSuffix($f); return ( in_array($t,$a) ) ? true : false; } function getSuffix($f) { $n = strrpos($f,"."); return substr($f,$n,strlen($f)-$n); } function createThumb($f) { // use max width config value global $maxw, $curdir, $copyfile, $thumbdir, $slash; $input = 0; $type = getSuffix($f); // png or jpeg? // either way get image if ($type==".png") { $input = imagecreatefrompng($f); } else { $input = imagecreatefromjpeg($f); } if ( !$input ) { error("not a valid image file ![]() return false; } // get size ( [0]=width, [1]=height ) $tmp = getimagesize($f); if ( !$tmp ) { error("Could not get input image size"); return false; } // get width of new thumbnail by taking // the smaller value from max and tmp width $w = ($tmp[0]>$maxw) ? $maxw : $tmp[0]; // scale height according to width $h = $tmp[1] * ($maxw/$tmp[0]); // create output image with true color JPG Thumbnail if imagecreatetruecolor() is present if (function_exists(imagecreatetruecolor)){ @ $output = imagecreatetruecolor($w,$h); }else{ @ $output = imagecreate($w,$h); } if ( !$output ) { error("could not create output image"); return false; } // copy big image over to thumbnail, and resize down imagecopyresized( $output,$input, 0,0, 0,0, $w,$h, $tmp[0],$tmp[1] ); $newfile = $thumbdir.$slash.$f; // do the outputting! if ( $type == ".png" ) { imagepng($output,$newfile); } else { imagejpeg($output,$newfile); } } function sortme($a,$b) { // setup global $sortby, $ascdsc; if ( $sortby == "name" ) { $n = 0; } elseif ( $sortby == "date" ) { $n = 1; } elseif ( $sortby == "size" ) { $n = 2; } $m = ( $ascdsc == "ASC" ) ? 1 : -1; if ( $a[$n] == $b[$n] ) return 0; return ($a[$n] > $b[$n]) ? $m : -1*$m; } function error($str) { echo '<div style="background-color:#ffffff;color:#660000;font-weight:bold">'.$str.'</div>'; } ?> </body> </html> EDIT: Poradziłem sobie... chyba wczorajsze zmęczenie nie dało pomyśleć:
@erix, miałeś rację, że to ścieżki ślepe... ![]() Ten post edytował Kshyhoo 9.01.2010, 20:41:49 -------------------- Jak poprawnie zadać pytanie | Jak poprawnie zatytułować wątek
Najczęstsze błędy | Błędy E_NOTICE | PHP FAQ | FAQ PHPedia | SQL-Injection | Logowanie i sesje | Hashowanie haseł | Server - od czego zacząć ? | Manual PHP Alternatywne Forum dla Ekspertów Nie pomagam na PW, nie mam GG |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 15.07.2025 - 18:02 |