$galerija) { $gallery_id = 1; } if (!isset($id)||$id<0||!is_numeric($id)) { $id = 0; } if (!isset($form)||$form<0||!is_numeric($form)||$form>2) { $form = 0; } //pathovi za galeriju //path gdje je galerija u odnosu na root prezentacije $gallery_url = "/galerije"; //gdje se nalazi galerija na disku, full path na serveru if ($_SERVER['SERVER_NAME']=='fly.bl.bravostudio.com') { $gallery_path = "/sites/fly/galerije/"; } else { $gallery_path = "/home/zepterff/public_html/eng/galerije/"; } //ovdje vuk ubacuje switch ($gallery_id) { case 1: $directory = '/pliva'; $gallery_title = 'Pliva'; break; case 2: $directory = '/ribnik'; $gallery_title = 'Ribnik'; break; case 3: $directory = '/sanica'; $gallery_title = 'Sanica'; break; case 4: $directory = '/unac'; $gallery_title = 'Unac'; break; case 5: $directory = '/una'; $gallery_title = 'Una'; break; case 6: $directory = '/muhe'; $gallery_title = "
Some of Jans favorites
Flies and Photos: Jan Janković
"; break; case 7: $directory = '/smjestaj'; $gallery_title = " "; break; case 8: $directory = '/krusnica'; $gallery_title = 'Krušnica'; break; case 9: $directory = '/neretva'; $gallery_title = 'Neretva'; break; case 10: $directory = '/njemacka'; $gallery_title = "
Report from Die Hohe Jagd und Fischerei, Salzburg,
February 26th - March 1st 2009
"; break; case 11: $directory = '/sameo'; $gallery_title = 'Sameo'; break; } $total = $rows * $cols; //*************************** galerija - settings ************************** function foto_galerija() { global $gallery_id, $cache_dir, $gallery_title, $cols, $rows, $thmb_width, $display_width, $library, $gallery_url, $gallery_path, $total, $directory; $cache_dir=''; $return = ''; //uzimamo ime slike za prikazivanje iz query stringa /* $image = rawurldecode ($_GET['image']); //da neko ne bi pokushavao da prchka po sistemu if (strlen($image)>0) { if (!ereg('^[^./][^/]*$', $image)) { $return = "Nedozvoljena komanda!"; return $return; } } //uzimamo id slike $id = rawurldecode ($_GET['id']); */ //uzimamo trenutnu stranicu na kojoj se nalazimo $currentpage = rawurldecode ($_GET['page']); // direktorijum u kojem radimo, bez trailing slasheva $directory_target = $gallery_path. substr($directory, 1); // definishemo cache direktorijum $path_parts = pathinfo($directory_target); $cache_dir = $gallery_path. 'cache'. $directory. '/'; $cache_url = $gallery_url. '/cache'. $directory. '/'; // skeniramo direktorijum if (!is_dir($directory_target)) { $return = 'Galerija koju ste tražili ne postoji!'; return $return; } else { chdir($directory_target); $handle = opendir($directory_target); $current_dir = getcwd(); $i = 0; $j = 0; while (false !== ($file = readdir($handle))) { if (is_file($file) == '1' && eregi(".(jpg|png|jpeg)$", $file)) { $filelist[$i] = $file; $i++; } elseif (is_dir($file) == '1' && $file <> '.' && $file <> '..' && $file <> 'cache') { $dirlist[$j] = $file; $j++; } } closedir($handle); } //count and sort elements in arrays $numdirs = count($dirlist); if ($numdirs != 0) { sort($dirlist); } $numimages = count($filelist); if ($numimages != 0) { sort($filelist); } // html stuff $return .= ''. "\n"; $return .= ''. "\n"; $return .= ''. "\n"; $return .= ''. "\n"; $return .= '
'. "\n"; $return .= '
'.$gallery_title.'
'. "\n"; $return .= '
'. "\n"; $return .= ''. "\n"; $return .= ''. "\n"; $return .= ''. "\n"; $return .= ''. "\n"; $return .= '
'. "\n"; // Na kojoj se stranici nalazimo? $currentpage = PageCheck ($currentpage); // ako je $image prazan to znachi da ili pravimo thumbnaile ili pravimo listu fajlova u diru if (empty($image)) { // ako $numimages nije nula pravimo thumbnaile if ($numimages != 0) { //rastavljamo u total i calc broj stranica $imagelist = array_chunk($filelist, $total, true); $pages = count ($imagelist); if ($currentpage > $pages) { $currentpage = $pages; } // koje su slike na trenutnoj stranici, pa -1 zbog niza koji pochinje od 0 $images = $imagelist[$currentpage - 1]; // koji je prvi kljuch niza? $id = ($total * $currentpage) - $total; // ako imamo manje slika nego shto je rows*cols koliko nam ih treba $newrows = intval($numimages / $cols); if ($newrows < $rows) { $rows = $newrows + 1; } // pravimo tabelu za thumbnaile $return .= ''. "\n"; // loop u zavisnosti od $cols i $rows // u svakom td po jedna slika iz niza $images array for ($jj = 1; $jj <= $rows; $jj++) { $return .= ''. "\n"; for ($ii = 1; $ii <= $cols; $ii++) { $return .= ''. "\n"; // povecjavamo brojach i idemo iz pochetka $id = $id + 1; } $return .= ''. "\n"; } $return .= ''. "\n"; $return .= ''. "\n"; $return .= '
'; // ako je element niza prazan ne pishemo nishta, sprechavamo broken link if (empty($images[$id])) { $return .= ' '; } else { // u suprotnom pravimo thumbnail i prikazujemo ga //$return .= ''; //$return .= ""; $return .= ''; } $return .= '
'; // prethodni link if ($currentpage > 1) { $return .= ''; } // showing xx of xx images $showingnow = ($currentpage * $total); if ($showingnow > $numimages) { $showingnow = $numimages; } //$return .= $showingnow. ' od '. $numimages. ' '; //$return.= $currentpage. ' od ' . $pages . ' '; $return.= " "; //sledecji link if ($currentpage < $pages) { $return .= ''; } $return .= ''. "\n"; $return .= '
 Previous | | Next 
