@@ -2,18 +2,18 @@ |
||
2 | 2 | class GetUserConfig extends AbstractRequest |
3 | 3 | { |
4 | 4 | |
5 | - function getApiEndPoint() |
|
6 | - { |
|
7 | - return '/v3/user/config/'; |
|
8 | - } |
|
9 | - function getPayload() |
|
10 | - { |
|
11 | - return array( |
|
12 | - ); |
|
13 | - } |
|
14 | - function getMethod() |
|
15 | - { |
|
16 | - return 'GET'; |
|
17 | - } |
|
5 | + function getApiEndPoint() |
|
6 | + { |
|
7 | + return '/v3/user/config/'; |
|
8 | + } |
|
9 | + function getPayload() |
|
10 | + { |
|
11 | + return array( |
|
12 | + ); |
|
13 | + } |
|
14 | + function getMethod() |
|
15 | + { |
|
16 | + return 'GET'; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 |
@@ -3,37 +3,37 @@ |
||
3 | 3 | |
4 | 4 | class UpdateLocation extends AbstractRequest { |
5 | 5 | /** |
6 | - * @var Location |
|
7 | - */ |
|
8 | - public $location; |
|
9 | - /** |
|
10 | - * @return Location |
|
11 | - */ |
|
12 | - public function getLocation() |
|
13 | - { |
|
14 | - return $this->location; |
|
15 | - } |
|
16 | - /** |
|
17 | - * @param Location $location |
|
18 | - */ |
|
19 | - public function setLocation($location) |
|
20 | - { |
|
21 | - $this->location = $location; |
|
22 | - } |
|
6 | + * @var Location |
|
7 | + */ |
|
8 | + public $location; |
|
9 | + /** |
|
10 | + * @return Location |
|
11 | + */ |
|
12 | + public function getLocation() |
|
13 | + { |
|
14 | + return $this->location; |
|
15 | + } |
|
16 | + /** |
|
17 | + * @param Location $location |
|
18 | + */ |
|
19 | + public function setLocation($location) |
|
20 | + { |
|
21 | + $this->location = $location; |
|
22 | + } |
|
23 | 23 | |
24 | - function getApiEndPoint() |
|
25 | - { |
|
26 | - return '/v2/users/location'; |
|
27 | - } |
|
28 | - function getPayload() |
|
29 | - { |
|
30 | - return array( |
|
24 | + function getApiEndPoint() |
|
25 | + { |
|
26 | + return '/v2/users/location'; |
|
27 | + } |
|
28 | + function getPayload() |
|
29 | + { |
|
30 | + return array( |
|
31 | 31 | 'location' => $this->getLocation()->toArray(), |
32 | - ); |
|
33 | - } |
|
34 | - function getMethod() |
|
35 | - { |
|
36 | - return 'PUT'; |
|
37 | - } |
|
32 | + ); |
|
33 | + } |
|
34 | + function getMethod() |
|
35 | + { |
|
36 | + return 'PUT'; |
|
37 | + } |
|
38 | 38 | } |
39 | 39 |
@@ -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 |
@@ -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 |
@@ -3,18 +3,18 @@ |
||
3 | 3 | |
4 | 4 | class GetPostDetails extends AbstractRequest { |
5 | 5 | |
6 | - function getApiEndPoint() |
|
7 | - { |
|
8 | - return '/v2/posts/' . $_GET['postId']; |
|
9 | - } |
|
10 | - function getPayload() |
|
11 | - { |
|
12 | - return array( |
|
13 | - ); |
|
14 | - } |
|
15 | - function getMethod() |
|
16 | - { |
|
17 | - return 'GET'; |
|
18 | - } |
|
6 | + function getApiEndPoint() |
|
7 | + { |
|
8 | + return '/v2/posts/' . $_GET['postId']; |
|
9 | + } |
|
10 | + function getPayload() |
|
11 | + { |
|
12 | + return array( |
|
13 | + ); |
|
14 | + } |
|
15 | + function getMethod() |
|
16 | + { |
|
17 | + return 'GET'; |
|
18 | + } |
|
19 | 19 | } |
20 | 20 |
@@ -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 = 'LDWWpuUigOnKCbCLpoNMDHCqHCWbLKPzHbnIUKIf'; |
|
8 | - const USERAGENT = 'Jodel/4.33.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
9 | - const CLIENT_TYPE = 'android_4.33.2'; |
|
5 | + const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
6 | + const APIURL = 'https://api.go-tellm.com/api'; |
|
7 | + const SECRET = 'LDWWpuUigOnKCbCLpoNMDHCqHCWbLKPzHbnIUKIf'; |
|
8 | + const USERAGENT = 'Jodel/4.33.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
9 | + const CLIENT_TYPE = 'android_4.33.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 | } |
@@ -2,41 +2,41 @@ |
||
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; |
|
11 | - public $lastPostId = ''; |
|
12 | - public $view = 'combo'; |
|
5 | + /** |
|
6 | + * @var Location |
|
7 | + */ |
|
8 | + public $location; |
|
9 | + public $channel; |
|
10 | + public $hasPayload = FALSE; |
|
11 | + public $lastPostId = ''; |
|
12 | + public $view = 'combo'; |
|
13 | 13 | |
14 | - function getApiEndPoint() |
|
15 | - { |
|
16 | - if($this->lastPostId == '') |
|
17 | - { |
|
18 | - $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel; |
|
19 | - } |
|
20 | - else |
|
21 | - { |
|
22 | - if($this->view == 'combo') |
|
23 | - { |
|
24 | - $apiEndPoint = '/v3/posts/hashtag?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
25 | - } |
|
26 | - else |
|
27 | - { |
|
28 | - $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
29 | - } |
|
30 | - } |
|
31 | - return $apiEndPoint; |
|
32 | - } |
|
33 | - function getPayload() |
|
34 | - { |
|
35 | - return array( |
|
36 | - ); |
|
37 | - } |
|
38 | - function getMethod() |
|
39 | - { |
|
40 | - return 'GET'; |
|
41 | - } |
|
14 | + function getApiEndPoint() |
|
15 | + { |
|
16 | + if($this->lastPostId == '') |
|
17 | + { |
|
18 | + $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel; |
|
19 | + } |
|
20 | + else |
|
21 | + { |
|
22 | + if($this->view == 'combo') |
|
23 | + { |
|
24 | + $apiEndPoint = '/v3/posts/hashtag?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
25 | + } |
|
26 | + else |
|
27 | + { |
|
28 | + $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
29 | + } |
|
30 | + } |
|
31 | + return $apiEndPoint; |
|
32 | + } |
|
33 | + function getPayload() |
|
34 | + { |
|
35 | + return array( |
|
36 | + ); |
|
37 | + } |
|
38 | + function getMethod() |
|
39 | + { |
|
40 | + return 'GET'; |
|
41 | + } |
|
42 | 42 | } |
@@ -129,7 +129,7 @@ |
||
129 | 129 | <?php |
130 | 130 | if(is_file(realpath(__DIR__ . '/..') . '/piwik-script.html')) |
131 | 131 | { |
132 | - include(realpath(__DIR__ . '/..') . '/piwik-script.html'); |
|
132 | + include(realpath(__DIR__ . '/..') . '/piwik-script.html'); |
|
133 | 133 | } |
134 | 134 | ?> |
135 | 135 |
@@ -2,107 +2,107 @@ discard block |
||
2 | 2 | |
3 | 3 | class View |
4 | 4 | { |
5 | - public $country; |
|
6 | - public $city; |
|
7 | - public $hashtag; |
|
5 | + public $country; |
|
6 | + public $city; |
|
7 | + public $hashtag; |
|
8 | 8 | public $view; |
9 | - public $postId; |
|
10 | - public $isDetailedView; |
|
11 | - public $baseUrl; |
|
9 | + public $postId; |
|
10 | + public $isDetailedView; |
|
11 | + public $baseUrl; |
|
12 | 12 | |
13 | 13 | public $lastPostId = ''; |
14 | 14 | |
15 | - function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '') |
|
16 | - { |
|
17 | - $this->baseUrl = $baseUrl; |
|
18 | - $this->country = $country; |
|
19 | - $this->city = $city; |
|
20 | - $this->hashtag = urldecode($hashtag); |
|
21 | - $this->view = $view; |
|
22 | - $this->postId = $postId; |
|
23 | - |
|
24 | - if($postId == '') |
|
25 | - { |
|
26 | - $this->isDetailedView = FALSE; |
|
27 | - } |
|
28 | - else |
|
29 | - { |
|
30 | - $this->isDetailedView = TRUE; |
|
31 | - } |
|
32 | - } |
|
15 | + function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '') |
|
16 | + { |
|
17 | + $this->baseUrl = $baseUrl; |
|
18 | + $this->country = $country; |
|
19 | + $this->city = $city; |
|
20 | + $this->hashtag = urldecode($hashtag); |
|
21 | + $this->view = $view; |
|
22 | + $this->postId = $postId; |
|
23 | + |
|
24 | + if($postId == '') |
|
25 | + { |
|
26 | + $this->isDetailedView = FALSE; |
|
27 | + } |
|
28 | + else |
|
29 | + { |
|
30 | + $this->isDetailedView = TRUE; |
|
31 | + } |
|
32 | + } |
|
33 | 33 | /** |
34 | 34 | * Compute HTML Code |
35 | 35 | */ |
36 | 36 | function jodelToHtml($post) |
37 | - { //ToDO |
|
38 | - //Replace # with link |
|
39 | - //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
40 | - |
|
41 | - //Time to time difference |
|
42 | - $now = new DateTime(); |
|
43 | - $d = new DateTime($post['created_at']); |
|
44 | - $timediff = $now->diff($d); |
|
45 | - |
|
46 | - $timediff_inSeconds = (string)$timediff->format('%s'); |
|
47 | - $timediff_inMinutes = (string)$timediff->format('%i'); |
|
48 | - $timediff_inHours = (string)$timediff->format('%h'); |
|
49 | - $timediff_inDays = (string)$timediff->format('%d'); |
|
50 | - $timediff_inMonth = (string)$timediff->format('%m'); |
|
51 | - |
|
52 | - if($timediff_inMonth!=0) |
|
53 | - { |
|
54 | - $timediff = $timediff_inMonth . "m"; |
|
55 | - } |
|
56 | - else |
|
57 | - { |
|
58 | - if($timediff_inDays!=0) |
|
59 | - { |
|
60 | - $timediff = $timediff_inDays . "d"; |
|
61 | - } |
|
62 | - else |
|
63 | - { |
|
64 | - if($timediff_inHours!=0) |
|
65 | - { |
|
66 | - $timediff = $timediff_inHours . "h"; |
|
67 | - } |
|
68 | - else |
|
69 | - { |
|
70 | - if($timediff_inMinutes!=0) |
|
71 | - { |
|
72 | - $timediff = $timediff_inMinutes . "m"; |
|
73 | - } |
|
74 | - else |
|
75 | - { |
|
76 | - $timediff = $timediff_inSeconds . "s"; |
|
77 | - } |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - ?> |
|
37 | + { //ToDO |
|
38 | + //Replace # with link |
|
39 | + //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
40 | + |
|
41 | + //Time to time difference |
|
42 | + $now = new DateTime(); |
|
43 | + $d = new DateTime($post['created_at']); |
|
44 | + $timediff = $now->diff($d); |
|
45 | + |
|
46 | + $timediff_inSeconds = (string)$timediff->format('%s'); |
|
47 | + $timediff_inMinutes = (string)$timediff->format('%i'); |
|
48 | + $timediff_inHours = (string)$timediff->format('%h'); |
|
49 | + $timediff_inDays = (string)$timediff->format('%d'); |
|
50 | + $timediff_inMonth = (string)$timediff->format('%m'); |
|
51 | + |
|
52 | + if($timediff_inMonth!=0) |
|
53 | + { |
|
54 | + $timediff = $timediff_inMonth . "m"; |
|
55 | + } |
|
56 | + else |
|
57 | + { |
|
58 | + if($timediff_inDays!=0) |
|
59 | + { |
|
60 | + $timediff = $timediff_inDays . "d"; |
|
61 | + } |
|
62 | + else |
|
63 | + { |
|
64 | + if($timediff_inHours!=0) |
|
65 | + { |
|
66 | + $timediff = $timediff_inHours . "h"; |
|
67 | + } |
|
68 | + else |
|
69 | + { |
|
70 | + if($timediff_inMinutes!=0) |
|
71 | + { |
|
72 | + $timediff = $timediff_inMinutes . "m"; |
|
73 | + } |
|
74 | + else |
|
75 | + { |
|
76 | + $timediff = $timediff_inSeconds . "s"; |
|
77 | + } |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + ?> |
|
84 | 84 | <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
85 | 85 | <content> |
86 | 86 | <?php |
87 | - if(isset($post['image_url'])) |
|
88 | - { |
|
89 | - $regexRest = '/[^\w$ .!?-]+/u'; |
|
90 | - |
|
91 | - echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
|
92 | - } |
|
93 | - else { |
|
94 | - echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
|
95 | - } |
|
96 | - ?> |
|
87 | + if(isset($post['image_url'])) |
|
88 | + { |
|
89 | + $regexRest = '/[^\w$ .!?-]+/u'; |
|
90 | + |
|
91 | + echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
|
92 | + } |
|
93 | + else { |
|
94 | + echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
|
95 | + } |
|
96 | + ?> |
|
97 | 97 | </content> |
98 | 98 | <aside> |
99 | 99 | <?php |
100 | - if($this->isDetailedView) |
|
101 | - {?> |
|
100 | + if($this->isDetailedView) |
|
101 | + {?> |
|
102 | 102 | <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
103 | 103 | <?php } |
104 | - else |
|
105 | - {?> |
|
104 | + else |
|
105 | + {?> |
|
106 | 106 | <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
107 | 107 | <?php } ?> |
108 | 108 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | <br /> |
111 | 111 | <?php echo $post["vote_count"];?><br /> |
112 | 112 | <?php |
113 | - if($this->isDetailedView) |
|
114 | - {?> |
|
113 | + if($this->isDetailedView) |
|
114 | + {?> |
|
115 | 115 | <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
116 | 116 | <?php } |
117 | - else |
|
118 | - {?> |
|
117 | + else |
|
118 | + {?> |
|
119 | 119 | <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
120 | 120 | <?php } ?> |
121 | 121 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
139 | 139 | <i class="fa fa-commenting-o"></i> |
140 | 140 | <?php if(array_key_exists("child_count", $post)) { |
141 | - echo $post["child_count"]; |
|
142 | - } else echo "0"; |
|
143 | - ?> |
|
141 | + echo $post["child_count"]; |
|
142 | + } else echo "0"; |
|
143 | + ?> |
|
144 | 144 | </a> |
145 | 145 | </span> |
146 | 146 | |
@@ -160,30 +160,30 @@ discard block |
||
160 | 160 | ?> |
161 | 161 | <span class="distance"> |
162 | 162 | <?php |
163 | - if($this->isDetailedView) |
|
164 | - { |
|
165 | - if(isset($post["parent_creator"]) && $post["parent_creator"] == 1) |
|
166 | - { |
|
167 | - ?> |
|
163 | + if($this->isDetailedView) |
|
164 | + { |
|
165 | + if(isset($post["parent_creator"]) && $post["parent_creator"] == 1) |
|
166 | + { |
|
167 | + ?> |
|
168 | 168 | <span data-tooltip="Author"> |
169 | 169 | <i class="fa fa-user-o"></i> OJ | |
170 | 170 | </span> |
171 | 171 | <?php |
172 | - } |
|
173 | - else |
|
174 | - { |
|
175 | - //Is not parent Jodel in detailed View |
|
176 | - if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post)) |
|
177 | - { |
|
178 | - ?> |
|
172 | + } |
|
173 | + else |
|
174 | + { |
|
175 | + //Is not parent Jodel in detailed View |
|
176 | + if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post)) |
|
177 | + { |
|
178 | + ?> |
|
179 | 179 | <span data-tooltip="Author"> |
180 | 180 | <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
181 | 181 | </span> |
182 | 182 | <?php |
183 | - } |
|
184 | - } |
|
185 | - } |
|
186 | - ?> |
|
183 | + } |
|
184 | + } |
|
185 | + } |
|
186 | + ?> |
|
187 | 187 | |
188 | 188 | <span class="tip" data-tooltip="Distance"> |
189 | 189 | <i class="fa fa-map-marker"></i> |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | </footer> |
197 | 197 | </article> |
198 | 198 | <?php |
199 | - } |
|
199 | + } |
|
200 | 200 | |
201 | 201 | |
202 | 202 | /** |
@@ -267,135 +267,135 @@ discard block |
||
267 | 267 | |
268 | 268 | } |
269 | 269 | |
270 | - function toUrl() |
|
271 | - { |
|
272 | - $url = $this->baseUrl . 'index.php?country=DE' . |
|
273 | - '&city=' . urlencode($this->city) . |
|
274 | - '&hashtag=' . urlencode($this->hashtag) . |
|
275 | - '&view=' . $this->view; |
|
276 | - if($this->postId != '') |
|
277 | - { |
|
278 | - $url .= '&postId=' . $this->postId . |
|
279 | - '&getPostDetails=TRUE'; |
|
280 | - } |
|
281 | - |
|
282 | - return $url; |
|
283 | - } |
|
284 | - |
|
285 | - function changePostId($postId) |
|
286 | - { |
|
287 | - $tempView = clone $this; |
|
288 | - $tempView->postId = $postId; |
|
289 | - $tempView->isDetailedView = TRUE; |
|
290 | - return $tempView; |
|
291 | - } |
|
292 | - |
|
293 | - function back() |
|
294 | - { |
|
295 | - $tempView = clone $this; |
|
296 | - $tempView->postId = ''; |
|
297 | - return $tempView; |
|
298 | - } |
|
299 | - |
|
300 | - function changeView($view) |
|
301 | - { |
|
302 | - $tempView = clone $this; |
|
303 | - $tempView->view = $view; |
|
304 | - return $tempView; |
|
305 | - } |
|
270 | + function toUrl() |
|
271 | + { |
|
272 | + $url = $this->baseUrl . 'index.php?country=DE' . |
|
273 | + '&city=' . urlencode($this->city) . |
|
274 | + '&hashtag=' . urlencode($this->hashtag) . |
|
275 | + '&view=' . $this->view; |
|
276 | + if($this->postId != '') |
|
277 | + { |
|
278 | + $url .= '&postId=' . $this->postId . |
|
279 | + '&getPostDetails=TRUE'; |
|
280 | + } |
|
281 | + |
|
282 | + return $url; |
|
283 | + } |
|
284 | + |
|
285 | + function changePostId($postId) |
|
286 | + { |
|
287 | + $tempView = clone $this; |
|
288 | + $tempView->postId = $postId; |
|
289 | + $tempView->isDetailedView = TRUE; |
|
290 | + return $tempView; |
|
291 | + } |
|
292 | + |
|
293 | + function back() |
|
294 | + { |
|
295 | + $tempView = clone $this; |
|
296 | + $tempView->postId = ''; |
|
297 | + return $tempView; |
|
298 | + } |
|
299 | + |
|
300 | + function changeView($view) |
|
301 | + { |
|
302 | + $tempView = clone $this; |
|
303 | + $tempView->view = $view; |
|
304 | + return $tempView; |
|
305 | + } |
|
306 | 306 | |
307 | 307 | function getPosts($jodelAccount) |
308 | 308 | { |
309 | - if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
310 | - { |
|
311 | - $accountCreator = new GetChannel(); |
|
312 | - $accountCreator->view = $this->view; |
|
313 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
314 | - $accountCreator->channel = $this->hashtag; |
|
315 | - $accountCreator->lastPostId = $this->lastPostId; |
|
316 | - $data = $accountCreator->execute(); |
|
317 | - } |
|
318 | - else |
|
319 | - { |
|
320 | - if($this->lastPostId == '' && $this->view == 'combo') |
|
321 | - { |
|
322 | - $url = "/v3/posts/location/combo"; |
|
323 | - } |
|
324 | - else |
|
325 | - { |
|
326 | - if($this->view == 'discussed') |
|
327 | - { |
|
328 | - $url = "/v2/posts/location/discussed/"; |
|
329 | - } |
|
330 | - else |
|
331 | - { |
|
332 | - if($this->view == 'popular') |
|
333 | - { |
|
334 | - $url = "/v2/posts/location/popular/"; |
|
335 | - } |
|
336 | - else |
|
337 | - { |
|
338 | - $url = "/v2/posts/location/"; |
|
339 | - } |
|
340 | - } |
|
341 | - } |
|
342 | - |
|
343 | - $accountCreator = new GetPosts(); |
|
344 | - $accountCreator->setLastPostId($this->lastPostId); |
|
345 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
346 | - $accountCreator->setUrl($url); |
|
347 | - $accountCreator->version = 'v3'; |
|
348 | - |
|
349 | - $config = parse_ini_file('config/config.ini.php'); |
|
350 | - $location = new Location(); |
|
351 | - $location->setLat($config['default_lat']); |
|
352 | - $location->setLng($config['default_lng']); |
|
353 | - $location->setCityName($config['default_location']); |
|
354 | - $accountCreator->location = $location; |
|
355 | - $data = $accountCreator->execute(); |
|
356 | - } |
|
357 | - if(array_key_exists('recent', $data)) |
|
358 | - { |
|
359 | - return $data['recent']; |
|
360 | - } |
|
361 | - else if(array_key_exists('posts', $data)) |
|
362 | - { |
|
363 | - return $data['posts']; |
|
364 | - } |
|
365 | - else |
|
366 | - { |
|
367 | - error_log('Fehler View getPosts '); |
|
368 | - error_log(print_r($data, true)); |
|
369 | - |
|
370 | - $notFound[0] = array( |
|
371 | - "post_id" => "0", |
|
372 | - "discovered_by" => 0, |
|
373 | - "message" => "Not found", |
|
374 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
375 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
376 | - "pin_count" => 0, |
|
377 | - "color" => "FFBA00", |
|
378 | - "got_thanks" => FALSE, |
|
379 | - "post_own" => "friend", |
|
380 | - "discovered" => 0, |
|
381 | - "distance" => 9, |
|
382 | - "vote_count" => 0, |
|
383 | - "location" => |
|
384 | - array("name" => "Berlin", |
|
385 | - "loc_coordinates" => |
|
386 | - array( |
|
387 | - "lat" => 0, |
|
388 | - "lng" => 0 |
|
389 | - ), |
|
390 | - "loc_accuracy" => 0, |
|
391 | - "country" => "", |
|
392 | - "city" => "", |
|
393 | - ), |
|
394 | - "tags" => |
|
395 | - array(), |
|
396 | - "user_handle" => "0" |
|
397 | - ); |
|
398 | - return $notFound; |
|
399 | - } |
|
309 | + if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
310 | + { |
|
311 | + $accountCreator = new GetChannel(); |
|
312 | + $accountCreator->view = $this->view; |
|
313 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
314 | + $accountCreator->channel = $this->hashtag; |
|
315 | + $accountCreator->lastPostId = $this->lastPostId; |
|
316 | + $data = $accountCreator->execute(); |
|
317 | + } |
|
318 | + else |
|
319 | + { |
|
320 | + if($this->lastPostId == '' && $this->view == 'combo') |
|
321 | + { |
|
322 | + $url = "/v3/posts/location/combo"; |
|
323 | + } |
|
324 | + else |
|
325 | + { |
|
326 | + if($this->view == 'discussed') |
|
327 | + { |
|
328 | + $url = "/v2/posts/location/discussed/"; |
|
329 | + } |
|
330 | + else |
|
331 | + { |
|
332 | + if($this->view == 'popular') |
|
333 | + { |
|
334 | + $url = "/v2/posts/location/popular/"; |
|
335 | + } |
|
336 | + else |
|
337 | + { |
|
338 | + $url = "/v2/posts/location/"; |
|
339 | + } |
|
340 | + } |
|
341 | + } |
|
342 | + |
|
343 | + $accountCreator = new GetPosts(); |
|
344 | + $accountCreator->setLastPostId($this->lastPostId); |
|
345 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
346 | + $accountCreator->setUrl($url); |
|
347 | + $accountCreator->version = 'v3'; |
|
348 | + |
|
349 | + $config = parse_ini_file('config/config.ini.php'); |
|
350 | + $location = new Location(); |
|
351 | + $location->setLat($config['default_lat']); |
|
352 | + $location->setLng($config['default_lng']); |
|
353 | + $location->setCityName($config['default_location']); |
|
354 | + $accountCreator->location = $location; |
|
355 | + $data = $accountCreator->execute(); |
|
356 | + } |
|
357 | + if(array_key_exists('recent', $data)) |
|
358 | + { |
|
359 | + return $data['recent']; |
|
360 | + } |
|
361 | + else if(array_key_exists('posts', $data)) |
|
362 | + { |
|
363 | + return $data['posts']; |
|
364 | + } |
|
365 | + else |
|
366 | + { |
|
367 | + error_log('Fehler View getPosts '); |
|
368 | + error_log(print_r($data, true)); |
|
369 | + |
|
370 | + $notFound[0] = array( |
|
371 | + "post_id" => "0", |
|
372 | + "discovered_by" => 0, |
|
373 | + "message" => "Not found", |
|
374 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
375 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
376 | + "pin_count" => 0, |
|
377 | + "color" => "FFBA00", |
|
378 | + "got_thanks" => FALSE, |
|
379 | + "post_own" => "friend", |
|
380 | + "discovered" => 0, |
|
381 | + "distance" => 9, |
|
382 | + "vote_count" => 0, |
|
383 | + "location" => |
|
384 | + array("name" => "Berlin", |
|
385 | + "loc_coordinates" => |
|
386 | + array( |
|
387 | + "lat" => 0, |
|
388 | + "lng" => 0 |
|
389 | + ), |
|
390 | + "loc_accuracy" => 0, |
|
391 | + "country" => "", |
|
392 | + "city" => "", |
|
393 | + ), |
|
394 | + "tags" => |
|
395 | + array(), |
|
396 | + "user_handle" => "0" |
|
397 | + ); |
|
398 | + return $notFound; |
|
399 | + } |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | \ No newline at end of file |