summaryrefslogtreecommitdiffstats
path: root/apis/webservice.inc.php
blob: 42ff674b848b3aba20d715bc80a0c9a45bdf0ba1 (plain) (blame)
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
<?php
// print results, insert id or affected row count
session_start();

if(!isset($_POST['request'])){
    echo json_encode(array(
        "errormsg"=>"Request not set, finishing session",
        "status" => "error",
        "msg" => ""));
    session_unset();
    session_destroy();
}else if($_POST['request']=='logout'){
    echo json_encode(array(
        "errormsg"=> "",
        "status" => "ok",
        "msg" => "Logout successful"));
    session_unset();
    session_destroy();

}else {
    $target_dir = "tmpUploads/";
    $requests = array("login","getinfo","upload","newupload");
    if( in_array($_POST['request'],$requests ))
        require("webservice/".$_POST['request'].".php");
    else{
        echo json_encode(array(
            "errormsg"=> "Request don't exist, finishing session",
            "status" => "error",
            "msg" => ""));
        session_unset();
        session_destroy();
    }
}
//TODO: analyze session unset/destroy