>"); define("TEXT_PREVIOUS_PAGE", "<< Elöző oldal"); define("TEXT_NEXT_PAGE", "Next page >>"); define("TEXT_DOWNLOAD", "Teljes méretű kép letöltése"); define("TEXT_IMAGE_LINK", ""); define("TEXT_START_SLIDE", "Diavetítés indítása"); define("TEXT_STOP_SLIDE", "Diavetítés leállítása"); define("TEXT_DATE", "Dátum: "); define("TEXT_FILESIZE", "Kép méret (bytes): "); define("TEXT_IMAGESIZE", "Image size: "); define("TEXT_DIRS", "Almappák: "); define("TEXT_IMAGES", "Képek: "); define("TEXT_FILES", "Fájlok: "); define("CHARSET", "iso-8859-1"); define("DATE_FORMAT", "Y-m-d h:i:s"); define("USE_JAVA", TRUE); define("SORT_DIVIDER", "--"); define("SLIDESHOW_DELAY", 5); define("THUMB_MAX_WIDTH", 160); define("THUMB_MAX_HEIGHT", 160); define("ENLARGE_SMALL_IMAGES", FALSE); define("JPEG_QUALITY", 75); define("GALLERY_COLUMNS", 3); define("ROWS_PER_PAGE", 3); define("SHOW_PAGE_NAVI", 3); define("TABLE_BORDER_WIDTH", 1); define("THUMB_BORDER_WIDTH", 1); define("THUMB_TD_PADDING", 7); define("THUMB_TD_SPACING", 15); define("THUMB_TD_BORDER_WIDTH", 1); define("FULLIMG_BORDER_WIDTH", 2); define("FULLIMG_TD_PADDING", 10); define("WINDOW_EXTRA_WIDTH", 80); define("WINDOW_EXTRA_HEIGHT", 130); define("WINDOW_MIN_WIDTH", 300); define("WINDOW_MIN_HEIGHT", 300); define("TEXT_HEIGHT", 15); define("SCROLLBAR_WIDTH", 17); $color_body_back = "white"; $color_body_text = "black"; $color_body_link = "black"; $color_body_hover = "red"; $color_table_back = "white"; $color_table_border = "white"; $color_table_header_back = "white"; $color_table_header_text = "red"; $color_navi_link = "black"; $color_navi_hover = "red"; $color_navi_text = "black"; $color_navi_back = "#EEEEEE"; $color_page_back = "#000000"; $color_page_link = "#b0b0b0"; $color_page_hover = "#ffffff"; $color_page_mark_link = "#b0b0b0"; $color_page_mark_hover = "#ffffff"; $color_page_mark_back = "#505050"; $color_desc_back = "silver"; $color_desc_text = "black"; $color_dir_link = "black"; $color_dir_hover = "red"; $color_dir_border = "silver"; $color_dir_td_border = "white"; $color_dir_td_back = "#EEEEEE"; $color_dir_td_text = "black"; $color_img_link = "black"; $color_img_hover = "red"; $color_img_border = "silver"; $color_img_td_border = "white"; $color_img_td_back = "#EEEEEE"; $color_img_td_text = "#black"; $color_file_link = "#a0a0a0"; $color_file_hover = "#ffffff"; $color_file_border = "#ffffff"; $color_file_td_border = "#404040"; $color_file_td_back = "#101010"; $color_file_td_text = "#606060"; $color_fullimg_link = "#b0b0b0"; $color_fullimg_hover = "#ffffff"; $color_fullimg_border = "#ffffff"; $color_fullimg_td_back = "#303030"; $color_fullimg_td_text = "#909090"; // ----------- CONFIGURATION END ------------ function sfpg_css_link() { echo ""; } function sfpg_html_start($head="", $body="") { echo ""; sfpg_css_link(); echo "" . htmlspecialchars(TEXT_GALLERY_NAME) . "" . $head . "
"; } function sfpg_html_end() { echo "
"; } function sfpg_make_dir($dir_path) { $dirs = explode("/", $dir_path); $path = ""; foreach ($dirs as $dir) { $path .= ($path ? "/" : "") . $dir; if(!is_dir($path)) { mkdir($path); } } } function sfpg_array_sort(&$arr, &$arr_time, $sort_by_time, $sort_reverse) { if ($sort_by_time) { if ($sort_reverse) { array_multisort ($arr_time, SORT_DESC, SORT_NUMERIC, $arr); } else { array_multisort ($arr_time, SORT_ASC, SORT_NUMERIC, $arr); } } else { if ($sort_reverse) { rsort ($arr); } else { sort ($arr); } } } function sfpg_base64url_encode($plain) { $base64 = base64_encode($plain); $base64url = strtr($base64, "+/", "-_"); return rtrim($base64url, "="); } function sfpg_base64url_decode($base64url) { $base64 = strtr($base64url, "-_", "+/"); $plain = base64_decode($base64); return ($plain); } function sfpg_url($dir = "", $img = "", $page = "", $cmd ="", $opt = "", $full_link = FALSE) { $res = $dir . "*" . $img . "*" . $page . "*" . $cmd . "*" . $opt . "*"; return ($full_link ? $_SERVER["HTTP_HOST"] : $_SERVER["PHP_SELF"]) . "?sfpg=" . sfpg_base64url_encode($res . md5($res . SECURITY_PHRASE)); } function sfpg_display_name($name, $underscore_as_space, $show_ext) { $break_pos = strpos($name, SORT_DIVIDER); if ($break_pos !== FALSE) { $display_name = substr($name, $break_pos + strlen(SORT_DIVIDER)); } else { $display_name = $name; } if ($underscore_as_space) { $display_name = str_replace("_", " ", $display_name); } if (!$show_ext) { $display_name = substr($display_name, 0, strrpos($display_name, ".")); } return $display_name; } function sfpg_image_type($file) { $type = strtolower(substr($file, strrpos($file, "."))); if (($type == ".jpg") or ($type == ".jpeg")) { return "jpeg"; } elseif ($type == ".png") { return "png"; } elseif ($type == ".gif") { return "gif"; } return FALSE; } function sfpg_get_dir($dir) { global $dir_exclude, $file_exclude, $file_ext_exclude; $dirs = array(); $dirs_time = array(); $images = array(); $images_time = array(); $files = array(); $files_time = array(); $directory_handle = @opendir(GALLERY_ROOT . $dir); if ($directory_handle != FALSE) { while($var = readdir($directory_handle)) { if (is_dir(GALLERY_ROOT . $dir . $var)) { if (($var != ".") and ($var != "..") and !in_array(strtolower($var), $dir_exclude)) { $dirs[] = $var; if (DIR_SORT_BY_TIME) { $dirs_time[] = filemtime(GALLERY_ROOT . $dir . $var . "/."); } } } elseif (sfpg_image_type($var)) { if ($var != DIR_IMAGE_FILE) { $images[] = $var; if (IMAGE_SORT_BY_TIME) { $images_time[] = filemtime(GALLERY_ROOT . $dir . $var); } } } elseif (SHOW_FILES) { if (!in_array(strtolower($var), $file_exclude) and !((strrpos($var, ".") !== FALSE) and in_array(strtolower(substr($var, strrpos($var, "."))), $file_ext_exclude))) { $files[] = $var; if (FILE_SORT_BY_TIME) { $files_time[] = filemtime(GALLERY_ROOT . $dir . $var); } } } } if (SHOW_FILES) { $item = 0; while($item < count($files)) { $fti = array_search($files[$item] . FILE_THUMB_EXT, $images); if ($fti !== FALSE) { array_splice($images, $fti, 1); array_splice($images_time, $fti, 1); } $item++; } } sfpg_array_sort($dirs, $dirs_time, DIR_SORT_BY_TIME, DIR_SORT_REVERSE); sfpg_array_sort($images, $images_time, IMAGE_SORT_BY_TIME, IMAGE_SORT_REVERSE); sfpg_array_sort($files, $files_time, FILE_SORT_BY_TIME, FILE_SORT_REVERSE); return array($dirs, $images, $files); } else { header("Location: " . $_SERVER["PHP_SELF"]); exit; } } function sfpg_thumb($image_dir, $image_file) { if (THUMB_ROOT != "") { $thumb_file = THUMB_ROOT . $image_dir . $image_file; } else { $thumb_file = ""; } $thumb_type = sfpg_image_type($thumb_file); if (file_exists($thumb_file) and $thumb_type) { header("Content-type: image/" . $thumb_type); readfile($thumb_file); exit; } else { $img_type = sfpg_image_type($image_file); if ($img_type == "jpeg") { if (!$image = @imagecreatefromjpeg(GALLERY_ROOT . $image_dir . $image_file)) { exit; } } elseif ($img_type == "png") { if (!$image = @imagecreatefrompng(GALLERY_ROOT . $image_dir . $image_file)) { exit; } } elseif ($img_type == "gif") { if (!$image = @imagecreatefromgif(GALLERY_ROOT . $image_dir . $image_file)) { exit; } } else { exit; } $image_size = getimagesize(GALLERY_ROOT . $image_dir . $image_file); $image_width = $image_size[0]; $image_height = $image_size[1]; if (($image_width < THUMB_MAX_WIDTH) and ($image_height < THUMB_MAX_HEIGHT) and !ENLARGE_SMALL_IMAGES) { $thumb_height = $image_height; $thumb_width = $image_width; } else { $aspect_x = $image_width / THUMB_MAX_WIDTH; $aspect_y = $image_height / THUMB_MAX_HEIGHT; if ($aspect_x > $aspect_y) { $thumb_width = THUMB_MAX_WIDTH; $thumb_height = $image_height / $aspect_x; } else { $thumb_height = THUMB_MAX_HEIGHT; $thumb_width = $image_width / $aspect_y; } } $thumb = @imagecreatetruecolor($thumb_width, $thumb_height); imagecopyresampled($thumb, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, imagesx($image), imagesy($image)); imagedestroy($image); if (THUMB_ROOT != "") { if (!is_dir(THUMB_ROOT . $image_dir)) { sfpg_make_dir(THUMB_ROOT . $image_dir); } if (SHOW_IMAGE_INFO) { $fp = fopen($thumb_file . ".sfpg", "w"); fwrite($fp, filemtime(GALLERY_ROOT . $image_dir . $image_file) . "|" . filesize(GALLERY_ROOT . $image_dir . $image_file) . "|" . $image_width . "|" . $image_height); fclose($fp); } } header("Content-type: image/" . $thumb_type); if ($img_type == "jpeg") { imagejpeg($thumb, NULL, JPEG_QUALITY); if (THUMB_ROOT != "") { imagejpeg($thumb, $thumb_file, JPEG_QUALITY); } } elseif ($img_type == "png") { imagepng($thumb); if (THUMB_ROOT != "") { imagepng($thumb, $thumb_file); } } elseif ($img_type == "gif") { imagegif($thumb); if (THUMB_ROOT != "") { imagegif($thumb, $thumb_file); } } imagedestroy($thumb); } } function sfpg_first_image($image_dir) { list($dirs, $images, $files) = sfpg_get_dir($image_dir); if (isset($images[0])) { $result = array("dir"=>$image_dir, "file"=>$images[0]); return $result; } else { foreach ($dirs as $subdir) { $subresult = sfpg_first_image($image_dir . $subdir . "/"); if (@isset($subresult[file])) { return $subresult; } } } } function sfpg_image() { global $images; $text_space = 0; $img_nr = array_search(IMAGE, $images); $prev_link = (($img_nr > 0) ? "" . htmlspecialchars(TEXT_PREVIOUS) . "" : ""); $next_link = (($img_nr < (count($images)-1)) ? "" . htmlspecialchars(TEXT_NEXT) . "" : ""); if ($prev_link or $next_link) { $next_previous = $prev_link . "  [" . ($img_nr + 1) . "/" . count($images) . "]  " . $next_link; if (SHOW_IMAGE_NAVI & 1) { $text_space += TEXT_HEIGHT; } if (SHOW_IMAGE_NAVI & 2) { $text_space += TEXT_HEIGHT; } } else { $next_previous = ""; } if (SHOW_IMAGE_NAME & 4) { $display_name = sfpg_display_name(IMAGE, IMAGE_UNDERSCORE_AS_SPACE, SHOW_IMAGE_EXT); $text_space += TEXT_HEIGHT; } else { $display_name = ""; } if (SHOW_IMAGE_DESC & 4) { $desc = @file_get_contents(GALLERY_ROOT . GALLERY . IMAGE . IMAGE_DESC_EXT); $text_space += (substr_count(strtolower(nl2br($desc)), "
") * TEXT_HEIGHT); if ($desc) { $text_space += TEXT_HEIGHT; } } if ((THUMB_ROOT != "") and (SHOW_IMAGE_INFO & 4)) { $text_space += TEXT_HEIGHT; $filed = explode("|", @file_get_contents(THUMB_ROOT . GALLERY . IMAGE . ".sfpg")); $info = @trim((TEXT_DATE ? htmlspecialchars(TEXT_DATE) . date(DATE_FORMAT, $filed[0]) . "     " : "") . (TEXT_FILESIZE ? htmlspecialchars(TEXT_FILESIZE) . number_format($filed[1], 0, '', '.') . "     " : "") . (TEXT_IMAGESIZE ? htmlspecialchars(TEXT_IMAGESIZE) . @$filed[2] . " x " . @$filed[3] : "")); } if (TEXT_CLICK_CLOSE != "") { $text_space += TEXT_HEIGHT; } if ((SHOW_IMAGE_DOWNLOAD & 2) and (TEXT_DOWNLOAD != "")) { $text_space += TEXT_HEIGHT; } if ((TEXT_IMAGE_LINK != "") and !((SHOW_IMAGE_DOWNLOAD & 2) and (TEXT_DOWNLOAD != ""))) { $text_space += TEXT_HEIGHT; } if (SLIDESHOW_DELAY and (count($images)>1)) { $text_space += TEXT_HEIGHT; } if (USE_JAVA and IMAGE_IN_NEW_WINDOW) { $add_to_head =""; } else { $add_to_head = ""; } if (SLIDESHOW_DELAY and (count($images)>1)) { if ($img_nr < (count($images)-1)) { $next_slide = $img_nr + 1; } else { $next_slide = 0; } if (P_OPT == "slide") { $add_to_head .= ""; } } if (IMAGE_IN_NEW_WINDOW or STAND_ALONE) { sfpg_html_start($add_to_head, ((USE_JAVA and IMAGE_IN_NEW_WINDOW) ? " OnLoad=\"javascript:windowchange();\"" : "")); } echo "
"; if (SHOW_IMAGE_NAME & 4) { echo "" . htmlspecialchars($display_name) . "
"; } if ($next_previous and (SHOW_IMAGE_NAVI & 1)) { echo $next_previous . "
"; } $img_link = (IMAGE_IN_NEW_WINDOW ? (USE_JAVA ? "javascript:full_res_close()" : "") : ((USE_JAVA and !SHOW_IMAGE_NAVI) ? "javascript:history.go(-1)" : sfpg_url(GALLERY, "", PAGE))); if ($img_link) { echo ""; } echo "\"\""; if (TEXT_CLICK_CLOSE != "") { echo "
" . htmlspecialchars(TEXT_CLICK_CLOSE) . ""; } if ($img_link) { echo "
"; } if ($next_previous and (SHOW_IMAGE_NAVI & 2)) { echo "
" . $next_previous; } if ((SHOW_IMAGE_DOWNLOAD & 2) and (TEXT_DOWNLOAD != "")) { echo "
" . htmlspecialchars(TEXT_DOWNLOAD) . ""; } if (TEXT_IMAGE_LINK != "") { echo (((SHOW_IMAGE_DOWNLOAD & 2) and (TEXT_DOWNLOAD != "")) ? " - " : "
") . "" . htmlspecialchars(TEXT_IMAGE_LINK) . ""; } if ((SHOW_IMAGE_DESC & 4) and $desc) { echo "
" . (IMAGE_DESC_HTML ? nl2br($desc) : nl2br(htmlspecialchars($desc))); } if ((THUMB_ROOT != "") and (SHOW_IMAGE_INFO & 4)) { echo "
" . @$info; } if (SLIDESHOW_DELAY and (count($images)>1)) { if (P_OPT == "slide") { echo "
" . htmlspecialchars(TEXT_STOP_SLIDE) . ""; } else { echo "
" . htmlspecialchars(TEXT_START_SLIDE) . ""; } } echo "
"; if (IMAGE_IN_NEW_WINDOW or STAND_ALONE) { sfpg_html_end(); } } function sfpg() { global $dirs, $images, $files, $items_per_page, $pages; if (P_CMD == "imageform") { sfpg_image(); } else { $total_columns = (GALLERY_COLUMNS * 2) + 1; $img_width = THUMB_MAX_WIDTH + (THUMB_BORDER_WIDTH * 2); $img_td_width = $img_width + ((THUMB_TD_BORDER_WIDTH + THUMB_TD_PADDING) * 2); $table_width = (($img_td_width + THUMB_TD_SPACING) * GALLERY_COLUMNS) + THUMB_TD_SPACING + (TABLE_BORDER_WIDTH * 2); $write_width = (($img_td_width + THUMB_TD_SPACING) * GALLERY_COLUMNS) + THUMB_TD_SPACING - 10; $spacing_row = ""; $spacing_col = ""; $empty_cell = ""; if (STAND_ALONE) { sfpg_html_start(); } echo ""; if (TEXT_GALLERY_NAME != "") { echo ""; } $links = explode("/", GALLERY); $navi_links = "[" . htmlspecialchars(TEXT_HOME) . "]"; $gal_dirs = ""; if (GALLERY != "" and is_array($links)) { for ($i=0; $i <= count($links) - 1; $i++) { if ($links[$i] != "") { $gal_dirs = ""; for ($u = 0; $u <= $i; $u++) { $gal_dirs .= $links[$u] . "/"; } $display_name = @file(GALLERY_ROOT . $gal_dirs . DIR_NAME_FILE); if ($display_name) { $display_name = trim($display_name[0]); } else { $display_name = sfpg_display_name($links[$i], DIR_UNDERSCORE_AS_SPACE, TRUE); } $navi_links .= " -> [" . htmlspecialchars($display_name) . "]"; } } } if (TEXT_HOME) { echo ""; } if ((ROWS_PER_PAGE != FALSE) and ($pages > 1)) { if (TEXT_PREVIOUS_PAGE) { $page_links = ((PAGE > 1) ? "" : "" ) . htmlspecialchars(TEXT_PREVIOUS_PAGE) . ((PAGE > 1) ? "  " : "  "); } else { $page_links = ""; } for ($page_nr = 1; $page_nr <= $pages; $page_nr++) { $page_links .= " " . $page_nr . "  "; } if (TEXT_NEXT_PAGE) { $page_links .= ((PAGE < $pages) ? "  " : "  " ) . htmlspecialchars(TEXT_NEXT_PAGE) . ((PAGE < $pages) ? "" : ""); } $start_item = ((PAGE-1) * $items_per_page); if (SHOW_PAGE_NAVI & 1) { echo ""; } } else { $start_item = 0; } if ((THUMB_ROOT != "") and (SHOW_DIR_INFO & 4)) { $filed = explode("|", @file_get_contents(THUMB_ROOT . GALLERY . "/_info.sfpg")); $dir_info = (TEXT_DATE ? htmlspecialchars(TEXT_DATE) . date(DATE_FORMAT, @$filed[3]) : ""); $dir_info .= (TEXT_DIRS ? ($dir_info ? "   " : "") . htmlspecialchars(TEXT_DIRS) . @$filed[0] : ""); $dir_info .= (TEXT_IMAGES ? ($dir_info ? "   " : "") . htmlspecialchars(TEXT_IMAGES) . @$filed[1] : ""); $dir_info .= ((TEXT_FILES and SHOW_FILES) ? ($dir_info ? "   " : "") . htmlspecialchars(TEXT_FILES) . @$filed[2] : ""); echo ""; } if (SHOW_DIR_DESC & 4) { $desc = @file_get_contents(GALLERY_ROOT . GALLERY . DIR_DESC_FILE); if ($desc) { echo ""; } } echo $spacing_row . ""; $row = 1; $col = 1; if (count($dirs) > 0) { $item = $start_item; while(($item < count($dirs)) and (($row <= ROWS_PER_PAGE) or (ROWS_PER_PAGE == FALSE))) { if ((SHOW_DIR_NAME & 1) or (SHOW_DIR_NAME & 2)) { $display_name = @file(GALLERY_ROOT . GALLERY . $dirs[$item] . "/" . DIR_NAME_FILE); if ($display_name) { $display_name = trim($display_name[0]); } else { $display_name = sfpg_display_name($dirs[$item], DIR_UNDERSCORE_AS_SPACE, TRUE); } } if (SHOW_DIR_NAME & 2) { $title = htmlspecialchars($display_name); } else { $title = ""; } if ((SHOW_DIR_DESC & 1) or (SHOW_DIR_DESC & 2)) { $dirdesc = @file_get_contents(GALLERY_ROOT . GALLERY . $dirs[$item] . "/" . DIR_DESC_FILE); if (SHOW_DIR_DESC & 2) { $title .= ((($title != "") and ($dirdesc != "")) ? "\r\n---\r\n" : ""); $title .= htmlspecialchars($dirdesc); } } if ((THUMB_ROOT != "") and ((SHOW_DIR_INFO & 1) or (SHOW_DIR_INFO & 2))) { $filed = explode("|", @file_get_contents(THUMB_ROOT . GALLERY . $dirs[$item] . "/_info.sfpg")); $info = @trim((TEXT_DATE ? htmlspecialchars(TEXT_DATE) . date(DATE_FORMAT, $filed[3]) . "\r\n" : "") . (TEXT_DIRS ? htmlspecialchars(TEXT_DIRS) . $filed[0] . "\r\n" : "") . (TEXT_IMAGES ? htmlspecialchars(TEXT_IMAGES) . $filed[1] . "\r\n" : "") . ((TEXT_FILES and SHOW_FILES) ? htmlspecialchars(TEXT_FILES) . @$filed[2] : "")); if (SHOW_DIR_INFO & 2) { $title .= ($title != "" ? "\r\n---\r\n" : "") . $info; } } echo $spacing_col . ""; $item++; $col++; if ($col > GALLERY_COLUMNS) { echo $spacing_col . "" . $spacing_row . ""; $col = 1; $row++; } } } if (count($images) > 0) { $item = ($start_item - count($dirs)); if ($item < 0) { $item = 0; } while(($item < count($images)) and (($row <= ROWS_PER_PAGE) or (ROWS_PER_PAGE == FALSE))) { if ((SHOW_IMAGE_NAME & 1) or (SHOW_IMAGE_NAME & 2)) { $display_name = sfpg_display_name($images[$item], IMAGE_UNDERSCORE_AS_SPACE, SHOW_IMAGE_EXT); } else { $display_name = ""; } if (SHOW_IMAGE_NAME & 2) { $title = htmlspecialchars($display_name); } else { $title = ""; } if ((SHOW_IMAGE_DESC & 1) or (SHOW_IMAGE_DESC & 2)) { $imgdesc = @file_get_contents(GALLERY_ROOT . GALLERY . $images[$item] . IMAGE_DESC_EXT); if (SHOW_IMAGE_DESC & 2) { $title .= ((($title != "") and ($imgdesc != "")) ? "\r\n---\r\n" : ""); $title .= htmlspecialchars($imgdesc); } } if ((THUMB_ROOT != "") and ((SHOW_IMAGE_INFO & 1) or (SHOW_IMAGE_INFO & 2))) { $filed = explode("|", @file_get_contents(THUMB_ROOT . GALLERY . $images[$item] . ".sfpg")); $info = @trim((TEXT_DATE ? htmlspecialchars(TEXT_DATE) . date(DATE_FORMAT, $filed[0]) . "\r\n" : "") . (TEXT_FILESIZE ? htmlspecialchars(TEXT_FILESIZE) . number_format($filed[1], 0, '', '.') . "\r\n" : "") . (TEXT_IMAGESIZE ? htmlspecialchars(TEXT_IMAGESIZE) . @$filed[2] . " x " . $filed[3] : "")); if (SHOW_IMAGE_INFO & 2) { $title .= ($title ? "\r\n---\r\n" : "") . $info; } } echo $spacing_col . ""; $item++; $col++; if ($col > GALLERY_COLUMNS) { echo $spacing_col . "" . $spacing_row . ""; $col = 1; $row++; } } } if (count($files) > 0) { $item = ($start_item - count($dirs) - count($images)); if ($item < 0) { $item = 0; } while(($item < count($files)) and (($row <= ROWS_PER_PAGE) or (ROWS_PER_PAGE == FALSE))) { $display_name = sfpg_display_name($files[$item], FILE_UNDERSCORE_AS_SPACE, SHOW_FILE_EXT); if (SHOW_FILE_NAME & 2) { $title = $display_name; } else { $title = ""; } if (SHOW_FILE_DESC) { $filedesc = @file_get_contents(GALLERY_ROOT . GALLERY . $files[$item] . FILE_DESC_EXT); if (SHOW_FILE_DESC & 2) { $title .= ((($title != "") and ($filedesc != "")) ? "\r\n---\r\n" : ""); $title .= htmlspecialchars($filedesc); } } if ((THUMB_ROOT != "") and SHOW_FILE_INFO) { $filed = explode("|", @file_get_contents(THUMB_ROOT . GALLERY . $files[$item] . ".sfpg")); $info = trim((TEXT_DATE ? htmlspecialchars(TEXT_DATE) . date(DATE_FORMAT, $filed[0]) . "\r\n" : "") . (TEXT_FILESIZE ? htmlspecialchars(TEXT_FILESIZE) . number_format($filed[1], 0, '', '.') : "")); if (SHOW_FILE_INFO & 2) { $title .= ($title ? "\r\n---\r\n" : "") . $info; } } echo $spacing_col . ""; $item++; $col++; if ($col > GALLERY_COLUMNS) { echo $spacing_col . "" . $spacing_row . ""; $col = 1; $row++; } } } echo str_repeat($spacing_col . $empty_cell, (GALLERY_COLUMNS - $col + 1)); echo $spacing_col . "" . ($col > 1 ? $spacing_row : ""); if ((SHOW_PAGE_NAVI & 2) and @$page_links) { echo ""; } echo "
" . htmlspecialchars(TEXT_GALLERY_NAME) . "
" . $navi_links . "
" . $page_links . "
" . $dir_info . "
" . nl2br((DIR_DESC_HTML ? $desc : htmlspecialchars($desc))) . "
\"\"" . ((SHOW_DIR_NAME & 1) ? "
[" . htmlspecialchars($display_name) . "]" : "") . "
"; if ((SHOW_DIR_DESC & 1) and ($dirdesc != "")) { echo "
" . nl2br((DIR_DESC_HTML ? $dirdesc : htmlspecialchars($dirdesc))) . "
"; } if ((SHOW_DIR_INFO & 1) and @($info != "")) { echo "
" . nl2br($info) . "
"; } echo "
"; if (USE_JAVA and IMAGE_IN_NEW_WINDOW) { echo ""; } else { echo ""; } echo "\"\"" . ((SHOW_IMAGE_NAME & 1) ? "
" . htmlspecialchars($display_name) : "") . "
"; if ((SHOW_IMAGE_DOWNLOAD & 1) and (TEXT_DOWNLOAD != "")) { echo ""; } if ((SHOW_IMAGE_DESC & 1) and ($imgdesc != "")) { echo "
" . (IMAGE_DESC_HTML ? nl2br($imgdesc) : nl2br(htmlspecialchars($imgdesc))) . "
"; } if ((SHOW_IMAGE_INFO & 1) and @($info != "")) { echo "
" . nl2br($info) . "
"; } echo "
"; if (FILE_THUMB_EXT and file_exists(GALLERY_ROOT . GALLERY . $files[$item] . FILE_THUMB_EXT)) { echo "\"\"
"; $file_thumb_shown = TRUE; } else { $file_thumb_shown = FALSE; } if (!(!(SHOW_FILE_NAME & 1) and $file_thumb_shown)) { echo htmlspecialchars($display_name); } echo "
"; if ((SHOW_FILE_DESC & 1) and ($filedesc != "")) { echo "
" . nl2br((FILE_DESC_HTML ? $filedesc : htmlspecialchars($filedesc))) . "
"; } if ((SHOW_FILE_INFO & 1) and ($info != "")) { echo "
" . nl2br($info) . "
"; } echo "
"; echo $page_links; echo "
"; if (STAND_ALONE) { sfpg_html_end(); } } } $get_set = FALSE; if (@$_GET["sfpg"]) { $get = explode("*", sfpg_base64url_decode($_GET["sfpg"])); if ((md5($get[0] . "*" . $get[1] . "*" . $get[2] . "*" . $get[3] . "*" . $get[4] . "*" . SECURITY_PHRASE) === $get[5]) and (strpos($get[0] . $get[1], "..") === FALSE)) { define("GALLERY", $get[0]); define("IMAGE", $get[1]); define("P_PAGE", $get[2]); define("P_CMD", $get[3]); define("P_OPT", $get[4]); $get_set = TRUE; } } if (!$get_set) { define("GALLERY", ""); define("IMAGE", ""); define("P_PAGE", ""); define("P_CMD", ""); define("P_OPT", ""); } if (P_CMD == "css") { header("Content-type: text/css"); echo " body.sfpg { background : $color_body_back; color: $color_body_text; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; margin : 15px; } body.sfpg a:active, body.sfpg a:link, body.sfpg a:visited, body.sfpg a:focus { color : $color_body_link; text-decoration : none; } body.sfpg a:hover { color : $color_body_hover; text-decoration : none; } table.sfpg td.dir a:active, table.sfpg td.dir a:link, table.sfpg td.dir a:visited, table.sfpg td.dir a:focus { color : $color_dir_link; text-decoration : none; } table.sfpg td.dir a:hover { color : $color_dir_hover; text-decoration : none; } table.sfpg td.img a:active, table.sfpg td.img a:link, table.sfpg td.img a:visited, table.sfpg td.img a:focus { color : $color_img_link; text-decoration : none; } table.sfpg td.img a:hover { color : $color_img_hover; text-decoration : none; } table.sfpg td.file a:active, table.sfpg td.file a:link, table.sfpg td.file a:visited, table.sfpg td.file a:focus { color : $color_file_link; text-decoration : none; } table.sfpg td.file a:hover { color : $color_file_hover; text-decoration : none; } table.sfpg td.navi a:active, table.sfpg td.navi a:link, table.sfpg td.navi a:visited, table.sfpg td.navi a:focus { color : $color_navi_link; text-decoration : none; } table.sfpg td.navi a:hover { color : $color_navi_hover; text-decoration : none; } table.sfpg a.navinorm:active, table.sfpg a.navinorm:link, table.sfpg a.navinorm:visited, table.sfpg a.navinorm:focus { color : $color_page_link; text-decoration : none; } table.sfpg a.navinorm:hover { color : $color_page_hover; text-decoration : none; } table.sfpg a.navimark:active, table.sfpg a.navimark:link, table.sfpg a.navimark:visited, table.sfpg a.navimark:focus { color : $color_page_mark_link; text-decoration : none; background-color: $color_page_mark_back; } table.sfpg a.navimark:hover { color : $color_page_mark_hover; text-decoration : none; } table.sfpg td.fullimg a:active, table.sfpg td.fullimg a:link, table.sfpg td.fullimg a:visited, table.sfpg td.fullimg a:focus { color : $color_fullimg_link; text-decoration : none; } table.sfpg td.fullimg a:hover { color : $color_fullimg_hover; text-decoration : none; } table.sfpg { border : ".TABLE_BORDER_WIDTH."px solid $color_table_border; background : $color_table_back; font-size: 12px; text-align : center; vertical-align : top; margin : 0px; padding : 0px; } table.sfpg td { border : none; border-bottom : ".TABLE_BORDER_WIDTH."px solid $color_table_border; padding : 3px; } table.sfpg td.img { border : ".THUMB_TD_BORDER_WIDTH."px solid $color_img_td_border; background : $color_img_td_back; color: $color_img_td_text; padding : ".THUMB_TD_PADDING."px; } table.sfpg td.dir { border : ".THUMB_TD_BORDER_WIDTH."px solid $color_dir_td_border; background : $color_dir_td_back; color: $color_dir_td_text; padding : ".THUMB_TD_PADDING."px; } table.sfpg td.file { border : ".THUMB_TD_BORDER_WIDTH."px solid $color_file_td_border; background : $color_file_td_back; color: $color_file_td_text; padding : ".THUMB_TD_PADDING."px; } table.sfpg td.navi { background : $color_navi_back; color: $color_navi_text; } table.sfpg td.page { background : $color_page_back; } table.sfpg td.pagebottom { background : $color_page_back; border-top : ".TABLE_BORDER_WIDTH."px solid $color_table_border; border-bottom : none; } table.sfpg td.desc { background : $color_desc_back; color: $color_desc_text; } table.sfpg td.empty { border : none; background : $color_table_back; padding : 0px; } table.sfpg td.fullimg { border: none; background : $color_fullimg_td_back; color: $color_fullimg_td_text; padding : ".FULLIMG_TD_PADDING."px; } table.sfpg td.fullimg img { border : ".FULLIMG_BORDER_WIDTH."px solid $color_fullimg_border; margin-top : 5px; margin-bottom : 5px; } table.sfpg th { border : none; border-bottom : ".TABLE_BORDER_WIDTH."px solid $color_table_border; background : $color_table_header_back; color: $color_table_header_text; font-size: 18px; font-weight: bold; text-align : center; padding : 5px; } table.sfpg td.dir img { border : ".THUMB_BORDER_WIDTH."px solid $color_dir_border; margin : 0px; } table.sfpg td.img img { border : ".THUMB_BORDER_WIDTH."px solid $color_img_border; margin : 0px; } table.sfpg td.file img { border : ".THUMB_BORDER_WIDTH."px solid $color_file_border; margin : 0px; } table.sfpg td.dir div { margin-top : 5px; padding-top : 5px; border-top : 1px solid $color_dir_td_border; text-align : left; font-size: 10px; } table.sfpg td.img div { margin-top : 5px; padding-top : 5px; border-top : 1px solid $color_img_td_border; text-align : left; font-size: 10px; } table.sfpg td.file div { margin-top : 5px; padding-top : 5px; border-top : 1px solid $color_file_td_border; text-align : left; font-size: 10px; } "; exit; } if (P_CMD == "thumb") { sfpg_thumb(GALLERY, IMAGE); exit; } if (P_CMD == "dirthumb") { if ((DIR_IMAGE_FILE != "") and file_exists(GALLERY_ROOT . GALLERY . DIR_IMAGE_FILE)) { sfpg_thumb(GALLERY, DIR_IMAGE_FILE); exit; } else { $first_image = sfpg_first_image(GALLERY); sfpg_thumb($first_image["dir"], $first_image["file"]); exit; } } if ((P_CMD == "image") or (P_OPT == "dl")) { $image_file = GALLERY_ROOT . GALLERY . IMAGE; $img_type = sfpg_image_type($image_file); if (file_exists($image_file) and $img_type) { if (P_OPT == "dl") { header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"" . IMAGE . "\""); } else { header("Content-Type: image/" . $img_type); header("Content-Disposition: inline; filename=\"" . IMAGE . "\""); } readfile($image_file); } else { header("Location: " . $_SERVER["PHP_SELF"]); } exit; } list($dirs, $images, $files) = sfpg_get_dir(GALLERY); if ((SHOW_DIR_INFO or SHOW_FILE_INFO) and (THUMB_ROOT != "") and (P_CMD != "imageform")) { $info = count($dirs) . "|" . count($images) . "|" . count($files) . "|" . filemtime(GALLERY_ROOT . GALLERY . "."); $file_info = @file_get_contents(THUMB_ROOT . GALLERY . "_info.sfpg"); if ($file_info != $info) { if ($fp = @fopen(THUMB_ROOT . GALLERY . "_info.sfpg", "w")) { fwrite($fp, $info); fclose($fp); } } if (SHOW_FILE_INFO) { $info_a = explode("|", $file_info); if (count($files) != @$info_a[2]) { $item = 0; while($item < count($files)) { if (!is_dir(THUMB_ROOT . GALLERY)) { sfpg_make_dir(THUMB_ROOT . GALLERY); } $fp = fopen(THUMB_ROOT . GALLERY . $files[$item] . ".sfpg", "w"); fwrite($fp, filemtime(GALLERY_ROOT . GALLERY . $files[$item]) . "|" . filesize(GALLERY_ROOT . GALLERY . $files[$item])); fclose($fp); $item++; } } } } if (ROWS_PER_PAGE != FALSE) { $items_per_page = (GALLERY_COLUMNS * ROWS_PER_PAGE); $pages = ceil((count($dirs) + count($images) + count($files)) / $items_per_page); if ((P_PAGE < 1) or (P_PAGE > $pages)) { define("PAGE", 1); } else { define("PAGE", P_PAGE); } } if ((P_CMD == "imageform") and IMAGE_IN_NEW_WINDOW) { sfpg_image(); exit; } if (STAND_ALONE) { sfpg(); } ?>