@@ -47,6 +47,6 @@ |
||
| 47 | 47 | |
| 48 | 48 | if(!$db->query($query) || !$db->query($query2)) |
| 49 | 49 | { |
| 50 | - throw new Exception($db->error($mysqli)); |
|
| 50 | + throw new Exception($db->error($mysqli)); |
|
| 51 | 51 | } |
| 52 | 52 | |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | |
| 295 | 295 | if($result->num_rows == 0) |
| 296 | 296 | { |
| 297 | - return FALSE; |
|
| 297 | + return FALSE; |
|
| 298 | 298 | } |
| 299 | 299 | else |
| 300 | 300 | { |
| 301 | - return TRUE; |
|
| 301 | + return TRUE; |
|
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | { |
| 393 | 393 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 394 | 394 | |
| 395 | - return (isset($matches[0])) ? true : false; |
|
| 395 | + return (isset($matches[0])) ? true : false; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | function botDeviceUidIsSet($config) |
@@ -1,21 +1,21 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Upvote extends AbstractRequest { |
| 3 | 3 | |
| 4 | - public $postId; |
|
| 4 | + public $postId; |
|
| 5 | 5 | |
| 6 | - function getApiEndPoint() |
|
| 7 | - { |
|
| 8 | - return '/v2/posts/' . $this->postId . '/upvote'; |
|
| 9 | - } |
|
| 10 | - function getPayload() |
|
| 11 | - { |
|
| 12 | - return array( |
|
| 6 | + function getApiEndPoint() |
|
| 7 | + { |
|
| 8 | + return '/v2/posts/' . $this->postId . '/upvote'; |
|
| 9 | + } |
|
| 10 | + function getPayload() |
|
| 11 | + { |
|
| 12 | + return array( |
|
| 13 | 13 | // "reason_code" => -1, |
| 14 | - ); |
|
| 15 | - } |
|
| 16 | - function getMethod() |
|
| 17 | - { |
|
| 18 | - return 'PUT'; |
|
| 19 | - } |
|
| 14 | + ); |
|
| 15 | + } |
|
| 16 | + function getMethod() |
|
| 17 | + { |
|
| 18 | + return 'PUT'; |
|
| 19 | + } |
|
| 20 | 20 | } |
| 21 | 21 | |
@@ -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,15 +24,15 @@ 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: |
|
| 35 | - /* |
|
| 31 | + if ($this->getAccessToken()) { |
|
| 32 | + $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
| 33 | + } |
|
| 34 | + //Comment out to debug the Request: |
|
| 35 | + /* |
|
| 36 | 36 | printf("URL: "); |
| 37 | 37 | var_dump($url); |
| 38 | 38 | echo "<br />"; |
@@ -43,82 +43,82 @@ discard block |
||
| 43 | 43 | var_dump($this->payLoad); |
| 44 | 44 | echo "<br />"; |
| 45 | 45 | */ |
| 46 | - /* |
|
| 46 | + /* |
|
| 47 | 47 | $options = array( |
| 48 | 48 | 'timeout' => 100, |
| 49 | 49 | 'connect_timeout' => 100, |
| 50 | 50 | 'proxy' => '186.103.169.165:8080', |
| 51 | 51 | );*/ |
| 52 | 52 | |
| 53 | - switch ($this->getMethod()) { |
|
| 54 | - case 'POST': |
|
| 55 | - $result = Requests::post($url, $header, $this->payLoad); |
|
| 56 | - break; |
|
| 57 | - case 'GET': |
|
| 58 | - if($this->version == 'v3') |
|
| 59 | - { |
|
| 60 | - $result = Requests::get($url, $header); |
|
| 61 | - } |
|
| 62 | - else |
|
| 63 | - { |
|
| 64 | - $result = Requests::get($url, $header); |
|
| 65 | - } |
|
| 66 | - break; |
|
| 67 | - case 'PUT': |
|
| 68 | - $result = Requests::put($url, $header);//, $this->payLoad); |
|
| 69 | - break; |
|
| 70 | - } |
|
| 71 | - switch ($result->status_code) { |
|
| 72 | - case 200: |
|
| 73 | - $result = json_decode($result->body, true); |
|
| 74 | - break; |
|
| 75 | - case 204: |
|
| 76 | - $result = "Success"; |
|
| 77 | - break; |
|
| 78 | - case 401: |
|
| 53 | + switch ($this->getMethod()) { |
|
| 54 | + case 'POST': |
|
| 55 | + $result = Requests::post($url, $header, $this->payLoad); |
|
| 56 | + break; |
|
| 57 | + case 'GET': |
|
| 58 | + if($this->version == 'v3') |
|
| 59 | + { |
|
| 60 | + $result = Requests::get($url, $header); |
|
| 61 | + } |
|
| 62 | + else |
|
| 63 | + { |
|
| 64 | + $result = Requests::get($url, $header); |
|
| 65 | + } |
|
| 66 | + break; |
|
| 67 | + case 'PUT': |
|
| 68 | + $result = Requests::put($url, $header);//, $this->payLoad); |
|
| 69 | + break; |
|
| 70 | + } |
|
| 71 | + switch ($result->status_code) { |
|
| 72 | + case 200: |
|
| 73 | + $result = json_decode($result->body, true); |
|
| 74 | + break; |
|
| 75 | + case 204: |
|
| 76 | + $result = "Success"; |
|
| 77 | + break; |
|
| 78 | + case 401: |
|
| 79 | 79 | //throw new \Exception('Unauthorized'); |
| 80 | - error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 81 | - break; |
|
| 82 | - case 404: |
|
| 83 | - //echo "Es wurde bereits gevoted"; |
|
| 84 | - error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid); |
|
| 80 | + error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 81 | + break; |
|
| 82 | + case 404: |
|
| 83 | + //echo "Es wurde bereits gevoted"; |
|
| 84 | + error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid); |
|
| 85 | 85 | case 477: |
| 86 | - //echo "Es wurde bereits gevoted"; |
|
| 87 | - //throw new \Exception('Signing failed!'); |
|
| 88 | - error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid); |
|
| 89 | - break; |
|
| 90 | - case 429: |
|
| 91 | - error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid); |
|
| 92 | - exit("Error 429: Too Many Requests"); |
|
| 93 | - break; |
|
| 94 | - case 403: |
|
| 95 | - error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid); |
|
| 96 | - exit("Error 403: Access denied"); |
|
| 97 | - break; |
|
| 98 | - default: |
|
| 99 | - error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 100 | - //throw new \Exception('Unknown Error: '.$result->status_code); |
|
| 101 | - } |
|
| 86 | + //echo "Es wurde bereits gevoted"; |
|
| 87 | + //throw new \Exception('Signing failed!'); |
|
| 88 | + error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid); |
|
| 89 | + break; |
|
| 90 | + case 429: |
|
| 91 | + error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid); |
|
| 92 | + exit("Error 429: Too Many Requests"); |
|
| 93 | + break; |
|
| 94 | + case 403: |
|
| 95 | + error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid); |
|
| 96 | + exit("Error 403: Access denied"); |
|
| 97 | + break; |
|
| 98 | + default: |
|
| 99 | + error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 100 | + //throw new \Exception('Unknown Error: '.$result->status_code); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - if($device_uid != '') |
|
| 104 | - { |
|
| 103 | + if($device_uid != '') |
|
| 104 | + { |
|
| 105 | 105 | $result[0] = $result; |
| 106 | 106 | $result[1] = $device_uid; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - /* |
|
| 109 | + /* |
|
| 110 | 110 | var_dump($result); |
| 111 | 111 | */ |
| 112 | 112 | |
| 113 | - return $result; |
|
| 114 | - } |
|
| 115 | - abstract function getPayload(); |
|
| 116 | - /** |
|
| 117 | - * Gets Sign headers |
|
| 118 | - * @return array headers |
|
| 119 | - */ |
|
| 120 | - private function getSignHeaders() |
|
| 121 | - { |
|
| 113 | + return $result; |
|
| 114 | + } |
|
| 115 | + abstract function getPayload(); |
|
| 116 | + /** |
|
| 117 | + * Gets Sign headers |
|
| 118 | + * @return array headers |
|
| 119 | + */ |
|
| 120 | + private function getSignHeaders() |
|
| 121 | + { |
|
| 122 | 122 | if($this->getAccessToken() == null) { |
| 123 | 123 | $payload_accessToken = ""; |
| 124 | 124 | } |
@@ -127,54 +127,54 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | |
| 130 | - $headers = array( |
|
| 131 | - "Connection" => "keep-alive", |
|
| 132 | - "Accept-Encoding" => "gzip", |
|
| 133 | - "Content-Type" => "application/json; charset=UTF-8", |
|
| 134 | - "User-Agent" => self::USERAGENT |
|
| 135 | - ); |
|
| 136 | - $timestamp = new DateTime(); |
|
| 137 | - $timestamp = $timestamp->format(DateTime::ATOM); |
|
| 138 | - $timestamp = substr($timestamp, 0, -6); |
|
| 139 | - $timestamp .= "Z"; |
|
| 140 | - $urlParts = parse_url($this->getFullUrl()); |
|
| 141 | - $url2 = ""; |
|
| 142 | - $req = [$this->getMethod(), |
|
| 143 | - $urlParts['host'], |
|
| 144 | - "443", |
|
| 145 | - $urlParts['path'], |
|
| 146 | - $payload_accessToken, |
|
| 147 | - $timestamp, |
|
| 148 | - $url2, |
|
| 149 | - $this->payLoad]; |
|
| 150 | - $reqString = implode("%", $req); |
|
| 151 | - $secret = self::SECRET; |
|
| 152 | - $signature = hash_hmac('sha1', $reqString, $secret); |
|
| 153 | - $signature = strtoupper($signature); |
|
| 154 | - $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
| 155 | - $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
| 156 | - $headers['X-Timestamp'] = $timestamp; |
|
| 157 | - $headers['X-Api-Version'] = '0.2'; |
|
| 158 | - return $headers; |
|
| 159 | - } |
|
| 160 | - private function getFullUrl() |
|
| 161 | - { |
|
| 162 | - return self::APIURL . $this->getApiEndPoint(); |
|
| 163 | - } |
|
| 164 | - abstract function getApiEndPoint(); |
|
| 165 | - abstract function getMethod(); |
|
| 166 | - /** |
|
| 167 | - * @return string |
|
| 168 | - */ |
|
| 169 | - private function getAccessToken() |
|
| 170 | - { |
|
| 171 | - return $this->accessToken; |
|
| 172 | - } |
|
| 173 | - /** |
|
| 174 | - * @param string $accessToken |
|
| 175 | - */ |
|
| 176 | - public function setAccessToken($accessToken) |
|
| 177 | - { |
|
| 178 | - $this->accessToken = $accessToken; |
|
| 179 | - } |
|
| 130 | + $headers = array( |
|
| 131 | + "Connection" => "keep-alive", |
|
| 132 | + "Accept-Encoding" => "gzip", |
|
| 133 | + "Content-Type" => "application/json; charset=UTF-8", |
|
| 134 | + "User-Agent" => self::USERAGENT |
|
| 135 | + ); |
|
| 136 | + $timestamp = new DateTime(); |
|
| 137 | + $timestamp = $timestamp->format(DateTime::ATOM); |
|
| 138 | + $timestamp = substr($timestamp, 0, -6); |
|
| 139 | + $timestamp .= "Z"; |
|
| 140 | + $urlParts = parse_url($this->getFullUrl()); |
|
| 141 | + $url2 = ""; |
|
| 142 | + $req = [$this->getMethod(), |
|
| 143 | + $urlParts['host'], |
|
| 144 | + "443", |
|
| 145 | + $urlParts['path'], |
|
| 146 | + $payload_accessToken, |
|
| 147 | + $timestamp, |
|
| 148 | + $url2, |
|
| 149 | + $this->payLoad]; |
|
| 150 | + $reqString = implode("%", $req); |
|
| 151 | + $secret = self::SECRET; |
|
| 152 | + $signature = hash_hmac('sha1', $reqString, $secret); |
|
| 153 | + $signature = strtoupper($signature); |
|
| 154 | + $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
| 155 | + $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
| 156 | + $headers['X-Timestamp'] = $timestamp; |
|
| 157 | + $headers['X-Api-Version'] = '0.2'; |
|
| 158 | + return $headers; |
|
| 159 | + } |
|
| 160 | + private function getFullUrl() |
|
| 161 | + { |
|
| 162 | + return self::APIURL . $this->getApiEndPoint(); |
|
| 163 | + } |
|
| 164 | + abstract function getApiEndPoint(); |
|
| 165 | + abstract function getMethod(); |
|
| 166 | + /** |
|
| 167 | + * @return string |
|
| 168 | + */ |
|
| 169 | + private function getAccessToken() |
|
| 170 | + { |
|
| 171 | + return $this->accessToken; |
|
| 172 | + } |
|
| 173 | + /** |
|
| 174 | + * @param string $accessToken |
|
| 175 | + */ |
|
| 176 | + public function setAccessToken($accessToken) |
|
| 177 | + { |
|
| 178 | + $this->accessToken = $accessToken; |
|
| 179 | + } |
|
| 180 | 180 | } |