@@ -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 | } |
@@ -616,7 +616,7 @@ |
||
| 616 | 616 | <?php |
| 617 | 617 | if(is_file('./piwik-script.html')) |
| 618 | 618 | { |
| 619 | - require_once('./piwik-script.html'); |
|
| 619 | + require_once('./piwik-script.html'); |
|
| 620 | 620 | } |
| 621 | 621 | ?> |
| 622 | 622 | |
@@ -1,14 +1,14 @@ discard block |
||
| 1 | -<?php include 'php/jodel-web.php';?> |
|
| 1 | +<?php include 'php/jodel-web.php'; ?> |
|
| 2 | 2 | <!DOCTYPE html> |
| 3 | 3 | <html lang="en"> |
| 4 | 4 | <head> |
| 5 | - <title><?php echo $viewTest::getTitle($posts[0], $view, $isDetailedView);?></title> |
|
| 5 | + <title><?php echo $viewTest::getTitle($posts[0], $view, $isDetailedView); ?></title> |
|
| 6 | 6 | |
| 7 | 7 | <meta charset="utf-8"> |
| 8 | 8 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 9 | 9 | <meta http-equiv="x-ua-compatible" content="ie=edge"> |
| 10 | 10 | |
| 11 | - <meta name="description" content="<?php echo $viewTest::getMetaDescription($posts[0], $view, $isDetailedView);?>"> |
|
| 11 | + <meta name="description" content="<?php echo $viewTest::getMetaDescription($posts[0], $view, $isDetailedView); ?>"> |
|
| 12 | 12 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app"> |
| 13 | 13 | |
| 14 | 14 | <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"> |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | <content id="posts"> |
| 92 | 92 | <?php |
| 93 | - for($i = 0; $i<$loops; $i++) |
|
| 93 | + for($i = 0; $i < $loops; $i++) |
|
| 94 | 94 | { |
| 95 | 95 | if(array_key_exists($i, $posts) && array_key_exists('post_id', $posts[$i]) && isset($posts[$i]['post_id'])) |
| 96 | 96 | { |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | <?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?> |
| 135 | 135 | <h2>Comment on Jodel</h2> |
| 136 | 136 | <form method="POST"> |
| 137 | - <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" /> |
|
| 137 | + <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']); ?>" /> |
|
| 138 | 138 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
| 139 | 139 | <br /> |
| 140 | 140 | <input type="submit" value="SEND" /> |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | <div class="col-xs-12"> |
| 172 | 172 | <div class="row"> |
| 173 | 173 | <div class="col-xs-3"> |
| 174 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 174 | + <a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 175 | 175 | </div> |
| 176 | 176 | <div class="col-xs-3"> |
| 177 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 177 | + <a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 178 | 178 | </div> |
| 179 | 179 | <div class="col-xs-3"> |
| 180 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 180 | + <a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 181 | 181 | </div> |
| 182 | 182 | <div class="col-xs-3"> |
| 183 | 183 | <nav> |
@@ -75,7 +75,11 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | <div id="location_mobile" class="hidden-sm-up"> |
| 77 | 77 | <form method="get"> |
| 78 | - <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
| 78 | + <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
| 79 | +{ |
|
| 80 | + echo $newPositionStatus; |
|
| 81 | +} |
|
| 82 | +?>" required> |
|
| 79 | 83 | |
| 80 | 84 | <input type="submit" id="submit_mobile" class="fa" value="" /> |
| 81 | 85 | </form> |
@@ -102,7 +106,9 @@ discard block |
||
| 102 | 106 | |
| 103 | 107 | </content> |
| 104 | 108 | |
| 105 | - <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 109 | + <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) |
|
| 110 | +{ |
|
| 111 | +?> |
|
| 106 | 112 | <p id="loading"> |
| 107 | 113 | Loading… |
| 108 | 114 | </p> |
@@ -115,7 +121,11 @@ discard block |
||
| 115 | 121 | <div> |
| 116 | 122 | <h2>Position / Hashtag</h2> |
| 117 | 123 | <form method="get"> |
| 118 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
| 124 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
| 125 | +{ |
|
| 126 | + echo $newPositionStatus; |
|
| 127 | +} |
|
| 128 | +?>" required> |
|
| 119 | 129 | <label>try: #jhj</label><br> |
| 120 | 130 | <input type="submit" value="Set Location" /> |
| 121 | 131 | </form> |
@@ -131,7 +141,9 @@ discard block |
||
| 131 | 141 | |
| 132 | 142 | <article> |
| 133 | 143 | <div> |
| 134 | - <?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?> |
|
| 144 | + <?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) |
|
| 145 | +{ |
|
| 146 | +?> |
|
| 135 | 147 | <h2>Comment on Jodel</h2> |
| 136 | 148 | <form method="POST"> |
| 137 | 149 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" /> |
@@ -139,7 +151,10 @@ discard block |
||
| 139 | 151 | <br /> |
| 140 | 152 | <input type="submit" value="SEND" /> |
| 141 | 153 | </form> |
| 142 | - <?php } else { ?> |
|
| 154 | + <?php } |
|
| 155 | +else |
|
| 156 | +{ |
|
| 157 | +?> |
|
| 143 | 158 | <h2>New Jodel</h2> |
| 144 | 159 | <form method="POST"> |
| 145 | 160 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -171,13 +186,25 @@ discard block |
||
| 171 | 186 | <div class="col-xs-12"> |
| 172 | 187 | <div class="row"> |
| 173 | 188 | <div class="col-xs-3"> |
| 174 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 189 | + <a href="index.php" <?php if($view=='time') |
|
| 190 | +{ |
|
| 191 | + echo 'class="active"'; |
|
| 192 | +} |
|
| 193 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 175 | 194 | </div> |
| 176 | 195 | <div class="col-xs-3"> |
| 177 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 196 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
| 197 | +{ |
|
| 198 | + echo 'class="active"'; |
|
| 199 | +} |
|
| 200 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 178 | 201 | </div> |
| 179 | 202 | <div class="col-xs-3"> |
| 180 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 203 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
| 204 | +{ |
|
| 205 | + echo 'class="active"'; |
|
| 206 | +} |
|
| 207 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 181 | 208 | </div> |
| 182 | 209 | <div class="col-xs-3"> |
| 183 | 210 | <nav> |
@@ -218,7 +245,9 @@ discard block |
||
| 218 | 245 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
| 219 | 246 | } |
| 220 | 247 | |
| 221 | - <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 248 | + <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) |
|
| 249 | +{ |
|
| 250 | +?> |
|
| 222 | 251 | |
| 223 | 252 | |
| 224 | 253 | |
@@ -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/'; |
@@ -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 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Jodel |
| 4 | 4 | { |
| 5 | - public $jodel; |
|
| 5 | + public $jodel; |
|
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | } |
| 9 | 9 | \ No newline at end of file |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | { |
| 44 | 44 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 45 | 45 | |
| 46 | - return (isset($matches[0])) ? true : false; |
|
| 46 | + return (isset($matches[0])) ? TRUE : FALSE; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | function configPropertyExists($config, $property) |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 45 | 45 | |
| 46 | - return (isset($matches[0])) ? true : false; |
|
| 46 | + return (isset($matches[0]))?true : false; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | function configPropertyExists($config, $property) |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | function isDeviceUidInDatabase($deviceUid) |
| 62 | 62 | { |
| 63 | 63 | $db = new DatabaseConnect(); |
| 64 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 64 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 65 | 65 | |
| 66 | - if ($result->num_rows > 0) |
|
| 66 | + if($result->num_rows > 0) |
|
| 67 | 67 | { |
| 68 | 68 | return TRUE; |
| 69 | 69 | } |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId'])) |
| 86 | 86 | { |
| 87 | 87 | $jodelAccountForView = new JodelAccount(); |
| 88 | - setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time()+60*60*24*365*10); |
|
| 89 | - error_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 88 | + setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time() + 60 * 60 * 24 * 365 * 10); |
|
| 89 | + error_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | else |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | //Set View |
| 115 | 115 | if(isset($_GET['view'])) |
| 116 | 116 | { |
| 117 | - switch ($_GET['view']) { |
|
| 117 | + switch($_GET['view']) { |
|
| 118 | 118 | case 'comment': |
| 119 | 119 | $view = 'comment'; |
| 120 | 120 | break; |
@@ -312,13 +312,13 @@ discard block |
||
| 312 | 312 | else |
| 313 | 313 | { |
| 314 | 314 | $version = 'v2'; |
| 315 | - if($view=='comment') |
|
| 315 | + if($view == 'comment') |
|
| 316 | 316 | { |
| 317 | 317 | $url = "/v2/posts/location/discussed/"; |
| 318 | 318 | } |
| 319 | 319 | else |
| 320 | 320 | { |
| 321 | - if($view=='upVote') |
|
| 321 | + if($view == 'upVote') |
|
| 322 | 322 | { |
| 323 | 323 | $url = "/v2/posts/location/popular/"; |
| 324 | 324 | } |
@@ -41,36 +41,36 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | function isUserBot() |
| 43 | 43 | { |
| 44 | - preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
| 44 | + preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
| 45 | 45 | |
| 46 | - return (isset($matches[0])) ? true : false; |
|
| 46 | + return (isset($matches[0])) ? true : false; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | function configPropertyExists($config, $property) |
| 50 | 50 | { |
| 51 | - if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
| 52 | - { |
|
| 53 | - return FALSE; |
|
| 54 | - } |
|
| 55 | - else |
|
| 56 | - { |
|
| 57 | - return TRUE; |
|
| 58 | - } |
|
| 51 | + if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
| 52 | + { |
|
| 53 | + return FALSE; |
|
| 54 | + } |
|
| 55 | + else |
|
| 56 | + { |
|
| 57 | + return TRUE; |
|
| 58 | + } |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | function isDeviceUidInDatabase($deviceUid) |
| 62 | 62 | { |
| 63 | - $db = new DatabaseConnect(); |
|
| 64 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 63 | + $db = new DatabaseConnect(); |
|
| 64 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 65 | 65 | |
| 66 | - if ($result->num_rows > 0) |
|
| 67 | - { |
|
| 68 | - return TRUE; |
|
| 69 | - } |
|
| 70 | - else |
|
| 71 | - { |
|
| 72 | - return FALSE; |
|
| 73 | - } |
|
| 66 | + if ($result->num_rows > 0) |
|
| 67 | + { |
|
| 68 | + return TRUE; |
|
| 69 | + } |
|
| 70 | + else |
|
| 71 | + { |
|
| 72 | + return FALSE; |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | //Check if it's a Spider or Google Bot |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | if(configPropertyExists($config, 'karmaDeviceUid')) |
| 100 | - { |
|
| 101 | - $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
| 102 | - } |
|
| 103 | - else |
|
| 104 | - { |
|
| 105 | - error_log("No Karma deviceUid set in config file"); |
|
| 100 | + { |
|
| 101 | + $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
| 102 | + } |
|
| 103 | + else |
|
| 104 | + { |
|
| 105 | + error_log("No Karma deviceUid set in config file"); |
|
| 106 | 106 | $jodelAccountForKarma = new JodelAccount($deviceUid); |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | $newPositionStatus = $jodelAccountForView->location->getCityName(); |
| 110 | 110 | |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | { |
| 152 | 152 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
| 153 | 153 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
| 154 | - { |
|
| 155 | - header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
| 156 | - } |
|
| 157 | - else |
|
| 158 | - { |
|
| 159 | - header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
| 160 | - } |
|
| 161 | - die(); |
|
| 154 | + { |
|
| 155 | + header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
| 156 | + } |
|
| 157 | + else |
|
| 158 | + { |
|
| 159 | + header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
| 160 | + } |
|
| 161 | + die(); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | //SendJodel |
@@ -203,32 +203,32 @@ discard block |
||
| 203 | 203 | if(!array_key_exists(0, $posts)) |
| 204 | 204 | { |
| 205 | 205 | $posts[0] = array( |
| 206 | - "post_id" => "0", |
|
| 207 | - "discovered_by" => 0, |
|
| 208 | - "message" => "Not found", |
|
| 209 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
| 210 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
| 211 | - "pin_count" => 0, |
|
| 212 | - "color" => "FFBA00", |
|
| 213 | - "got_thanks" => FALSE, |
|
| 214 | - "post_own" => "friend", |
|
| 215 | - "discovered" => 0, |
|
| 216 | - "distance" => 9, |
|
| 217 | - "vote_count" => 0, |
|
| 218 | - "location" => |
|
| 219 | - array("name" => "Berlin", |
|
| 220 | - "loc_coordinates" => |
|
| 221 | - array( |
|
| 222 | - "lat" => 0, |
|
| 223 | - "lng" => 0 |
|
| 224 | - ), |
|
| 225 | - "loc_accuracy" => 0, |
|
| 226 | - "country" => "", |
|
| 227 | - "city" => "", |
|
| 228 | - ), |
|
| 229 | - "tags" => |
|
| 230 | - array(), |
|
| 231 | - "user_handle" => "0" |
|
| 206 | + "post_id" => "0", |
|
| 207 | + "discovered_by" => 0, |
|
| 208 | + "message" => "Not found", |
|
| 209 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
| 210 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
| 211 | + "pin_count" => 0, |
|
| 212 | + "color" => "FFBA00", |
|
| 213 | + "got_thanks" => FALSE, |
|
| 214 | + "post_own" => "friend", |
|
| 215 | + "discovered" => 0, |
|
| 216 | + "distance" => 9, |
|
| 217 | + "vote_count" => 0, |
|
| 218 | + "location" => |
|
| 219 | + array("name" => "Berlin", |
|
| 220 | + "loc_coordinates" => |
|
| 221 | + array( |
|
| 222 | + "lat" => 0, |
|
| 223 | + "lng" => 0 |
|
| 224 | + ), |
|
| 225 | + "loc_accuracy" => 0, |
|
| 226 | + "country" => "", |
|
| 227 | + "city" => "", |
|
| 228 | + ), |
|
| 229 | + "tags" => |
|
| 230 | + array(), |
|
| 231 | + "user_handle" => "0" |
|
| 232 | 232 | ); |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -237,32 +237,32 @@ discard block |
||
| 237 | 237 | $posts = array(); |
| 238 | 238 | $posts[0] = |
| 239 | 239 | array( |
| 240 | - "post_id" => "0", |
|
| 241 | - "discovered_by" => 0, |
|
| 242 | - "message" => "Bad Request", |
|
| 243 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
| 244 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
| 245 | - "pin_count" => 0, |
|
| 246 | - "color" => "FFBA00", |
|
| 247 | - "got_thanks" => FALSE, |
|
| 248 | - "post_own" => "friend", |
|
| 249 | - "discovered" => 0, |
|
| 250 | - "distance" => 9, |
|
| 251 | - "vote_count" => 0, |
|
| 252 | - "location" => |
|
| 253 | - array("name" => "Berlin", |
|
| 254 | - "loc_coordinates" => |
|
| 255 | - array( |
|
| 256 | - "lat" => 0, |
|
| 257 | - "lng" => 0 |
|
| 258 | - ), |
|
| 259 | - "loc_accuracy" => 0, |
|
| 260 | - "country" => "", |
|
| 261 | - "city" => "", |
|
| 262 | - ), |
|
| 263 | - "tags" => |
|
| 264 | - array(), |
|
| 265 | - "user_handle" => "0" |
|
| 240 | + "post_id" => "0", |
|
| 241 | + "discovered_by" => 0, |
|
| 242 | + "message" => "Bad Request", |
|
| 243 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
| 244 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
| 245 | + "pin_count" => 0, |
|
| 246 | + "color" => "FFBA00", |
|
| 247 | + "got_thanks" => FALSE, |
|
| 248 | + "post_own" => "friend", |
|
| 249 | + "discovered" => 0, |
|
| 250 | + "distance" => 9, |
|
| 251 | + "vote_count" => 0, |
|
| 252 | + "location" => |
|
| 253 | + array("name" => "Berlin", |
|
| 254 | + "loc_coordinates" => |
|
| 255 | + array( |
|
| 256 | + "lat" => 0, |
|
| 257 | + "lng" => 0 |
|
| 258 | + ), |
|
| 259 | + "loc_accuracy" => 0, |
|
| 260 | + "country" => "", |
|
| 261 | + "city" => "", |
|
| 262 | + ), |
|
| 263 | + "tags" => |
|
| 264 | + array(), |
|
| 265 | + "user_handle" => "0" |
|
| 266 | 266 | ); |
| 267 | 267 | |
| 268 | 268 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | if(configPropertyExists($config, 'karmaDeviceUid')) |
| 100 | - { |
|
| 100 | + { |
|
| 101 | 101 | $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
| 102 | 102 | } |
| 103 | 103 | else |
@@ -114,7 +114,8 @@ discard block |
||
| 114 | 114 | //Set View |
| 115 | 115 | if(isset($_GET['view'])) |
| 116 | 116 | { |
| 117 | - switch ($_GET['view']) { |
|
| 117 | + switch ($_GET['view']) |
|
| 118 | + { |
|
| 118 | 119 | case 'comment': |
| 119 | 120 | $view = 'comment'; |
| 120 | 121 | break; |
@@ -151,7 +152,7 @@ discard block |
||
| 151 | 152 | { |
| 152 | 153 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
| 153 | 154 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
| 154 | - { |
|
| 155 | + { |
|
| 155 | 156 | header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
| 156 | 157 | } |
| 157 | 158 | else |
@@ -169,7 +170,7 @@ discard block |
||
| 169 | 170 | |
| 170 | 171 | |
| 171 | 172 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
| 172 | - { |
|
| 173 | + { |
|
| 173 | 174 | $accountCreator = new GetPosts(); |
| 174 | 175 | $accountCreator->setLastPostId($lastPostId); |
| 175 | 176 | $accountCreator->setAccessToken($accessToken); |
@@ -290,7 +291,8 @@ discard block |
||
| 290 | 291 | |
| 291 | 292 | $posts[0] = $data; |
| 292 | 293 | |
| 293 | - if(array_key_exists('children', $data)) { |
|
| 294 | + if(array_key_exists('children', $data)) |
|
| 295 | + { |
|
| 294 | 296 | foreach($data['children'] as $key => $child) |
| 295 | 297 | { |
| 296 | 298 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | if(substr($_GET['city'], 0, 1) === '#') |
| 57 | 57 | { |
| 58 | 58 | return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | else |
| 61 | 61 | { |
| 62 | 62 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
@@ -203,7 +203,8 @@ discard block |
||
| 203 | 203 | if(isset($_POST['color'])) |
| 204 | 204 | { |
| 205 | 205 | $color = $_POST['color']; |
| 206 | - switch ($color) { |
|
| 206 | + switch ($color) |
|
| 207 | + { |
|
| 207 | 208 | case '8ABDB0': |
| 208 | 209 | $color = '8ABDB0'; |
| 209 | 210 | break; |
@@ -262,7 +263,8 @@ discard block |
||
| 262 | 263 | if ($result->num_rows > 0) |
| 263 | 264 | { |
| 264 | 265 | // output data of each row |
| 265 | - while($row = $result->fetch_assoc()) { |
|
| 266 | + while($row = $result->fetch_assoc()) |
|
| 267 | + { |
|
| 266 | 268 | //$access_token = $row["access_token"]; |
| 267 | 269 | $expiration_date = $row["expiration_date"]; |
| 268 | 270 | $deviceUid = $row["device_uid"]; |
@@ -274,7 +276,8 @@ discard block |
||
| 274 | 276 | echo '0 results'; |
| 275 | 277 | } |
| 276 | 278 | |
| 277 | - if($expiration_date <= time()) { |
|
| 279 | + if($expiration_date <= time()) |
|
| 280 | + { |
|
| 278 | 281 | $accountCreator = new CreateUser(); |
| 279 | 282 | $accountCreator->setAccessToken($access_token); |
| 280 | 283 | $accountCreator->setDeviceUid($deviceUid); |
@@ -291,7 +294,8 @@ discard block |
||
| 291 | 294 | expiration_date='" . $expiration_date . "' |
| 292 | 295 | WHERE device_uid='" . $device_uid . "'"); |
| 293 | 296 | |
| 294 | - if($result === false){ |
|
| 297 | + if($result === false) |
|
| 298 | + { |
|
| 295 | 299 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 296 | 300 | } |
| 297 | 301 | } |
@@ -381,14 +385,16 @@ discard block |
||
| 381 | 385 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 382 | 386 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
| 383 | 387 | |
| 384 | - if($result === false){ |
|
| 388 | + if($result === false) |
|
| 389 | + { |
|
| 385 | 390 | $error = db_error(); |
| 386 | 391 | echo $error; |
| 387 | 392 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
| 388 | 393 | } |
| 389 | 394 | } |
| 390 | 395 | |
| 391 | - function registerAccount($location) { |
|
| 396 | + function registerAccount($location) |
|
| 397 | + { |
|
| 392 | 398 | $accountCreator = new CreateUser(); |
| 393 | 399 | $accountCreator->setLocation($location); |
| 394 | 400 | $data = $accountCreator->execute(); |
@@ -413,7 +419,8 @@ discard block |
||
| 413 | 419 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 414 | 420 | |
| 415 | 421 | $success = TRUE; |
| 416 | - if($result === false){ |
|
| 422 | + if($result === false) |
|
| 423 | + { |
|
| 417 | 424 | $error = db_error(); |
| 418 | 425 | echo $error; |
| 419 | 426 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -385,6 +385,9 @@ |
||
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | + /** |
|
| 389 | + * @param Location $location |
|
| 390 | + */ |
|
| 388 | 391 | function registerAccount($location) { |
| 389 | 392 | $accountCreator = new CreateUser(); |
| 390 | 393 | $accountCreator->setLocation($location); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | $this->refreshToken(); |
| 37 | 37 | } |
| 38 | - $this->accessToken = $this->getAccessToken(); |
|
| 38 | + $this->accessToken = $this->getAccessToken(); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | function isAccountVerified() |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | else |
| 96 | 96 | { |
| 97 | - error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 97 | + error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | function getLocation() |
| 107 | 107 | { |
| 108 | 108 | $db = new DatabaseConnect(); |
| 109 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 109 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 110 | 110 | |
| 111 | 111 | $location = new Location(); |
| 112 | 112 | |
| 113 | - if ($result->num_rows > 0) |
|
| 113 | + if($result->num_rows > 0) |
|
| 114 | 114 | { |
| 115 | 115 | // output data of each row |
| 116 | 116 | while($row = $result->fetch_assoc()) |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | if(isset($_POST['color'])) |
| 212 | 212 | { |
| 213 | 213 | $color = $_POST['color']; |
| 214 | - switch ($color) { |
|
| 214 | + switch($color) { |
|
| 215 | 215 | case '8ABDB0': |
| 216 | 216 | $color = '8ABDB0'; |
| 217 | 217 | break; |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | |
| 268 | 268 | $access_token; |
| 269 | 269 | |
| 270 | - if ($result->num_rows > 0) |
|
| 270 | + if($result->num_rows > 0) |
|
| 271 | 271 | { |
| 272 | 272 | // output data of each row |
| 273 | 273 | while($row = $result->fetch_assoc()) { |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | expiration_date='" . $expiration_date . "' |
| 300 | 300 | WHERE device_uid='" . $device_uid . "'"); |
| 301 | 301 | |
| 302 | - if($result === false){ |
|
| 302 | + if($result === false) { |
|
| 303 | 303 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 304 | 304 | } |
| 305 | 305 | } |
@@ -317,11 +317,11 @@ discard block |
||
| 317 | 317 | function getAccessToken() |
| 318 | 318 | { |
| 319 | 319 | $db = new DatabaseConnect(); |
| 320 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 320 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 321 | 321 | |
| 322 | 322 | $accessToken; |
| 323 | 323 | |
| 324 | - if ($result->num_rows > 0) |
|
| 324 | + if($result->num_rows > 0) |
|
| 325 | 325 | { |
| 326 | 326 | // output data of each row |
| 327 | 327 | while($row = $result->fetch_assoc()) |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 390 | 390 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
| 391 | 391 | |
| 392 | - if($result === false){ |
|
| 392 | + if($result === false) { |
|
| 393 | 393 | $error = db_error(); |
| 394 | 394 | echo $error; |
| 395 | 395 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -417,11 +417,11 @@ discard block |
||
| 417 | 417 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
| 418 | 418 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
| 419 | 419 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
| 420 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 420 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 421 | 421 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 422 | 422 | |
| 423 | 423 | $success = TRUE; |
| 424 | - if($result === false){ |
|
| 424 | + if($result === false) { |
|
| 425 | 425 | $error = db_error(); |
| 426 | 426 | echo $error; |
| 427 | 427 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -2,447 +2,447 @@ |
||
| 2 | 2 | |
| 3 | 3 | class JodelAccount |
| 4 | 4 | { |
| 5 | - public $accessToken; |
|
| 6 | - public $expirationDate; |
|
| 7 | - public $refreshToken; |
|
| 8 | - public $distinctId; |
|
| 9 | - public $deviceUid; |
|
| 10 | - |
|
| 11 | - //is the Account a Bot or Spider? |
|
| 12 | - public $isBot; |
|
| 5 | + public $accessToken; |
|
| 6 | + public $expirationDate; |
|
| 7 | + public $refreshToken; |
|
| 8 | + public $distinctId; |
|
| 9 | + public $deviceUid; |
|
| 10 | + |
|
| 11 | + //is the Account a Bot or Spider? |
|
| 12 | + public $isBot; |
|
| 13 | 13 | |
| 14 | - // array of voted Jodels |
|
| 15 | - public $votes; |
|
| 16 | - |
|
| 17 | - //Location of the Account |
|
| 18 | - public $location; |
|
| 19 | - |
|
| 20 | - function __construct($deviceUid = NULL, $isBot = FALSE) |
|
| 21 | - { |
|
| 22 | - if($deviceUid == NULL) |
|
| 23 | - { |
|
| 24 | - $this->deviceUid = $this->createAccount(); |
|
| 25 | - } |
|
| 26 | - else |
|
| 27 | - { |
|
| 28 | - $this->deviceUid = $deviceUid; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - $this->isBot = $isBot; |
|
| 32 | - $this->location = $this->getLocation(); |
|
| 33 | - |
|
| 34 | - if(!$this->isTokenFresh()) |
|
| 35 | - { |
|
| 36 | - $this->refreshToken(); |
|
| 37 | - } |
|
| 38 | - $this->accessToken = $this->getAccessToken(); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - function isAccountVerified() |
|
| 42 | - { |
|
| 43 | - $accountCreator = new GetUserConfig(); |
|
| 44 | - $accountCreator->setAccessToken($this->accessToken); |
|
| 45 | - $data = $accountCreator->execute(); |
|
| 46 | - |
|
| 47 | - return $data['verified']; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - function setLocation() |
|
| 51 | - { |
|
| 52 | - //Is Channel or City |
|
| 53 | - if(substr($_GET['city'], 0, 1) === '#') |
|
| 54 | - { |
|
| 55 | - return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
| 56 | - } |
|
| 57 | - else |
|
| 58 | - { |
|
| 59 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
| 60 | - $result = Requests::post($url); |
|
| 61 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
| 62 | - { |
|
| 63 | - return "0 results"; |
|
| 64 | - } |
|
| 65 | - else |
|
| 66 | - { |
|
| 67 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
| 68 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
| 69 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
| 70 | - |
|
| 71 | - $location = new Location(); |
|
| 72 | - $location->setLat($lat); |
|
| 73 | - $location->setLng($lng); |
|
| 74 | - $location->setCityName($name); |
|
| 75 | - $accountCreator = new UpdateLocation(); |
|
| 76 | - $accountCreator->setLocation($location); |
|
| 77 | - $accountCreator->setAccessToken($this->accessToken); |
|
| 78 | - $data = $accountCreator->execute(); |
|
| 79 | - |
|
| 80 | - //safe location to db |
|
| 81 | - $db = new DatabaseConnect(); |
|
| 82 | - |
|
| 83 | - if($data == 'Success') |
|
| 84 | - { |
|
| 85 | - $result = $db->query("UPDATE accounts |
|
| 14 | + // array of voted Jodels |
|
| 15 | + public $votes; |
|
| 16 | + |
|
| 17 | + //Location of the Account |
|
| 18 | + public $location; |
|
| 19 | + |
|
| 20 | + function __construct($deviceUid = NULL, $isBot = FALSE) |
|
| 21 | + { |
|
| 22 | + if($deviceUid == NULL) |
|
| 23 | + { |
|
| 24 | + $this->deviceUid = $this->createAccount(); |
|
| 25 | + } |
|
| 26 | + else |
|
| 27 | + { |
|
| 28 | + $this->deviceUid = $deviceUid; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + $this->isBot = $isBot; |
|
| 32 | + $this->location = $this->getLocation(); |
|
| 33 | + |
|
| 34 | + if(!$this->isTokenFresh()) |
|
| 35 | + { |
|
| 36 | + $this->refreshToken(); |
|
| 37 | + } |
|
| 38 | + $this->accessToken = $this->getAccessToken(); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + function isAccountVerified() |
|
| 42 | + { |
|
| 43 | + $accountCreator = new GetUserConfig(); |
|
| 44 | + $accountCreator->setAccessToken($this->accessToken); |
|
| 45 | + $data = $accountCreator->execute(); |
|
| 46 | + |
|
| 47 | + return $data['verified']; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + function setLocation() |
|
| 51 | + { |
|
| 52 | + //Is Channel or City |
|
| 53 | + if(substr($_GET['city'], 0, 1) === '#') |
|
| 54 | + { |
|
| 55 | + return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
| 56 | + } |
|
| 57 | + else |
|
| 58 | + { |
|
| 59 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
| 60 | + $result = Requests::post($url); |
|
| 61 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
| 62 | + { |
|
| 63 | + return "0 results"; |
|
| 64 | + } |
|
| 65 | + else |
|
| 66 | + { |
|
| 67 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
| 68 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
| 69 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
| 70 | + |
|
| 71 | + $location = new Location(); |
|
| 72 | + $location->setLat($lat); |
|
| 73 | + $location->setLng($lng); |
|
| 74 | + $location->setCityName($name); |
|
| 75 | + $accountCreator = new UpdateLocation(); |
|
| 76 | + $accountCreator->setLocation($location); |
|
| 77 | + $accountCreator->setAccessToken($this->accessToken); |
|
| 78 | + $data = $accountCreator->execute(); |
|
| 79 | + |
|
| 80 | + //safe location to db |
|
| 81 | + $db = new DatabaseConnect(); |
|
| 82 | + |
|
| 83 | + if($data == 'Success') |
|
| 84 | + { |
|
| 85 | + $result = $db->query("UPDATE accounts |
|
| 86 | 86 | SET name='" . $name . "', |
| 87 | 87 | lat='" . $lat . "', |
| 88 | 88 | lng='" . $lng . "' |
| 89 | 89 | WHERE access_token='" . $this->accessToken . "'"); |
| 90 | 90 | |
| 91 | - if($result === false) |
|
| 92 | - { |
|
| 93 | - echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
| 94 | - } |
|
| 95 | - else |
|
| 96 | - { |
|
| 97 | - error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $name; |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - function getLocation() |
|
| 107 | - { |
|
| 108 | - $db = new DatabaseConnect(); |
|
| 109 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 91 | + if($result === false) |
|
| 92 | + { |
|
| 93 | + echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
| 94 | + } |
|
| 95 | + else |
|
| 96 | + { |
|
| 97 | + error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + return $name; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + function getLocation() |
|
| 107 | + { |
|
| 108 | + $db = new DatabaseConnect(); |
|
| 109 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 110 | 110 | |
| 111 | - $location = new Location(); |
|
| 111 | + $location = new Location(); |
|
| 112 | 112 | |
| 113 | - if ($result->num_rows > 0) |
|
| 114 | - { |
|
| 115 | - // output data of each row |
|
| 116 | - while($row = $result->fetch_assoc()) |
|
| 117 | - { |
|
| 118 | - $location->setLat($row['lat']); |
|
| 119 | - $location->setLng($row['lng']); |
|
| 120 | - $location->setCityName($row['name']); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - else |
|
| 124 | - { |
|
| 125 | - echo "Error: 0 results"; |
|
| 126 | - error_log("Error no Location found - getLocation"); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - return $location; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - function verifyCaptcha() |
|
| 133 | - { |
|
| 134 | - if(isset($_GET['deviceUid'])) |
|
| 135 | - { |
|
| 136 | - $deviceUid = $_GET['deviceUid']; |
|
| 137 | - } |
|
| 138 | - if(isset($_POST['deviceUid'])) |
|
| 139 | - { |
|
| 140 | - $deviceUid = $_POST['deviceUid']; |
|
| 141 | - } |
|
| 142 | - $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
| 143 | - |
|
| 144 | - $solution = $_GET['solution']; |
|
| 145 | - $solution = array_map('intval', explode('-', $solution)); |
|
| 146 | - |
|
| 147 | - $accountCreator = new PostCaptcha(); |
|
| 148 | - $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
| 149 | - $accountCreator->captchaKey = $_GET['key']; |
|
| 150 | - $accountCreator->captchaSolution = $solution; |
|
| 151 | - $verified = $accountCreator->execute(); |
|
| 152 | - |
|
| 153 | - if(isset($verified->status_code)) |
|
| 154 | - { |
|
| 155 | - return $verified->status_code; |
|
| 156 | - } |
|
| 157 | - return $verified['verified']; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - //ToDo Spider Check |
|
| 161 | - function votePostId($postId, $vote) |
|
| 162 | - { |
|
| 163 | - if(!$this->isAccountVerified()) |
|
| 164 | - { |
|
| 165 | - $view = new View(); |
|
| 166 | - $view->showCaptcha($this->accessToken, $this->deviceUid); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - if(!$this->hasVoted($postId)) |
|
| 170 | - { |
|
| 171 | - if($vote == "up") |
|
| 172 | - { |
|
| 173 | - $accountCreator = new Upvote(); |
|
| 174 | - } |
|
| 175 | - else if($vote == "down") |
|
| 176 | - { |
|
| 177 | - $accountCreator = new Downvote(); |
|
| 178 | - } |
|
| 179 | - $accountCreator->setAccessToken($this->accessToken); |
|
| 180 | - $accountCreator->postId = htmlspecialchars($postId); |
|
| 181 | - $data = $accountCreator->execute(); |
|
| 182 | - |
|
| 183 | - if(array_key_exists('post', $data)) |
|
| 184 | - { |
|
| 185 | - $this->addVoteWithPostIdAndType($postId, $vote); |
|
| 186 | - return TRUE; |
|
| 187 | - } |
|
| 188 | - else |
|
| 189 | - { |
|
| 190 | - error_log("Could not vote: " . var_dump($data)); |
|
| 191 | - return FALSE; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - else |
|
| 195 | - { |
|
| 196 | - return FALSE; |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - //ToDo Spider Check |
|
| 201 | - function sendJodel() |
|
| 202 | - { |
|
| 203 | - if(!$this->isAccountVerified()) |
|
| 204 | - { |
|
| 205 | - showCaptcha($this->accessToken); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - $accountCreator = new SendJodel(); |
|
| 209 | - |
|
| 210 | - if(isset($_POST['ancestor'])) |
|
| 211 | - { |
|
| 212 | - $ancestor = $_POST['ancestor']; |
|
| 213 | - $accountCreator->ancestor = $ancestor; |
|
| 214 | - } |
|
| 215 | - if(isset($_POST['color'])) |
|
| 216 | - { |
|
| 217 | - $color = $_POST['color']; |
|
| 218 | - switch ($color) { |
|
| 219 | - case '8ABDB0': |
|
| 220 | - $color = '8ABDB0'; |
|
| 221 | - break; |
|
| 222 | - case '9EC41C': |
|
| 223 | - $color = '9EC41C'; |
|
| 224 | - break; |
|
| 225 | - case '06A3CB': |
|
| 226 | - $color = '06A3CB'; |
|
| 227 | - break; |
|
| 228 | - case 'FFBA00': |
|
| 229 | - $color = 'FFBA00'; |
|
| 230 | - break; |
|
| 231 | - case 'DD5F5F': |
|
| 232 | - $color = 'DD5F5F'; |
|
| 233 | - break; |
|
| 234 | - case 'FF9908': |
|
| 235 | - $color = 'FF9908'; |
|
| 236 | - break; |
|
| 237 | - default: |
|
| 238 | - $color = '8ABDB0'; |
|
| 239 | - break; |
|
| 240 | - } |
|
| 241 | - $accountCreator->color = $color; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - $accountCreatorLocation = new UpdateLocation(); |
|
| 245 | - $accountCreatorLocation->setLocation($this->location); |
|
| 246 | - $accountCreatorLocation->setAccessToken($this->accessToken); |
|
| 247 | - $data = $accountCreatorLocation->execute(); |
|
| 113 | + if ($result->num_rows > 0) |
|
| 114 | + { |
|
| 115 | + // output data of each row |
|
| 116 | + while($row = $result->fetch_assoc()) |
|
| 117 | + { |
|
| 118 | + $location->setLat($row['lat']); |
|
| 119 | + $location->setLng($row['lng']); |
|
| 120 | + $location->setCityName($row['name']); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + else |
|
| 124 | + { |
|
| 125 | + echo "Error: 0 results"; |
|
| 126 | + error_log("Error no Location found - getLocation"); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + return $location; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + function verifyCaptcha() |
|
| 133 | + { |
|
| 134 | + if(isset($_GET['deviceUid'])) |
|
| 135 | + { |
|
| 136 | + $deviceUid = $_GET['deviceUid']; |
|
| 137 | + } |
|
| 138 | + if(isset($_POST['deviceUid'])) |
|
| 139 | + { |
|
| 140 | + $deviceUid = $_POST['deviceUid']; |
|
| 141 | + } |
|
| 142 | + $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
| 143 | + |
|
| 144 | + $solution = $_GET['solution']; |
|
| 145 | + $solution = array_map('intval', explode('-', $solution)); |
|
| 146 | + |
|
| 147 | + $accountCreator = new PostCaptcha(); |
|
| 148 | + $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
| 149 | + $accountCreator->captchaKey = $_GET['key']; |
|
| 150 | + $accountCreator->captchaSolution = $solution; |
|
| 151 | + $verified = $accountCreator->execute(); |
|
| 152 | + |
|
| 153 | + if(isset($verified->status_code)) |
|
| 154 | + { |
|
| 155 | + return $verified->status_code; |
|
| 156 | + } |
|
| 157 | + return $verified['verified']; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + //ToDo Spider Check |
|
| 161 | + function votePostId($postId, $vote) |
|
| 162 | + { |
|
| 163 | + if(!$this->isAccountVerified()) |
|
| 164 | + { |
|
| 165 | + $view = new View(); |
|
| 166 | + $view->showCaptcha($this->accessToken, $this->deviceUid); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + if(!$this->hasVoted($postId)) |
|
| 170 | + { |
|
| 171 | + if($vote == "up") |
|
| 172 | + { |
|
| 173 | + $accountCreator = new Upvote(); |
|
| 174 | + } |
|
| 175 | + else if($vote == "down") |
|
| 176 | + { |
|
| 177 | + $accountCreator = new Downvote(); |
|
| 178 | + } |
|
| 179 | + $accountCreator->setAccessToken($this->accessToken); |
|
| 180 | + $accountCreator->postId = htmlspecialchars($postId); |
|
| 181 | + $data = $accountCreator->execute(); |
|
| 182 | + |
|
| 183 | + if(array_key_exists('post', $data)) |
|
| 184 | + { |
|
| 185 | + $this->addVoteWithPostIdAndType($postId, $vote); |
|
| 186 | + return TRUE; |
|
| 187 | + } |
|
| 188 | + else |
|
| 189 | + { |
|
| 190 | + error_log("Could not vote: " . var_dump($data)); |
|
| 191 | + return FALSE; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + else |
|
| 195 | + { |
|
| 196 | + return FALSE; |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + //ToDo Spider Check |
|
| 201 | + function sendJodel() |
|
| 202 | + { |
|
| 203 | + if(!$this->isAccountVerified()) |
|
| 204 | + { |
|
| 205 | + showCaptcha($this->accessToken); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + $accountCreator = new SendJodel(); |
|
| 209 | + |
|
| 210 | + if(isset($_POST['ancestor'])) |
|
| 211 | + { |
|
| 212 | + $ancestor = $_POST['ancestor']; |
|
| 213 | + $accountCreator->ancestor = $ancestor; |
|
| 214 | + } |
|
| 215 | + if(isset($_POST['color'])) |
|
| 216 | + { |
|
| 217 | + $color = $_POST['color']; |
|
| 218 | + switch ($color) { |
|
| 219 | + case '8ABDB0': |
|
| 220 | + $color = '8ABDB0'; |
|
| 221 | + break; |
|
| 222 | + case '9EC41C': |
|
| 223 | + $color = '9EC41C'; |
|
| 224 | + break; |
|
| 225 | + case '06A3CB': |
|
| 226 | + $color = '06A3CB'; |
|
| 227 | + break; |
|
| 228 | + case 'FFBA00': |
|
| 229 | + $color = 'FFBA00'; |
|
| 230 | + break; |
|
| 231 | + case 'DD5F5F': |
|
| 232 | + $color = 'DD5F5F'; |
|
| 233 | + break; |
|
| 234 | + case 'FF9908': |
|
| 235 | + $color = 'FF9908'; |
|
| 236 | + break; |
|
| 237 | + default: |
|
| 238 | + $color = '8ABDB0'; |
|
| 239 | + break; |
|
| 240 | + } |
|
| 241 | + $accountCreator->color = $color; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + $accountCreatorLocation = new UpdateLocation(); |
|
| 245 | + $accountCreatorLocation->setLocation($this->location); |
|
| 246 | + $accountCreatorLocation->setAccessToken($this->accessToken); |
|
| 247 | + $data = $accountCreatorLocation->execute(); |
|
| 248 | 248 | |
| 249 | - $accountCreator->location = $this->location; |
|
| 249 | + $accountCreator->location = $this->location; |
|
| 250 | 250 | |
| 251 | - $accountCreator->setAccessToken($this->accessToken); |
|
| 252 | - $data = $accountCreator->execute(); |
|
| 253 | - |
|
| 254 | - if(isset($_POST['ancestor'])) |
|
| 255 | - { |
|
| 256 | - $actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 257 | - header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id'])); |
|
| 258 | - exit; |
|
| 259 | - } |
|
| 260 | - else |
|
| 261 | - { |
|
| 262 | - header('Location: ./#'); |
|
| 263 | - exit; |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - function isTokenFresh() |
|
| 268 | - { |
|
| 269 | - $db = new DatabaseConnect(); |
|
| 270 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 271 | - |
|
| 272 | - $access_token; |
|
| 273 | - |
|
| 274 | - if ($result->num_rows > 0) |
|
| 275 | - { |
|
| 276 | - // output data of each row |
|
| 277 | - while($row = $result->fetch_assoc()) { |
|
| 278 | - //$access_token = $row["access_token"]; |
|
| 279 | - $expiration_date = $row["expiration_date"]; |
|
| 280 | - $deviceUid = $row["device_uid"]; |
|
| 281 | - $access_token = $row["access_token"]; |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - else |
|
| 285 | - { |
|
| 286 | - echo '0 results'; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - if($expiration_date <= time()) { |
|
| 290 | - $accountCreator = new CreateUser(); |
|
| 291 | - $accountCreator->setAccessToken($access_token); |
|
| 292 | - $accountCreator->setDeviceUid($deviceUid); |
|
| 293 | - $accountCreator->setLocation($this->location); |
|
| 294 | - $data = $accountCreator->execute(); |
|
| 295 | - |
|
| 296 | - $access_token = (string)$data[0]['access_token']; |
|
| 297 | - $expiration_date = $data[0]['expiration_date']; |
|
| 298 | - $device_uid = (string)$data[1]; |
|
| 251 | + $accountCreator->setAccessToken($this->accessToken); |
|
| 252 | + $data = $accountCreator->execute(); |
|
| 253 | + |
|
| 254 | + if(isset($_POST['ancestor'])) |
|
| 255 | + { |
|
| 256 | + $actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 257 | + header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id'])); |
|
| 258 | + exit; |
|
| 259 | + } |
|
| 260 | + else |
|
| 261 | + { |
|
| 262 | + header('Location: ./#'); |
|
| 263 | + exit; |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + function isTokenFresh() |
|
| 268 | + { |
|
| 269 | + $db = new DatabaseConnect(); |
|
| 270 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 271 | + |
|
| 272 | + $access_token; |
|
| 273 | + |
|
| 274 | + if ($result->num_rows > 0) |
|
| 275 | + { |
|
| 276 | + // output data of each row |
|
| 277 | + while($row = $result->fetch_assoc()) { |
|
| 278 | + //$access_token = $row["access_token"]; |
|
| 279 | + $expiration_date = $row["expiration_date"]; |
|
| 280 | + $deviceUid = $row["device_uid"]; |
|
| 281 | + $access_token = $row["access_token"]; |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + else |
|
| 285 | + { |
|
| 286 | + echo '0 results'; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + if($expiration_date <= time()) { |
|
| 290 | + $accountCreator = new CreateUser(); |
|
| 291 | + $accountCreator->setAccessToken($access_token); |
|
| 292 | + $accountCreator->setDeviceUid($deviceUid); |
|
| 293 | + $accountCreator->setLocation($this->location); |
|
| 294 | + $data = $accountCreator->execute(); |
|
| 295 | + |
|
| 296 | + $access_token = (string)$data[0]['access_token']; |
|
| 297 | + $expiration_date = $data[0]['expiration_date']; |
|
| 298 | + $device_uid = (string)$data[1]; |
|
| 299 | 299 | |
| 300 | - $db = new DatabaseConnect(); |
|
| 301 | - $result = $db->query("UPDATE accounts |
|
| 300 | + $db = new DatabaseConnect(); |
|
| 301 | + $result = $db->query("UPDATE accounts |
|
| 302 | 302 | SET access_token='" . $access_token . "', |
| 303 | 303 | expiration_date='" . $expiration_date . "' |
| 304 | 304 | WHERE device_uid='" . $device_uid . "'"); |
| 305 | 305 | |
| 306 | - if($result === false){ |
|
| 307 | - echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
|
| 308 | - } |
|
| 309 | - } |
|
| 306 | + if($result === false){ |
|
| 307 | + echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - return $access_token; |
|
| 312 | - } |
|
| 311 | + return $access_token; |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - function refreshToken() |
|
| 315 | - { |
|
| 314 | + function refreshToken() |
|
| 315 | + { |
|
| 316 | 316 | |
| 317 | - } |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | 319 | |
| 320 | 320 | |
| 321 | - function getAccessToken() |
|
| 322 | - { |
|
| 323 | - $db = new DatabaseConnect(); |
|
| 324 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 321 | + function getAccessToken() |
|
| 322 | + { |
|
| 323 | + $db = new DatabaseConnect(); |
|
| 324 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 325 | 325 | |
| 326 | - $accessToken; |
|
| 326 | + $accessToken; |
|
| 327 | 327 | |
| 328 | - if ($result->num_rows > 0) |
|
| 329 | - { |
|
| 330 | - // output data of each row |
|
| 331 | - while($row = $result->fetch_assoc()) |
|
| 332 | - { |
|
| 333 | - $accessToken = $row['access_token']; |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - else |
|
| 337 | - { |
|
| 338 | - echo "Error: 0 results"; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - return $accessToken; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - function getKarma() |
|
| 346 | - { |
|
| 347 | - $accountCreator = new GetKarma(); |
|
| 348 | - $accountCreator->setAccessToken($this->accessToken); |
|
| 349 | - $data = $accountCreator->execute(); |
|
| 328 | + if ($result->num_rows > 0) |
|
| 329 | + { |
|
| 330 | + // output data of each row |
|
| 331 | + while($row = $result->fetch_assoc()) |
|
| 332 | + { |
|
| 333 | + $accessToken = $row['access_token']; |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + else |
|
| 337 | + { |
|
| 338 | + echo "Error: 0 results"; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + return $accessToken; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + function getKarma() |
|
| 346 | + { |
|
| 347 | + $accountCreator = new GetKarma(); |
|
| 348 | + $accountCreator->setAccessToken($this->accessToken); |
|
| 349 | + $data = $accountCreator->execute(); |
|
| 350 | 350 | |
| 351 | - return $data["karma"]; |
|
| 352 | - } |
|
| 351 | + return $data["karma"]; |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - function hasVoted($postId) |
|
| 355 | - { |
|
| 356 | - $db = new DatabaseConnect(); |
|
| 354 | + function hasVoted($postId) |
|
| 355 | + { |
|
| 356 | + $db = new DatabaseConnect(); |
|
| 357 | 357 | |
| 358 | - $postId = $db->real_escape_string($postId); |
|
| 358 | + $postId = $db->real_escape_string($postId); |
|
| 359 | 359 | |
| 360 | - $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
| 360 | + $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
| 361 | 361 | |
| 362 | - if($result === false) |
|
| 363 | - { |
|
| 364 | - $error = db_error(); |
|
| 365 | - echo $error; |
|
| 366 | - error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - if($result->num_rows == 0) |
|
| 370 | - { |
|
| 371 | - return FALSE; |
|
| 372 | - } |
|
| 373 | - else |
|
| 374 | - { |
|
| 375 | - return TRUE; |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - function addVoteWithPostIdAndType($postId, $voteType) |
|
| 380 | - { |
|
| 381 | - $db = new DatabaseConnect(); |
|
| 382 | - |
|
| 383 | - $postId = $db->real_escape_string($postId); |
|
| 384 | - $voteType = $db->real_escape_string($voteType); |
|
| 362 | + if($result === false) |
|
| 363 | + { |
|
| 364 | + $error = db_error(); |
|
| 365 | + echo $error; |
|
| 366 | + error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + if($result->num_rows == 0) |
|
| 370 | + { |
|
| 371 | + return FALSE; |
|
| 372 | + } |
|
| 373 | + else |
|
| 374 | + { |
|
| 375 | + return TRUE; |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + function addVoteWithPostIdAndType($postId, $voteType) |
|
| 380 | + { |
|
| 381 | + $db = new DatabaseConnect(); |
|
| 382 | + |
|
| 383 | + $postId = $db->real_escape_string($postId); |
|
| 384 | + $voteType = $db->real_escape_string($voteType); |
|
| 385 | 385 | |
| 386 | - if($this->hasVoted($postId)) |
|
| 387 | - { |
|
| 388 | - return "Already voted"; |
|
| 389 | - } |
|
| 386 | + if($this->hasVoted($postId)) |
|
| 387 | + { |
|
| 388 | + return "Already voted"; |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | - $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
| 391 | + $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
| 392 | 392 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
| 393 | 393 | |
| 394 | - if($result === false){ |
|
| 395 | - $error = db_error(); |
|
| 396 | - echo $error; |
|
| 397 | - echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
| 398 | - } |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - function registerAccount($location) { |
|
| 402 | - $accountCreator = new CreateUser(); |
|
| 403 | - $accountCreator->setLocation($location); |
|
| 404 | - $data = $accountCreator->execute(); |
|
| 394 | + if($result === false){ |
|
| 395 | + $error = db_error(); |
|
| 396 | + echo $error; |
|
| 397 | + echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + function registerAccount($location) { |
|
| 402 | + $accountCreator = new CreateUser(); |
|
| 403 | + $accountCreator->setLocation($location); |
|
| 404 | + $data = $accountCreator->execute(); |
|
| 405 | 405 | |
| 406 | - $access_token = (string)$data[0]['access_token']; |
|
| 407 | - $refresh_token = (string)$data[0]['refresh_token']; |
|
| 408 | - $token_type = (string)$data[0]['token_type']; |
|
| 409 | - $expires_in = $data[0]['expires_in']; |
|
| 410 | - $expiration_date = $data[0]['expiration_date']; |
|
| 411 | - $distinct_id = (string)$data[0]['distinct_id']; |
|
| 412 | - $device_uid = (string)$data[1]; |
|
| 413 | - |
|
| 414 | - $name = $location->cityName; |
|
| 415 | - $lat = $location->lat; |
|
| 416 | - $lng = $location->lng; |
|
| 406 | + $access_token = (string)$data[0]['access_token']; |
|
| 407 | + $refresh_token = (string)$data[0]['refresh_token']; |
|
| 408 | + $token_type = (string)$data[0]['token_type']; |
|
| 409 | + $expires_in = $data[0]['expires_in']; |
|
| 410 | + $expiration_date = $data[0]['expiration_date']; |
|
| 411 | + $distinct_id = (string)$data[0]['distinct_id']; |
|
| 412 | + $device_uid = (string)$data[1]; |
|
| 413 | + |
|
| 414 | + $name = $location->cityName; |
|
| 415 | + $lat = $location->lat; |
|
| 416 | + $lng = $location->lng; |
|
| 417 | 417 | |
| 418 | - $db = new DatabaseConnect(); |
|
| 419 | - $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
| 418 | + $db = new DatabaseConnect(); |
|
| 419 | + $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
| 420 | 420 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
| 421 | 421 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
| 422 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 423 | - "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
| 424 | - |
|
| 425 | - $success = TRUE; |
|
| 426 | - if($result === false){ |
|
| 427 | - $error = db_error(); |
|
| 428 | - echo $error; |
|
| 429 | - echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
| 430 | - $success = FALSE; |
|
| 431 | - } |
|
| 422 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 423 | + "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
| 424 | + |
|
| 425 | + $success = TRUE; |
|
| 426 | + if($result === false){ |
|
| 427 | + $error = db_error(); |
|
| 428 | + echo $error; |
|
| 429 | + echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
| 430 | + $success = FALSE; |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | - return $device_uid; |
|
| 434 | - } |
|
| 433 | + return $device_uid; |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | - function createAccount() |
|
| 437 | - { |
|
| 438 | - $config = parse_ini_file('config/config.ini.php'); |
|
| 439 | - $location = new Location(); |
|
| 440 | - $location->setLat($config['default_lat']); |
|
| 441 | - $location->setLng($config['default_lng']); |
|
| 442 | - $location->setCityName($config['default_location']); |
|
| 436 | + function createAccount() |
|
| 437 | + { |
|
| 438 | + $config = parse_ini_file('config/config.ini.php'); |
|
| 439 | + $location = new Location(); |
|
| 440 | + $location->setLat($config['default_lat']); |
|
| 441 | + $location->setLng($config['default_lng']); |
|
| 442 | + $location->setCityName($config['default_location']); |
|
| 443 | 443 | |
| 444 | - $deviceUid = $this->registerAccount($location); |
|
| 444 | + $deviceUid = $this->registerAccount($location); |
|
| 445 | 445 | |
| 446 | - return $deviceUid; |
|
| 447 | - } |
|
| 446 | + return $deviceUid; |
|
| 447 | + } |
|
| 448 | 448 | } |
| 449 | 449 | \ No newline at end of file |
@@ -58,15 +58,15 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
| 60 | 60 | $result = Requests::post($url); |
| 61 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
| 61 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
| 62 | 62 | { |
| 63 | 63 | return "0 results"; |
| 64 | 64 | } |
| 65 | 65 | else |
| 66 | 66 | { |
| 67 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
| 68 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
| 69 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
| 67 | + $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name']; |
|
| 68 | + $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']; |
|
| 69 | + $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']; |
|
| 70 | 70 | |
| 71 | 71 | $location = new Location(); |
| 72 | 72 | $location->setLat($lat); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | lng='" . $lng . "' |
| 89 | 89 | WHERE access_token='" . $this->accessToken . "'"); |
| 90 | 90 | |
| 91 | - if($result === false) |
|
| 91 | + if($result === FALSE) |
|
| 92 | 92 | { |
| 93 | 93 | echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
| 94 | 94 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | expiration_date='" . $expiration_date . "' |
| 304 | 304 | WHERE device_uid='" . $device_uid . "'"); |
| 305 | 305 | |
| 306 | - if($result === false){ |
|
| 306 | + if($result === FALSE){ |
|
| 307 | 307 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
| 361 | 361 | |
| 362 | - if($result === false) |
|
| 362 | + if($result === FALSE) |
|
| 363 | 363 | { |
| 364 | 364 | $error = db_error(); |
| 365 | 365 | echo $error; |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 392 | 392 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
| 393 | 393 | |
| 394 | - if($result === false){ |
|
| 394 | + if($result === FALSE){ |
|
| 395 | 395 | $error = db_error(); |
| 396 | 396 | echo $error; |
| 397 | 397 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 424 | 424 | |
| 425 | 425 | $success = TRUE; |
| 426 | - if($result === false){ |
|
| 426 | + if($result === FALSE){ |
|
| 427 | 427 | $error = db_error(); |
| 428 | 428 | echo $error; |
| 429 | 429 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |