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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
<?php if (session_id() === "") { session_start(); }
//new pdo define("PRODUCTION", 0);
if (PRODUCTION == 1) { $dbh2 = new PDO("mysql:host=localhost;dbname=muscircledb", "muscirclesa", "Mus.#0933"); error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); ini_set('display_errors', 0); } else { $dbh2 = new PDO("mysql:host=192.168.171.23;dbname=dev_imusiccircle", "admin", "PHac7dru"); error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); ini_set('display_errors', 1); }
$dbh2->exec("set names utf8");
date_default_timezone_set("Asia/Hong_Kong");
//get member data if (!function_exists('dump_sql')) { function dump_sql($sql, $parameters) { $keys = array();
# build a regular expression for each parameter foreach ($parameters as $key => $value) { if (is_string($key)) { $keys[] = '/:' . $key . '/'; } else { $keys[] = '/[?]/'; } }
foreach ($parameters as $key2 => $value) { $parameters[$key2] = "'" . $value . "'"; }
$sql = preg_replace($keys, $parameters, $sql, 1, $count);
#trigger_error('replaced '.$count.' keys');
return $sql; } }
if (!function_exists('bind_pdo')) { function bind_pdo($sql, $parameters = NULL, $action = NULL) { global $dbh2;
if ($action == "insert" || $action == "update" || $action == "delete" || empty($action)) { if (!($sth = $dbh2->prepare($sql))) { debug_print_backtrace(); throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { debug_print_backtrace(); throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); } else { return true; } }
if ($action == "selectone") { if (!($sth = $dbh2->prepare($sql))) { debug_print_backtrace(); throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { debug_print_backtrace(); throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
return $sth->fetch(PDO::FETCH_ASSOC);
}
if ($action == "selectall") { if (!($sth = $dbh2->prepare($sql))) { debug_print_backtrace(); throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { debug_print_backtrace(); throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
return $sth->fetchAll(PDO::FETCH_ASSOC);
}
if ($action == "dump") { return dump_sql($sql, $parameters); } } }
header('Content-Type: application/json; charset=utf-8');
//$_SESSION["app_device_id"] = 111; //$_SESSION["app_notification_token"] = 222;
/*"cannot_get_json_message" => "伺服器連接錯誤,請先檢查你的手機是否可以連接互聯網。", "confirm_close_app_message" => "確定離開?",*/
if ($_GET["action"] == "app_user_info") { $_SESSION["app_device_id"] = $_POST["app_device_id"]; $_SESSION["app_notification_token"] = $_POST["app_notification_token"];
if (!empty($_SESSION["app_device_id"]) && !empty($_SESSION["app_notification_token"])) { $response = array("success"); }else{ $response = array("fail"); }
echo json_encode($response); } else if ($_GET["action"] == "basic_info") { $response = array( "app_index_url" => "http://www.hkosl.com/m.musiccircle/index.php?key=dMuZetw5", "version" => "1.3.0", "ios_version" => "1.3.1", "force_update_word" => "應用程式已更新,請更新後再嘗試。", "force_update_link" => "https://play.google.com/store/apps/details?id=com.musiccircle&hl=zh-TW", "confirm_leave" => "確定離開?", "alert_box_right" => "確定", "alert_box_left" => "取消", );
echo json_encode($response); }
|