-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
32 lines (32 loc) · 956 Bytes
/
index.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
<?php
require "setup.php";
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = substr(str_shuffle($characters),0,$length);
return $randomString;
}
if(isset($_POST["data"])){
$data=$_POST["data"];
for($i=0;$i<=10;$i+=1){
$hash=generateRandomString();
$query="INSERT INTO `lightxlab`(`HASHKEY`, `DATA`) VALUES ('$hash','$data')";
$result = mysqli_query($myConnection,$query);
if($result)break;
}
echo $hash;
exit();
}
else if(isset($_POST["retrieve"])){
$query="SELECT * FROM `lightxlab` WHERE HASHKEY='$_POST[retrieve]'";
$result = mysqli_query($myConnection,$query);
$data=mysqli_fetch_assoc($result)["DATA"];
if($data){
echo $data;
}
else echo "ERROR";
// echo '{"mirrorList":[],"sphericalMirrorList":[],"lightRayList":[],"radialSourceList":[],"lightBeamList":[]}';
exit();
}
else
require("index.html");
?>