'."\n"; $return .= '
'. "\n"; } } else { $return = 'Pogresan pristup!'. "\n"; return $return; } $return .= '
'. "\n"; return $return; } //ako ne postoji funkcija array_chunk definisacjemo je if (!function_exists('array_chunk')) { function array_chunk( $input, $size, $preserve_keys = false) { @reset( $input ); $i = $j = 0; while (@list($key, $value) = @each($input)) { if (!(isset($chunks[$i]))) { $chunks[$i] = array(); } if (count($chunks[$i]) < $size) { if ($preserve_keys) { $chunks[$i][$key] = $value; $j++; } else { $chunks[$i][] = $value; } } else { $i++; if ($preserve_keys) { $chunks[$i][$key] = $value; $j++; } else { $j = 0; $chunks[$i][$j] = $value; } } } return $chunks; } } function mkdir_r($strPath, $mode = 0777) { return is_dir($strPath) or ( mkdir_r(dirname($strPath), $mode) and mkdir($strPath, $mode) ); } function chmod_r($path, $filemode) { if (!is_dir($path)) return chmod($path, $filemode); $dh = opendir($path); while ($file = readdir($dh)) { if($file != '.' && $file != '..') { $fullpath = $path.'/'.$file; if(!is_dir($fullpath)) { if (!chmod($fullpath, $filemode)) return FALSE; } else { if (!chmod_r($fullpath, $filemode)) return FALSE; } } } closedir($dh); if(chmod($path, $filemode)) return TRUE; else return FALSE; } function Resize ($src_image, $dest_width, $library) { global $directory_target; global $gd2; global $cache_dir; global $thmb_height; global $thmb_width; if (is_dir("$cache_dir")) { } else { mkdir_r ("$cache_dir", 0777); chmod_r ("$cache_dir", 0777); } $dest_image = rawurldecode ($cache_dir. $dest_width. '_'. $src_image); if (!is_file($dest_image)) { $pic_info = getimagesize($src_image); $pic_width = $pic_info[0]; $pic_height = $pic_info[1]; $x='x'; if ($pic_width <= $dest_width) { $dest_width = $pic_width; } /* ovdje je stara skripta za svaki sluchaj ako nova ne radi kako treba //ako je slika polozhena if ($pic_width > $pic_height) { $scale_factor = $dest_width / $pic_width; $new_pic_width = $dest_width; $new_pic_height = intval($pic_height * $scale_factor); } else { //ako je slika uspravna $scale_factor = $dest_width / $pic_height; $new_pic_height = $dest_width; $new_pic_width = intval($pic_width * $scale_factor); } if ($library == 'IM') { $make_magick = system("/usr/X11R6/bin/convert -size $new_pic_width$x$new_pic_height -geometry $new_pic_width$x$new_pic_height \"$src_image\" \"$dest_image\"", $retval); if ($retval) { echo 'Greska: imagemagick nije odradio svoj posao uspjesno
'; } */ //ovdje je nova funkcija if ($dest_width==$thmb_width) { $new_pic_width = $thmb_width; $new_pic_height = $thmb_height; $komanda = "/usr/X11R6/bin/convert -size $new_pic_width$x$new_pic_height \"$src_image\" -gravity center -crop $thmb_width$x$thmb_height+0+0! \"$dest_image\""; } else { //ako je slika polozhena if ($pic_width > $pic_height) { $scale_factor = $dest_width / $pic_width; $new_pic_width = $dest_width; $new_pic_height = intval($pic_height * $scale_factor); } else { //ako je slika uspravna $scale_factor = $dest_width / $pic_height; $new_pic_height = $dest_width; $new_pic_width = intval($pic_width * $scale_factor); } $komanda = "/usr/X11R6/bin/convert -size $new_pic_width$x$new_pic_height -geometry $new_pic_width$x$new_pic_height \"$src_image\" \"$dest_image\""; } if ($library == 'IM') { $make_magick = system($komanda, $retval); if ($retval) { echo 'Greska: imagemagick nije odradio svoj posao uspjesno
'; } //ovdje zavrshava nova funkcija } else { if (eregi(".(jpg|jpeg)$", $src_image)) { $src_img = imagecreatefromjpeg($src_image); } if (eregi(".(png)$", $src_image)) { $src_img=imagecreatefrompng($src_image); } if ($gd2 == 'yes') { $tmp_img = ImageCreateTrueColor($new_pic_width, $new_pic_height); imagecopyresampled($tmp_img, $src_img, 0, 0, 0, 0, $new_pic_width, $new_pic_height, $pic_width, $pic_height); } else { $tmp_img = ImageCreate($new_pic_width, $new_pic_height); imagecopyresized($tmp_img,$src_img, 0, 0, 0, 0, $new_pic_width, $new_pic_height, $pic_width, $pic_height); } if (preg_match("/png/", $system[1])){ imagepng($tmp_img, $dest_image); } else { imagejpeg($tmp_img, $dest_image); } imagedestroy($tmp_img); imagedestroy($src_img); } } return $dest_image; } function PageCheck ($currentpage) { if (empty($currentpage)) { $currentpage = 1; } else { $currentpage = $currentpage; } return $currentpage; } function NavBar ($current_dir, $gallery_url, $gallery_path) { $str = strlen($gallery_path); $url = substr($current_dir, $str); $url = str_replace(chr(92), chr(47), $url); $navlink = explode("/", trim($url)); $ii = count($navlink); //echo'Navigation:',"\n" , '/'; for ($count = 0;$count < count($navlink) - 1;$count++) { echo ''. $navlink[$count]. ''. '/'; } //echo $navlink[count($navlink) - 1]; //echo '

