0) { $meta[$tag] = stripslashes($$tag); echo "$tag tag was updated.
"; } else { unset($meta[$tag]); echo "$tag tag was deleted.
"; } } } } write_descript($dir); } if (isset($meta["title"])) echo "

".$meta["title"]."

"; echo "
\n"; echo "\n"; echo "\n"; foreach ($edit_meta as $tag) { echo ucfirst($tag)."
\n"; } echo "

"; echo "

\n"; echo "
\n"; $dirlist = array(); $filelist = array(); $handle = opendir($dir); while (false !== ($file = readdir($handle))) { $fullname = "$dir/$file"; if (!is_file($fullname)) { array_push($dirlist, $file); } else { # ignore html files if (!preg_match("/html$/",$fullname)) { array_push($filelist, $file); } } } closedir($handle); sort ($dirlist); foreach ($dirlist as $file) { $fullname = truepath("$dir/$file"); echo "edit | "; echo "$file
"; if ($dirs[$file]["short_descript"]) { echo "".$dirs[$file]["short_descript"]."
\n"; } } echo "

\n"; sort ($filelist); foreach ($filelist as $file) { $fullname = "$dir/$file"; if ($file == $caption_filename) { echo "$file
\n"; } else { echo "$file
"; if ($photos[$file]["short_descript"]) { echo "".$photos[$file]["short_descript"]."
\n"; } } } ?> <?PHP print($dir);?> 0) { $dirs[$basedir][$tag] = stripslashes($$tag); echo "$tag was updated.
"; } else { unset($dirs[$basedir][$tag]); echo "$tag was deleted.
"; } } } } if ($changed == 1) { write_descript("$dir/.."); } echo "

\n"; echo "\n"; echo "\n"; foreach ($edit_dir as $tag) { echo ucfirst($tag)."
\n"; } echo "

"; echo "

\n"; echo "Return to Index

"; ?> <?PHP print($photo);?> 0) { $photos[basename($photo)][$tag] = stripslashes($$tag); echo "$tag was updated.
"; } else { unset($photos[basename($photo)][$tag]); echo "$tag was deleted.
"; } } } } if ($changed == 1) { write_descript(dirname($photo)); } echo "

\n"; echo "\n"; echo "\n"; foreach ($edit_photos as $tag) { echo ucfirst($tag)."
\n"; } echo "

"; echo "

\n"; echo "Return to Index

"; $photo_size = getimagesize("$photo"); ?> name="photo"> 0) { if (strlen($currfile)>0) { # only store the value if it a valid photo attribute $photos[$currfile][$currtag] = stripslashes($data); } else if (strlen($currdir)>0) { $dirs[$currdir][$currtag] = stripslashes($data); #print "$currdir/$currtag = $data
"; } else { $meta[$currtag] = stripslashes($data); #print "meta/$currtag = $data
"; } } break; } } function read_descript($directory) { global $caption_filename; if (!file_exists($directory."/".$caption_filename)) return; $fd = fopen ($directory."/".$caption_filename, "r"); $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, 'characterData'); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0); while ($data = fread($fd, 4096)) { if (!xml_parse($xml_parser, $data, feof($fd))) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); fclose($fd); } function write_descript($directory) { global $meta, $photos, $dirs; global $caption_filename; $fd = fopen ("$directory/$caption_filename", "w"); fwrite($fd, "\n"); fwrite($fd, "\n"); $pre = " "; if (isset($meta)) { ksort($meta); foreach ($meta as $label => $value) { fwrite($fd, "$pre<$label>$value\n"); } } if (isset($dirs)) { ksort($dirs); foreach ($dirs as $name) { fwrite($fd, "$pre\n"); $pre .= $pre; foreach($name as $label => $value) { if ($label != "name") { fwrite($fd, "$pre<$label>$value\n"); } } $pre = " "; fwrite($fd, "$pre\n"); } } if (isset($photos)) { ksort($photos); foreach ($photos as $name) { fwrite($fd, "$pre\n"); $pre .= $pre; foreach($name as $label => $value) { if ($label != "filename") { fwrite($fd, "$pre<$label>$value\n"); } } $pre = " "; fwrite($fd, "$pre\n"); } } fwrite($fd, "\n"); fclose($fd); } # copied from the PHP docs function truepath ($path){ if ($path == ".") return ($path); $patharray = explode ("/", $path); $path=""; $count=count($patharray); for ($i=0;$i<$count; $i++){ if ( $patharray[$i] == "." || $patharray[$i]== ".." || ( (($i+1) < $count) && ($patharray[$i+1]== "..")) ) { //If the current pos is a . ignore, if pos+1 == .. ignore, lastly if current = .. ignore. } else { $path .= $patharray[$i]."/"; } } //Trim trailing slash $path = substr($path,0,-1); return ($path); } ?>