aboutsummaryrefslogtreecommitdiffstats
path: root/managing-ui/deleteFile.php
blob: 24f8c9c0c62de74942414be6191f2dde82fba8a2 (plain)
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
33
34
35
36
<?php

include_once(__DIR__.'/lib/functions.http.inc.php');
require_once(__DIR__."/XMPPClient.php");
session_start();

if (empty($_SESSION['JID']) || empty($_SESSION['authenticated']) || $_SESSION['authenticated'] != 'yeah') {
    header('Location: login.php');
    exit();
}

//
$jid = $_SESSION['JID'];
$password = $_SESSION['PASSWORD'];

$fileurl = $_POST['fileurl'];

if (null != $fileurl && "" != $fileurl) {
    try {
        $client = new XMPPClient($jid, $password, true);
        if ($client->login()) {
            $client->deleteFile($fileurl);
            $client->disconnect();
        } else {
            $data = ['error' => true, 'msg' => 'Failed to login'];
        }
    } catch (XMPPException $e) {
        $data = ['error' => true, 'msg' => $e->getMessage()];
    }
} else {
    $data = ['error' => true, 'msg' => 'Missing required file url to delete'];
}

sendHttpReturnCodeAndJson(200, $data);

?>