-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdelete.php
executable file
·32 lines (26 loc) · 1.12 KB
/
delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?
session_start();
include_once('globals.php');
$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
// Apre la risorsa SSH
$connection_handler = ssh2_connect($_SESSION['sshserver'],$_SESSION['sshport']);
if(!$connection_handler) {
die("[delete.php] Connection Failed: ". $_SESSION['sshserver']." at ".$_SESSION['sshport']);
}
// Esegue la autenticazione in SSH con password plain
$connection = ssh2_auth_password($connection_handler,$_SESSION['username'],$_SESSION['password']);
if (!$connection) {
die("[delete.php] AuthPass Connection Failed!");
}
$sftp = ssh2_sftp($connection_handler);
// Elimino il file, usando le risorse di connessione
$file = $_SESSION['home'].'/'.$_GET['file'];
if (!ssh2_sftp_unlink($sftp,$file)) {
die("[delete.php] Cannot delete file: ".$_GET['file']);
}
$redirect = "https://".$_SERVER['HTTP_HOST']."/jsubmit.php#ReloadExisting";
header('Location:'.$redirect);
?>