This repository was archived by the owner on Jan 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAPI.php
More file actions
64 lines (42 loc) · 1.52 KB
/
API.php
File metadata and controls
64 lines (42 loc) · 1.52 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
include("assets/php/connect.php");
if(isset($_GET['Authorization'])){
if(isset($_POST['link'])) {
$sql = "SELECT * FROM api WHERE token='" . $_GET['Authorization'] . "'";
$rs = mysqli_query($con,$sql);
$row = mysqli_fetch_array($rs);
$count = mysqli_num_rows($rs);
if($count == 1){
$sql2 = "SELECT * FROM skinnylinks WHERE url='" . $_POST['link'] . "' AND username='" . $row['user'] . "'";
$rs2 = mysqli_query($con, $sql2);
$row2 = mysqli_fetch_array($rs2);
$count2 = mysqli_num_rows($rs2);
if($count2 == 1){
echo "{\"short\": \"" . $row2["shorter"] . "\"}";
} else {
$found = 0;
$shorter = "TEST";
while($found == 0){
$shorter = bin2hex(openssl_random_pseudo_bytes(4));
$sql = "SELECT * FROM skinnylinks WHERE shorter='" . $shorter . "'";
$rs = mysqli_query($con,$sql);
$count = mysqli_num_rows($rs);
if($count == 0){
$found = 1;
mysqli_query($con, "INSERT INTO `skinnylinks` (username, url, shorter, clicks) VALUES ('" . $row['user'] . "', '" . $_POST['link'] . "', '$shorter', '0')");
$_SESSION["message"] = "https://iloot.it/minilinks?m=$shorter";
}
}
echo "{\"short\": \"" . $shorter . "\"}";
}
} else {
echo "{\"error\": \"Authorization header not vailid(".$headers['Authorization'].")\"}";
}
} else {
echo "{\"error\": \"Post link not set\"}";
}
} else {
echo "{\"error\": \"no Authorization header\"}";
}
header('Content-Type: application/json');
?>