questa è la homepage.php
Codice PHP:
<? session_start(); ?>
<HTML>
<HEAD>
<TITLE>homepage</TITLE>
</HEAD><style type="text/css" media="all">
body {
background-color: black;
font-family: Comic sans ms, Arial, Helvetica, sans-serif;
font-size: 20px;
color: #FF0000;
margin: 5;
padding: 0;}
a {color: yellow;}
.titolo {font-size: 24px;
color:red ;
font-weight: bold;
line-height: 1.25em;}
.link {font-size: 14px;
color: yellow;
font-weight: bold;
line-height: 1.25em;}
</style>
<BODY><?php
session_start();
"?PHPSESSID=".session_id();
$name = htmlspecialchars($_POST['name']);
if($name != ""){
$_SESSION['name'] = $name;}
else {
echo ('Attenzione dovete inserire un nome valido<br/>');
echo('<a href="index.php">Indietro</a>');
exit();}
?>
<?php
$path = "upload/";
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$file = $path.'../upload/'.$file;
if (is_file($file)) @$n_file++;
//if(is_dir($file)) @$n_dir++;
}
}
closedir($handle);
}
?>
<div align="center"><div class="titolo">*HOME*</div><br><font color="green"><?php echo (date("d/m/Y G:i")); ?></font><br><hr>[<a href="homepage.php<?php session_start(); echo "?PHPSESSID=".session_id(); ?>">Aggiorna</a>]
[<a href="upload_file.php<?php session_start(); echo "?PHPSESSID=".session_id(); ?>">Upload</a>] [<a href="visualizza_file.php<?php session_start(); echo "?PHPSESSID=".session_id(); ?>">Visualizza i file</a> (<?=$n_file?>)]</hr></div>
</BODY>
</HTML>
le seguente visualizza_file.php
Codice PHP:
<? session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD><meta http-equiv="Content-Language" content="it">
<TITLE>file_uploadati</TITLE>
</HEAD><style type="text/css" media="all">
body {
background-color: black;
font-family: Comic sans ms, Arial, Helvetica, sans-serif;
font-size: 20px;
color: #FF0000;
margin: 5;
padding: 0;}
a {color: yellow;}
.titolo {font-size: 24px;
color: red;
font-weight: bold;
line-height: 1.25em;}
.testo {font-size: 14px;
color: yellow;
font-weight: bold;
line-height: 1.25em;}
</style>
<BODY>
<? php
$path = "upload/";
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$file = $path.'../upload/'.$file;
if(is_file($file)) @$n_file++;
//if(is_dir($file)) @$n_dir++;
}
}
closedir($handle);
}
?>
<div align="center"><hr><div class="titolo">*FILE PRESENTI (<?=$n_file?>)*</div><br><font color="green"><?php echo (date("d/m/Y G:i")); ?></font></hr><br><hr>[<a href="visualizza_file.php<?php session_start(); echo "?PHPSESSID=".session_id(); ?>">Aggiorna</a>] [<a href="upload_file.php<?php session_start(); echo "?PHPSESSID=".session_id(); ?>">Carica File</a>] [<a href="homepage.php<?php session_start(); echo "?PHPSESSID=".session_id(); ?>">Homepage</a>] </hr><br><hr>
<?php
$path = "../../upload/";
$cartella = opendir('upload/');
while ($file = readdir($cartella)) {
$file_array[] = $file;
}
foreach ($file_array as $file) {
# se il file inizia con .. lo tralascio
if ( $file == ".." || $file == ".") {
continue;
}
#trovo i file e creo il link
$e=substr(strrchr($file, "."), 0); // rimuovo l'estensione
$a="";
$b=" ";
$nome1=ereg_replace($e, $a, $file);
$nome=ereg_replace("_", "$b", $nome1);
echo "<font color=\"red\"><a href=\"upload/$file\" title=\"$nome\" class=\"link1\">$nome</a></font><br>";
//questo crea il link
}
?>
</hr>
</BODY>
</HTML>
se vado dalla homepage al visualizza file.php funziona , se vado dal visualizza alla homepage non funziona