@@ -33,6 +33,9 @@ |
||
| 33 | 33 | return $this->random_str(64, 'abcdef0123456789'); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | + /** |
|
| 37 | + * @param integer $length |
|
| 38 | + */ |
|
| 36 | 39 | private function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') |
| 37 | 40 | { |
| 38 | 41 | $str = ''; |
@@ -1,53 +1,53 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class CreateUser extends AbstractRequest { |
| 4 | - /** |
|
| 5 | - * @var Location |
|
| 6 | - */ |
|
| 7 | - private $location; |
|
| 8 | - private $deviceUid; |
|
| 9 | - /** |
|
| 10 | - * @return Location |
|
| 11 | - */ |
|
| 12 | - private function getLocation() |
|
| 13 | - { |
|
| 14 | - return $this->location; |
|
| 15 | - } |
|
| 16 | - /** |
|
| 17 | - * @param Location $location |
|
| 18 | - */ |
|
| 19 | - public function setLocation(Location $location) |
|
| 20 | - { |
|
| 21 | - $this->location = $location; |
|
| 22 | - } |
|
| 23 | - private function getDeviceUid() |
|
| 24 | - { |
|
| 4 | + /** |
|
| 5 | + * @var Location |
|
| 6 | + */ |
|
| 7 | + private $location; |
|
| 8 | + private $deviceUid; |
|
| 9 | + /** |
|
| 10 | + * @return Location |
|
| 11 | + */ |
|
| 12 | + private function getLocation() |
|
| 13 | + { |
|
| 14 | + return $this->location; |
|
| 15 | + } |
|
| 16 | + /** |
|
| 17 | + * @param Location $location |
|
| 18 | + */ |
|
| 19 | + public function setLocation(Location $location) |
|
| 20 | + { |
|
| 21 | + $this->location = $location; |
|
| 22 | + } |
|
| 23 | + private function getDeviceUid() |
|
| 24 | + { |
|
| 25 | 25 | return $this->deviceUid; |
| 26 | 26 | } |
| 27 | 27 | public function setDeviceUid($deviceUid) |
| 28 | - { |
|
| 28 | + { |
|
| 29 | 29 | $this->deviceUid = $deviceUid; |
| 30 | 30 | } |
| 31 | - private function generateDeviceUid() |
|
| 32 | - { |
|
| 33 | - return $this->random_str(64, 'abcdef0123456789'); |
|
| 34 | - } |
|
| 31 | + private function generateDeviceUid() |
|
| 32 | + { |
|
| 33 | + return $this->random_str(64, 'abcdef0123456789'); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - private function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') |
|
| 37 | - { |
|
| 38 | - $str = ''; |
|
| 39 | - $max = mb_strlen($keyspace, '8bit') - 1; |
|
| 40 | - for ($i = 0; $i < $length; ++$i) { |
|
| 41 | - $str .= $keyspace[random_int(0, $max)]; |
|
| 42 | - } |
|
| 43 | - return $str; |
|
| 44 | - } |
|
| 45 | - public function getApiEndPoint() |
|
| 46 | - { |
|
| 47 | - return '/v2/users'; |
|
| 48 | - } |
|
| 49 | - public function getPayload() |
|
| 50 | - { |
|
| 36 | + private function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') |
|
| 37 | + { |
|
| 38 | + $str = ''; |
|
| 39 | + $max = mb_strlen($keyspace, '8bit') - 1; |
|
| 40 | + for ($i = 0; $i < $length; ++$i) { |
|
| 41 | + $str .= $keyspace[random_int(0, $max)]; |
|
| 42 | + } |
|
| 43 | + return $str; |
|
| 44 | + } |
|
| 45 | + public function getApiEndPoint() |
|
| 46 | + { |
|
| 47 | + return '/v2/users'; |
|
| 48 | + } |
|
| 49 | + public function getPayload() |
|
| 50 | + { |
|
| 51 | 51 | if(!isset($this->deviceUid)) |
| 52 | 52 | { |
| 53 | 53 | $this->setDeviceUid($this->generateDeviceUid()); |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | "client_id" => self::CLIENTID, |
| 59 | 59 | "device_uid" => $this->getDeviceUid(), |
| 60 | 60 | ); |
| 61 | - } |
|
| 62 | - public function getMethod() |
|
| 63 | - { |
|
| 64 | - return 'POST'; |
|
| 65 | - } |
|
| 61 | + } |
|
| 62 | + public function getMethod() |
|
| 63 | + { |
|
| 64 | + return 'POST'; |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -17,18 +17,22 @@ discard block |
||
| 17 | 17 | require_once 'php/Requests/libary/Requests.php'; |
| 18 | 18 | Requests::register_autoloader(); |
| 19 | 19 | |
| 20 | -function getPosts($lastPostId, $url) { |
|
| 20 | +function getPosts($lastPostId, $url) |
|
| 21 | +{ |
|
| 21 | 22 | $db = new DatabaseConnect(); |
| 22 | - if ($db->connect_errno) { |
|
| 23 | + if ($db->connect_errno) |
|
| 24 | + { |
|
| 23 | 25 | echo 'Sorry, die Verbindung zu unserem superfetten endgeilen |
| 24 | 26 | Server ist hops gegangen. Wegen '. $db -> connect_error; |
| 25 | 27 | } |
| 26 | 28 | |
| 27 | 29 | $result = $db->query("SELECT * FROM accounts WHERE id='1'"); |
| 28 | 30 | |
| 29 | - if ($result->num_rows > 0) { |
|
| 31 | + if ($result->num_rows > 0) |
|
| 32 | + { |
|
| 30 | 33 | // output data of each row |
| 31 | - while($row = $result->fetch_assoc()) { |
|
| 34 | + while($row = $result->fetch_assoc()) |
|
| 35 | + { |
|
| 32 | 36 | $access_token = $row["access_token"]; |
| 33 | 37 | } |
| 34 | 38 | } |
@@ -66,7 +70,8 @@ discard block |
||
| 66 | 70 | } |
| 67 | 71 | } |
| 68 | 72 | |
| 69 | - if(isset($_GET['lastPostId'])) { |
|
| 73 | + if(isset($_GET['lastPostId'])) |
|
| 74 | + { |
|
| 70 | 75 | |
| 71 | 76 | $lastPostId = $_GET['lastPostId']; |
| 72 | 77 | |
@@ -76,9 +81,11 @@ discard block |
||
| 76 | 81 | ?> |
| 77 | 82 | <div class="nextPosts"> |
| 78 | 83 | <?php |
| 79 | - for($i = 0; $i<$loops; $i++) { |
|
| 84 | + for($i = 0; $i<$loops; $i++) |
|
| 85 | + { |
|
| 80 | 86 | |
| 81 | - if(isset($posts[$i])) { |
|
| 87 | + if(isset($posts[$i])) |
|
| 88 | + { |
|
| 82 | 89 | $lastPostId = $posts[$i]['post_id']; |
| 83 | 90 | |
| 84 | 91 | |
@@ -94,7 +101,8 @@ discard block |
||
| 94 | 101 | $timediff_inHours = (string)$timediff->format('%h'); |
| 95 | 102 | $timediff_inDays = (string)$timediff->format('%d'); |
| 96 | 103 | $timediff_inMonth = (string)$timediff->format('%m'); |
| 97 | - if($timediff_inMonth!=0) { |
|
| 104 | + if($timediff_inMonth!=0) |
|
| 105 | + { |
|
| 98 | 106 | $timediff = $timediff_inMonth . "m"; |
| 99 | 107 | } |
| 100 | 108 | else |
@@ -127,10 +135,12 @@ discard block |
||
| 127 | 135 | <article class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
| 128 | 136 | <content> |
| 129 | 137 | <?php |
| 130 | - if(isset($posts[$i]["image_url"])) { |
|
| 138 | + if(isset($posts[$i]["image_url"])) |
|
| 139 | + { |
|
| 131 | 140 | echo '<img src="' . $posts[$i]["image_url"] . '">'; |
| 132 | 141 | } |
| 133 | - else { |
|
| 142 | + else |
|
| 143 | + { |
|
| 134 | 144 | echo nl2br($posts[$i]["message"]); |
| 135 | 145 | } |
| 136 | 146 | ?> |
@@ -156,13 +166,19 @@ discard block |
||
| 156 | 166 | </span> |
| 157 | 167 | </td> |
| 158 | 168 | <td class="comments"> |
| 159 | - <?php if($showCommentIcon) {?> |
|
| 169 | + <?php if($showCommentIcon) |
|
| 170 | +{ |
|
| 171 | +?> |
|
| 160 | 172 | <span data-tooltip="Comments"> |
| 161 | 173 | <a href="index.php?getPostDetails=true&postID=<?php echo $posts[$i]["post_id"];?>"> |
| 162 | 174 | <i class="fa fa-commenting-o"></i> |
| 163 | - <?php if(array_key_exists("child_count", $posts[$i])) { |
|
| 175 | + <?php if(array_key_exists("child_count", $posts[$i])) |
|
| 176 | +{ |
|
| 164 | 177 | echo $posts[$i]["child_count"]; |
| 165 | - } else echo "0"; |
|
| 178 | + } |
|
| 179 | + else { |
|
| 180 | + echo "0"; |
|
| 181 | + } |
|
| 166 | 182 | ?> |
| 167 | 183 | </a> |
| 168 | 184 | </span> |
@@ -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 = "VwJHzYUbPjGiXWauoVNaHoCWsaacTmnkGwNtHhjy"; |
|
| 8 | - const USERAGENT = "Jodel/4.27.1 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )"; |
|
| 9 | - const CLIENT_TYPE = 'android_4.27.1'; |
|
| 5 | + CONST CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
| 6 | + CONST APIURL = 'https://api.go-tellm.com/api'; |
|
| 7 | + const SECRET = "VwJHzYUbPjGiXWauoVNaHoCWsaacTmnkGwNtHhjy"; |
|
| 8 | + const USERAGENT = "Jodel/4.27.1 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )"; |
|
| 9 | + const CLIENT_TYPE = 'android_4.27.1'; |
|
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @var string |
|
| 13 | - */ |
|
| 14 | - private $accessToken = null; |
|
| 15 | - private $payLoad; |
|
| 16 | - public function execute() |
|
| 17 | - { |
|
| 11 | + /** |
|
| 12 | + * @var string |
|
| 13 | + */ |
|
| 14 | + private $accessToken = null; |
|
| 15 | + private $payLoad; |
|
| 16 | + public function execute() |
|
| 17 | + { |
|
| 18 | 18 | $result = new \stdClass(); |
| 19 | 19 | |
| 20 | 20 | $this->payLoad = $this->getPayload(); |
@@ -24,71 +24,71 @@ 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 | *var_dump($url); |
| 37 | 37 | *var_dump($header); |
| 38 | 38 | *var_dump($this->payLoad); |
| 39 | 39 | */ |
| 40 | 40 | |
| 41 | 41 | |
| 42 | - switch ($this->getMethod()) { |
|
| 43 | - case 'POST': |
|
| 44 | - $result = Requests::post($url, $header, $this->payLoad); |
|
| 45 | - break; |
|
| 46 | - case 'GET': |
|
| 47 | - $result = Requests::get($url, $header); |
|
| 48 | - break; |
|
| 49 | - case 'PUT': |
|
| 50 | - $result = Requests::put($url, $header, $this->payLoad); |
|
| 51 | - break; |
|
| 52 | - } |
|
| 53 | - switch ($result->status_code) { |
|
| 54 | - case 200: |
|
| 55 | - $result = json_decode($result->body, true); |
|
| 56 | - break; |
|
| 57 | - case 204: |
|
| 58 | - $result = "Success"; |
|
| 59 | - break; |
|
| 60 | - case 401: |
|
| 42 | + switch ($this->getMethod()) { |
|
| 43 | + case 'POST': |
|
| 44 | + $result = Requests::post($url, $header, $this->payLoad); |
|
| 45 | + break; |
|
| 46 | + case 'GET': |
|
| 47 | + $result = Requests::get($url, $header); |
|
| 48 | + break; |
|
| 49 | + case 'PUT': |
|
| 50 | + $result = Requests::put($url, $header, $this->payLoad); |
|
| 51 | + break; |
|
| 52 | + } |
|
| 53 | + switch ($result->status_code) { |
|
| 54 | + case 200: |
|
| 55 | + $result = json_decode($result->body, true); |
|
| 56 | + break; |
|
| 57 | + case 204: |
|
| 58 | + $result = "Success"; |
|
| 59 | + break; |
|
| 60 | + case 401: |
|
| 61 | 61 | throw new \Exception('Unauthorized'); |
| 62 | - break; |
|
| 63 | - case 404: |
|
| 64 | - echo "Es wurde bereits gevoted"; |
|
| 62 | + break; |
|
| 63 | + case 404: |
|
| 64 | + echo "Es wurde bereits gevoted"; |
|
| 65 | 65 | case 477: |
| 66 | - echo "Es wurde bereits gevoted"; |
|
| 67 | - throw new \Exception('Signing failed!'); |
|
| 68 | - break; |
|
| 69 | - default: |
|
| 70 | - throw new \Exception('Unknown Error: '.$result->status_code); |
|
| 71 | - } |
|
| 66 | + echo "Es wurde bereits gevoted"; |
|
| 67 | + throw new \Exception('Signing failed!'); |
|
| 68 | + break; |
|
| 69 | + default: |
|
| 70 | + throw new \Exception('Unknown Error: '.$result->status_code); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - if($device_uid != "") |
|
| 74 | - { |
|
| 73 | + if($device_uid != "") |
|
| 74 | + { |
|
| 75 | 75 | $result[0] = $result; |
| 76 | 76 | $result[1] = $device_uid; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - /* |
|
| 79 | + /* |
|
| 80 | 80 | var_dump($result); |
| 81 | 81 | */ |
| 82 | 82 | |
| 83 | - return $result; |
|
| 84 | - } |
|
| 85 | - abstract function getPayload(); |
|
| 86 | - /** |
|
| 87 | - * Gets Sign headers |
|
| 88 | - * @return array headers |
|
| 89 | - */ |
|
| 90 | - private function getSignHeaders() |
|
| 91 | - { |
|
| 83 | + return $result; |
|
| 84 | + } |
|
| 85 | + abstract function getPayload(); |
|
| 86 | + /** |
|
| 87 | + * Gets Sign headers |
|
| 88 | + * @return array headers |
|
| 89 | + */ |
|
| 90 | + private function getSignHeaders() |
|
| 91 | + { |
|
| 92 | 92 | if($this->getAccessToken() == null) { |
| 93 | 93 | $payload_accessToken = ""; |
| 94 | 94 | } |
@@ -97,54 +97,54 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
| 100 | - $headers = array( |
|
| 101 | - "Connection" => "keep-alive", |
|
| 102 | - "Accept-Encoding" => "gzip", |
|
| 103 | - "Content-Type" => "application/json; charset=UTF-8", |
|
| 104 | - "User-Agent" => self::USERAGENT |
|
| 105 | - ); |
|
| 106 | - $timestamp = new DateTime(); |
|
| 107 | - $timestamp = $timestamp->format(DateTime::ATOM); |
|
| 108 | - $timestamp = substr($timestamp, 0, -6); |
|
| 109 | - $timestamp .= "Z"; |
|
| 110 | - $urlParts = parse_url($this->getFullUrl()); |
|
| 111 | - $url2 = ""; |
|
| 112 | - $req = [$this->getMethod(), |
|
| 113 | - $urlParts['host'], |
|
| 114 | - "443", |
|
| 115 | - $urlParts['path'], |
|
| 116 | - $payload_accessToken, |
|
| 117 | - $timestamp, |
|
| 118 | - $url2, |
|
| 119 | - $this->payLoad]; |
|
| 120 | - $reqString = implode("%", $req); |
|
| 121 | - $secret = self::SECRET; |
|
| 122 | - $signature = hash_hmac('sha1', $reqString, $secret); |
|
| 123 | - $signature = strtoupper($signature); |
|
| 124 | - $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
| 125 | - $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
| 126 | - $headers['X-Timestamp'] = $timestamp; |
|
| 127 | - $headers['X-Api-Version'] = '0.2'; |
|
| 128 | - return $headers; |
|
| 129 | - } |
|
| 130 | - private function getFullUrl() |
|
| 131 | - { |
|
| 132 | - return self::APIURL . $this->getApiEndPoint(); |
|
| 133 | - } |
|
| 134 | - abstract function getApiEndPoint(); |
|
| 135 | - abstract function getMethod(); |
|
| 136 | - /** |
|
| 137 | - * @return string |
|
| 138 | - */ |
|
| 139 | - private function getAccessToken() |
|
| 140 | - { |
|
| 141 | - return $this->accessToken; |
|
| 142 | - } |
|
| 143 | - /** |
|
| 144 | - * @param string $accessToken |
|
| 145 | - */ |
|
| 146 | - public function setAccessToken(string $accessToken) |
|
| 147 | - { |
|
| 148 | - $this->accessToken = $accessToken; |
|
| 149 | - } |
|
| 100 | + $headers = array( |
|
| 101 | + "Connection" => "keep-alive", |
|
| 102 | + "Accept-Encoding" => "gzip", |
|
| 103 | + "Content-Type" => "application/json; charset=UTF-8", |
|
| 104 | + "User-Agent" => self::USERAGENT |
|
| 105 | + ); |
|
| 106 | + $timestamp = new DateTime(); |
|
| 107 | + $timestamp = $timestamp->format(DateTime::ATOM); |
|
| 108 | + $timestamp = substr($timestamp, 0, -6); |
|
| 109 | + $timestamp .= "Z"; |
|
| 110 | + $urlParts = parse_url($this->getFullUrl()); |
|
| 111 | + $url2 = ""; |
|
| 112 | + $req = [$this->getMethod(), |
|
| 113 | + $urlParts['host'], |
|
| 114 | + "443", |
|
| 115 | + $urlParts['path'], |
|
| 116 | + $payload_accessToken, |
|
| 117 | + $timestamp, |
|
| 118 | + $url2, |
|
| 119 | + $this->payLoad]; |
|
| 120 | + $reqString = implode("%", $req); |
|
| 121 | + $secret = self::SECRET; |
|
| 122 | + $signature = hash_hmac('sha1', $reqString, $secret); |
|
| 123 | + $signature = strtoupper($signature); |
|
| 124 | + $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
| 125 | + $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
| 126 | + $headers['X-Timestamp'] = $timestamp; |
|
| 127 | + $headers['X-Api-Version'] = '0.2'; |
|
| 128 | + return $headers; |
|
| 129 | + } |
|
| 130 | + private function getFullUrl() |
|
| 131 | + { |
|
| 132 | + return self::APIURL . $this->getApiEndPoint(); |
|
| 133 | + } |
|
| 134 | + abstract function getApiEndPoint(); |
|
| 135 | + abstract function getMethod(); |
|
| 136 | + /** |
|
| 137 | + * @return string |
|
| 138 | + */ |
|
| 139 | + private function getAccessToken() |
|
| 140 | + { |
|
| 141 | + return $this->accessToken; |
|
| 142 | + } |
|
| 143 | + /** |
|
| 144 | + * @param string $accessToken |
|
| 145 | + */ |
|
| 146 | + public function setAccessToken(string $accessToken) |
|
| 147 | + { |
|
| 148 | + $this->accessToken = $accessToken; |
|
| 149 | + } |
|
| 150 | 150 | } |
@@ -2,8 +2,8 @@ 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'; |
|
| 5 | + const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
| 6 | + const APIURL = 'https://api.go-tellm.com/api'; |
|
| 7 | 7 | const SECRET = "VwJHzYUbPjGiXWauoVNaHoCWsaacTmnkGwNtHhjy"; |
| 8 | 8 | const USERAGENT = "Jodel/4.27.1 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )"; |
| 9 | 9 | const CLIENT_TYPE = 'android_4.27.1'; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @var string |
| 13 | 13 | */ |
| 14 | - private $accessToken = null; |
|
| 14 | + private $accessToken = NULL; |
|
| 15 | 15 | private $payLoad; |
| 16 | 16 | public function execute() |
| 17 | 17 | { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | switch ($result->status_code) { |
| 54 | 54 | case 200: |
| 55 | - $result = json_decode($result->body, true); |
|
| 55 | + $result = json_decode($result->body, TRUE); |
|
| 56 | 56 | break; |
| 57 | 57 | case 204: |
| 58 | 58 | $result = "Success"; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | private function getSignHeaders() |
| 91 | 91 | { |
| 92 | - if($this->getAccessToken() == null) { |
|
| 92 | + if($this->getAccessToken() == NULL) { |
|
| 93 | 93 | $payload_accessToken = ""; |
| 94 | 94 | } |
| 95 | 95 | else { |