'. "\n"; } function checkgd(){ $gd2=""; ob_start(); phpinfo(8); $phpinfo=ob_get_contents(); ob_end_clean(); $phpinfo=strip_tags($phpinfo); $phpinfo=stristr($phpinfo,"gd version"); $phpinfo=stristr($phpinfo,"version"); $end=strpos($phpinfo," "); $phpinfo=substr($phpinfo,0,$end); $phpinfo=substr($phpinfo,7); if (preg_match("/2./",$phpinfo)) { $gd2="yes"; } return $gd2; } function galerija_preview($full_preview=0) { global $gallery_id, $form, $cache_dir, $id, $gallery_title, $cols, $rows, $thmb_width, $display_width, $library, $gallery_url, $gallery_path, $total, $directory, $gost; global $ime_slike, $sifra, $db, $xmbuser, $ime_primaoca, $mail_primaoca, $naslov, $poruka, $potpis, $ime_posiljaoca, $mail_posiljaoca; $cache_dir=''; $return = ''; //uzimamo ime slike za prikazivanje iz query stringa /* $image = rawurldecode ($_GET['image']); //da neko ne bi pokushavao da prchka po sistemu if (strlen($image)>0) { if (!ereg('^[^./][^/]*$', $image)) { $return = "Nedozvoljena komanda!"; return $return; } } */ //uzimamo id slike /* if (!isset($id)) { $id = rawurldecode ($_GET['id']); } */ //uzimamo trenutnu stranicu na kojoj se nalazimo //$currentpage = rawurldecode ($_GET['page']); // direktorijum u kojem radimo, bez trailing slasheva $directory_target = $gallery_path. substr($directory, 1); // definishemo cache direktorijum $path_parts = pathinfo($directory_target); $cache_dir = $gallery_path. 'cache'. $directory. '/'; $cache_url = $gallery_url. '/cache'. $directory. '/'; // skeniramo direktorijum if (!is_dir($directory_target)) { $return = 'Galerija koju ste tražili ne postoji!'; return $return; } else { chdir($directory_target); $handle = opendir($directory_target); $current_dir = getcwd(); $i = 0; $j = 0; while (false !== ($file = readdir($handle))) { if (is_file($file) == '1' && eregi(".(jpg|png|jpeg)$", $file)) { $filelist[$i] = $file; $i++; } elseif (is_dir($file) == '1' && $file <> '.' && $file <> '..' && $file <> 'cache') { $dirlist[$j] = $file; $j++; } } closedir($handle); } //brojimo i sortiramo elemente u nizu $numdirs = count($dirlist); if ($numdirs != 0) { sort($dirlist); } $numimages = count($filelist); if ($numimages != 0) { sort($filelist); } if ($id>=$numimages) { $id = $numimages-1; } $currentpage = floor ((($id+$total)/$total)); //ako smo pozvani samo da damo path do slike izacji cjemo ovdje if ($full_preview==1) { $file_temp = $gallery_path.substr($directory,1).'/'.$filelist[$id]; if (is_file($file_temp)) { return ($gallery_url.$directory.'/'.$filelist[$id]); } else { return ''; } } //u suprotnom nastavljamo sa obradom // html stuff $return .= ''. "\n"; $return .= ''. "\n"; $return .= ''. "\n"; $return .= ''. "\n"; $return .= '
'. "\n"; $return .= '
'.$gallery_title.'
'. "\n"; $return .= '
'. "\n"; // Na kojoj se stranici nalazimo? $currentpage = PageCheck ($currentpage); $return .= ''. "\n"; // pokazhi trenutnu sliku $return .= ''. "\n"; $file_temp = $gallery_path.substr($directory,1).'/'.$filelist[$id]; if (is_file($file_temp) == '1' && eregi(".(jpg|png|jpeg)$", $file_temp)) { $dimensions = @getimagesize($file_temp); //print $dimensions[0]."x".$dimensions[1]; $return .= ''. "\n"; } else { $return .= ''. "\n"; } //print $gallery_path.substr($directory,1).'/'.$filelist[$id];; $return .= ''. "\n"; //malo razmaka $return .= ''. "\n"; $return .= ''. "\n"; $return .= ''. "\n"; // prethodna slika if ($form==0) { $return .= ''. "\n"; if ($id > 0) { //$return .= ''. "\n"; $return .= ''. "\n"; }else{ $return .= ''. "\n"; } } // zatvori prozor link $thmb_page = intval(($id + $total) / $total); if ($form==0) { $return .= ''. "\n"; // sledecja slika if ($id < $numimages - 1) { //$return .= ''. "\n"; $return .= ''. "\n"; } else { $return .= ''. "\n"; } $return .= ''. "\n"; } $return .= '


 Prethodna


 Previous
 
Back to gallery


Sledeća 


Next 
 
'. "\n"; return($return); } ?>