";
} else
while (false != ($subdir = readdir($handle))) {
// pick out subdirectories (not <.> e <..>)
if (is_dir($pwd."/".$subdir) && $subdir != "." && $subdir != "..") {
echo " $subdir \n";
$flag_dir=1;
}
}
rewinddir($handle);
if ($flag_dir) {echo "
|
";}
// done with subdirs
if ($in=@fopen($pwd."/.authors",r)) {
$fs=$pwd."/.authors";
$contents = fread ($in, filesize($fs));
echo "$contents \n";
$flag_any=1;
}
if ($in=@fopen($pwd."/.title",r)) {
$fs=$pwd."/.title";
$contents = fread ($in, filesize($fs));
echo "$contents \n";
$flag_any=1;
}
if ($in=@fopen($pwd."/.others",r)) {
$fs=$pwd."/.others";
$contents = fread ($in,filesize($fs));
echo "$contents \n";
$flag_any=1;
}
rewinddir($handle);
$notified=0; // for printin just one time locked files
if ($flag_any) {echo " \n";}
if ($wd!="") while ((false != ($file = readdir($handle)))&&($notified==0)) {
if (is_file($pwd."/".$file) && $file!=".authors" && $file!=".title"
&& $file!=".others" && !(ereg("\.php[3,4]?$",$file)) &&
!(ereg("^\.",$file)) ) {
$bdir=ereg_replace("/data/httpd",$raw_location,$pwd);
if ((file_exists($pwd."/.lock"))&&(!(validate($user)))) {
echo "( files locked by ";
$fp=fopen($pwd."/.lock","r");
$lockedby=fread($fp,255);
echo "$lockedby)";
$notified++;
} else {
echo "($file)\n";
}
$flag_file=1;
}
}
//if (($flag_file)||($flag_any)) {echo "
|
";}
//DEBUG
//rewinddir($handle);
//echo "Dir contents: \n";
// while (false != ($sub = readdir($handle))) {
// echo "$sub ";
//}
//echo " \n";
//ENDDEBUG
closedir($handle);
} // END parse_dir
//--------------- MAIN PROG ---------------------------------------------------------
umask(666);
//setup some useful pointers
if (ISSET($_REQUEST["user"])) $user=$_REQUEST["user"];
if(!ISSET($user)) {
if (ISSET($_REQUEST["name"])&&ISSET($_REQUEST["pass"])) {
$user=create_user($_REQUEST["name"],$_REQUEST["pass"]);
} else {
$user="";
}
}
// base directory
$pwd_base=trim(`pwd`);
//base path (corrected for http referencing)
$http_pwd_base=ereg_replace("/data/httpd",$raw_location,$pwd_base);
//current dir
$pwd=$pwd_base;
// current path
$http_pwd=$http_pwd_base;
//
$wd="";
if (ISSET($_REQUEST["wd"])) {
$wd=$_REQUEST["wd"];
$pwd=$pwd_base."/".$wd;
$http_pwd=$http_pwd_base."/".$wd;
}
// in the case, take care of locking/unlocking of dirs
if (ISSET($_REQUEST["lock"])&&($_REQUEST["lock"]==1)&&validate($user)) {
$fp=fopen($pwd_base."/$wd/.lock","w");
fwrite($fp,get_username($user));
fclose($fp);
chmod ($pwd_base."/$wd/.lock",0777);
} else if (ISSET($_REQUEST["unlock"])&&($_REQUEST["unlock"]==1)&&validate($user)) {
unlink($pwd_base."/$wd/.lock");
}
//this being done, go on with the prog!
echo "";
echo "\n";
echo "";
if (validate($user)) {
echo "User: ".get_username($user);
echo "
\nLOGOUT\n";
} else {
echo "Unknown user
";
echo "to access some of the papers you will need to log in here at right --->";
echo " click here if you need help";
}
echo " | \n | ";
if ((!(validate($user)))&&(get_username($user))!="Guest") {
// the needed login form is provided
echo "";
} else {
// we can add a dir/upload a file/etc
echo "RELOAD this directory \n";
echo "CREATE a new directory here \n";
echo "UPLOAD a file in this directory \n";
echo "MODIFY paper authors/title/etc. \n";
// if it's the case, let's you lock/unlock the files
if ( !(is_file($pwd_base."/".$wd."/.lock")) ) {
echo "LOCK";
} else echo "LOCK";
echo " data in this directory \n";
if (is_writeable($pwd_base."/".$wd."/.lock")) {
echo "UNLOCK";
} else echo "UNLOCK";
echo " data in this directory \n";
}
echo " | \n";
?>
remember: each paper should have its own dir.
for each directory a title and a list of authors can be specified
and several files (*.ps, *.pdf, ...) can be included
l33t dynamic page created by
Riccardo
|