@@ -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 | |
@@ -3,37 +3,37 @@ |
||
| 3 | 3 | |
| 4 | 4 | class UpdateLocation extends AbstractRequest { |
| 5 | 5 | /** |
| 6 | - * @var Location |
|
| 7 | - */ |
|
| 8 | - public $location; |
|
| 9 | - /** |
|
| 10 | - * @return Location |
|
| 11 | - */ |
|
| 12 | - public function getLocation() |
|
| 13 | - { |
|
| 14 | - return $this->location; |
|
| 15 | - } |
|
| 16 | - /** |
|
| 17 | - * @param Location $location |
|
| 18 | - */ |
|
| 19 | - public function setLocation($location) |
|
| 20 | - { |
|
| 21 | - $this->location = $location; |
|
| 22 | - } |
|
| 6 | + * @var Location |
|
| 7 | + */ |
|
| 8 | + public $location; |
|
| 9 | + /** |
|
| 10 | + * @return Location |
|
| 11 | + */ |
|
| 12 | + public function getLocation() |
|
| 13 | + { |
|
| 14 | + return $this->location; |
|
| 15 | + } |
|
| 16 | + /** |
|
| 17 | + * @param Location $location |
|
| 18 | + */ |
|
| 19 | + public function setLocation($location) |
|
| 20 | + { |
|
| 21 | + $this->location = $location; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - function getApiEndPoint() |
|
| 25 | - { |
|
| 26 | - return '/v2/users/location'; |
|
| 27 | - } |
|
| 28 | - function getPayload() |
|
| 29 | - { |
|
| 30 | - return array( |
|
| 24 | + function getApiEndPoint() |
|
| 25 | + { |
|
| 26 | + return '/v2/users/location'; |
|
| 27 | + } |
|
| 28 | + function getPayload() |
|
| 29 | + { |
|
| 30 | + return array( |
|
| 31 | 31 | 'location' => $this->getLocation()->toArray(), |
| 32 | - ); |
|
| 33 | - } |
|
| 34 | - function getMethod() |
|
| 35 | - { |
|
| 36 | - return 'PUT'; |
|
| 37 | - } |
|
| 32 | + ); |
|
| 33 | + } |
|
| 34 | + function getMethod() |
|
| 35 | + { |
|
| 36 | + return 'PUT'; |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
@@ -2,19 +2,19 @@ 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'; |
|
| 11 | + private $accessToken = null; |
|
| 12 | + private $payLoad; |
|
| 13 | + public $expects = ''; |
|
| 14 | + public $version = 'v2'; |
|
| 15 | 15 | |
| 16 | - public function execute() |
|
| 17 | - { |
|
| 16 | + public function execute() |
|
| 17 | + { |
|
| 18 | 18 | $result = new \stdClass(); |
| 19 | 19 | |
| 20 | 20 | $this->payLoad = $this->getPayload(); |
@@ -24,16 +24,16 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - $this->payLoad = json_encode($this->payLoad); |
|
| 28 | - $header = $this->getSignHeaders(); |
|
| 29 | - $url = $this->getFullUrl(); |
|
| 27 | + $this->payLoad = json_encode($this->payLoad); |
|
| 28 | + $header = $this->getSignHeaders(); |
|
| 29 | + $url = $this->getFullUrl(); |
|
| 30 | 30 | |
| 31 | - if ($this->getAccessToken()) { |
|
| 32 | - $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
| 33 | - } |
|
| 34 | - //Comment out to debug the Request: |
|
| 31 | + if ($this->getAccessToken()) { |
|
| 32 | + $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
| 33 | + } |
|
| 34 | + //Comment out to debug the Request: |
|
| 35 | 35 | |
| 36 | - /* |
|
| 36 | + /* |
|
| 37 | 37 | printf("URL: "); |
| 38 | 38 | var_dump($url); |
| 39 | 39 | echo "<br />"; |
@@ -44,82 +44,82 @@ discard block |
||
| 44 | 44 | var_dump($this->payLoad); |
| 45 | 45 | echo "<br />"; |
| 46 | 46 | */ |
| 47 | - /* |
|
| 47 | + /* |
|
| 48 | 48 | $options = array( |
| 49 | 49 | 'timeout' => 100, |
| 50 | 50 | 'connect_timeout' => 100, |
| 51 | 51 | 'proxy' => '186.103.169.165:8080', |
| 52 | 52 | );*/ |
| 53 | 53 | |
| 54 | - switch ($this->getMethod()) { |
|
| 55 | - case 'POST': |
|
| 56 | - $result = Requests::post($url, $header, $this->payLoad); |
|
| 57 | - break; |
|
| 58 | - case 'GET': |
|
| 59 | - if($this->version == 'v3') |
|
| 60 | - { |
|
| 61 | - $result = Requests::get($url, $header); |
|
| 62 | - } |
|
| 63 | - else |
|
| 64 | - { |
|
| 65 | - $result = Requests::get($url, $header); |
|
| 66 | - } |
|
| 67 | - break; |
|
| 68 | - case 'PUT': |
|
| 69 | - $result = Requests::put($url, $header, $this->payLoad); |
|
| 70 | - break; |
|
| 71 | - } |
|
| 72 | - switch ($result->status_code) { |
|
| 73 | - case 200: |
|
| 74 | - $result = json_decode($result->body, true); |
|
| 75 | - break; |
|
| 76 | - case 204: |
|
| 77 | - $result = "Success"; |
|
| 78 | - break; |
|
| 79 | - case 401: |
|
| 54 | + switch ($this->getMethod()) { |
|
| 55 | + case 'POST': |
|
| 56 | + $result = Requests::post($url, $header, $this->payLoad); |
|
| 57 | + break; |
|
| 58 | + case 'GET': |
|
| 59 | + if($this->version == 'v3') |
|
| 60 | + { |
|
| 61 | + $result = Requests::get($url, $header); |
|
| 62 | + } |
|
| 63 | + else |
|
| 64 | + { |
|
| 65 | + $result = Requests::get($url, $header); |
|
| 66 | + } |
|
| 67 | + break; |
|
| 68 | + case 'PUT': |
|
| 69 | + $result = Requests::put($url, $header, $this->payLoad); |
|
| 70 | + break; |
|
| 71 | + } |
|
| 72 | + switch ($result->status_code) { |
|
| 73 | + case 200: |
|
| 74 | + $result = json_decode($result->body, true); |
|
| 75 | + break; |
|
| 76 | + case 204: |
|
| 77 | + $result = "Success"; |
|
| 78 | + break; |
|
| 79 | + case 401: |
|
| 80 | 80 | //throw new \Exception('Unauthorized'); |
| 81 | - error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 82 | - break; |
|
| 83 | - case 404: |
|
| 84 | - //echo "Es wurde bereits gevoted"; |
|
| 85 | - error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid); |
|
| 81 | + error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 82 | + break; |
|
| 83 | + case 404: |
|
| 84 | + //echo "Es wurde bereits gevoted"; |
|
| 85 | + error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid); |
|
| 86 | 86 | case 477: |
| 87 | - //echo "Es wurde bereits gevoted"; |
|
| 88 | - //throw new \Exception('Signing failed!'); |
|
| 89 | - error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid); |
|
| 90 | - break; |
|
| 91 | - case 429: |
|
| 92 | - error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid); |
|
| 93 | - exit("Error 429: Too Many Requests"); |
|
| 94 | - break; |
|
| 95 | - case 403: |
|
| 96 | - error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid); |
|
| 97 | - exit("Error 403: Access denied"); |
|
| 98 | - break; |
|
| 99 | - default: |
|
| 100 | - error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 101 | - //throw new \Exception('Unknown Error: '.$result->status_code); |
|
| 102 | - } |
|
| 87 | + //echo "Es wurde bereits gevoted"; |
|
| 88 | + //throw new \Exception('Signing failed!'); |
|
| 89 | + error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid); |
|
| 90 | + break; |
|
| 91 | + case 429: |
|
| 92 | + error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid); |
|
| 93 | + exit("Error 429: Too Many Requests"); |
|
| 94 | + break; |
|
| 95 | + case 403: |
|
| 96 | + error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid); |
|
| 97 | + exit("Error 403: Access denied"); |
|
| 98 | + break; |
|
| 99 | + default: |
|
| 100 | + error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 101 | + //throw new \Exception('Unknown Error: '.$result->status_code); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - if($device_uid != '') |
|
| 105 | - { |
|
| 104 | + if($device_uid != '') |
|
| 105 | + { |
|
| 106 | 106 | $result[0] = $result; |
| 107 | 107 | $result[1] = $device_uid; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /* |
|
| 110 | + /* |
|
| 111 | 111 | var_dump($result); |
| 112 | 112 | */ |
| 113 | 113 | |
| 114 | - return $result; |
|
| 115 | - } |
|
| 116 | - abstract function getPayload(); |
|
| 117 | - /** |
|
| 118 | - * Gets Sign headers |
|
| 119 | - * @return array headers |
|
| 120 | - */ |
|
| 121 | - private function getSignHeaders() |
|
| 122 | - { |
|
| 114 | + return $result; |
|
| 115 | + } |
|
| 116 | + abstract function getPayload(); |
|
| 117 | + /** |
|
| 118 | + * Gets Sign headers |
|
| 119 | + * @return array headers |
|
| 120 | + */ |
|
| 121 | + private function getSignHeaders() |
|
| 122 | + { |
|
| 123 | 123 | if($this->getAccessToken() == null) { |
| 124 | 124 | $payload_accessToken = ""; |
| 125 | 125 | } |
@@ -128,54 +128,54 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
| 131 | - $headers = array( |
|
| 132 | - "Connection" => "keep-alive", |
|
| 133 | - "Accept-Encoding" => "gzip", |
|
| 134 | - "Content-Type" => "application/json; charset=UTF-8", |
|
| 135 | - "User-Agent" => self::USERAGENT |
|
| 136 | - ); |
|
| 137 | - $timestamp = new DateTime(); |
|
| 138 | - $timestamp = $timestamp->format(DateTime::ATOM); |
|
| 139 | - $timestamp = substr($timestamp, 0, -6); |
|
| 140 | - $timestamp .= "Z"; |
|
| 141 | - $urlParts = parse_url($this->getFullUrl()); |
|
| 142 | - $url2 = ""; |
|
| 143 | - $req = [$this->getMethod(), |
|
| 144 | - $urlParts['host'], |
|
| 145 | - "443", |
|
| 146 | - $urlParts['path'], |
|
| 147 | - $payload_accessToken, |
|
| 148 | - $timestamp, |
|
| 149 | - $url2, |
|
| 150 | - $this->payLoad]; |
|
| 151 | - $reqString = implode("%", $req); |
|
| 152 | - $secret = self::SECRET; |
|
| 153 | - $signature = hash_hmac('sha1', $reqString, $secret); |
|
| 154 | - $signature = strtoupper($signature); |
|
| 155 | - $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
| 156 | - $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
| 157 | - $headers['X-Timestamp'] = $timestamp; |
|
| 158 | - $headers['X-Api-Version'] = '0.2'; |
|
| 159 | - return $headers; |
|
| 160 | - } |
|
| 161 | - private function getFullUrl() |
|
| 162 | - { |
|
| 163 | - return self::APIURL . $this->getApiEndPoint(); |
|
| 164 | - } |
|
| 165 | - abstract function getApiEndPoint(); |
|
| 166 | - abstract function getMethod(); |
|
| 167 | - /** |
|
| 168 | - * @return string |
|
| 169 | - */ |
|
| 170 | - private function getAccessToken() |
|
| 171 | - { |
|
| 172 | - return $this->accessToken; |
|
| 173 | - } |
|
| 174 | - /** |
|
| 175 | - * @param string $accessToken |
|
| 176 | - */ |
|
| 177 | - public function setAccessToken($accessToken) |
|
| 178 | - { |
|
| 179 | - $this->accessToken = $accessToken; |
|
| 180 | - } |
|
| 131 | + $headers = array( |
|
| 132 | + "Connection" => "keep-alive", |
|
| 133 | + "Accept-Encoding" => "gzip", |
|
| 134 | + "Content-Type" => "application/json; charset=UTF-8", |
|
| 135 | + "User-Agent" => self::USERAGENT |
|
| 136 | + ); |
|
| 137 | + $timestamp = new DateTime(); |
|
| 138 | + $timestamp = $timestamp->format(DateTime::ATOM); |
|
| 139 | + $timestamp = substr($timestamp, 0, -6); |
|
| 140 | + $timestamp .= "Z"; |
|
| 141 | + $urlParts = parse_url($this->getFullUrl()); |
|
| 142 | + $url2 = ""; |
|
| 143 | + $req = [$this->getMethod(), |
|
| 144 | + $urlParts['host'], |
|
| 145 | + "443", |
|
| 146 | + $urlParts['path'], |
|
| 147 | + $payload_accessToken, |
|
| 148 | + $timestamp, |
|
| 149 | + $url2, |
|
| 150 | + $this->payLoad]; |
|
| 151 | + $reqString = implode("%", $req); |
|
| 152 | + $secret = self::SECRET; |
|
| 153 | + $signature = hash_hmac('sha1', $reqString, $secret); |
|
| 154 | + $signature = strtoupper($signature); |
|
| 155 | + $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
| 156 | + $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
| 157 | + $headers['X-Timestamp'] = $timestamp; |
|
| 158 | + $headers['X-Api-Version'] = '0.2'; |
|
| 159 | + return $headers; |
|
| 160 | + } |
|
| 161 | + private function getFullUrl() |
|
| 162 | + { |
|
| 163 | + return self::APIURL . $this->getApiEndPoint(); |
|
| 164 | + } |
|
| 165 | + abstract function getApiEndPoint(); |
|
| 166 | + abstract function getMethod(); |
|
| 167 | + /** |
|
| 168 | + * @return string |
|
| 169 | + */ |
|
| 170 | + private function getAccessToken() |
|
| 171 | + { |
|
| 172 | + return $this->accessToken; |
|
| 173 | + } |
|
| 174 | + /** |
|
| 175 | + * @param string $accessToken |
|
| 176 | + */ |
|
| 177 | + public function setAccessToken($accessToken) |
|
| 178 | + { |
|
| 179 | + $this->accessToken = $accessToken; |
|
| 180 | + } |
|
| 181 | 181 | } |
@@ -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/'; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | else |
| 109 | 109 | { |
| 110 | - error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 110 | + error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | if(isset($_POST['color'])) |
| 170 | 170 | { |
| 171 | 171 | $color = $_POST['color']; |
| 172 | - switch ($color) { |
|
| 172 | + switch($color) { |
|
| 173 | 173 | case '8ABDB0': |
| 174 | 174 | $color = '8ABDB0'; |
| 175 | 175 | break; |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | function isDeviceUidInDatabase($deviceUid) |
| 222 | 222 | { |
| 223 | 223 | $db = new DatabaseConnect(); |
| 224 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 224 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 225 | 225 | |
| 226 | - if ($result->num_rows > 0) |
|
| 226 | + if($result->num_rows > 0) |
|
| 227 | 227 | { |
| 228 | 228 | return TRUE; |
| 229 | 229 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | $access_token; |
| 242 | 242 | |
| 243 | - if ($result->num_rows > 0) |
|
| 243 | + if($result->num_rows > 0) |
|
| 244 | 244 | { |
| 245 | 245 | // output data of each row |
| 246 | 246 | while($row = $result->fetch_assoc()) { |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | if($expiration_date <= time()) { |
| 259 | 259 | $accountCreator = new CreateUser(); |
| 260 | - $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
|
| 260 | + $accountCreator->setAccessToken($access_token); //$accountData->getAccessToken()); |
|
| 261 | 261 | $accountCreator->setDeviceUid($deviceUid); |
| 262 | 262 | $accountCreator->setLocation($location); |
| 263 | 263 | $data = $accountCreator->execute(); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | expiration_date='" . $expiration_date . "' |
| 273 | 273 | WHERE device_uid='" . $device_uid . "'"); |
| 274 | 274 | |
| 275 | - if($result === false){ |
|
| 275 | + if($result === false) { |
|
| 276 | 276 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $db = new DatabaseConnect(); |
| 286 | 286 | $result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'"); |
| 287 | 287 | |
| 288 | - if ($result->num_rows > 0) |
|
| 288 | + if($result->num_rows > 0) |
|
| 289 | 289 | { |
| 290 | 290 | // output data of each row |
| 291 | 291 | while($row = $result->fetch_assoc()) { |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | if($expiration_date <= time()) { |
| 304 | 304 | $accountCreator = new CreateUser(); |
| 305 | - $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
|
| 305 | + $accountCreator->setAccessToken($access_token); //$accountData->getAccessToken()); |
|
| 306 | 306 | $accountCreator->setDeviceUid($deviceUid); |
| 307 | 307 | $accountCreator->setLocation($location); |
| 308 | 308 | $data = $accountCreator->execute(); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | expiration_date='" . $expiration_date . "' |
| 318 | 318 | WHERE device_uid='" . $device_uid . "'"); |
| 319 | 319 | |
| 320 | - if($result === false){ |
|
| 320 | + if($result === false) { |
|
| 321 | 321 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 322 | 322 | } |
| 323 | 323 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | |
| 333 | 333 | $access_token; |
| 334 | 334 | |
| 335 | - if ($result->num_rows > 0) |
|
| 335 | + if($result->num_rows > 0) |
|
| 336 | 336 | { |
| 337 | 337 | // output data of each row |
| 338 | 338 | while($row = $result->fetch_assoc()) { |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | expiration_date='" . $expiration_date . "' |
| 365 | 365 | WHERE device_uid='" . $device_uid . "'"); |
| 366 | 366 | |
| 367 | - if($result === false){ |
|
| 367 | + if($result === false) { |
|
| 368 | 368 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 369 | 369 | } |
| 370 | 370 | } |
@@ -375,11 +375,11 @@ discard block |
||
| 375 | 375 | function getLocationByAccessToken($accessToken) |
| 376 | 376 | { |
| 377 | 377 | $db = new DatabaseConnect(); |
| 378 | - $result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'"); |
|
| 378 | + $result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'"); |
|
| 379 | 379 | |
| 380 | 380 | $location = new Location(); |
| 381 | 381 | |
| 382 | - if ($result->num_rows > 0) |
|
| 382 | + if($result->num_rows > 0) |
|
| 383 | 383 | { |
| 384 | 384 | // output data of each row |
| 385 | 385 | while($row = $result->fetch_assoc()) |
@@ -400,11 +400,11 @@ discard block |
||
| 400 | 400 | function getLocationByDeviceUid($deviceUid) |
| 401 | 401 | { |
| 402 | 402 | $db = new DatabaseConnect(); |
| 403 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 403 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 404 | 404 | |
| 405 | 405 | $location = new Location(); |
| 406 | 406 | |
| 407 | - if ($result->num_rows > 0) |
|
| 407 | + if($result->num_rows > 0) |
|
| 408 | 408 | { |
| 409 | 409 | // output data of each row |
| 410 | 410 | while($row = $result->fetch_assoc()) |
@@ -425,11 +425,11 @@ discard block |
||
| 425 | 425 | function getDeviceUidByAccessToken($accesstoken) |
| 426 | 426 | { |
| 427 | 427 | $db = new DatabaseConnect(); |
| 428 | - $result = $db->query("SELECT device_uid FROM accounts WHERE access_token='" . $accesstoken . "'"); |
|
| 428 | + $result = $db->query("SELECT device_uid FROM accounts WHERE access_token='" . $accesstoken . "'"); |
|
| 429 | 429 | |
| 430 | 430 | $deviceUid; |
| 431 | 431 | |
| 432 | - if ($result->num_rows > 0) |
|
| 432 | + if($result->num_rows > 0) |
|
| 433 | 433 | { |
| 434 | 434 | // output data of each row |
| 435 | 435 | while($row = $result->fetch_assoc()) |
@@ -448,11 +448,11 @@ discard block |
||
| 448 | 448 | function getAccessTokenByDeviceUid($deviceUid) |
| 449 | 449 | { |
| 450 | 450 | $db = new DatabaseConnect(); |
| 451 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 451 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 452 | 452 | |
| 453 | 453 | $accessToken; |
| 454 | 454 | |
| 455 | - if ($result->num_rows > 0) |
|
| 455 | + if($result->num_rows > 0) |
|
| 456 | 456 | { |
| 457 | 457 | // output data of each row |
| 458 | 458 | while($row = $result->fetch_assoc()) |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 521 | 521 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
| 522 | 522 | |
| 523 | - if($result === false){ |
|
| 523 | + if($result === false) { |
|
| 524 | 524 | $error = db_error(); |
| 525 | 525 | echo $error; |
| 526 | 526 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -548,11 +548,11 @@ discard block |
||
| 548 | 548 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
| 549 | 549 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
| 550 | 550 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
| 551 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 551 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 552 | 552 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 553 | 553 | |
| 554 | 554 | $success = TRUE; |
| 555 | - if($result === false){ |
|
| 555 | + if($result === false) { |
|
| 556 | 556 | $error = db_error(); |
| 557 | 557 | echo $error; |
| 558 | 558 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | { |
| 599 | 599 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 600 | 600 | |
| 601 | - return (isset($matches[0])) ? true : false; |
|
| 601 | + return (isset($matches[0]))?true : false; |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | function botDeviceUidIsSet($config) |
@@ -667,25 +667,25 @@ discard block |
||
| 667 | 667 | $timediff_inDays = (string)$timediff->format('%d'); |
| 668 | 668 | $timediff_inMonth = (string)$timediff->format('%m'); |
| 669 | 669 | |
| 670 | - if($timediff_inMonth!=0) |
|
| 670 | + if($timediff_inMonth != 0) |
|
| 671 | 671 | { |
| 672 | 672 | $timediff = $timediff_inMonth . "m"; |
| 673 | 673 | } |
| 674 | 674 | else |
| 675 | 675 | { |
| 676 | - if($timediff_inDays!=0) |
|
| 676 | + if($timediff_inDays != 0) |
|
| 677 | 677 | { |
| 678 | 678 | $timediff = $timediff_inDays . "d"; |
| 679 | 679 | } |
| 680 | 680 | else |
| 681 | 681 | { |
| 682 | - if($timediff_inHours!=0) |
|
| 682 | + if($timediff_inHours != 0) |
|
| 683 | 683 | { |
| 684 | 684 | $timediff = $timediff_inHours . "h"; |
| 685 | 685 | } |
| 686 | 686 | else |
| 687 | 687 | { |
| 688 | - if($timediff_inMinutes!=0) |
|
| 688 | + if($timediff_inMinutes != 0) |
|
| 689 | 689 | { |
| 690 | 690 | $timediff = $timediff_inMinutes . "m"; |
| 691 | 691 | } |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | |
| 700 | 700 | |
| 701 | 701 | ?> |
| 702 | - <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
|
| 702 | + <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color']; ?>;"> |
|
| 703 | 703 | <content> |
| 704 | 704 | <?php |
| 705 | 705 | if(isset($post['image_url'])) |
@@ -717,24 +717,24 @@ discard block |
||
| 717 | 717 | <?php |
| 718 | 718 | if($isDetailedView) |
| 719 | 719 | {?> |
| 720 | - <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
|
| 720 | + <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>" rel="nofollow"> |
|
| 721 | 721 | <?php } |
| 722 | 722 | else |
| 723 | 723 | {?> |
| 724 | - <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
| 724 | + <a href="index.php?vote=up&postID=<?php echo $post['post_id']; ?>" rel="nofollow"> |
|
| 725 | 725 | <?php } ?> |
| 726 | 726 | <i class="fa fa-angle-up fa-3x"></i> |
| 727 | 727 | </a> |
| 728 | 728 | <br /> |
| 729 | - <?php echo $post["vote_count"];?><br /> |
|
| 729 | + <?php echo $post["vote_count"]; ?><br /> |
|
| 730 | 730 | <?php |
| 731 | 731 | if($isDetailedView) |
| 732 | 732 | {?> |
| 733 | - <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
|
| 733 | + <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>" rel="nofollow"> |
|
| 734 | 734 | <?php } |
| 735 | 735 | else |
| 736 | 736 | {?> |
| 737 | - <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
| 737 | + <a href="index.php?vote=down&postID=<?php echo $post['post_id']; ?>" rel="nofollow"> |
|
| 738 | 738 | <?php } ?> |
| 739 | 739 | <i class="fa fa-angle-down fa-3x"></i> |
| 740 | 740 | </a> |
@@ -746,14 +746,14 @@ discard block |
||
| 746 | 746 | <td class="time"> |
| 747 | 747 | <span class="tip" data-tooltip="Time"> |
| 748 | 748 | <i class="fa fa-clock-o"></i> |
| 749 | - <?php echo $timediff;?> |
|
| 750 | - <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
|
| 749 | + <?php echo $timediff; ?> |
|
| 750 | + <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span> |
|
| 751 | 751 | </span> |
| 752 | 752 | </td> |
| 753 | 753 | <td class="comments"> |
| 754 | 754 | <?php if(!$isDetailedView) {?> |
| 755 | 755 | <span data-tooltip="Comments"> |
| 756 | - <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
|
| 756 | + <a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $post["post_id"]; ?>"> |
|
| 757 | 757 | <i class="fa fa-commenting-o"></i> |
| 758 | 758 | <?php if(array_key_exists("child_count", $post)) { |
| 759 | 759 | echo $post["child_count"]; |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | { |
| 783 | 783 | ?> |
| 784 | 784 | <span data-tooltip="Author"> |
| 785 | - <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
|
| 785 | + <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> | |
|
| 786 | 786 | </span> |
| 787 | 787 | <?php |
| 788 | 788 | } |
@@ -792,8 +792,8 @@ discard block |
||
| 792 | 792 | |
| 793 | 793 | <span class="tip" data-tooltip="Distance"> |
| 794 | 794 | <i class="fa fa-map-marker"></i> |
| 795 | - <?php echo $post['distance'];?> km |
|
| 796 | - <span class="tiptext"><?php echo $post['location']['name'];?></span> |
|
| 795 | + <?php echo $post['distance']; ?> km |
|
| 796 | + <span class="tiptext"><?php echo $post['location']['name']; ?></span> |
|
| 797 | 797 | </span> |
| 798 | 798 | </td> |
| 799 | 799 | </tr> |
@@ -169,7 +169,8 @@ discard block |
||
| 169 | 169 | if(isset($_POST['color'])) |
| 170 | 170 | { |
| 171 | 171 | $color = $_POST['color']; |
| 172 | - switch ($color) { |
|
| 172 | + switch ($color) |
|
| 173 | + { |
|
| 173 | 174 | case '8ABDB0': |
| 174 | 175 | $color = '8ABDB0'; |
| 175 | 176 | break; |
@@ -243,7 +244,8 @@ discard block |
||
| 243 | 244 | if ($result->num_rows > 0) |
| 244 | 245 | { |
| 245 | 246 | // output data of each row |
| 246 | - while($row = $result->fetch_assoc()) { |
|
| 247 | + while($row = $result->fetch_assoc()) |
|
| 248 | + { |
|
| 247 | 249 | //$access_token = $row["access_token"]; |
| 248 | 250 | $expiration_date = $row["expiration_date"]; |
| 249 | 251 | $deviceUid = $row["device_uid"]; |
@@ -255,7 +257,8 @@ discard block |
||
| 255 | 257 | echo '0 results'; |
| 256 | 258 | } |
| 257 | 259 | |
| 258 | - if($expiration_date <= time()) { |
|
| 260 | + if($expiration_date <= time()) |
|
| 261 | + { |
|
| 259 | 262 | $accountCreator = new CreateUser(); |
| 260 | 263 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
| 261 | 264 | $accountCreator->setDeviceUid($deviceUid); |
@@ -272,7 +275,8 @@ discard block |
||
| 272 | 275 | expiration_date='" . $expiration_date . "' |
| 273 | 276 | WHERE device_uid='" . $device_uid . "'"); |
| 274 | 277 | |
| 275 | - if($result === false){ |
|
| 278 | + if($result === false) |
|
| 279 | + { |
|
| 276 | 280 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 277 | 281 | } |
| 278 | 282 | } |
@@ -288,7 +292,8 @@ discard block |
||
| 288 | 292 | if ($result->num_rows > 0) |
| 289 | 293 | { |
| 290 | 294 | // output data of each row |
| 291 | - while($row = $result->fetch_assoc()) { |
|
| 295 | + while($row = $result->fetch_assoc()) |
|
| 296 | + { |
|
| 292 | 297 | //$access_token = $row["access_token"]; |
| 293 | 298 | $expiration_date = $row["expiration_date"]; |
| 294 | 299 | $deviceUid = $row["device_uid"]; |
@@ -300,7 +305,8 @@ discard block |
||
| 300 | 305 | echo '0 results'; |
| 301 | 306 | } |
| 302 | 307 | |
| 303 | - if($expiration_date <= time()) { |
|
| 308 | + if($expiration_date <= time()) |
|
| 309 | + { |
|
| 304 | 310 | $accountCreator = new CreateUser(); |
| 305 | 311 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
| 306 | 312 | $accountCreator->setDeviceUid($deviceUid); |
@@ -317,7 +323,8 @@ discard block |
||
| 317 | 323 | expiration_date='" . $expiration_date . "' |
| 318 | 324 | WHERE device_uid='" . $device_uid . "'"); |
| 319 | 325 | |
| 320 | - if($result === false){ |
|
| 326 | + if($result === false) |
|
| 327 | + { |
|
| 321 | 328 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 322 | 329 | } |
| 323 | 330 | } |
@@ -335,7 +342,8 @@ discard block |
||
| 335 | 342 | if ($result->num_rows > 0) |
| 336 | 343 | { |
| 337 | 344 | // output data of each row |
| 338 | - while($row = $result->fetch_assoc()) { |
|
| 345 | + while($row = $result->fetch_assoc()) |
|
| 346 | + { |
|
| 339 | 347 | //$access_token = $row["access_token"]; |
| 340 | 348 | $expiration_date = $row["expiration_date"]; |
| 341 | 349 | $deviceUid = $row["device_uid"]; |
@@ -347,7 +355,8 @@ discard block |
||
| 347 | 355 | echo '0 results'; |
| 348 | 356 | } |
| 349 | 357 | |
| 350 | - if($expiration_date <= time()) { |
|
| 358 | + if($expiration_date <= time()) |
|
| 359 | + { |
|
| 351 | 360 | $accountCreator = new CreateUser(); |
| 352 | 361 | $accountCreator->setAccessToken($access_token); |
| 353 | 362 | $accountCreator->setDeviceUid($deviceUid); |
@@ -364,7 +373,8 @@ discard block |
||
| 364 | 373 | expiration_date='" . $expiration_date . "' |
| 365 | 374 | WHERE device_uid='" . $device_uid . "'"); |
| 366 | 375 | |
| 367 | - if($result === false){ |
|
| 376 | + if($result === false) |
|
| 377 | + { |
|
| 368 | 378 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 369 | 379 | } |
| 370 | 380 | } |
@@ -520,14 +530,16 @@ discard block |
||
| 520 | 530 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 521 | 531 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
| 522 | 532 | |
| 523 | - if($result === false){ |
|
| 533 | + if($result === false) |
|
| 534 | + { |
|
| 524 | 535 | $error = db_error(); |
| 525 | 536 | echo $error; |
| 526 | 537 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
| 527 | 538 | } |
| 528 | 539 | } |
| 529 | 540 | |
| 530 | -function registerAccount(Location $location) { |
|
| 541 | +function registerAccount(Location $location) |
|
| 542 | +{ |
|
| 531 | 543 | $accountCreator = new CreateUser(); |
| 532 | 544 | $accountCreator->setLocation($location); |
| 533 | 545 | $data = $accountCreator->execute(); |
@@ -552,7 +564,8 @@ discard block |
||
| 552 | 564 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 553 | 565 | |
| 554 | 566 | $success = TRUE; |
| 555 | - if($result === false){ |
|
| 567 | + if($result === false) |
|
| 568 | + { |
|
| 556 | 569 | $error = db_error(); |
| 557 | 570 | echo $error; |
| 558 | 571 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -563,7 +576,7 @@ discard block |
||
| 563 | 576 | } |
| 564 | 577 | |
| 565 | 578 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
| 566 | -{ |
|
| 579 | +{ |
|
| 567 | 580 | $accountCreator = new GetPosts(); |
| 568 | 581 | $accountCreator->setLastPostId($lastPostId); |
| 569 | 582 | $accountCreator->setAccessToken($accessToken); |
@@ -652,7 +665,8 @@ discard block |
||
| 652 | 665 | } |
| 653 | 666 | |
| 654 | 667 | function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE) |
| 655 | -{ //ToDO |
|
| 668 | +{ |
|
| 669 | +//ToDO |
|
| 656 | 670 | //Replace # with link |
| 657 | 671 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
| 658 | 672 | |
@@ -708,7 +722,8 @@ discard block |
||
| 708 | 722 | |
| 709 | 723 | echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
| 710 | 724 | } |
| 711 | - else { |
|
| 725 | + else |
|
| 726 | + { |
|
| 712 | 727 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
| 713 | 728 | } |
| 714 | 729 | ?> |
@@ -716,11 +731,13 @@ discard block |
||
| 716 | 731 | <aside> |
| 717 | 732 | <?php |
| 718 | 733 | if($isDetailedView) |
| 719 | - {?> |
|
| 734 | + { |
|
| 735 | +?> |
|
| 720 | 736 | <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
| 721 | 737 | <?php } |
| 722 | - else |
|
| 723 | - {?> |
|
| 738 | +else |
|
| 739 | + { |
|
| 740 | +?> |
|
| 724 | 741 | <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
| 725 | 742 | <?php } ?> |
| 726 | 743 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -729,11 +746,13 @@ discard block |
||
| 729 | 746 | <?php echo $post["vote_count"];?><br /> |
| 730 | 747 | <?php |
| 731 | 748 | if($isDetailedView) |
| 732 | - {?> |
|
| 749 | + { |
|
| 750 | +?> |
|
| 733 | 751 | <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
| 734 | 752 | <?php } |
| 735 | - else |
|
| 736 | - {?> |
|
| 753 | +else |
|
| 754 | + { |
|
| 755 | +?> |
|
| 737 | 756 | <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
| 738 | 757 | <?php } ?> |
| 739 | 758 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -751,13 +770,19 @@ discard block |
||
| 751 | 770 | </span> |
| 752 | 771 | </td> |
| 753 | 772 | <td class="comments"> |
| 754 | - <?php if(!$isDetailedView) {?> |
|
| 773 | + <?php if(!$isDetailedView) |
|
| 774 | +{ |
|
| 775 | +?> |
|
| 755 | 776 | <span data-tooltip="Comments"> |
| 756 | 777 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
| 757 | 778 | <i class="fa fa-commenting-o"></i> |
| 758 | - <?php if(array_key_exists("child_count", $post)) { |
|
| 779 | + <?php if(array_key_exists("child_count", $post)) |
|
| 780 | +{ |
|
| 759 | 781 | echo $post["child_count"]; |
| 760 | - } else echo "0"; |
|
| 782 | + } |
|
| 783 | + else { |
|
| 784 | + echo "0"; |
|
| 785 | + } |
|
| 761 | 786 | ?> |
| 762 | 787 | </a> |
| 763 | 788 | </span> |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
| 73 | 73 | $result = Requests::post($url); |
| 74 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
| 74 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
| 75 | 75 | { |
| 76 | 76 | return "0 results"; |
| 77 | 77 | } |
| 78 | 78 | else |
| 79 | 79 | { |
| 80 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
| 81 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
| 82 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
| 80 | + $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name']; |
|
| 81 | + $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']; |
|
| 82 | + $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']; |
|
| 83 | 83 | |
| 84 | 84 | $location = new Location(); |
| 85 | 85 | $location->setLat($lat); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | lng='" . $lng . "' |
| 102 | 102 | WHERE access_token='" . $accessToken . "'"); |
| 103 | 103 | |
| 104 | - if($result === false) |
|
| 104 | + if($result === FALSE) |
|
| 105 | 105 | { |
| 106 | 106 | echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
| 107 | 107 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | expiration_date='" . $expiration_date . "' |
| 273 | 273 | WHERE device_uid='" . $device_uid . "'"); |
| 274 | 274 | |
| 275 | - if($result === false){ |
|
| 275 | + if($result === FALSE){ |
|
| 276 | 276 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | expiration_date='" . $expiration_date . "' |
| 318 | 318 | WHERE device_uid='" . $device_uid . "'"); |
| 319 | 319 | |
| 320 | - if($result === false){ |
|
| 320 | + if($result === FALSE){ |
|
| 321 | 321 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 322 | 322 | } |
| 323 | 323 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | expiration_date='" . $expiration_date . "' |
| 365 | 365 | WHERE device_uid='" . $device_uid . "'"); |
| 366 | 366 | |
| 367 | - if($result === false){ |
|
| 367 | + if($result === FALSE){ |
|
| 368 | 368 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 369 | 369 | } |
| 370 | 370 | } |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | FROM votes |
| 489 | 489 | WHERE (postId = '" . $postId . "' AND device_uid = '" . $deviceUid . "')"); |
| 490 | 490 | |
| 491 | - if($result === false) |
|
| 491 | + if($result === FALSE) |
|
| 492 | 492 | { |
| 493 | 493 | $error = db_error(); |
| 494 | 494 | echo $error; |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 521 | 521 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
| 522 | 522 | |
| 523 | - if($result === false){ |
|
| 523 | + if($result === FALSE){ |
|
| 524 | 524 | $error = db_error(); |
| 525 | 525 | echo $error; |
| 526 | 526 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 553 | 553 | |
| 554 | 554 | $success = TRUE; |
| 555 | - if($result === false){ |
|
| 555 | + if($result === FALSE){ |
|
| 556 | 556 | $error = db_error(); |
| 557 | 557 | echo $error; |
| 558 | 558 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | { |
| 599 | 599 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 600 | 600 | |
| 601 | - return (isset($matches[0])) ? true : false; |
|
| 601 | + return (isset($matches[0])) ? TRUE : FALSE; |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | function botDeviceUidIsSet($config) |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId'])) |
| 37 | 37 | { |
| 38 | 38 | $deviceUid = createAccount(); |
| 39 | - setcookie('JodelDeviceId', $deviceUid, time()+60*60*24*365*10); |
|
| 40 | - error_log('Created account with JodelDeviceId:' . $deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 39 | + setcookie('JodelDeviceId', $deviceUid, time() + 60 * 60 * 24 * 365 * 10); |
|
| 40 | + error_log('Created account with JodelDeviceId:' . $deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | else |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | //Set View |
| 58 | 58 | if(isset($_GET['view'])) |
| 59 | 59 | { |
| 60 | - switch ($_GET['view']) { |
|
| 60 | + switch($_GET['view']) { |
|
| 61 | 61 | case 'comment': |
| 62 | 62 | $view = 'comment'; |
| 63 | 63 | break; |
@@ -145,13 +145,13 @@ discard block |
||
| 145 | 145 | else |
| 146 | 146 | { |
| 147 | 147 | $version = 'v2'; |
| 148 | - if($view=='comment') |
|
| 148 | + if($view == 'comment') |
|
| 149 | 149 | { |
| 150 | 150 | $url = "/v2/posts/location/discussed/"; |
| 151 | 151 | } |
| 152 | 152 | else |
| 153 | 153 | { |
| 154 | - if($view=='upVote') |
|
| 154 | + if($view == 'upVote') |
|
| 155 | 155 | { |
| 156 | 156 | $url = "/v2/posts/location/popular/"; |
| 157 | 157 | } |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | <!DOCTYPE html> |
| 178 | 178 | <html lang="en"> |
| 179 | 179 | <head> |
| 180 | - <title><?php echo getTitle($posts[0], $view, $isDetailedView);?></title> |
|
| 180 | + <title><?php echo getTitle($posts[0], $view, $isDetailedView); ?></title> |
|
| 181 | 181 | |
| 182 | 182 | <meta charset="utf-8"> |
| 183 | 183 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 184 | 184 | <meta http-equiv="x-ua-compatible" content="ie=edge"> |
| 185 | 185 | |
| 186 | - <meta name="description" content="<?php echo getMetaDescription($posts[0], $view, $isDetailedView);?>"> |
|
| 186 | + <meta name="description" content="<?php echo getMetaDescription($posts[0], $view, $isDetailedView); ?>"> |
|
| 187 | 187 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app"> |
| 188 | 188 | |
| 189 | 189 | <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"> |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | <content id="posts"> |
| 266 | 266 | <?php |
| 267 | - for($i = 0; $i<$loops; $i++) |
|
| 267 | + for($i = 0; $i < $loops; $i++) |
|
| 268 | 268 | { |
| 269 | 269 | if(array_key_exists($i, $posts) && array_key_exists('post_id', $posts[$i]) && isset($posts[$i]['post_id'])) |
| 270 | 270 | { |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
| 309 | 309 | <h2>Comment on Jodel</h2> |
| 310 | 310 | <form method="POST"> |
| 311 | - <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
|
| 311 | + <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" /> |
|
| 312 | 312 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
| 313 | 313 | <br /> |
| 314 | 314 | <input type="submit" value="SEND" /> |
@@ -345,13 +345,13 @@ discard block |
||
| 345 | 345 | <div class="col-xs-12"> |
| 346 | 346 | <div class="row"> |
| 347 | 347 | <div class="col-xs-3"> |
| 348 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 348 | + <a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 349 | 349 | </div> |
| 350 | 350 | <div class="col-xs-3"> |
| 351 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 351 | + <a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 352 | 352 | </div> |
| 353 | 353 | <div class="col-xs-3"> |
| 354 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 354 | + <a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 355 | 355 | </div> |
| 356 | 356 | <div class="col-xs-3"> |
| 357 | 357 | <nav> |
@@ -57,7 +57,8 @@ discard block |
||
| 57 | 57 | //Set View |
| 58 | 58 | if(isset($_GET['view'])) |
| 59 | 59 | { |
| 60 | - switch ($_GET['view']) { |
|
| 60 | + switch ($_GET['view']) |
|
| 61 | + { |
|
| 61 | 62 | case 'comment': |
| 62 | 63 | $view = 'comment'; |
| 63 | 64 | break; |
@@ -113,7 +114,8 @@ discard block |
||
| 113 | 114 | $data = $accountCreator->execute(); |
| 114 | 115 | |
| 115 | 116 | $posts[0] = $data; |
| 116 | - if(array_key_exists('children', $data)) { |
|
| 117 | + if(array_key_exists('children', $data)) |
|
| 118 | + { |
|
| 117 | 119 | foreach($data['children'] as $key => $child) |
| 118 | 120 | { |
| 119 | 121 | |
@@ -249,7 +251,11 @@ discard block |
||
| 249 | 251 | |
| 250 | 252 | <div id="location_mobile" class="hidden-sm-up"> |
| 251 | 253 | <form method="get"> |
| 252 | - <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
| 254 | + <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
| 255 | +{ |
|
| 256 | + echo $newPositionStatus; |
|
| 257 | +} |
|
| 258 | +?>" required> |
|
| 253 | 259 | |
| 254 | 260 | <input type="submit" id="submit_mobile" class="fa" value="" /> |
| 255 | 261 | </form> |
@@ -276,7 +282,9 @@ discard block |
||
| 276 | 282 | |
| 277 | 283 | </content> |
| 278 | 284 | |
| 279 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 285 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
| 286 | +{ |
|
| 287 | +?> |
|
| 280 | 288 | <p id="loading"> |
| 281 | 289 | Loading… |
| 282 | 290 | </p> |
@@ -289,7 +297,11 @@ discard block |
||
| 289 | 297 | <div> |
| 290 | 298 | <h2>Position</h2> |
| 291 | 299 | <form method="get"> |
| 292 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
| 300 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
| 301 | +{ |
|
| 302 | + echo $newPositionStatus; |
|
| 303 | +} |
|
| 304 | +?>" required> |
|
| 293 | 305 | |
| 294 | 306 | <input type="submit" value="Set Location" /> |
| 295 | 307 | </form> |
@@ -305,7 +317,9 @@ discard block |
||
| 305 | 317 | |
| 306 | 318 | <article> |
| 307 | 319 | <div> |
| 308 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
| 320 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
| 321 | +{ |
|
| 322 | +?> |
|
| 309 | 323 | <h2>Comment on Jodel</h2> |
| 310 | 324 | <form method="POST"> |
| 311 | 325 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
@@ -313,7 +327,10 @@ discard block |
||
| 313 | 327 | <br /> |
| 314 | 328 | <input type="submit" value="SEND" /> |
| 315 | 329 | </form> |
| 316 | - <?php } else { ?> |
|
| 330 | + <?php } |
|
| 331 | +else |
|
| 332 | +{ |
|
| 333 | +?> |
|
| 317 | 334 | <h2>New Jodel</h2> |
| 318 | 335 | <form method="POST"> |
| 319 | 336 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -345,13 +362,25 @@ discard block |
||
| 345 | 362 | <div class="col-xs-12"> |
| 346 | 363 | <div class="row"> |
| 347 | 364 | <div class="col-xs-3"> |
| 348 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 365 | + <a href="index.php" <?php if($view=='time') |
|
| 366 | +{ |
|
| 367 | + echo 'class="active"'; |
|
| 368 | +} |
|
| 369 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 349 | 370 | </div> |
| 350 | 371 | <div class="col-xs-3"> |
| 351 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 372 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
| 373 | +{ |
|
| 374 | + echo 'class="active"'; |
|
| 375 | +} |
|
| 376 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 352 | 377 | </div> |
| 353 | 378 | <div class="col-xs-3"> |
| 354 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 379 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
| 380 | +{ |
|
| 381 | + echo 'class="active"'; |
|
| 382 | +} |
|
| 383 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 355 | 384 | </div> |
| 356 | 385 | <div class="col-xs-3"> |
| 357 | 386 | <nav> |
@@ -392,7 +421,9 @@ discard block |
||
| 392 | 421 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
| 393 | 422 | } |
| 394 | 423 | |
| 395 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 424 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
| 425 | +{ |
|
| 426 | +?> |
|
| 396 | 427 | |
| 397 | 428 | |
| 398 | 429 | |