", field0<|>field1<|>field2
$sep="<|>";
//$thumb_dir is relative to the directory holding the images
$thumb_dir="thumbnails";
$form_act=$PHP_SELF;
//If you make static html pages you'll have to copy them from $write_dir
// default is /tmp, since the webserver user should be able to write there
$write_dir="/tmp";
// filename, filesize, image size, description, sort category
$k0="file";
$k1="byte";
$k2="size";
$k3="desc";
$k4="sort";
// default values
$v0=""; // pretty useless, actually
$v1="0"; //ditto
$v2="0x0"; //duh!
$v3="NO DESCRIPTION"; // finally a default value that makes sense
$v4="unsorted";
//$keys=array("file","byte","size","desc","sort");
//$vals=array("","0","0x0","NO DESCRIPTION","unsorted");
/* table variables, in case i want to make a table */
$tcols="3";
$tborder="7";
$tsummary="A table of image data";
$cpad="7";
$cspace="2";
$tabletop ="
\n";
/* html vars */
$doctype ="\n";
$head ="\n";
$head.=" \n";
$head.=" \n";
$head.=" \n";
$title=" " . $_self;
$head1 =" \n";
$head1.= " \n";
/*
* END INITIALIZE VARS
*/
/*
* FUNCTIONS
*/
/*
* BEGIN function test_print()
* to aid in debugging
*/
function test_print($ar, $comment)
{
echo " $comment = \n";
echo "
\n";
print_r($ar);
echo "
\n";
}
/*
* END function test_print()
*/
/*
* BEGIN function get_imgs()
* to find image files in the current directory
*/
function get_imgs(&$_array, $_k1, $_k2)
{
// check for image files in the current directory,
// make an associative array:
// $_array[filename] = array( $_k1 => filesize, $_k2 => imagesize )
global $debug;
$handle=opendir('.');
while ($file=readdir($handle)){
//don't run getimagesize() on directories or 0 byte files
if ((!is_dir($file)) && (filesize($file) != 0)){
if (getimagesize($file) !=""){
$_byte=filesize($file);
$_size=getimagesize($file);
$_s=$_size[0] . "x" . $_size[1];
$_b=strval($_byte);
$_s=strval($_s);
$_fn=strval($file);
$_array[$_fn][$_k1]=$_b;
$_array[$_fn][$_k2]=$_s;
}
}
}
ksort($_array);
}
/*
* END function get_imgs()
*/
/*
* BEGIN function init_array()
*/
function init_array()
{
global $debug, $i_name, $k1, $k2, $k3, $k4, $v3, $v4, $data_file, $sep;
// find all image files in the current directory
get_imgs($i_name,$k1,$k2);
// fill in the default values for description and sort
while (list($_n,) = each($i_name)){
$i_name[$_n][$k3]=$v3;
$i_name[$_n][$k4]=$v4;
}
// read $data_file and see if it results in an array
$u_data=file($data_file);
// substitute descriptions and sort categories from $data_file
// if they match the filename found
if(is_array($u_data)){
for ($count=0; $count array
* (
* [byte] => filesize,
* [size] => imagesize,
* [desc] => description,
* [sort] => sort category
* )
* ...
* )
*/
}
/*
* END function init_array()
*/
function edit_form()
{
global $debug, $form_act, $tabletop, $i_name, $thumb_dir, $switcher;
// test_print($i_name,"i_name");
echo "
\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
}
/*
* BEGIN function up_desc()
*/
function up_desc(&$_array,$_fp,$_sep)
{
global $debug;
// test_print($_array," up_desc");
$d_count=count($_array);
$fp=fopen($_fp,"w");
rewind($fp);
foreach ($_array as $_file => $_ar){
foreach ($_ar as $key => $val){
$d_c_t=trim($val);
$d_c_c=stripslashes($d_c_t);
$_array[$_file][$key]=$d_c_c;
}
$test_str =$_file . $_sep;
$test_str.=implode($_sep, $_array[$_file]);
fwrite($fp,$test_str);
fwrite($fp,"\n");
}
fclose($fp);
}
/*
* END function up_desc()
*/
function make_pages(&$hashdat,&$write_dir,&$data_file,&$sep)
{
global $debug,$doctype,$tabletop,$head,$head1,$thumb_dir;
while (list($key,$value) = each($hashdat)){
$s_key=$hashdat[$key]["sort"];
$ar[$s_key][$key]=array(
"byte" => $hashdat[$key]["byte"],
"size" => $hashdat[$key]["size"],
"desc" => stripslashes($hashdat[$key]["desc"])
);
}
while (list($key,) = each($ar)){
$new=strtr($key," ","_");
$_links.=" [" . $key ."]\n";
}
reset($ar);
while (list($key,$value) = each ($ar)){
$new=strtr($key," ","_");
$new_file=$write_dir . "/" . $new . ".html";
$fp=fopen($new_file,"w");
rewind($fp);
$_str =$doctype;
$_str.=$head;
$title=" " . $new . " images\n";
$_str.=$title;
$_str.=$head1;
$_str.=" \n";
$_str.="
" . $key . "
\n";
$_str.=$_links;
$_str.=$tabletop;
$_str.="
Thumbnail\n";
$_str.="
Filesize\n";
$_str.="
Image size\n";
$_str.="
Description\n";
while (list($_key,$_val)=each($value)){
$_str.="