-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
65 lines (56 loc) · 1.93 KB
/
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
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
65
<?php
/**
*
* @author Porntip Chaibamrung <pchaibamrung@gmail.com>
*
*/
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
date_default_timezone_set('UTC');
include_once './utilities.php';
// get the HTTP method, path and body of the request
$method = $_SERVER['REQUEST_METHOD'];
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
$uri = 'https://';
} else {
$uri = 'http://';
}
$uri .= $_SERVER['HTTP_HOST'];
$params = $_GET['params'];
error_log( "GET params data: " . $params );
$str_items = explode('/', $params);
$api_type = $str_items[0];
error_log( "API type: " . $api_type );
if($api_type === 'circle'){
if($method !== 'GET'){
returnNotOKResponse($method);
} else {
$post_fix_url = getPostfixRedirectURL($api_type);
if($post_fix_url === ""){
error_log( "Unable to get post fix URL." );
throw new Exception("Something wrong with request path string.");
}
$page = $uri . $post_fix_url . $str_items[1];
error_log( "Re-direct to: " . $page );
header('Location: '. $page);
}
} elseif($api_type === 'square'){
if($method !== 'GET'){
returnNotOKResponse($method);
} else {
$post_fix_url = getPostfixRedirectURL($api_type);
if($post_fix_url === ""){
error_log( "Unable to get post fix URL." );
throw new Exception("Something wrong with request path string.");
}
$page = $uri . $post_fix_url . $_GET['length'];
error_log( "Re-direct to: " . $page );
header('Location: '. $page);
}
} else {
error_log( "Unsupported API type: " . $api_type );
header('Location: '.$uri.'/dashboard/');
}
exit;
?>
Something is wrong with the XAMPP installation :-(