$val) { $cmd = ""; $cmd = preg_replace('/^.*-(long|brief)$/', '1', $key); if (($cmd == "long") || ($cmd == "brief")) { $key = preg_replace('/.jpg-(long|brief)$/', '.txt', $key); $val = trim($val); // REmove blank spaces at end of string if ($val) { $new_data[$key][$cmd] = $val; } } } $dir = GALLERY_ROOT . "/" . get_var('dir'); // Go thru each image and save comments to file. foreach ($new_data as $key => $val) { $handle = fopen("$dir/$key", "w"); if ($handle) { if (fwrite($handle, $new_data[$key]['brief'] . "\n") == FALSE) { print "Failed to write to file: $dir/$key
"; } else if (fwrite($handle, $new_data[$key]['long'] . "\n") == FALSE) { print "Failed to write to file: $dir/$key
"; } } else { print "Failed to open file: $dir/$key
"; } } } ?>
"; $cur_user = @$_SERVER['REMOTE_USER']; $is_owner = 0; if (in_array(strtolower($cur_user), get_owners($dir))) { $is_owner = 1; } else { $comment = ""; } if ($image) { Display_Image("$dir/$image", $dir); exit; } if ($dir == ".") { print "

Welcome to the gallery page.

"; } $title = @file("$path/title.txt"); if (!$title) { $title[0] = preg_replace("|^.*/([^/]*)$|", "$1", $dir); } # Remove the leading "./" in the directory variable $dir = preg_replace("|^./|", "", $dir); # Space out the "/" in the directory variable for cosmetic purposes $title_dir = preg_replace("|/|", " :: ", $dir); if ($dir != ".") { $title_dir = "gallery :: $title_dir"; } $title_dir_arr = preg_split("/ :: /", $title_dir); $num = count($title_dir_arr); $i = 0; $url = "/gallery.php?comment=$comment&dir=."; while ($i < $num-1) { if ($i > 0) { $url = "$url%2F" . urlencode($title_dir_arr[$i]); } $title_dir_arr[$i] = "$title_dir_arr[$i]"; $i++; } $title_dir = implode(" $arrow_img ", $title_dir_arr); # Only display the title dir path if we are not at the root if ($dir != ".") { print "$title_dir

"; } if ($is_owner) { if ($comment == 'yes') { $comment_link = " [Stop Commenting]"; } else { $comment_link = " [Add Comments]"; } } else { $comment_link = ""; } $dir_array = array(); print "$title[0] $comment_link

"; if (is_dir($path)) { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { if (($file[0] != ".") && (is_dir("$path/$file"))) { $dir_array[] = $file; } } if (count($dir_array) > 0) { sort($dir_array); print ""; } // IF COUNT } // IF $DH } else { print "

There was an error displaying the gallery. Please contact Ray Hodel. "; print "This is anot a directory: $path

; exit; } // IF IS_DIR Display_Thumbs($path, $dir, $comment); ############################################ ################ Display_Thumbs ############################################ ## Purpose ## ## function Display_Thumbs($path, $dir, $comment) { global $domain; $owners = get_owners($dir); $i = 0; $columns = 6; $align = 'center'; if ($comment == 'yes') { $columns = 1; $align = 'left'; } $file_array = array(); if (@is_dir($path)) { if ($dh = @opendir($path)) { while (($file = @readdir($dh)) !== false) { if (($file[0] != ".") && (!is_dir("$path/$file"))) { $file_array[] = $file; } } if (count($file_array)) { sort($file_array); } if (count($file_array) > 0) { $file_array = preg_grep("/\.gif$/", $file_array); sort($file_array); if ($comment == 'yes') { print "
"; } print ""; foreach ($file_array as $file) { $thumb = $file; if ($comment == 'yes') { $brief_comment = get_brief_comment($dir, $file, 0); $long_comment = get_long_comment($dir, $file, 0); } else { $brief_comment = get_brief_comment($dir, $file, 1); $long_comment = get_long_comment($dir, $file, 1); } $file = preg_replace("/(.+)gif$/", "$1jpg", $file); ### print translate_uri($dir) . "/" . $file . "
"; if (($i++ % $columns) == 0) { print ""; } print "\n"; } } // FOREACH print "
"; if ($comment == 'yes') { print "
"; print "$long_comment"; print ""; print "Thumbnail image comment
"; print "
"; print "Large image comment
"; print ""; print "
"; } else { print "$long_comment"; print "
$brief_comment
"; if ($comment == 'yes') { print ""; print ""; print "
"; } } // IF COUNT } // IF $DH } else { print "

There was an error displaying the gallery. Please contact Ray Hodel. "; print "This is anot a directory: $path

"; exit; } // IF IS_DIR } ############################################ ################ Display_Image ############################################ ## Purpose ## ## function Display_Image($image, $dir) { $arrow_img = ""; # Space out the "/" in the directory variable for cosmetic purposes $title_dir = preg_replace("|/|", " :: ", $dir); $title_dir_arr = preg_split("/ :: /", $title_dir); $num = count($title_dir_arr); $i = 0; $url = "http://www.hodel.com/gallery.php?dir=."; while ($i < $num) { if ($i > 0) { $url = "$url%2F" . urlencode($title_dir_arr[$i]); } $title_dir_arr[$i] = "$title_dir_arr[$i]"; $i++; } $title_dir = implode(" $little_arrow ", $title_dir_arr); $image_fn = preg_replace("|^.*/([^/]*)$|", "$1", $image); if ($dir != ".") { print "$title_dir $little_arrow $image_fn"; } print "

$title[0]

"; print ""; print ""; $image = preg_replace("|$dir/|", "", $image); $image = preg_replace("|.jpg$|", "", $image); print ""; print "
$image
$image
"; } ############################################ ################ get_owners ############################################ ## Purpose ## ## function get_owners($dir) { $dir_arr = preg_split("/\//", $dir); $owner_file = GALLERY_ROOT . "/" . $dir_arr[0] . "/owner.txt"; $owners = split("\n", chop(@file_get_contents($owner_file))); return $owners; } ############################################ ################ get_brief_comment ############################################ ## Purpose ## ## function get_brief_comment($dir, $file, $display_only=0) { $comment_file = preg_replace("/(.+)gif$/", "$1txt", $file); $comment_file = GALLERY_ROOT . "/$dir/$comment_file"; $comment = array(); if (file_exists($comment_file)) { $comment = split("\n", chop(@file_get_contents($comment_file))); } else { if ($display_only) { $comment = split("\.", $file); } } if (@$comment[0]) { return $comment[0]; } return @$comment[1]; } ############################################ ################ get_long_comment ############################################ ## Purpose ## ## function get_long_comment($dir, $file, $display_only=0) { $comment_file = preg_replace("/(.+)...$/", "$1txt", $file); $comment_file = GALLERY_ROOT . "/$dir/$comment_file"; $comment = ""; if (file_exists($comment_file)) { $comment = split("\n", chop(@file_get_contents($comment_file))); if ($comment[1]) { $comment[0] = ""; # Remove the brief comment } $comment = implode(" ", $comment); } else { if ($display_only) { $comment = split("\.", $file); $comment = $comment[0]; } } return $comment; } ############################################ ################ get_lastupdate ############################################ ## Purpose ## ## function get_lastupdate($dir) { $filelist = Array(); $path = getcwd(); if (is_dir($dir)) { # System command to get all the directories within a certain directory $a = `find "$dir" -type d'; $filelist = explode ("\n", $a); # Break up the lines and put into an array } else if (is_file($dir)) { $filelist[] = $dir; } $lastmod = 0; for($i=0;$i $lastmod) ? $date : $lastmod; clearstatcache(); } #print "The last modification was on ". date("M d, Y", $lastmod) . "
"; return $lastmod; } ############################################ ################ translate_uri ############################################ ## Purpose ## ## function translate_uri($uri) { $parts = explode('/', $uri); for ($i = 0; $i < count($parts); $i++) { $parts[$i] = rawurlencode($parts[$i]); } return implode('/', $parts); } ?>