-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathredirect.php
45 lines (41 loc) · 1.24 KB
/
redirect.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
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
if(isset($_GET["code"])){
$servername = "xxx";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn){
die("Connection failed: " . mysqli_connect_error());
}
function get_result( $Statement ) {
$RESULT = array();
$Statement->store_result();
for ( $i = 0; $i < $Statement->num_rows; $i++ ) {
$Metadata = $Statement->result_metadata();
$PARAMS = array();
while ( $Field = $Metadata->fetch_field() ) {
$PARAMS[] = &$RESULT[ $i ][ $Field->name ];
}
call_user_func_array( array( $Statement, 'bind_result' ), $PARAMS );
$Statement->fetch();
}
return $RESULT;
}
$stmt = $conn->prepare("SELECT link FROM associations WHERE code=?");
$stmt->bind_param("s",$_GET["code"]);
$stmt->execute();
$result = get_result($stmt);
$stmt->close();
if(count($result)){
mysqli_close($conn);
header("Location: " . $result[0]["link"]);
}
else{
mysqli_close($conn);
header("Location: https://ed0.it/sl");
}
}
?>