![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Zarejestrowani Postów: 4 Pomógł: 0 Dołączył: 21.01.2007 Skąd: Lublin Ostrzeżenie: (0%) ![]() ![]() |
jestem dosc zielony w php i mam skrypt napisany przez kolege, ktory odmowil mi dalszej wspolpracy.
czy ktos moze mi powiedziec w jaki sposob dodac do skryptu (galeria) opcje sortowania katalogow ze zdjeciami (od a do z, od 0 do 9)? oto glowny plik galerii: Kod <?
//require('galeria/config.php'); define("GDIR", "galeria/"); //gdzie znajduja sie foldery ze zdjeciami define("FNAME", "../galeria.php"); //gdzie znajduja sie foldery ze zdjeciami define("COLS", 2); //kolumn define("ROWS", 20); //max wierszy class gallery { function show_tree($node = '', $depth = -1, $ground = 0) { $return = ''; $dname = Array(); $dh = opendir(GDIR.$node); $spacer = ''; for($sp = 1; $sp < $ground - $depth; $sp++) { $spacer .= ' '; } while($file = readdir($dh)) { if ($file != "." && $file != ".." && is_dir(GDIR.$node.$file)) { if(file_exists(GDIR.$node.$file.'/'.$file.'.txt')) { $label = file(GDIR.$node.$file.'/'.$file.'.txt'); $return .= $spacer.'<a href="'.FNAME.'?cat='.$node.$file.'/">'.$label[0].'</a><br>'."\n"; } else { $return .= $spacer.'<a href="'.FNAME.'?cat='.$node.$file.'/">'.$file.'</a><br>'."\n"; } if($depth != 0) { $return .= $this -> show_tree($node.$file.'/', $depth - 1); } } } return $return; } function is_image($f_name) { if(in_array(strtolower(substr($f_name,-3)), array('jpg', 'gif', 'png'))) { return true; } else return false; } function show_thumbnails($node, $page = 0) { $images = array(); $dh = opendir(GDIR.$node); while($file = readdir($dh)) { if ($file != "." && $file != ".." && !is_dir(GDIR.$node.$file) && $this -> is_image($file)) { $images[] = $file; } } $total = count($images); if($total > 0) { sort($images); $per_page = COLS*ROWS; if($total > $per_page) { $page_list = "<br> \n"; $pages = ceil($total/$per_page); for($i = 0; $i < $pages; $i++) { $p = $i+1; if($i != $page) { $page_list .= ' <a href="'.FNAME.'?cat='.$node.'&page='.$i.'">'. $p .'</a> '; } else { $page_list .= ' ['.$p.'] '; } } $return['p_list'] = $page_list."<br> \n"; } else $return['p_list'] = ""; $images_table = "<center><table width=95%border=0cellpadding=2 cellspacing=2>\n"; for($j = $page * $per_page, $r = 0; $j < min(($page + 1) * $per_page, $total); $j++, $r++) { $size = getimagesize (GDIR.$node.$images[$j]); if($size[1] < $size[0]) { $height = 86; $width = 130; $thumbnail = ''.GDIR.'thumbs.php?image='.$node.$images[$j].'&newheight=86&newwidth=130&width='.$size[0].'&height='.$size[1].''; } else { $height = 130; $width = 86; $thumbnail = ''.GDIR.'thumbs.php?image='.$node.$images[$j].'&newheight=130&newwidth=86&width='.$size[0].'&height='.$size[1].''; } $image_cell = ''; if($r == 0) $image_cell = '<tr>'."\n"; $x = $size[0] + 0; $y = $size[1] + 30; $image_cell .= '<td align=center> <a href="#" onclick="window.open(\''.GDIR.'popup.php?node='.$node.'&img='.$j.'&w='.$size[0].'&h='.$size[1].'&t='.$j.'\',\''.$j.'\',\'width='. $x .',height='. $y .',directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,re sizable=no\');return false" target="_blank"> <img class="cienie" src="'.$thumbnail.'" border=0> </a> </td>'."\n"; if($r == COLS - 1) { $image_cell .= '</tr>'."\n"; $r = -1; } $images_table .= $image_cell; } $images_table .= '</table></center>'; $return['images'] = $images_table; } else { $return['images'] = ''; $return['p_list'] = ''; } return $return; } function tracker($node) { $current = ''; $return = '<b>galeria</b> » '; $path = explode("/", $node); $last = count($path) - 2; foreach($path as $n => $folder) { if(strlen($folder) > 0) { $current.=$folder."/"; if(file_exists(GDIR.$current.$folder.'.txt')) { $label = file(GDIR.$current.$folder.'.txt'); if($n != $last) $return .= '<a href="'.FNAME.'?cat='.$current.'">'.$label[0].'</a> » '; else $return .= $label[0].' '; } else { if($n != $last) $return .= '<a href="'.FNAME.'?cat='.$current.'">'.$folder.'</a> » '; else $return .= $folder.' '; } } } echo $return."<br> \n"; } function menu($node) { $path = explode("/", $node); return $this -> menu_2($path, '', 0); } function menu_2($path, $node = '', $lvl = 0) { $return = ''; $dh = opendir(GDIR.$node); $spacer = ''; for($sp = 0; $sp < $lvl; $sp++) { $spacer .= ' '; } while($file = readdir($dh)) { if ($file != "." && $file != ".." && is_dir(GDIR.$node.$file)) { if(file_exists(GDIR.$node.$file.'/'.$file.'.txt')) { $label = file(GDIR.$node.$file.'/'.$file.'.txt'); $return .= $spacer.'<a href="'.FNAME.'?cat='.$node.$file.'/">'.$label[0].'</a><br>'."\n"; } else { $return .= $spacer.'<a href="'.FNAME.'?cat='.$node.$file.'/">'.$file.'</a><br>'."\n"; } if(in_array($file, $path)) { $return .= $this -> menu_2($path, $node.$file.'/', $lvl + 1); } } } return $return; } } $gal = new gallery; if(isset($cat)) $dir = $cat; else $dir = ''; echo $gal -> tracker($dir); echo $gal -> menu($dir); if(!isset($page)) $page = 0; if(isset($cat)) { $all = $gal -> show_thumbnails($cat, $page); echo $all['p_list']; echo $all['images']; } //print_r($gal -> show_tree($cat, 0)); ?> -------------------- uczyc sie zamierzam.. jak zdam sesje :]
|
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 14.08.2025 - 12:40 |