@@ -3,7 +3,7 @@ |
||
3 | 3 | $config = parse_ini_file('config/config.ini.php'); |
4 | 4 | if(!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) |
5 | 5 | { |
6 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on admin.php'); |
|
6 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on admin.php'); |
|
7 | 7 | die(); |
8 | 8 | } |
9 | 9 |
@@ -40,10 +40,12 @@ |
||
40 | 40 | $accessToken = isTokenFreshByAccessToken($location, $accessToken); |
41 | 41 | |
42 | 42 | |
43 | - if($_POST['vote'] == "up") { |
|
43 | + if($_POST['vote'] == "up") |
|
44 | + { |
|
44 | 45 | $accountCreator = new Upvote(); |
45 | 46 | } |
46 | - else if($_POST['vote'] == "down") { |
|
47 | + else if($_POST['vote'] == "down") |
|
48 | + { |
|
47 | 49 | $accountCreator = new Downvote(); |
48 | 50 | } |
49 | 51 |
@@ -1,5 +1,6 @@ |
||
1 | 1 | <?php |
2 | -class Upvote extends AbstractRequest { |
|
2 | +class Upvote extends AbstractRequest |
|
3 | +{ |
|
3 | 4 | |
4 | 5 | public $postId; |
5 | 6 |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php |
2 | 2 | class Upvote extends AbstractRequest { |
3 | 3 | |
4 | - public $postId; |
|
4 | + public $postId; |
|
5 | 5 | |
6 | - function getApiEndPoint() |
|
7 | - { |
|
8 | - return '/v2/posts/' . $this->postId . '/upvote'; |
|
9 | - } |
|
10 | - function getPayload() |
|
11 | - { |
|
12 | - return array( |
|
6 | + function getApiEndPoint() |
|
7 | + { |
|
8 | + return '/v2/posts/' . $this->postId . '/upvote'; |
|
9 | + } |
|
10 | + function getPayload() |
|
11 | + { |
|
12 | + return array( |
|
13 | 13 | // "reason_code" => -1, |
14 | - ); |
|
15 | - } |
|
16 | - function getMethod() |
|
17 | - { |
|
18 | - return 'PUT'; |
|
19 | - } |
|
14 | + ); |
|
15 | + } |
|
16 | + function getMethod() |
|
17 | + { |
|
18 | + return 'PUT'; |
|
19 | + } |
|
20 | 20 | } |
21 | 21 |
@@ -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 = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG'; |
@@ -19,7 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | $this->payLoad = $this->getPayload(); |
21 | 21 | $device_uid = ''; |
22 | - if(isset($this->payLoad['device_uid'])) { |
|
22 | + if(isset($this->payLoad['device_uid'])) |
|
23 | + { |
|
23 | 24 | $device_uid = $this->payLoad['device_uid']; |
24 | 25 | } |
25 | 26 | |
@@ -28,7 +29,8 @@ discard block |
||
28 | 29 | $header = $this->getSignHeaders(); |
29 | 30 | $url = $this->getFullUrl(); |
30 | 31 | |
31 | - if ($this->getAccessToken()) { |
|
32 | + if ($this->getAccessToken()) |
|
33 | + { |
|
32 | 34 | $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
33 | 35 | } |
34 | 36 | //Comment out to debug the Request: |
@@ -45,7 +47,8 @@ discard block |
||
45 | 47 | 'proxy' => '186.103.169.165:8080', |
46 | 48 | );*/ |
47 | 49 | |
48 | - switch ($this->getMethod()) { |
|
50 | + switch ($this->getMethod()) |
|
51 | + { |
|
49 | 52 | case 'POST': |
50 | 53 | $result = Requests::post($url, $header, $this->payLoad); |
51 | 54 | break; |
@@ -63,7 +66,8 @@ discard block |
||
63 | 66 | $result = Requests::put($url, $header, $this->payLoad); |
64 | 67 | break; |
65 | 68 | } |
66 | - switch ($result->status_code) { |
|
69 | + switch ($result->status_code) |
|
70 | + { |
|
67 | 71 | case 200: |
68 | 72 | $result = json_decode($result->body, true); |
69 | 73 | break; |
@@ -114,10 +118,12 @@ discard block |
||
114 | 118 | */ |
115 | 119 | private function getSignHeaders() |
116 | 120 | { |
117 | - if($this->getAccessToken() == null) { |
|
121 | + if($this->getAccessToken() == null) |
|
122 | + { |
|
118 | 123 | $payload_accessToken = ""; |
119 | 124 | } |
120 | - else { |
|
125 | + else |
|
126 | + { |
|
121 | 127 | $payload_accessToken = $this->getAccessToken(); |
122 | 128 | } |
123 | 129 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
9 | 9 | const CLIENT_TYPE = 'android_4.32.2'; |
10 | 10 | |
11 | - private $accessToken = null; |
|
11 | + private $accessToken = NULL; |
|
12 | 12 | private $payLoad; |
13 | 13 | public $expects = ''; |
14 | 14 | public $version = 'v2'; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | switch ($result->status_code) { |
67 | 67 | case 200: |
68 | - $result = json_decode($result->body, true); |
|
68 | + $result = json_decode($result->body, TRUE); |
|
69 | 69 | break; |
70 | 70 | case 204: |
71 | 71 | $result = "Success"; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | private function getSignHeaders() |
116 | 116 | { |
117 | - if($this->getAccessToken() == null) { |
|
117 | + if($this->getAccessToken() == NULL) { |
|
118 | 118 | $payload_accessToken = ""; |
119 | 119 | } |
120 | 120 | else { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $header = $this->getSignHeaders(); |
29 | 29 | $url = $this->getFullUrl(); |
30 | 30 | |
31 | - if ($this->getAccessToken()) { |
|
31 | + if($this->getAccessToken()) { |
|
32 | 32 | $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
33 | 33 | } |
34 | 34 | //Comment out to debug the Request: |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | 'proxy' => '186.103.169.165:8080', |
51 | 51 | );*/ |
52 | 52 | |
53 | - switch ($this->getMethod()) { |
|
53 | + switch($this->getMethod()) { |
|
54 | 54 | case 'POST': |
55 | 55 | $result = Requests::post($url, $header, $this->payLoad); |
56 | 56 | break; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $result = Requests::put($url, $header, $this->payLoad); |
69 | 69 | break; |
70 | 70 | } |
71 | - switch ($result->status_code) { |
|
71 | + switch($result->status_code) { |
|
72 | 72 | case 200: |
73 | 73 | $result = json_decode($result->body, true); |
74 | 74 | break; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | exit("Error 403: Access denied"); |
97 | 97 | break; |
98 | 98 | default: |
99 | - error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
99 | + error_log('Error ' . $result->status_code . ' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
100 | 100 | //throw new \Exception('Unknown Error: '.$result->status_code); |
101 | 101 | } |
102 | 102 |
@@ -2,20 +2,20 @@ 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 = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG'; |
|
8 | - const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
9 | - const CLIENT_TYPE = 'android_4.32.2'; |
|
5 | + const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
6 | + const APIURL = 'https://api.go-tellm.com/api'; |
|
7 | + const SECRET = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG'; |
|
8 | + const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
9 | + const CLIENT_TYPE = 'android_4.32.2'; |
|
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 | - { |
|
17 | + public function execute() |
|
18 | + { |
|
19 | 19 | $result = new \stdClass(); |
20 | 20 | |
21 | 21 | $this->payLoad = $this->getPayload(); |
@@ -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,86 +45,86 @@ 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 | - } |
|
73 | - switch ($result->status_code) { |
|
74 | - case 200: |
|
75 | - $result = json_decode($result->body, true); |
|
76 | - break; |
|
77 | - case 204: |
|
78 | - $result = "Success"; |
|
79 | - break; |
|
80 | - case 400: |
|
81 | - //throw new \Exception('Unauthorized'); |
|
82 | - error_log('Error 400 - Fehlerhafte Anfrage'); // - JodelDeviceId:' . $deviceUid); |
|
83 | - break; |
|
84 | - case 401: |
|
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 | + switch ($result->status_code) { |
|
74 | + case 200: |
|
75 | + $result = json_decode($result->body, true); |
|
76 | + break; |
|
77 | + case 204: |
|
78 | + $result = "Success"; |
|
79 | + break; |
|
80 | + case 400: |
|
81 | + //throw new \Exception('Unauthorized'); |
|
82 | + error_log('Error 400 - Fehlerhafte Anfrage'); // - JodelDeviceId:' . $deviceUid); |
|
83 | + break; |
|
84 | + case 401: |
|
85 | 85 | //throw new \Exception('Unauthorized'); |
86 | - error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
87 | - break; |
|
88 | - case 404: |
|
89 | - //echo "Es wurde bereits gevoted"; |
|
90 | - error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid); |
|
86 | + error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
87 | + break; |
|
88 | + case 404: |
|
89 | + //echo "Es wurde bereits gevoted"; |
|
90 | + error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid); |
|
91 | 91 | case 477: |
92 | - //echo "Es wurde bereits gevoted"; |
|
93 | - //throw new \Exception('Signing failed!'); |
|
94 | - error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid); |
|
95 | - break; |
|
96 | - case 429: |
|
97 | - error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid); |
|
98 | - exit("Error 429: Too Many Requests"); |
|
99 | - break; |
|
100 | - case 403: |
|
101 | - error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid); |
|
102 | - exit("Error 403: Access denied"); |
|
103 | - break; |
|
104 | - default: |
|
105 | - error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
106 | - //throw new \Exception('Unknown Error: '.$result->status_code); |
|
107 | - } |
|
92 | + //echo "Es wurde bereits gevoted"; |
|
93 | + //throw new \Exception('Signing failed!'); |
|
94 | + error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid); |
|
95 | + break; |
|
96 | + case 429: |
|
97 | + error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid); |
|
98 | + exit("Error 429: Too Many Requests"); |
|
99 | + break; |
|
100 | + case 403: |
|
101 | + error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid); |
|
102 | + exit("Error 403: Access denied"); |
|
103 | + break; |
|
104 | + default: |
|
105 | + error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
106 | + //throw new \Exception('Unknown Error: '.$result->status_code); |
|
107 | + } |
|
108 | 108 | |
109 | - if($device_uid != '') |
|
110 | - { |
|
109 | + if($device_uid != '') |
|
110 | + { |
|
111 | 111 | $result[0] = $result; |
112 | 112 | $result[1] = $device_uid; |
113 | 113 | } |
114 | 114 | |
115 | - /* |
|
115 | + /* |
|
116 | 116 | var_dump($result); |
117 | 117 | */ |
118 | 118 | |
119 | - return $result; |
|
120 | - } |
|
121 | - abstract function getPayload(); |
|
122 | - /** |
|
123 | - * Gets Sign headers |
|
124 | - * @return array headers |
|
125 | - */ |
|
126 | - private function getSignHeaders() |
|
127 | - { |
|
119 | + return $result; |
|
120 | + } |
|
121 | + abstract function getPayload(); |
|
122 | + /** |
|
123 | + * Gets Sign headers |
|
124 | + * @return array headers |
|
125 | + */ |
|
126 | + private function getSignHeaders() |
|
127 | + { |
|
128 | 128 | if($this->getAccessToken() == null) { |
129 | 129 | $payload_accessToken = ""; |
130 | 130 | } |
@@ -133,54 +133,54 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | |
136 | - $headers = array( |
|
137 | - "Connection" => "keep-alive", |
|
138 | - "Accept-Encoding" => "gzip", |
|
139 | - "Content-Type" => "application/json; charset=UTF-8", |
|
140 | - "User-Agent" => self::USERAGENT |
|
141 | - ); |
|
142 | - $timestamp = new DateTime(); |
|
143 | - $timestamp = $timestamp->format(DateTime::ATOM); |
|
144 | - $timestamp = substr($timestamp, 0, -6); |
|
145 | - $timestamp .= "Z"; |
|
146 | - $urlParts = parse_url($this->getFullUrl()); |
|
147 | - $url2 = ""; |
|
148 | - $req = [$this->getMethod(), |
|
149 | - $urlParts['host'], |
|
150 | - "443", |
|
151 | - $urlParts['path'], |
|
152 | - $payload_accessToken, |
|
153 | - $timestamp, |
|
154 | - $url2, |
|
155 | - $this->payLoad]; |
|
156 | - $reqString = implode("%", $req); |
|
157 | - $secret = self::SECRET; |
|
158 | - $signature = hash_hmac('sha1', $reqString, $secret); |
|
159 | - $signature = strtoupper($signature); |
|
160 | - $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
161 | - $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
162 | - $headers['X-Timestamp'] = $timestamp; |
|
163 | - $headers['X-Api-Version'] = '0.2'; |
|
164 | - return $headers; |
|
165 | - } |
|
166 | - private function getFullUrl() |
|
167 | - { |
|
168 | - return self::APIURL . $this->getApiEndPoint(); |
|
169 | - } |
|
170 | - abstract function getApiEndPoint(); |
|
171 | - abstract function getMethod(); |
|
172 | - /** |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - private function getAccessToken() |
|
176 | - { |
|
177 | - return $this->accessToken; |
|
178 | - } |
|
179 | - /** |
|
180 | - * @param string $accessToken |
|
181 | - */ |
|
182 | - public function setAccessToken($accessToken) |
|
183 | - { |
|
184 | - $this->accessToken = $accessToken; |
|
185 | - } |
|
136 | + $headers = array( |
|
137 | + "Connection" => "keep-alive", |
|
138 | + "Accept-Encoding" => "gzip", |
|
139 | + "Content-Type" => "application/json; charset=UTF-8", |
|
140 | + "User-Agent" => self::USERAGENT |
|
141 | + ); |
|
142 | + $timestamp = new DateTime(); |
|
143 | + $timestamp = $timestamp->format(DateTime::ATOM); |
|
144 | + $timestamp = substr($timestamp, 0, -6); |
|
145 | + $timestamp .= "Z"; |
|
146 | + $urlParts = parse_url($this->getFullUrl()); |
|
147 | + $url2 = ""; |
|
148 | + $req = [$this->getMethod(), |
|
149 | + $urlParts['host'], |
|
150 | + "443", |
|
151 | + $urlParts['path'], |
|
152 | + $payload_accessToken, |
|
153 | + $timestamp, |
|
154 | + $url2, |
|
155 | + $this->payLoad]; |
|
156 | + $reqString = implode("%", $req); |
|
157 | + $secret = self::SECRET; |
|
158 | + $signature = hash_hmac('sha1', $reqString, $secret); |
|
159 | + $signature = strtoupper($signature); |
|
160 | + $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
161 | + $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
162 | + $headers['X-Timestamp'] = $timestamp; |
|
163 | + $headers['X-Api-Version'] = '0.2'; |
|
164 | + return $headers; |
|
165 | + } |
|
166 | + private function getFullUrl() |
|
167 | + { |
|
168 | + return self::APIURL . $this->getApiEndPoint(); |
|
169 | + } |
|
170 | + abstract function getApiEndPoint(); |
|
171 | + abstract function getMethod(); |
|
172 | + /** |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + private function getAccessToken() |
|
176 | + { |
|
177 | + return $this->accessToken; |
|
178 | + } |
|
179 | + /** |
|
180 | + * @param string $accessToken |
|
181 | + */ |
|
182 | + public function setAccessToken($accessToken) |
|
183 | + { |
|
184 | + $this->accessToken = $accessToken; |
|
185 | + } |
|
186 | 186 | } |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | |
298 | 298 | if($result->num_rows == 0) |
299 | 299 | { |
300 | - return FALSE; |
|
300 | + return FALSE; |
|
301 | 301 | } |
302 | 302 | else |
303 | 303 | { |
304 | - return TRUE; |
|
304 | + return TRUE; |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | { |
399 | 399 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
400 | 400 | |
401 | - return (isset($matches[0])) ? true : false; |
|
401 | + return (isset($matches[0])) ? true : false; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | function botDeviceUidIsSet($config) |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | <?php |
505 | 505 | if(isset($post['image_url'])) |
506 | 506 | { |
507 | - $regexRest = '/[^\w$ .!?-]+/u'; |
|
507 | + $regexRest = '/[^\w$ .!?-]+/u'; |
|
508 | 508 | |
509 | 509 | echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
510 | 510 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | else |
128 | 128 | { |
129 | - error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
129 | + error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | if(isset($_POST['color'])) |
190 | 190 | { |
191 | 191 | $color = $_POST['color']; |
192 | - switch ($color) { |
|
192 | + switch($color) { |
|
193 | 193 | case '8ABDB0': |
194 | 194 | $color = '8ABDB0'; |
195 | 195 | break; |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | function isDeviceUidInDatabase($deviceUid) |
242 | 242 | { |
243 | 243 | $db = new DatabaseConnect(); |
244 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
244 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
245 | 245 | |
246 | - if ($result->num_rows > 0) |
|
246 | + if($result->num_rows > 0) |
|
247 | 247 | { |
248 | 248 | return TRUE; |
249 | 249 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | |
261 | 261 | $access_token; |
262 | 262 | |
263 | - if ($result->num_rows > 0) |
|
263 | + if($result->num_rows > 0) |
|
264 | 264 | { |
265 | 265 | // output data of each row |
266 | 266 | while($row = $result->fetch_assoc()) { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | if($expiration_date <= time()) { |
279 | 279 | $accountCreator = new CreateUser(); |
280 | - $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
|
280 | + $accountCreator->setAccessToken($access_token); //$accountData->getAccessToken()); |
|
281 | 281 | $accountCreator->setDeviceUid($deviceUid); |
282 | 282 | $accountCreator->setLocation($location); |
283 | 283 | $data = $accountCreator->execute(); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | expiration_date='" . $expiration_date . "' |
293 | 293 | WHERE device_uid='" . $device_uid . "'"); |
294 | 294 | |
295 | - if($result === false){ |
|
295 | + if($result === false) { |
|
296 | 296 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
297 | 297 | } |
298 | 298 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $db = new DatabaseConnect(); |
306 | 306 | $result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'"); |
307 | 307 | |
308 | - if ($result->num_rows > 0) |
|
308 | + if($result->num_rows > 0) |
|
309 | 309 | { |
310 | 310 | // output data of each row |
311 | 311 | while($row = $result->fetch_assoc()) { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | if($expiration_date <= time()) { |
324 | 324 | $accountCreator = new CreateUser(); |
325 | - $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
|
325 | + $accountCreator->setAccessToken($access_token); //$accountData->getAccessToken()); |
|
326 | 326 | $accountCreator->setDeviceUid($deviceUid); |
327 | 327 | $accountCreator->setLocation($location); |
328 | 328 | $data = $accountCreator->execute(); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | expiration_date='" . $expiration_date . "' |
338 | 338 | WHERE device_uid='" . $device_uid . "'"); |
339 | 339 | |
340 | - if($result === false){ |
|
340 | + if($result === false) { |
|
341 | 341 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
342 | 342 | } |
343 | 343 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | $access_token; |
354 | 354 | |
355 | - if ($result->num_rows > 0) |
|
355 | + if($result->num_rows > 0) |
|
356 | 356 | { |
357 | 357 | // output data of each row |
358 | 358 | while($row = $result->fetch_assoc()) { |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | expiration_date='" . $expiration_date . "' |
385 | 385 | WHERE device_uid='" . $device_uid . "'"); |
386 | 386 | |
387 | - if($result === false){ |
|
387 | + if($result === false) { |
|
388 | 388 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
389 | 389 | } |
390 | 390 | } |
@@ -395,11 +395,11 @@ discard block |
||
395 | 395 | function getLocationByAccessToken($accessToken) |
396 | 396 | { |
397 | 397 | $db = new DatabaseConnect(); |
398 | - $result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'"); |
|
398 | + $result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'"); |
|
399 | 399 | |
400 | 400 | $location = new Location(); |
401 | 401 | |
402 | - if ($result->num_rows > 0) |
|
402 | + if($result->num_rows > 0) |
|
403 | 403 | { |
404 | 404 | // output data of each row |
405 | 405 | while($row = $result->fetch_assoc()) |
@@ -420,11 +420,11 @@ discard block |
||
420 | 420 | function getLocationByDeviceUid($deviceUid) |
421 | 421 | { |
422 | 422 | $db = new DatabaseConnect(); |
423 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
423 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
424 | 424 | |
425 | 425 | $location = new Location(); |
426 | 426 | |
427 | - if ($result->num_rows > 0) |
|
427 | + if($result->num_rows > 0) |
|
428 | 428 | { |
429 | 429 | // output data of each row |
430 | 430 | while($row = $result->fetch_assoc()) |
@@ -445,11 +445,11 @@ discard block |
||
445 | 445 | function getDeviceUidByAccessToken($accesstoken) |
446 | 446 | { |
447 | 447 | $db = new DatabaseConnect(); |
448 | - $result = $db->query("SELECT device_uid FROM accounts WHERE access_token='" . $accesstoken . "'"); |
|
448 | + $result = $db->query("SELECT device_uid FROM accounts WHERE access_token='" . $accesstoken . "'"); |
|
449 | 449 | |
450 | 450 | $deviceUid; |
451 | 451 | |
452 | - if ($result->num_rows > 0) |
|
452 | + if($result->num_rows > 0) |
|
453 | 453 | { |
454 | 454 | // output data of each row |
455 | 455 | while($row = $result->fetch_assoc()) |
@@ -468,11 +468,11 @@ discard block |
||
468 | 468 | function getAccessTokenByDeviceUid($deviceUid) |
469 | 469 | { |
470 | 470 | $db = new DatabaseConnect(); |
471 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
471 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
472 | 472 | |
473 | 473 | $accessToken; |
474 | 474 | |
475 | - if ($result->num_rows > 0) |
|
475 | + if($result->num_rows > 0) |
|
476 | 476 | { |
477 | 477 | // output data of each row |
478 | 478 | while($row = $result->fetch_assoc()) |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
541 | 541 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
542 | 542 | |
543 | - if($result === false){ |
|
543 | + if($result === false) { |
|
544 | 544 | $error = db_error(); |
545 | 545 | echo $error; |
546 | 546 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -568,11 +568,11 @@ discard block |
||
568 | 568 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
569 | 569 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
570 | 570 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
571 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
571 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
572 | 572 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
573 | 573 | |
574 | 574 | $success = TRUE; |
575 | - if($result === false){ |
|
575 | + if($result === false) { |
|
576 | 576 | $error = db_error(); |
577 | 577 | echo $error; |
578 | 578 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | { |
619 | 619 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
620 | 620 | |
621 | - return (isset($matches[0])) ? true : false; |
|
621 | + return (isset($matches[0]))?true : false; |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | function botDeviceUidIsSet($config) |
@@ -687,25 +687,25 @@ discard block |
||
687 | 687 | $timediff_inDays = (string)$timediff->format('%d'); |
688 | 688 | $timediff_inMonth = (string)$timediff->format('%m'); |
689 | 689 | |
690 | - if($timediff_inMonth!=0) |
|
690 | + if($timediff_inMonth != 0) |
|
691 | 691 | { |
692 | 692 | $timediff = $timediff_inMonth . "m"; |
693 | 693 | } |
694 | 694 | else |
695 | 695 | { |
696 | - if($timediff_inDays!=0) |
|
696 | + if($timediff_inDays != 0) |
|
697 | 697 | { |
698 | 698 | $timediff = $timediff_inDays . "d"; |
699 | 699 | } |
700 | 700 | else |
701 | 701 | { |
702 | - if($timediff_inHours!=0) |
|
702 | + if($timediff_inHours != 0) |
|
703 | 703 | { |
704 | 704 | $timediff = $timediff_inHours . "h"; |
705 | 705 | } |
706 | 706 | else |
707 | 707 | { |
708 | - if($timediff_inMinutes!=0) |
|
708 | + if($timediff_inMinutes != 0) |
|
709 | 709 | { |
710 | 710 | $timediff = $timediff_inMinutes . "m"; |
711 | 711 | } |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | |
720 | 720 | |
721 | 721 | ?> |
722 | - <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
|
722 | + <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color']; ?>;"> |
|
723 | 723 | <content> |
724 | 724 | <?php |
725 | 725 | if(isset($post['image_url'])) |
@@ -737,24 +737,24 @@ discard block |
||
737 | 737 | <?php |
738 | 738 | if($isDetailedView) |
739 | 739 | {?> |
740 | - <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
|
740 | + <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>" rel="nofollow"> |
|
741 | 741 | <?php } |
742 | 742 | else |
743 | 743 | {?> |
744 | - <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
744 | + <a href="index.php?vote=up&postID=<?php echo $post['post_id']; ?>" rel="nofollow"> |
|
745 | 745 | <?php } ?> |
746 | 746 | <i class="fa fa-angle-up fa-3x"></i> |
747 | 747 | </a> |
748 | 748 | <br /> |
749 | - <?php echo $post["vote_count"];?><br /> |
|
749 | + <?php echo $post["vote_count"]; ?><br /> |
|
750 | 750 | <?php |
751 | 751 | if($isDetailedView) |
752 | 752 | {?> |
753 | - <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
|
753 | + <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>" rel="nofollow"> |
|
754 | 754 | <?php } |
755 | 755 | else |
756 | 756 | {?> |
757 | - <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
757 | + <a href="index.php?vote=down&postID=<?php echo $post['post_id']; ?>" rel="nofollow"> |
|
758 | 758 | <?php } ?> |
759 | 759 | <i class="fa fa-angle-down fa-3x"></i> |
760 | 760 | </a> |
@@ -766,14 +766,14 @@ discard block |
||
766 | 766 | <td class="time"> |
767 | 767 | <span class="tip" data-tooltip="Time"> |
768 | 768 | <i class="fa fa-clock-o"></i> |
769 | - <?php echo $timediff;?> |
|
770 | - <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
|
769 | + <?php echo $timediff; ?> |
|
770 | + <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span> |
|
771 | 771 | </span> |
772 | 772 | </td> |
773 | 773 | <td class="comments"> |
774 | 774 | <?php if(!$isDetailedView) {?> |
775 | 775 | <span data-tooltip="Comments"> |
776 | - <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
|
776 | + <a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $post["post_id"]; ?>"> |
|
777 | 777 | <i class="fa fa-commenting-o"></i> |
778 | 778 | <?php if(array_key_exists("child_count", $post)) { |
779 | 779 | echo $post["child_count"]; |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | { |
803 | 803 | ?> |
804 | 804 | <span data-tooltip="Author"> |
805 | - <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
|
805 | + <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> | |
|
806 | 806 | </span> |
807 | 807 | <?php |
808 | 808 | } |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | |
813 | 813 | <span class="tip" data-tooltip="Distance"> |
814 | 814 | <i class="fa fa-map-marker"></i> |
815 | - <?php echo $post['distance'];?> km |
|
816 | - <span class="tiptext"><?php echo $post['location']['name'];?></span> |
|
815 | + <?php echo $post['distance']; ?> km |
|
816 | + <span class="tiptext"><?php echo $post['location']['name']; ?></span> |
|
817 | 817 | </span> |
818 | 818 | </td> |
819 | 819 | </tr> |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | { |
91 | 91 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
92 | 92 | $result = Requests::post($url); |
93 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
93 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
94 | 94 | { |
95 | 95 | return "0 results"; |
96 | 96 | } |
97 | 97 | else |
98 | 98 | { |
99 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
100 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
101 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
99 | + $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name']; |
|
100 | + $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']; |
|
101 | + $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']; |
|
102 | 102 | |
103 | 103 | $location = new Location(); |
104 | 104 | $location->setLat($lat); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | lng='" . $lng . "' |
121 | 121 | WHERE access_token='" . $accessToken . "'"); |
122 | 122 | |
123 | - if($result === false) |
|
123 | + if($result === FALSE) |
|
124 | 124 | { |
125 | 125 | echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
126 | 126 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | expiration_date='" . $expiration_date . "' |
293 | 293 | WHERE device_uid='" . $device_uid . "'"); |
294 | 294 | |
295 | - if($result === false){ |
|
295 | + if($result === FALSE){ |
|
296 | 296 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
297 | 297 | } |
298 | 298 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | expiration_date='" . $expiration_date . "' |
338 | 338 | WHERE device_uid='" . $device_uid . "'"); |
339 | 339 | |
340 | - if($result === false){ |
|
340 | + if($result === FALSE){ |
|
341 | 341 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
342 | 342 | } |
343 | 343 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | expiration_date='" . $expiration_date . "' |
385 | 385 | WHERE device_uid='" . $device_uid . "'"); |
386 | 386 | |
387 | - if($result === false){ |
|
387 | + if($result === FALSE){ |
|
388 | 388 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
389 | 389 | } |
390 | 390 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | FROM votes |
509 | 509 | WHERE (postId = '" . $postId . "' AND device_uid = '" . $deviceUid . "')"); |
510 | 510 | |
511 | - if($result === false) |
|
511 | + if($result === FALSE) |
|
512 | 512 | { |
513 | 513 | $error = db_error(); |
514 | 514 | echo $error; |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
541 | 541 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
542 | 542 | |
543 | - if($result === false){ |
|
543 | + if($result === FALSE){ |
|
544 | 544 | $error = db_error(); |
545 | 545 | echo $error; |
546 | 546 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
573 | 573 | |
574 | 574 | $success = TRUE; |
575 | - if($result === false){ |
|
575 | + if($result === FALSE){ |
|
576 | 576 | $error = db_error(); |
577 | 577 | echo $error; |
578 | 578 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | { |
619 | 619 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
620 | 620 | |
621 | - return (isset($matches[0])) ? true : false; |
|
621 | + return (isset($matches[0])) ? TRUE : FALSE; |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | function botDeviceUidIsSet($config) |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | if(substr($_GET['city'], 0, 1) === '#') |
84 | 84 | { |
85 | 85 | return htmlspecialchars($_GET['city']) . " " . $cityName; |
86 | - } |
|
86 | + } |
|
87 | 87 | else |
88 | 88 | { |
89 | 89 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
@@ -187,7 +187,8 @@ discard block |
||
187 | 187 | if(isset($_POST['color'])) |
188 | 188 | { |
189 | 189 | $color = $_POST['color']; |
190 | - switch ($color) { |
|
190 | + switch ($color) |
|
191 | + { |
|
191 | 192 | case '8ABDB0': |
192 | 193 | $color = '8ABDB0'; |
193 | 194 | break; |
@@ -261,7 +262,8 @@ discard block |
||
261 | 262 | if ($result->num_rows > 0) |
262 | 263 | { |
263 | 264 | // output data of each row |
264 | - while($row = $result->fetch_assoc()) { |
|
265 | + while($row = $result->fetch_assoc()) |
|
266 | + { |
|
265 | 267 | //$access_token = $row["access_token"]; |
266 | 268 | $expiration_date = $row["expiration_date"]; |
267 | 269 | $deviceUid = $row["device_uid"]; |
@@ -273,7 +275,8 @@ discard block |
||
273 | 275 | echo '0 results'; |
274 | 276 | } |
275 | 277 | |
276 | - if($expiration_date <= time()) { |
|
278 | + if($expiration_date <= time()) |
|
279 | + { |
|
277 | 280 | $accountCreator = new CreateUser(); |
278 | 281 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
279 | 282 | $accountCreator->setDeviceUid($deviceUid); |
@@ -290,7 +293,8 @@ discard block |
||
290 | 293 | expiration_date='" . $expiration_date . "' |
291 | 294 | WHERE device_uid='" . $device_uid . "'"); |
292 | 295 | |
293 | - if($result === false){ |
|
296 | + if($result === false) |
|
297 | + { |
|
294 | 298 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
295 | 299 | } |
296 | 300 | } |
@@ -306,7 +310,8 @@ discard block |
||
306 | 310 | if ($result->num_rows > 0) |
307 | 311 | { |
308 | 312 | // output data of each row |
309 | - while($row = $result->fetch_assoc()) { |
|
313 | + while($row = $result->fetch_assoc()) |
|
314 | + { |
|
310 | 315 | //$access_token = $row["access_token"]; |
311 | 316 | $expiration_date = $row["expiration_date"]; |
312 | 317 | $deviceUid = $row["device_uid"]; |
@@ -318,7 +323,8 @@ discard block |
||
318 | 323 | echo '0 results'; |
319 | 324 | } |
320 | 325 | |
321 | - if($expiration_date <= time()) { |
|
326 | + if($expiration_date <= time()) |
|
327 | + { |
|
322 | 328 | $accountCreator = new CreateUser(); |
323 | 329 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
324 | 330 | $accountCreator->setDeviceUid($deviceUid); |
@@ -335,7 +341,8 @@ discard block |
||
335 | 341 | expiration_date='" . $expiration_date . "' |
336 | 342 | WHERE device_uid='" . $device_uid . "'"); |
337 | 343 | |
338 | - if($result === false){ |
|
344 | + if($result === false) |
|
345 | + { |
|
339 | 346 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
340 | 347 | } |
341 | 348 | } |
@@ -353,7 +360,8 @@ discard block |
||
353 | 360 | if ($result->num_rows > 0) |
354 | 361 | { |
355 | 362 | // output data of each row |
356 | - while($row = $result->fetch_assoc()) { |
|
363 | + while($row = $result->fetch_assoc()) |
|
364 | + { |
|
357 | 365 | //$access_token = $row["access_token"]; |
358 | 366 | $expiration_date = $row["expiration_date"]; |
359 | 367 | $deviceUid = $row["device_uid"]; |
@@ -365,7 +373,8 @@ discard block |
||
365 | 373 | echo '0 results'; |
366 | 374 | } |
367 | 375 | |
368 | - if($expiration_date <= time()) { |
|
376 | + if($expiration_date <= time()) |
|
377 | + { |
|
369 | 378 | $accountCreator = new CreateUser(); |
370 | 379 | $accountCreator->setAccessToken($access_token); |
371 | 380 | $accountCreator->setDeviceUid($deviceUid); |
@@ -382,7 +391,8 @@ discard block |
||
382 | 391 | expiration_date='" . $expiration_date . "' |
383 | 392 | WHERE device_uid='" . $device_uid . "'"); |
384 | 393 | |
385 | - if($result === false){ |
|
394 | + if($result === false) |
|
395 | + { |
|
386 | 396 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
387 | 397 | } |
388 | 398 | } |
@@ -538,14 +548,16 @@ discard block |
||
538 | 548 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
539 | 549 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
540 | 550 | |
541 | - if($result === false){ |
|
551 | + if($result === false) |
|
552 | + { |
|
542 | 553 | $error = db_error(); |
543 | 554 | echo $error; |
544 | 555 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
545 | 556 | } |
546 | 557 | } |
547 | 558 | |
548 | -function registerAccount(Location $location) { |
|
559 | +function registerAccount(Location $location) |
|
560 | +{ |
|
549 | 561 | $accountCreator = new CreateUser(); |
550 | 562 | $accountCreator->setLocation($location); |
551 | 563 | $data = $accountCreator->execute(); |
@@ -570,7 +582,8 @@ discard block |
||
570 | 582 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
571 | 583 | |
572 | 584 | $success = TRUE; |
573 | - if($result === false){ |
|
585 | + if($result === false) |
|
586 | + { |
|
574 | 587 | $error = db_error(); |
575 | 588 | echo $error; |
576 | 589 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -581,7 +594,7 @@ discard block |
||
581 | 594 | } |
582 | 595 | |
583 | 596 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
584 | -{ |
|
597 | +{ |
|
585 | 598 | $accountCreator = new GetPosts(); |
586 | 599 | $accountCreator->setLastPostId($lastPostId); |
587 | 600 | $accountCreator->setAccessToken($accessToken); |
@@ -670,7 +683,8 @@ discard block |
||
670 | 683 | } |
671 | 684 | |
672 | 685 | function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE) |
673 | -{ //ToDO |
|
686 | +{ |
|
687 | +//ToDO |
|
674 | 688 | //Replace # with link |
675 | 689 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
676 | 690 | |
@@ -726,7 +740,8 @@ discard block |
||
726 | 740 | |
727 | 741 | echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
728 | 742 | } |
729 | - else { |
|
743 | + else |
|
744 | + { |
|
730 | 745 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
731 | 746 | } |
732 | 747 | ?> |
@@ -734,11 +749,13 @@ discard block |
||
734 | 749 | <aside> |
735 | 750 | <?php |
736 | 751 | if($isDetailedView) |
737 | - {?> |
|
752 | + { |
|
753 | +?> |
|
738 | 754 | <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
739 | 755 | <?php } |
740 | - else |
|
741 | - {?> |
|
756 | +else |
|
757 | + { |
|
758 | +?> |
|
742 | 759 | <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
743 | 760 | <?php } ?> |
744 | 761 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -747,11 +764,13 @@ discard block |
||
747 | 764 | <?php echo $post["vote_count"];?><br /> |
748 | 765 | <?php |
749 | 766 | if($isDetailedView) |
750 | - {?> |
|
767 | + { |
|
768 | +?> |
|
751 | 769 | <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
752 | 770 | <?php } |
753 | - else |
|
754 | - {?> |
|
771 | +else |
|
772 | + { |
|
773 | +?> |
|
755 | 774 | <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
756 | 775 | <?php } ?> |
757 | 776 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -769,13 +788,19 @@ discard block |
||
769 | 788 | </span> |
770 | 789 | </td> |
771 | 790 | <td class="comments"> |
772 | - <?php if(!$isDetailedView) {?> |
|
791 | + <?php if(!$isDetailedView) |
|
792 | +{ |
|
793 | +?> |
|
773 | 794 | <span data-tooltip="Comments"> |
774 | 795 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
775 | 796 | <i class="fa fa-commenting-o"></i> |
776 | - <?php if(array_key_exists("child_count", $post)) { |
|
797 | + <?php if(array_key_exists("child_count", $post)) |
|
798 | +{ |
|
777 | 799 | echo $post["child_count"]; |
778 | - } else echo "0"; |
|
800 | + } |
|
801 | + else { |
|
802 | + echo "0"; |
|
803 | + } |
|
779 | 804 | ?> |
780 | 805 | </a> |
781 | 806 | </span> |
@@ -2,22 +2,22 @@ |
||
2 | 2 | class PostCaptcha extends AbstractRequest |
3 | 3 | { |
4 | 4 | public $captchaKey; |
5 | - public $captchaSolution; |
|
5 | + public $captchaSolution; |
|
6 | 6 | |
7 | - function getApiEndPoint() |
|
8 | - { |
|
9 | - return '/v3/user/verification/imageCaptcha/'; |
|
10 | - } |
|
11 | - function getPayload() |
|
12 | - { |
|
13 | - return array( |
|
14 | - 'key' => $this->captchaKey, |
|
15 | - 'answer' => $this->captchaSolution, |
|
16 | - ); |
|
17 | - } |
|
18 | - function getMethod() |
|
19 | - { |
|
20 | - return 'POST'; |
|
21 | - } |
|
7 | + function getApiEndPoint() |
|
8 | + { |
|
9 | + return '/v3/user/verification/imageCaptcha/'; |
|
10 | + } |
|
11 | + function getPayload() |
|
12 | + { |
|
13 | + return array( |
|
14 | + 'key' => $this->captchaKey, |
|
15 | + 'answer' => $this->captchaSolution, |
|
16 | + ); |
|
17 | + } |
|
18 | + function getMethod() |
|
19 | + { |
|
20 | + return 'POST'; |
|
21 | + } |
|
22 | 22 | } |
23 | 23 |
@@ -2,18 +2,18 @@ |
||
2 | 2 | class GetUserConfig extends AbstractRequest |
3 | 3 | { |
4 | 4 | |
5 | - function getApiEndPoint() |
|
6 | - { |
|
7 | - return '/v3/user/config/'; |
|
8 | - } |
|
9 | - function getPayload() |
|
10 | - { |
|
11 | - return array( |
|
12 | - ); |
|
13 | - } |
|
14 | - function getMethod() |
|
15 | - { |
|
16 | - return 'GET'; |
|
17 | - } |
|
5 | + function getApiEndPoint() |
|
6 | + { |
|
7 | + return '/v3/user/config/'; |
|
8 | + } |
|
9 | + function getPayload() |
|
10 | + { |
|
11 | + return array( |
|
12 | + ); |
|
13 | + } |
|
14 | + function getMethod() |
|
15 | + { |
|
16 | + return 'GET'; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | class GetCaptcha extends AbstractRequest |
3 | 3 | { |
4 | - function getApiEndPoint() |
|
5 | - { |
|
6 | - return '/v3/user/verification/imageCaptcha/'; |
|
7 | - } |
|
8 | - function getPayload() |
|
9 | - { |
|
10 | - return array( |
|
11 | - ); |
|
12 | - } |
|
13 | - function getMethod() |
|
14 | - { |
|
15 | - return 'GET'; |
|
16 | - } |
|
4 | + function getApiEndPoint() |
|
5 | + { |
|
6 | + return '/v3/user/verification/imageCaptcha/'; |
|
7 | + } |
|
8 | + function getPayload() |
|
9 | + { |
|
10 | + return array( |
|
11 | + ); |
|
12 | + } |
|
13 | + function getMethod() |
|
14 | + { |
|
15 | + return 'GET'; |
|
16 | + } |
|
17 | 17 | } |
18 | 18 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | class GetCaptcha extends AbstractRequest |
3 | -{ |
|
3 | +{ |
|
4 | 4 | function getApiEndPoint() |
5 | 5 | { |
6 | 6 | return '/v3/user/verification/imageCaptcha/'; |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | $config = parse_ini_file('config/config.ini.php'); |
4 | 4 | if(!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) |
5 | 5 | { |
6 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
7 | - $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
6 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
7 | + $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php', "success" => false); |
|
8 | 8 | echo json_encode($response); |
9 | 9 | |
10 | 10 | die(); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | -if (isset($captcha)) |
|
73 | +if(isset($captcha)) |
|
74 | 74 | { |
75 | 75 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "accessToken" => $token); |
76 | 76 | } |
@@ -40,17 +40,20 @@ discard block |
||
40 | 40 | $token = $accessToken; |
41 | 41 | $success = false; |
42 | 42 | } |
43 | - else { |
|
43 | + else |
|
44 | + { |
|
44 | 45 | |
45 | 46 | $location = getLocationByAccessToken($accessToken); |
46 | 47 | |
47 | 48 | $accessToken = isTokenFreshByAccessToken($location, $accessToken); |
48 | 49 | |
49 | 50 | |
50 | - if($_POST['vote'] == "up") { |
|
51 | + if($_POST['vote'] == "up") |
|
52 | + { |
|
51 | 53 | $accountCreator = new Upvote(); |
52 | 54 | } |
53 | - else if($_POST['vote'] == "down") { |
|
55 | + else if($_POST['vote'] == "down") |
|
56 | + { |
|
54 | 57 | $accountCreator = new Downvote(); |
55 | 58 | } |
56 | 59 | |
@@ -74,7 +77,7 @@ discard block |
||
74 | 77 | { |
75 | 78 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "accessToken" => $token); |
76 | 79 | } |
77 | -else |
|
80 | +else |
|
78 | 81 | { |
79 | 82 | $response = array("success" => $success, "message" => $message); |
80 | 83 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | if(!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) |
5 | 5 | { |
6 | 6 | error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
7 | - $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
7 | + $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => FALSE); |
|
8 | 8 | echo json_encode($response); |
9 | 9 | |
10 | 10 | die(); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | $message = ""; |
23 | -$success = true; |
|
23 | +$success = TRUE; |
|
24 | 24 | $token = ""; |
25 | 25 | if(isset($_POST['vote']) && isset($_POST['postId'])) |
26 | 26 | { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $message = "This account is not verified. Please verify this account first."; |
39 | 39 | $captcha = getCaptcha($accessToken); |
40 | 40 | $token = $accessToken; |
41 | - $success = false; |
|
41 | + $success = FALSE; |
|
42 | 42 | } |
43 | 43 | else { |
44 | 44 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | else |
67 | 67 | { |
68 | 68 | $message = 'There is no account available for this jodel. Please create at least one new account to vote this jodel.'; |
69 | - $success = false; |
|
69 | + $success = FALSE; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 |
@@ -2,25 +2,25 @@ |
||
2 | 2 | |
3 | 3 | class GetChannel extends AbstractRequest |
4 | 4 | { |
5 | - /** |
|
6 | - * @var Location |
|
7 | - */ |
|
8 | - public $location; |
|
9 | - public $channel; |
|
10 | - public $hasPayload = FALSE; |
|
5 | + /** |
|
6 | + * @var Location |
|
7 | + */ |
|
8 | + public $location; |
|
9 | + public $channel; |
|
10 | + public $hasPayload = FALSE; |
|
11 | 11 | |
12 | - function getApiEndPoint() |
|
13 | - { |
|
14 | - $apiEndPoint = '/v3/posts/hashtag/combo?hashtag=' . $this->channel; |
|
15 | - return $apiEndPoint; |
|
16 | - } |
|
17 | - function getPayload() |
|
18 | - { |
|
19 | - return array( |
|
20 | - ); |
|
21 | - } |
|
22 | - function getMethod() |
|
23 | - { |
|
24 | - return 'GET'; |
|
25 | - } |
|
12 | + function getApiEndPoint() |
|
13 | + { |
|
14 | + $apiEndPoint = '/v3/posts/hashtag/combo?hashtag=' . $this->channel; |
|
15 | + return $apiEndPoint; |
|
16 | + } |
|
17 | + function getPayload() |
|
18 | + { |
|
19 | + return array( |
|
20 | + ); |
|
21 | + } |
|
22 | + function getMethod() |
|
23 | + { |
|
24 | + return 'GET'; |
|
25 | + } |
|
26 | 26 | } |