summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-03-26 09:31:24 +0100
committerSimon Rettberg2019-03-26 09:31:24 +0100
commit7c55bc72acbda4522767531f27fbbf51c2305bb6 (patch)
tree88cef613c38bcce0553bcc4b69ec3aa667d83734
parentDelete unused and unmaintained modules (diff)
downloadslx-admin-7c55bc72acbda4522767531f27fbbf51c2305bb6.tar.gz
slx-admin-7c55bc72acbda4522767531f27fbbf51c2305bb6.tar.xz
slx-admin-7c55bc72acbda4522767531f27fbbf51c2305bb6.zip
Delete unused legacy API too
-rw-r--r--apis/webservice.inc.php34
-rw-r--r--apis/webservice/getinfo.php25
-rw-r--r--apis/webservice/login.php23
-rw-r--r--apis/webservice/newupload.php67
-rw-r--r--apis/webservice/upload.php62
5 files changed, 0 insertions, 211 deletions
diff --git a/apis/webservice.inc.php b/apis/webservice.inc.php
deleted file mode 100644
index 42ff674b..00000000
--- a/apis/webservice.inc.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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
diff --git a/apis/webservice/getinfo.php b/apis/webservice/getinfo.php
deleted file mode 100644
index 3404008e..00000000
--- a/apis/webservice/getinfo.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-if(isset($_SESSION['userid'])){
- $sql = "select user.login, user.fullname, user.email, cities.name from"
- ." `user` left join cities on user.city=cities.cityid"
- ." where user.userid= :userid";
-
- $user=Database::queryFirst($sql, array("userid"=> $_SESSION['userid']));
- $ret = array(
- "login"=>$user['login'],
- "name"=>$user['fullname'],
- "email"=>$user['email'],
- "city"=>$user['name'],
- "errormsg" => "",
- "status" => "ok",
- "msg" => "Get informations of user successful"
- );
- echo json_encode($ret);
-
-}else{
- echo json_encode(array(
- "errormsg"=> "Not logged in",
- "status" => "error",
- "msg" => ""));
-}
-
diff --git a/apis/webservice/login.php b/apis/webservice/login.php
deleted file mode 100644
index e21975af..00000000
--- a/apis/webservice/login.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-$login = $_POST['login'];
-$sql = "select * from `user` WHERE login= :login";
-$user=Database::queryFirst($sql, array("login"=> $login));
-if($user){
- if(Crypto::verify($_POST['passwd'],$user['passwd'])){
- $_SESSION['userid']=$user['userid'];
- echo json_encode(array(
- "errormsg"=> "",
- "status" => "ok",
- "msg" => "Login successful"));
- }else{
- echo json_encode(array(
- "errormsg"=> "Wrong passwd",
- "status" => "error",
- "msg" => ""));
- }
-}else{
- echo json_encode(array(
- "errormsg"=> "User not found",
- "status" => "error",
- "msg" => ""));
-}
diff --git a/apis/webservice/newupload.php b/apis/webservice/newupload.php
deleted file mode 100644
index b0e683c3..00000000
--- a/apis/webservice/newupload.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-if(!isset($_SESSION['userid'])){
- echo json_encode(array(
- "errormsg"=>"Not logged in",
- "status" => "error",
- "msg" => ""));
- die();
-}
-if(!isset($_POST['nparts'])){
- echo json_encode(array(
- "errormsg"=>"Number of parts isn't set",
- "status" => "error",
- "msg" => ""));
- die();
-}
-
-function crypto_rand_secure($min, $max){
- $range = $max - $min;
- if ($range < 1) return $min; // not so random...
- $log = ceil(log($range, 2));
- $bytes = (int) ($log / 8) + 1; // length in bytes
- $bits = (int) $log + 1; // length in bits
- $filter = (int) (1 << $bits) - 1; // set all lower bits to 1
- do {
- $rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes)));
- $rnd = $rnd & $filter; // discard irrelevant bits
- } while ($rnd >= $range);
- return $min + $rnd;
-}
-
-function getToken($length){
- $token = "";
- $codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- $codeAlphabet.= "abcdefghijklmnopqrstuvwxyz";
- $codeAlphabet.= "0123456789";
- $max = strlen($codeAlphabet) - 1;
- for ($i=0; $i < $length; $i++) {
- $token .= $codeAlphabet[crypto_rand_secure(0, $max)];
- }
- return $token;
-}
-$token=getToken(35);
-while(Database::queryFirst("select * from upload where `token`=:token", array(
- "token" => $token))){
- $token = getToken(35);
-}
-$okay=Database::exec("INSERT INTO upload(`userid`, `nparts`, `nremaining`, `token`)".
- " values (:userid, :nparts, :nremaining, :token)", array(
- "userid"=>$_SESSION['userid'],
- "nparts"=>$_POST['nparts'],
- "nremaining"=>$_POST['nparts'],
- "token"=> $token
- ));
-if($okay){
- echo json_encode(array(
- "uploadid"=>$token,
- "errormsg"=>"",
- "status" => "ok",
- "msg" => "New upload succesful"));
- mkdir($target_dir.$token."/",0755, true);
-}else{
- echo json_encode(array(
- "errormsg"=>"Error when saving new upload, please retry",
- "status" => "error",
- "msg" => ""));
-}
-
diff --git a/apis/webservice/upload.php b/apis/webservice/upload.php
deleted file mode 100644
index 50ada40e..00000000
--- a/apis/webservice/upload.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-if(!isset($_POST['uploadid'])){
- echo json_encode(array(
- "errormsg"=>"Not logged in",
- "status" => "error",
- "msg" => ""));
- die();
-}elseif (!isset($_FILES['fileToUpload'])){
- echo json_encode(array(
- "errormsg"=>"No file received",
- "status" => "error",
- "msg" => ""));
- die();
-}
-
-$upload = Database::queryFirst("Select * from upload where token = :token",
- array( "token" => $_POST['uploadid']));
-if($upload['userid']!= $_SESSION['userid']){
- echo json_encode(array(
- "errormsg"=>"Not same owner",
- "status" => "error",
- "msg" => ""));
- die();
-}
-
-$name = $_FILES["fileToUpload"]["name"];
-$upload['nremaining'] = $upload['nremaining'] - 1;
-if ($upload['nremaining'] < 0){
- echo json_encode(array(
- "errormsg"=>"Already received all the parts",
- "status" => "error",
- "msg" => ""));
- die();
-}
-$target_file = $target_dir.$_POST['uploadid']."/".$name;
-if(move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)){
- $ret = Database::exec("UPDATE upload SET nremaining= :nremaining".
- " WHERE id=:id", array(
- "id"=>$upload['id'],
- "nremaining"=>$upload['nremaining']
- ));
- if ($upload['nremaining'] == 0) {
- echo json_encode(array(
- "errormsg"=>"",
- "status" => "ok",
- "msg" => "Upload successful, sending to taskmanager"));
- //passa pro taskmanager;
- die();
- }else{
- echo json_encode(array(
- "errormsg"=>"",
- "status" => "ok",
- "msg" => "Upload successful, waiting next part"));
- die();
- }
-} else {
- echo json_encode(array(
- "errormsg"=>"",
- "status" => "error",
- "msg" => "Error on upload, please resend"));
-}
-