Hello all,
I'm trying to create a script which allow me to index all the files on a directory (DONE) and, if I click on a link, open this files (DONE). The only problem is when I'm trying to pass information about how this file should be open it. I
Thanks in advance
<?php
function modo(){
$v = "<form action=\"".$PHP_SELF." method=\"get\">";
$v = $v."READ <input type=\"radio\" name=\"modo[]\" value=\"read\" checked=\"checked\">";
$v = $v."WRITE <input type=\"radio\" name=\"modo[]\" value=\"write\">";
$v = $v."APPEND <input type=\"radio\" name=\"modo[]\" value=\"append\">";
$v = $v."</form>";
return $v;
}
function listar_files(){
$path =(".");
$a =0;
$files = opendir($path);
while( false !== ($file =readdir($files))){
if($file !== "." && $file !== ".."){
$docs[$a] = $file;
echo("<a href=\"new.php?modo&file=$file\" >$file</a>, ");
$a++;
}
}
echo("<hr/>");
echo(modo());
}
function leer($a){
if (!isset($a)){}
else{
$b = fopen($a,r); // HOW TO PASS THIS VARIABLE 😕
echo("<form action=\"".$PHP_SELF." method=\"post\"><textarea rows=\"20\" cols=\"90\">");
while(!feof($b)){
$page = fgets($b);
echo("$page");}
echo("</textarea><hr/><input type=\"submit\" value=\"SALVAR\"></input></form>");
}
}
?>
<html>
<head><title>merda</title> </head>
<body>
<?php listar_files() ?>
<hr/>
<?php leer($file) ?>
</body>
</html>