@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | if(isset($_GET['postId']) && $_GET['vote']) |
6 | 6 | { |
7 | 7 | header('Content-Type: application/json'); |
8 | - echo json_encode($jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote'])); |
|
9 | - die(); |
|
8 | + echo json_encode($jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote'])); |
|
9 | + die(); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | if(isset($_GET['solution']) && isset($_POST['deviceUid'])) |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | WHERE user_token='" . $_COOKIE['JodelVoterPassword'] . "'"); |
129 | 129 | if($result === false) |
130 | 130 | { |
131 | - error_log("Update remaining votes failed: (" . $db->errno . ") " . $db->error); |
|
132 | - } |
|
131 | + error_log("Update remaining votes failed: (" . $db->errno . ") " . $db->error); |
|
132 | + } |
|
133 | 133 | |
134 | 134 | $jodelAccount->votePostId($_POST['postId'], $_POST['vote']); |
135 | 135 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | |
22 | 22 | if(!$userIsVoter && !$userIsAdmin) |
23 | 23 | { |
24 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
25 | - $response = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
24 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
25 | + $response = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php', "success" => false); |
|
26 | 26 | echo json_encode($response); |
27 | 27 | die(); |
28 | 28 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | - if (isset($captcha)) |
|
144 | + if(isset($captcha)) |
|
145 | 145 | { |
146 | 146 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid); |
147 | 147 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | if(!$userIsVoter && !$userIsAdmin) |
23 | 23 | { |
24 | 24 | error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
25 | - $response = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
25 | + $response = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => FALSE); |
|
26 | 26 | echo json_encode($response); |
27 | 27 | die(); |
28 | 28 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | if($remaining_votes <= 0) |
40 | 40 | { |
41 | 41 | $message = 'This voter account run out of votes. For more information please contact [email protected]'; |
42 | - $success = false; |
|
42 | + $success = FALSE; |
|
43 | 43 | |
44 | 44 | $response = array("success" => $success, "message" => $message); |
45 | 45 | echo json_encode($response); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | $message = ""; |
52 | - $success = true; |
|
52 | + $success = TRUE; |
|
53 | 53 | $token = ""; |
54 | 54 | if(isset($_POST['vote']) && isset($_POST['postId'])) |
55 | 55 | { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | //$response = array("success" => $jodelAccount->verifyCaptcha()); |
119 | 119 | //echo json_encode($response); |
120 | 120 | //die(); |
121 | - $success = false; |
|
121 | + $success = FALSE; |
|
122 | 122 | } |
123 | 123 | else |
124 | 124 | { |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $result = $db->query("UPDATE users |
127 | 127 | SET remaining_votes='" . $remaining_votes . "' |
128 | 128 | WHERE user_token='" . $_COOKIE['JodelVoterPassword'] . "'"); |
129 | - if($result === false) |
|
129 | + if($result === FALSE) |
|
130 | 130 | { |
131 | 131 | error_log("Update remaining votes failed: (" . $db->errno . ") " . $db->error); |
132 | 132 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | else |
138 | 138 | { |
139 | 139 | $message = 'There is no account available for this jodel. Please create at least one new account to vote this jodel.'; |
140 | - $success = false; |
|
140 | + $success = FALSE; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 |
@@ -2,21 +2,21 @@ discard block |
||
2 | 2 | |
3 | 3 | abstract class AbstractRequest |
4 | 4 | { |
5 | - const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
6 | - const APIURL = 'https://api.go-tellm.com/api'; |
|
7 | - const SECRET = 'cYjTAwjdJyiuXAyrMhkCDiVZhshhLhotNotLiPVu'; |
|
8 | - const USERAGENT = 'Jodel/4.35.6 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
9 | - const CLIENT_TYPE = 'android_4.35.6'; |
|
5 | + const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
6 | + const APIURL = 'https://api.go-tellm.com/api'; |
|
7 | + const SECRET = 'cYjTAwjdJyiuXAyrMhkCDiVZhshhLhotNotLiPVu'; |
|
8 | + const USERAGENT = 'Jodel/4.35.6 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
9 | + const CLIENT_TYPE = 'android_4.35.6'; |
|
10 | 10 | |
11 | - private $accessToken = null; |
|
12 | - private $payLoad; |
|
13 | - public $expects = ''; |
|
14 | - public $version = 'v2'; |
|
15 | - public $hasPayload = FALSE; |
|
11 | + private $accessToken = null; |
|
12 | + private $payLoad; |
|
13 | + public $expects = ''; |
|
14 | + public $version = 'v2'; |
|
15 | + public $hasPayload = FALSE; |
|
16 | 16 | |
17 | - public function execute() |
|
18 | - { |
|
19 | - $result = new \stdClass(); |
|
17 | + public function execute() |
|
18 | + { |
|
19 | + $result = new \stdClass(); |
|
20 | 20 | |
21 | 21 | $this->payLoad = $this->getPayload(); |
22 | 22 | $device_uid = ''; |
@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | - $this->payLoad = json_encode($this->payLoad); |
|
29 | - $header = $this->getSignHeaders(); |
|
30 | - $url = $this->getFullUrl(); |
|
28 | + $this->payLoad = json_encode($this->payLoad); |
|
29 | + $header = $this->getSignHeaders(); |
|
30 | + $url = $this->getFullUrl(); |
|
31 | 31 | |
32 | - if ($this->getAccessToken()) { |
|
33 | - $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
34 | - } |
|
35 | - //Comment out to debug the Request: |
|
32 | + if ($this->getAccessToken()) { |
|
33 | + $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
34 | + } |
|
35 | + //Comment out to debug the Request: |
|
36 | 36 | |
37 | - /* |
|
37 | + /* |
|
38 | 38 | printf("URL: "); |
39 | 39 | var_dump($url); |
40 | 40 | echo "<br />"; |
@@ -45,112 +45,112 @@ discard block |
||
45 | 45 | var_dump($this->payLoad); |
46 | 46 | echo "<br />"; |
47 | 47 | */ |
48 | - /* |
|
48 | + /* |
|
49 | 49 | $options = array( |
50 | 50 | 'timeout' => 100, |
51 | 51 | 'connect_timeout' => 100, |
52 | 52 | 'proxy' => '186.103.169.165:8080', |
53 | 53 | );*/ |
54 | 54 | |
55 | - switch ($this->getMethod()) { |
|
56 | - case 'POST': |
|
57 | - $result = Requests::post($url, $header, $this->payLoad); |
|
58 | - break; |
|
59 | - case 'GET': |
|
60 | - if($this->hasPayload) |
|
61 | - { |
|
62 | - $result = Requests::get($url, $header, $this->payLoad); |
|
63 | - } |
|
64 | - else |
|
65 | - { |
|
66 | - $result = Requests::get($url, $header); |
|
67 | - } |
|
68 | - break; |
|
69 | - case 'PUT': |
|
70 | - $result = Requests::put($url, $header, $this->payLoad); |
|
71 | - break; |
|
72 | - } |
|
55 | + switch ($this->getMethod()) { |
|
56 | + case 'POST': |
|
57 | + $result = Requests::post($url, $header, $this->payLoad); |
|
58 | + break; |
|
59 | + case 'GET': |
|
60 | + if($this->hasPayload) |
|
61 | + { |
|
62 | + $result = Requests::get($url, $header, $this->payLoad); |
|
63 | + } |
|
64 | + else |
|
65 | + { |
|
66 | + $result = Requests::get($url, $header); |
|
67 | + } |
|
68 | + break; |
|
69 | + case 'PUT': |
|
70 | + $result = Requests::put($url, $header, $this->payLoad); |
|
71 | + break; |
|
72 | + } |
|
73 | 73 | |
74 | - http_response_code($result->status_code); |
|
74 | + http_response_code($result->status_code); |
|
75 | 75 | |
76 | - switch ($result->status_code) { |
|
77 | - case 200: |
|
78 | - $result = json_decode($result->body, true); |
|
79 | - break; |
|
80 | - case 204: |
|
81 | - $result = 'Success'; |
|
82 | - http_response_code(200); |
|
83 | - break; |
|
84 | - case 400: |
|
85 | - $result = json_decode($result->body, true); |
|
86 | - error_log('Error 400 - ' . print_r($result, true)); |
|
87 | - break; |
|
88 | - case 401: |
|
89 | - $result = json_decode($result->body, true); |
|
76 | + switch ($result->status_code) { |
|
77 | + case 200: |
|
78 | + $result = json_decode($result->body, true); |
|
79 | + break; |
|
80 | + case 204: |
|
81 | + $result = 'Success'; |
|
82 | + http_response_code(200); |
|
83 | + break; |
|
84 | + case 400: |
|
85 | + $result = json_decode($result->body, true); |
|
86 | + error_log('Error 400 - ' . print_r($result, true)); |
|
87 | + break; |
|
88 | + case 401: |
|
89 | + $result = json_decode($result->body, true); |
|
90 | 90 | |
91 | - if(array_key_exists('error', $result) && $result['error'] == 'length') |
|
92 | - { |
|
91 | + if(array_key_exists('error', $result) && $result['error'] == 'length') |
|
92 | + { |
|
93 | 93 | |
94 | - } |
|
95 | - else |
|
96 | - { |
|
97 | - error_log('Error 401 - ' . print_r($result, true)); |
|
98 | - } |
|
99 | - break; |
|
100 | - case 404: |
|
101 | - error_log('Error 404 - ' . print_r($result, true)); |
|
102 | - $result = json_decode($result->body, true); |
|
103 | - break; |
|
94 | + } |
|
95 | + else |
|
96 | + { |
|
97 | + error_log('Error 401 - ' . print_r($result, true)); |
|
98 | + } |
|
99 | + break; |
|
100 | + case 404: |
|
101 | + error_log('Error 404 - ' . print_r($result, true)); |
|
102 | + $result = json_decode($result->body, true); |
|
103 | + break; |
|
104 | 104 | case 477: |
105 | - $result = json_decode($result->body, true); |
|
106 | - error_log('Error 477 - ' . print_r($result, true)); |
|
107 | - break; |
|
108 | - case 429: |
|
109 | - error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
110 | - exit("Error 429: Too Many Requests"); |
|
111 | - break; |
|
112 | - case 403: |
|
113 | - error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
114 | - $result = json_decode($result->body, true); |
|
115 | - break; |
|
116 | - case 502: |
|
117 | - error_log('Error 502 - ' . print_r($result, true)); |
|
118 | - $result = json_decode($result->body, true); |
|
119 | - header('location:'.$_SERVER['PHP_SELF']); |
|
120 | - break; |
|
121 | - case 503: |
|
122 | - error_log('Error 503 - ' . print_r($result, true)); |
|
123 | - $result = json_decode($result->body, true); |
|
105 | + $result = json_decode($result->body, true); |
|
106 | + error_log('Error 477 - ' . print_r($result, true)); |
|
107 | + break; |
|
108 | + case 429: |
|
109 | + error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
110 | + exit("Error 429: Too Many Requests"); |
|
111 | + break; |
|
112 | + case 403: |
|
113 | + error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
114 | + $result = json_decode($result->body, true); |
|
115 | + break; |
|
116 | + case 502: |
|
117 | + error_log('Error 502 - ' . print_r($result, true)); |
|
118 | + $result = json_decode($result->body, true); |
|
119 | + header('location:'.$_SERVER['PHP_SELF']); |
|
120 | + break; |
|
121 | + case 503: |
|
122 | + error_log('Error 503 - ' . print_r($result, true)); |
|
123 | + $result = json_decode($result->body, true); |
|
124 | 124 | |
125 | - if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable') |
|
126 | - { |
|
127 | - header('location:'.$_SERVER['PHP_SELF']); |
|
128 | - } |
|
129 | - break; |
|
130 | - default: |
|
131 | - error_log('Error '.$result->status_code.' - unknown error'); |
|
132 | - $result = json_decode($result->body, true); |
|
133 | - } |
|
125 | + if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable') |
|
126 | + { |
|
127 | + header('location:'.$_SERVER['PHP_SELF']); |
|
128 | + } |
|
129 | + break; |
|
130 | + default: |
|
131 | + error_log('Error '.$result->status_code.' - unknown error'); |
|
132 | + $result = json_decode($result->body, true); |
|
133 | + } |
|
134 | 134 | |
135 | - //important for account refresh |
|
136 | - if($device_uid != '') |
|
137 | - { |
|
135 | + //important for account refresh |
|
136 | + if($device_uid != '') |
|
137 | + { |
|
138 | 138 | $result[0] = $result; |
139 | 139 | $result[1] = $device_uid; |
140 | - } |
|
140 | + } |
|
141 | 141 | |
142 | 142 | |
143 | - /* var_dump($result); */ |
|
143 | + /* var_dump($result); */ |
|
144 | 144 | |
145 | - return $result; |
|
146 | - } |
|
147 | - abstract function getPayload(); |
|
148 | - /** |
|
149 | - * Gets Sign headers |
|
150 | - * @return array headers |
|
151 | - */ |
|
152 | - private function getSignHeaders() |
|
153 | - { |
|
145 | + return $result; |
|
146 | + } |
|
147 | + abstract function getPayload(); |
|
148 | + /** |
|
149 | + * Gets Sign headers |
|
150 | + * @return array headers |
|
151 | + */ |
|
152 | + private function getSignHeaders() |
|
153 | + { |
|
154 | 154 | if($this->getAccessToken() == null) { |
155 | 155 | $payload_accessToken = ""; |
156 | 156 | } |
@@ -159,54 +159,54 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | - $headers = array( |
|
163 | - "Connection" => "keep-alive", |
|
164 | - "Accept-Encoding" => "gzip", |
|
165 | - "Content-Type" => "application/json; charset=UTF-8", |
|
166 | - "User-Agent" => self::USERAGENT |
|
167 | - ); |
|
168 | - $timestamp = new DateTime(); |
|
169 | - $timestamp = $timestamp->format(DateTime::ATOM); |
|
170 | - $timestamp = substr($timestamp, 0, -6); |
|
171 | - $timestamp .= "Z"; |
|
172 | - $urlParts = parse_url($this->getFullUrl()); |
|
173 | - $url2 = ""; |
|
174 | - $req = [$this->getMethod(), |
|
175 | - $urlParts['host'], |
|
176 | - "443", |
|
177 | - $urlParts['path'], |
|
178 | - $payload_accessToken, |
|
179 | - $timestamp, |
|
180 | - $url2, |
|
181 | - $this->payLoad]; |
|
182 | - $reqString = implode("%", $req); |
|
183 | - $secret = self::SECRET; |
|
184 | - $signature = hash_hmac('sha1', $reqString, $secret); |
|
185 | - $signature = strtoupper($signature); |
|
186 | - $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
187 | - $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
188 | - $headers['X-Timestamp'] = $timestamp; |
|
189 | - $headers['X-Api-Version'] = '0.2'; |
|
190 | - return $headers; |
|
191 | - } |
|
192 | - private function getFullUrl() |
|
193 | - { |
|
194 | - return self::APIURL . $this->getApiEndPoint(); |
|
195 | - } |
|
196 | - abstract function getApiEndPoint(); |
|
197 | - abstract function getMethod(); |
|
198 | - /** |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - private function getAccessToken() |
|
202 | - { |
|
203 | - return $this->accessToken; |
|
204 | - } |
|
205 | - /** |
|
206 | - * @param string $accessToken |
|
207 | - */ |
|
208 | - public function setAccessToken($accessToken) |
|
209 | - { |
|
210 | - $this->accessToken = $accessToken; |
|
211 | - } |
|
162 | + $headers = array( |
|
163 | + "Connection" => "keep-alive", |
|
164 | + "Accept-Encoding" => "gzip", |
|
165 | + "Content-Type" => "application/json; charset=UTF-8", |
|
166 | + "User-Agent" => self::USERAGENT |
|
167 | + ); |
|
168 | + $timestamp = new DateTime(); |
|
169 | + $timestamp = $timestamp->format(DateTime::ATOM); |
|
170 | + $timestamp = substr($timestamp, 0, -6); |
|
171 | + $timestamp .= "Z"; |
|
172 | + $urlParts = parse_url($this->getFullUrl()); |
|
173 | + $url2 = ""; |
|
174 | + $req = [$this->getMethod(), |
|
175 | + $urlParts['host'], |
|
176 | + "443", |
|
177 | + $urlParts['path'], |
|
178 | + $payload_accessToken, |
|
179 | + $timestamp, |
|
180 | + $url2, |
|
181 | + $this->payLoad]; |
|
182 | + $reqString = implode("%", $req); |
|
183 | + $secret = self::SECRET; |
|
184 | + $signature = hash_hmac('sha1', $reqString, $secret); |
|
185 | + $signature = strtoupper($signature); |
|
186 | + $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
187 | + $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
188 | + $headers['X-Timestamp'] = $timestamp; |
|
189 | + $headers['X-Api-Version'] = '0.2'; |
|
190 | + return $headers; |
|
191 | + } |
|
192 | + private function getFullUrl() |
|
193 | + { |
|
194 | + return self::APIURL . $this->getApiEndPoint(); |
|
195 | + } |
|
196 | + abstract function getApiEndPoint(); |
|
197 | + abstract function getMethod(); |
|
198 | + /** |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + private function getAccessToken() |
|
202 | + { |
|
203 | + return $this->accessToken; |
|
204 | + } |
|
205 | + /** |
|
206 | + * @param string $accessToken |
|
207 | + */ |
|
208 | + public function setAccessToken($accessToken) |
|
209 | + { |
|
210 | + $this->accessToken = $accessToken; |
|
211 | + } |
|
212 | 212 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | abstract class AbstractRequest |
4 | -{ |
|
4 | +{ |
|
5 | 5 | const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
6 | 6 | const APIURL = 'https://api.go-tellm.com/api'; |
7 | 7 | const SECRET = 'cYjTAwjdJyiuXAyrMhkCDiVZhshhLhotNotLiPVu'; |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | |
21 | 21 | $this->payLoad = $this->getPayload(); |
22 | 22 | $device_uid = ''; |
23 | - if(isset($this->payLoad['device_uid'])) { |
|
23 | + if(isset($this->payLoad['device_uid'])) |
|
24 | + { |
|
24 | 25 | $device_uid = $this->payLoad['device_uid']; |
25 | 26 | } |
26 | 27 | |
@@ -29,7 +30,8 @@ discard block |
||
29 | 30 | $header = $this->getSignHeaders(); |
30 | 31 | $url = $this->getFullUrl(); |
31 | 32 | |
32 | - if ($this->getAccessToken()) { |
|
33 | + if ($this->getAccessToken()) |
|
34 | + { |
|
33 | 35 | $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
34 | 36 | } |
35 | 37 | //Comment out to debug the Request: |
@@ -52,7 +54,8 @@ discard block |
||
52 | 54 | 'proxy' => '186.103.169.165:8080', |
53 | 55 | );*/ |
54 | 56 | |
55 | - switch ($this->getMethod()) { |
|
57 | + switch ($this->getMethod()) |
|
58 | + { |
|
56 | 59 | case 'POST': |
57 | 60 | $result = Requests::post($url, $header, $this->payLoad); |
58 | 61 | break; |
@@ -73,7 +76,8 @@ discard block |
||
73 | 76 | |
74 | 77 | http_response_code($result->status_code); |
75 | 78 | |
76 | - switch ($result->status_code) { |
|
79 | + switch ($result->status_code) |
|
80 | + { |
|
77 | 81 | case 200: |
78 | 82 | $result = json_decode($result->body, true); |
79 | 83 | break; |
@@ -151,10 +155,12 @@ discard block |
||
151 | 155 | */ |
152 | 156 | private function getSignHeaders() |
153 | 157 | { |
154 | - if($this->getAccessToken() == null) { |
|
158 | + if($this->getAccessToken() == null) |
|
159 | + { |
|
155 | 160 | $payload_accessToken = ""; |
156 | 161 | } |
157 | - else { |
|
162 | + else |
|
163 | + { |
|
158 | 164 | $payload_accessToken = $this->getAccessToken(); |
159 | 165 | } |
160 | 166 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | const USERAGENT = 'Jodel/4.35.6 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
9 | 9 | const CLIENT_TYPE = 'android_4.35.6'; |
10 | 10 | |
11 | - private $accessToken = null; |
|
11 | + private $accessToken = NULL; |
|
12 | 12 | private $payLoad; |
13 | 13 | public $expects = ''; |
14 | 14 | public $version = 'v2'; |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | |
76 | 76 | switch ($result->status_code) { |
77 | 77 | case 200: |
78 | - $result = json_decode($result->body, true); |
|
78 | + $result = json_decode($result->body, TRUE); |
|
79 | 79 | break; |
80 | 80 | case 204: |
81 | 81 | $result = 'Success'; |
82 | 82 | http_response_code(200); |
83 | 83 | break; |
84 | 84 | case 400: |
85 | - $result = json_decode($result->body, true); |
|
86 | - error_log('Error 400 - ' . print_r($result, true)); |
|
85 | + $result = json_decode($result->body, TRUE); |
|
86 | + error_log('Error 400 - ' . print_r($result, TRUE)); |
|
87 | 87 | break; |
88 | 88 | case 401: |
89 | - $result = json_decode($result->body, true); |
|
89 | + $result = json_decode($result->body, TRUE); |
|
90 | 90 | |
91 | 91 | if(array_key_exists('error', $result) && $result['error'] == 'length') |
92 | 92 | { |
@@ -94,33 +94,33 @@ discard block |
||
94 | 94 | } |
95 | 95 | else |
96 | 96 | { |
97 | - error_log('Error 401 - ' . print_r($result, true)); |
|
97 | + error_log('Error 401 - ' . print_r($result, TRUE)); |
|
98 | 98 | } |
99 | 99 | break; |
100 | 100 | case 404: |
101 | - error_log('Error 404 - ' . print_r($result, true)); |
|
102 | - $result = json_decode($result->body, true); |
|
101 | + error_log('Error 404 - ' . print_r($result, TRUE)); |
|
102 | + $result = json_decode($result->body, TRUE); |
|
103 | 103 | break; |
104 | 104 | case 477: |
105 | - $result = json_decode($result->body, true); |
|
106 | - error_log('Error 477 - ' . print_r($result, true)); |
|
105 | + $result = json_decode($result->body, TRUE); |
|
106 | + error_log('Error 477 - ' . print_r($result, TRUE)); |
|
107 | 107 | break; |
108 | 108 | case 429: |
109 | - error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
109 | + error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, TRUE), TRUE)); |
|
110 | 110 | exit("Error 429: Too Many Requests"); |
111 | 111 | break; |
112 | 112 | case 403: |
113 | - error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
114 | - $result = json_decode($result->body, true); |
|
113 | + error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, TRUE), TRUE)); |
|
114 | + $result = json_decode($result->body, TRUE); |
|
115 | 115 | break; |
116 | 116 | case 502: |
117 | - error_log('Error 502 - ' . print_r($result, true)); |
|
118 | - $result = json_decode($result->body, true); |
|
117 | + error_log('Error 502 - ' . print_r($result, TRUE)); |
|
118 | + $result = json_decode($result->body, TRUE); |
|
119 | 119 | header('location:'.$_SERVER['PHP_SELF']); |
120 | 120 | break; |
121 | 121 | case 503: |
122 | - error_log('Error 503 - ' . print_r($result, true)); |
|
123 | - $result = json_decode($result->body, true); |
|
122 | + error_log('Error 503 - ' . print_r($result, TRUE)); |
|
123 | + $result = json_decode($result->body, TRUE); |
|
124 | 124 | |
125 | 125 | if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable') |
126 | 126 | { |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | break; |
130 | 130 | default: |
131 | 131 | error_log('Error '.$result->status_code.' - unknown error'); |
132 | - $result = json_decode($result->body, true); |
|
132 | + $result = json_decode($result->body, TRUE); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | //important for account refresh |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | private function getSignHeaders() |
153 | 153 | { |
154 | - if($this->getAccessToken() == null) { |
|
154 | + if($this->getAccessToken() == NULL) { |
|
155 | 155 | $payload_accessToken = ""; |
156 | 156 | } |
157 | 157 | else { |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | |
6 | 6 | if(isset($_GET['pw'])) |
7 | 7 | { |
8 | - setcookie('JodelAdminPassword', $_GET['pw'], time()+60*60*24*365*10); |
|
8 | + setcookie('JodelAdminPassword', $_GET['pw'], time() + 60 * 60 * 24 * 365 * 10); |
|
9 | 9 | error_log('admin password saved for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
10 | 10 | header('Location: ' . $baseUrl . 'admin.php'); |
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | else if(isset($_GET['voterPw'])) |
14 | 14 | { |
15 | - setcookie('JodelVoterPassword', $_GET['voterPw'], time()+60*60*24*365*10); |
|
15 | + setcookie('JodelVoterPassword', $_GET['voterPw'], time() + 60 * 60 * 24 * 365 * 10); |
|
16 | 16 | error_log('voter password saved for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
17 | 17 | header('Location: ' . $baseUrl . 'admin.php'); |
18 | 18 | exit; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | else |
44 | 44 | { |
45 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong voterPw / pw on admin.php'); |
|
45 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong voterPw / pw on admin.php'); |
|
46 | 46 | die(); |
47 | 47 | } |
48 | 48 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | . "','" . $db->escape_string($_POST['device_uid']) |
63 | 63 | . "','" . $db->escape_string($_POST['rights']) . "')"); |
64 | 64 | |
65 | - if($result === false){ |
|
65 | + if($result === false) { |
|
66 | 66 | $error = db_error(); |
67 | 67 | error_log($error); |
68 | 68 | error_log("Adding Voter failed: (" . $result->errno . ") " . $result->error); |
@@ -110,42 +110,42 @@ discard block |
||
110 | 110 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client"> |
111 | 111 | |
112 | 112 | <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous"> |
113 | - <link rel="stylesheet" href="<?php echo $baseUrl;?>css/font-awesome.min.css"> |
|
114 | - <link rel="stylesheet" href="<?php echo $baseUrl;?>style.css" type="text/css"> |
|
113 | + <link rel="stylesheet" href="<?php echo $baseUrl; ?>css/font-awesome.min.css"> |
|
114 | + <link rel="stylesheet" href="<?php echo $baseUrl; ?>style.css" type="text/css"> |
|
115 | 115 | |
116 | - <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
|
117 | - <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
|
118 | - <link rel="icon" type="image/gif" href="<?php echo $baseUrl;?>img/favicon/favicon.gif"> |
|
119 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon.png"> |
|
120 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon.png"> |
|
121 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
|
122 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
|
123 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
|
124 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
|
125 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
|
126 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
|
127 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
|
128 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
|
129 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
|
130 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
|
131 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-precomposed.png"> |
|
132 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-16x16.png" sizes="16x16"> |
|
133 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-32x32.png" sizes="32x32"> |
|
134 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-96x96.png" sizes="96x96"> |
|
135 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-160x160.png" sizes="160x160"> |
|
136 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-192x192.png" sizes="192x192"> |
|
137 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-196x196.png" sizes="196x196"> |
|
138 | - <meta name="msapplication-TileImage" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
|
116 | + <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl; ?>img/favicon/favicon.ico"> |
|
117 | + <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl; ?>img/favicon/favicon.ico"> |
|
118 | + <link rel="icon" type="image/gif" href="<?php echo $baseUrl; ?>img/favicon/favicon.gif"> |
|
119 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon.png"> |
|
120 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon.png"> |
|
121 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
|
122 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
|
123 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
|
124 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
|
125 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
|
126 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
|
127 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
|
128 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
|
129 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
|
130 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
|
131 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-precomposed.png"> |
|
132 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-16x16.png" sizes="16x16"> |
|
133 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-32x32.png" sizes="32x32"> |
|
134 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-96x96.png" sizes="96x96"> |
|
135 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-160x160.png" sizes="160x160"> |
|
136 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-192x192.png" sizes="192x192"> |
|
137 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-196x196.png" sizes="196x196"> |
|
138 | + <meta name="msapplication-TileImage" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-144x144.png"> |
|
139 | 139 | <meta name="msapplication-TileColor" content="#5682a3"> |
140 | 140 | <meta name="msapplication-navbutton-color" content="#5682a3"> |
141 | 141 | <meta name="application-name" content="JodelBlue"/> |
142 | 142 | <meta name="msapplication-tooltip" content="JodelBlue"/> |
143 | 143 | <meta name="apple-mobile-web-app-title" content="JodelBlue"/> |
144 | - <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-70x70.png"> |
|
145 | - <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
|
146 | - <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-150x150.png"> |
|
147 | - <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x150.png"> |
|
148 | - <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x310.png"> |
|
144 | + <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-70x70.png"> |
|
145 | + <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-144x144.png"> |
|
146 | + <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-150x150.png"> |
|
147 | + <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-310x150.png"> |
|
148 | + <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-310x310.png"> |
|
149 | 149 | </head> |
150 | 150 | |
151 | 151 | <body> |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | ?> |
217 | 217 | <div class="row"> |
218 | 218 | <div class="col-12 col-sm-12"> |
219 | - <h2>Voting (<?php echo $votesRemaining;?> votes remaining)</h2> |
|
219 | + <h2>Voting (<?php echo $votesRemaining; ?> votes remaining)</h2> |
|
220 | 220 | <form> |
221 | 221 | <div class="form-group"> |
222 | 222 | <label for="quantityDelay">Quantity</label> |
@@ -224,15 +224,15 @@ discard block |
||
224 | 224 | </div> |
225 | 225 | <div class="form-group"> |
226 | 226 | <label for="minDelay">Minimum delay</label> |
227 | - <input placeholder="min interval" class="form-control" id="minDelay" value="<?php echo $config['minInterval'];?>" type="number" name="min"> |
|
227 | + <input placeholder="min interval" class="form-control" id="minDelay" value="<?php echo $config['minInterval']; ?>" type="number" name="min"> |
|
228 | 228 | </div> |
229 | 229 | <div class="form-group"> |
230 | 230 | <label for="maxDelay">Maximum delay</label> |
231 | - <input placeholder="max interval" class="form-control" id="maxDelay" value="<?php echo $config['maxInterval'];?>" type="number" name="max"> |
|
231 | + <input placeholder="max interval" class="form-control" id="maxDelay" value="<?php echo $config['maxInterval']; ?>" type="number" name="max"> |
|
232 | 232 | </div> |
233 | 233 | <div class="form-group"> |
234 | 234 | <label for="postIdDelay">Post Id</label> |
235 | - <input placeholder="postId" class="form-control" id="postIdDelay" value="<?php if(isset($_GET['postId'])) echo $_GET['postId'];?>" type="text" name="postId"> |
|
235 | + <input placeholder="postId" class="form-control" id="postIdDelay" value="<?php if(isset($_GET['postId'])) echo $_GET['postId']; ?>" type="text" name="postId"> |
|
236 | 236 | </div> |
237 | 237 | <div class="row"> |
238 | 238 | <div class="col-6 col-sm-6"><button type="button" name="vote" value="up" class="half" onclick="voteWithAjax('up');">Upvote</button></div> |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | crossorigin="anonymous"></script> |
259 | 259 | <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script> |
260 | 260 | <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script> |
261 | - <script src="<?php echo $baseUrl;?>js/jQueryEmoji.js"></script> |
|
261 | + <script src="<?php echo $baseUrl; ?>js/jQueryEmoji.js"></script> |
|
262 | 262 | <script src="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.1.1/ekko-lightbox.min.js" integrity="sha256-1odJPEl+KoMUaA1T7QNMGSSU/r5LCKCRC6SL8P0r2gY=" crossorigin="anonymous"></script> |
263 | 263 | |
264 | 264 | <script> |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | { |
303 | 303 | $.ajax({ |
304 | 304 | type: "POST", |
305 | - url: "<?php echo $baseUrl;?>vote-ajax.php", |
|
305 | + url: "<?php echo $baseUrl; ?>vote-ajax.php", |
|
306 | 306 | data: {"vote" : data["vote"], |
307 | 307 | "postId" : data["id"]}, |
308 | 308 | success: function(result){ |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | console.log(solution); |
357 | 357 | $.ajax({ |
358 | 358 | type: "POST", |
359 | - url: "<?php echo $baseUrl;?>vote-ajax.php?solution=" + solution + "&key="+key, |
|
359 | + url: "<?php echo $baseUrl; ?>vote-ajax.php?solution=" + solution + "&key="+key, |
|
360 | 360 | data: {"deviceUid" : deviceUid}, |
361 | 361 | success: function(result){ |
362 | 362 | var response = JSON.parse(result); |
@@ -62,7 +62,8 @@ discard block |
||
62 | 62 | . "','" . $db->escape_string($_POST['device_uid']) |
63 | 63 | . "','" . $db->escape_string($_POST['rights']) . "')"); |
64 | 64 | |
65 | - if($result === false){ |
|
65 | + if($result === false) |
|
66 | + { |
|
66 | 67 | $error = db_error(); |
67 | 68 | error_log($error); |
68 | 69 | error_log("Adding Voter failed: (" . $result->errno . ") " . $result->error); |
@@ -165,7 +166,9 @@ discard block |
||
165 | 166 | <div class="row"> |
166 | 167 | <article class="topContent col-12 col-sm-12"> |
167 | 168 | <content id="posts" class="adminpanel"> |
168 | - <?php if($userIsAdmin) { ?> |
|
169 | + <?php if($userIsAdmin) |
|
170 | +{ |
|
171 | +?> |
|
169 | 172 | <div class="row"> |
170 | 173 | <div class="col-md-12"> |
171 | 174 | <h2>Account management</h2> |
@@ -212,7 +215,8 @@ discard block |
||
212 | 215 | <?php |
213 | 216 | } |
214 | 217 | |
215 | - if($userIsVoter) { |
|
218 | + if($userIsVoter) |
|
219 | + { |
|
216 | 220 | ?> |
217 | 221 | <div class="row"> |
218 | 222 | <div class="col-12 col-sm-12"> |
@@ -232,7 +236,11 @@ discard block |
||
232 | 236 | </div> |
233 | 237 | <div class="form-group"> |
234 | 238 | <label for="postIdDelay">Post Id</label> |
235 | - <input placeholder="postId" class="form-control" id="postIdDelay" value="<?php if(isset($_GET['postId'])) echo $_GET['postId'];?>" type="text" name="postId"> |
|
239 | + <input placeholder="postId" class="form-control" id="postIdDelay" value="<?php if(isset($_GET['postId'])) |
|
240 | +{ |
|
241 | + echo $_GET['postId']; |
|
242 | +} |
|
243 | +?>" type="text" name="postId"> |
|
236 | 244 | </div> |
237 | 245 | <div class="row"> |
238 | 246 | <div class="col-6 col-sm-6"><button type="button" name="vote" value="up" class="half" onclick="voteWithAjax('up');">Upvote</button></div> |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | |
21 | 21 | if(isUserAdmin()) |
22 | 22 | { |
23 | - $userIsAdmin = true; |
|
24 | - $userIsVoter = true; |
|
23 | + $userIsAdmin = TRUE; |
|
24 | + $userIsVoter = TRUE; |
|
25 | 25 | $votesRemaining = 'Unlimited'; |
26 | 26 | } |
27 | 27 | else if(isUserVoter()) |
28 | 28 | { |
29 | - $userIsAdmin = false; |
|
30 | - $userIsVoter = true; |
|
29 | + $userIsAdmin = FALSE; |
|
30 | + $userIsVoter = TRUE; |
|
31 | 31 | |
32 | 32 | $result = $db->query("SELECT user_token, remaining_votes FROM users WHERE user_token = '" . $_COOKIE['JodelVoterPassword'] . "'"); |
33 | 33 | if($result->num_rows > 0) |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | . "','" . $db->escape_string($_POST['device_uid']) |
63 | 63 | . "','" . $db->escape_string($_POST['rights']) . "')"); |
64 | 64 | |
65 | - if($result === false){ |
|
65 | + if($result === FALSE){ |
|
66 | 66 | $error = db_error(); |
67 | 67 | error_log($error); |
68 | 68 | error_log("Adding Voter failed: (" . $result->errno . ") " . $result->error); |