Completed
Push — master ( 7b8c34...be2f09 )
by mains
03:01
created
php/Requests/AbstractRequest.php 3 patches
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -2,21 +2,21 @@  discard block
 block discarded – undo
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 = 'hFvMqLauMtnodakokftuKETbIsVLxpqfjAXiRoih';
8
-    const USERAGENT = 'Jodel/4.41.0 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
-    const CLIENT_TYPE = 'android_4.41.0';
5
+	const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26';
6
+	const APIURL = 'https://api.go-tellm.com/api';
7
+	const SECRET = 'hFvMqLauMtnodakokftuKETbIsVLxpqfjAXiRoih';
8
+	const USERAGENT = 'Jodel/4.41.0 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
+	const CLIENT_TYPE = 'android_4.41.0';
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
-    {
19
-        $result = new \stdClass();
17
+	public function execute()
18
+	{
19
+		$result = new \stdClass();
20 20
 		        
21 21
 		$this->payLoad = $this->getPayload();
22 22
 		$device_uid = '';
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
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,114 +45,114 @@  discard block
 block discarded – undo
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
-        }
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 73
 
74
-        http_response_code($result->status_code);
74
+		http_response_code($result->status_code);
75 75
 
76
-        switch ($result->status_code) {
77
-            case 200:
78
-                $result = json_decode($result->body, true);
79
-                break;
80
-            case 204:
81
-                $result = 'Success';
82
-                http_response_code(200);
83
-                break;
84
-            case 400:
85
-                $result = json_decode($result->body, true);
86
-                error_log('Error 400 - ' . print_r($result, true));
87
-                break;
88
-            case 401:
89
-                $result = json_decode($result->body, true);
76
+		switch ($result->status_code) {
77
+			case 200:
78
+				$result = json_decode($result->body, true);
79
+				break;
80
+			case 204:
81
+				$result = 'Success';
82
+				http_response_code(200);
83
+				break;
84
+			case 400:
85
+				$result = json_decode($result->body, true);
86
+				error_log('Error 400 - ' . print_r($result, true));
87
+				break;
88
+			case 401:
89
+				$result = json_decode($result->body, true);
90 90
 
91
-                if(array_key_exists('error', $result) && $result['error'] == 'length')
92
-                {
91
+				if(array_key_exists('error', $result) && $result['error'] == 'length')
92
+				{
93 93
 
94
-                }
95
-                else
96
-                {
97
-                    error_log('Error 401 - ' . print_r($result, true));
98
-                }
99
-                break;
100
-            case 404:
101
-                error_log('Error 404 - ' . print_r($result, true));
102
-                $result = json_decode($result->body, true);
103
-                break;
94
+				}
95
+				else
96
+				{
97
+					error_log('Error 401 - ' . print_r($result, true));
98
+				}
99
+				break;
100
+			case 404:
101
+				error_log('Error 404 - ' . print_r($result, true));
102
+				$result = json_decode($result->body, true);
103
+				break;
104 104
 			case 477:
105
-                $result = json_decode($result->body, true);
106
-                error_log('Error 477 - ' . print_r($result, true));
107
-                break;
108
-            case 429:
109
-                error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true));
110
-            	exit("Error 429: Too Many Requests");
111
-            	break;
112
-            case 403:
113
-                error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true));
114
-                $result = json_decode($result->body, true);
115
-                break;
116
-            case 502:
117
-                error_log('Error 502 - ' . print_r($result, true));
118
-                $result = json_decode($result->body, true);
119
-                header('location:'.$_SERVER['PHP_SELF']);
120
-                break;
121
-            case 503:
122
-                error_log('Error 503 - ' . print_r($result, true));
123
-                $result = json_decode($result->body, true);
105
+				$result = json_decode($result->body, true);
106
+				error_log('Error 477 - ' . print_r($result, true));
107
+				break;
108
+			case 429:
109
+				error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true));
110
+				exit("Error 429: Too Many Requests");
111
+				break;
112
+			case 403:
113
+				error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true));
114
+				$result = json_decode($result->body, true);
115
+				break;
116
+			case 502:
117
+				error_log('Error 502 - ' . print_r($result, true));
118
+				$result = json_decode($result->body, true);
119
+				header('location:'.$_SERVER['PHP_SELF']);
120
+				break;
121
+			case 503:
122
+				error_log('Error 503 - ' . print_r($result, true));
123
+				$result = json_decode($result->body, true);
124 124
 
125
-                if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
126
-                {
127
-                    header('location:'.$_SERVER['PHP_SELF']); 
128
-                }
129
-                break;
130
-            default:
131
-                error_log('Error '.$result->status_code.' - unknown error');
132
-                $result = json_decode($result->body, true);
133
-        }
125
+				if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
126
+				{
127
+					header('location:'.$_SERVER['PHP_SELF']); 
128
+				}
129
+				break;
130
+			default:
131
+				error_log('Error '.$result->status_code.' - unknown error');
132
+				$result = json_decode($result->body, true);
133
+		}
134 134
 
135
-        //important for account refresh
136
-        if($device_uid != '')
137
-        {
135
+		//important for account refresh
136
+		if($device_uid != '')
137
+		{
138 138
 			$result[0] = $result;
139 139
 			$result[1] = $device_uid;
140
-        }
140
+		}
141 141
 
142 142
         
143
-        /*
143
+		/*
144 144
         var_dump($result);
145 145
         */
146 146
         
147
-        return $result;
148
-    }
149
-    abstract function getPayload();
150
-    /**
151
-     * Gets Sign headers
152
-     * @return array headers
153
-     */
154
-    private function getSignHeaders()
155
-    {
147
+		return $result;
148
+	}
149
+	abstract function getPayload();
150
+	/**
151
+	 * Gets Sign headers
152
+	 * @return array headers
153
+	 */
154
+	private function getSignHeaders()
155
+	{
156 156
 			if($this->getAccessToken() == null) {
157 157
 				$payload_accessToken = "";
158 158
 			}
@@ -161,54 +161,54 @@  discard block
 block discarded – undo
161 161
 			}
162 162
 			
163 163
 			
164
-        $headers = array(
165
-            "Connection" => "keep-alive",
166
-            "Accept-Encoding" => "gzip",
167
-            "Content-Type" => "application/json; charset=UTF-8",
168
-            "User-Agent" => self::USERAGENT
169
-        );
170
-        $timestamp = new DateTime();
171
-        $timestamp = $timestamp->format(DateTime::ATOM);
172
-        $timestamp = substr($timestamp, 0, -6);
173
-        $timestamp .= "Z";
174
-        $urlParts = parse_url($this->getFullUrl());
175
-        $url2 = "";
176
-        $req = [$this->getMethod(),
177
-            $urlParts['host'],
178
-            "443",
179
-            $urlParts['path'],
180
-            $payload_accessToken,
181
-            $timestamp,
182
-            $url2,
183
-            $this->payLoad];
184
-        $reqString = implode("%", $req);
185
-        $secret = self::SECRET;
186
-        $signature = hash_hmac('sha1', $reqString, $secret);
187
-        $signature = strtoupper($signature);
188
-        $headers['X-Authorization'] = 'HMAC ' . $signature;
189
-        $headers['X-Client-Type'] = self::CLIENT_TYPE;
190
-        $headers['X-Timestamp'] = $timestamp;
191
-        $headers['X-Api-Version'] = '0.2';
192
-        return $headers;
193
-    }
194
-    private function getFullUrl()
195
-    {
196
-        return self::APIURL . $this->getApiEndPoint();
197
-    }
198
-    abstract function getApiEndPoint();
199
-    abstract function getMethod();
200
-    /**
201
-     * @return string
202
-     */
203
-    private function getAccessToken()
204
-    {
205
-        return $this->accessToken;
206
-    }
207
-    /**
208
-     * @param string $accessToken
209
-     */
210
-    public function setAccessToken($accessToken)
211
-    {
212
-        $this->accessToken = $accessToken;
213
-    }
164
+		$headers = array(
165
+			"Connection" => "keep-alive",
166
+			"Accept-Encoding" => "gzip",
167
+			"Content-Type" => "application/json; charset=UTF-8",
168
+			"User-Agent" => self::USERAGENT
169
+		);
170
+		$timestamp = new DateTime();
171
+		$timestamp = $timestamp->format(DateTime::ATOM);
172
+		$timestamp = substr($timestamp, 0, -6);
173
+		$timestamp .= "Z";
174
+		$urlParts = parse_url($this->getFullUrl());
175
+		$url2 = "";
176
+		$req = [$this->getMethod(),
177
+			$urlParts['host'],
178
+			"443",
179
+			$urlParts['path'],
180
+			$payload_accessToken,
181
+			$timestamp,
182
+			$url2,
183
+			$this->payLoad];
184
+		$reqString = implode("%", $req);
185
+		$secret = self::SECRET;
186
+		$signature = hash_hmac('sha1', $reqString, $secret);
187
+		$signature = strtoupper($signature);
188
+		$headers['X-Authorization'] = 'HMAC ' . $signature;
189
+		$headers['X-Client-Type'] = self::CLIENT_TYPE;
190
+		$headers['X-Timestamp'] = $timestamp;
191
+		$headers['X-Api-Version'] = '0.2';
192
+		return $headers;
193
+	}
194
+	private function getFullUrl()
195
+	{
196
+		return self::APIURL . $this->getApiEndPoint();
197
+	}
198
+	abstract function getApiEndPoint();
199
+	abstract function getMethod();
200
+	/**
201
+	 * @return string
202
+	 */
203
+	private function getAccessToken()
204
+	{
205
+		return $this->accessToken;
206
+	}
207
+	/**
208
+	 * @param string $accessToken
209
+	 */
210
+	public function setAccessToken($accessToken)
211
+	{
212
+		$this->accessToken = $accessToken;
213
+	}
214 214
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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 = 'hFvMqLauMtnodakokftuKETbIsVLxpqfjAXiRoih';
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
20 20
 		        
21 21
 		$this->payLoad = $this->getPayload();
22 22
 		$device_uid = '';
23
-		if(isset($this->payLoad['device_uid'])) {
23
+		if(isset($this->payLoad['device_uid']))
24
+		{
24 25
 			$device_uid = $this->payLoad['device_uid'];
25 26
 		}
26 27
 				
@@ -29,7 +30,8 @@  discard block
 block discarded – undo
29 30
         $header = $this->getSignHeaders();
30 31
         $url = $this->getFullUrl();
31 32
 
32
-        if ($this->getAccessToken()) {
33
+        if ($this->getAccessToken())
34
+        {
33 35
             $header['Authorization'] = "Bearer " . $this->getAccessToken();
34 36
         }
35 37
         //Comment out to debug the Request:
@@ -52,7 +54,8 @@  discard block
 block discarded – undo
52 54
             'proxy' => '186.103.169.165:8080',
53 55
         );*/
54 56
 
55
-        switch ($this->getMethod()) {
57
+        switch ($this->getMethod())
58
+        {
56 59
             case 'POST':
57 60
                 $result = Requests::post($url, $header, $this->payLoad);
58 61
                 break;
@@ -73,7 +76,8 @@  discard block
 block discarded – undo
73 76
 
74 77
         http_response_code($result->status_code);
75 78
 
76
-        switch ($result->status_code) {
79
+        switch ($result->status_code)
80
+        {
77 81
             case 200:
78 82
                 $result = json_decode($result->body, true);
79 83
                 break;
@@ -153,10 +157,12 @@  discard block
 block discarded – undo
153 157
      */
154 158
     private function getSignHeaders()
155 159
     {
156
-			if($this->getAccessToken() == null) {
160
+			if($this->getAccessToken() == null)
161
+			{
157 162
 				$payload_accessToken = "";
158 163
 			}
159
-			else {
164
+			else
165
+			{
160 166
 				$payload_accessToken = $this->getAccessToken();
161 167
 			}
162 168
 			
Please login to merge, or discard this patch.
Upper-Lower-Casing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     const USERAGENT = 'Jodel/4.41.0 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9 9
     const CLIENT_TYPE = 'android_4.41.0';
10 10
     
11
-    private $accessToken = null;
11
+    private $accessToken = NULL;
12 12
     private $payLoad;
13 13
     public $expects = '';
14 14
     public $version = 'v2';
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
 
76 76
         switch ($result->status_code) {
77 77
             case 200:
78
-                $result = json_decode($result->body, true);
78
+                $result = json_decode($result->body, TRUE);
79 79
                 break;
80 80
             case 204:
81 81
                 $result = 'Success';
82 82
                 http_response_code(200);
83 83
                 break;
84 84
             case 400:
85
-                $result = json_decode($result->body, true);
86
-                error_log('Error 400 - ' . print_r($result, true));
85
+                $result = json_decode($result->body, TRUE);
86
+                error_log('Error 400 - ' . print_r($result, TRUE));
87 87
                 break;
88 88
             case 401:
89
-                $result = json_decode($result->body, true);
89
+                $result = json_decode($result->body, TRUE);
90 90
 
91 91
                 if(array_key_exists('error', $result) && $result['error'] == 'length')
92 92
                 {
@@ -94,33 +94,33 @@  discard block
 block discarded – undo
94 94
                 }
95 95
                 else
96 96
                 {
97
-                    error_log('Error 401 - ' . print_r($result, true));
97
+                    error_log('Error 401 - ' . print_r($result, TRUE));
98 98
                 }
99 99
                 break;
100 100
             case 404:
101
-                error_log('Error 404 - ' . print_r($result, true));
102
-                $result = json_decode($result->body, true);
101
+                error_log('Error 404 - ' . print_r($result, TRUE));
102
+                $result = json_decode($result->body, TRUE);
103 103
                 break;
104 104
 			case 477:
105
-                $result = json_decode($result->body, true);
106
-                error_log('Error 477 - ' . print_r($result, true));
105
+                $result = json_decode($result->body, TRUE);
106
+                error_log('Error 477 - ' . print_r($result, TRUE));
107 107
                 break;
108 108
             case 429:
109
-                error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true));
109
+                error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, TRUE), TRUE));
110 110
             	exit("Error 429: Too Many Requests");
111 111
             	break;
112 112
             case 403:
113
-                error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true));
114
-                $result = json_decode($result->body, true);
113
+                error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, TRUE), TRUE));
114
+                $result = json_decode($result->body, TRUE);
115 115
                 break;
116 116
             case 502:
117
-                error_log('Error 502 - ' . print_r($result, true));
118
-                $result = json_decode($result->body, true);
117
+                error_log('Error 502 - ' . print_r($result, TRUE));
118
+                $result = json_decode($result->body, TRUE);
119 119
                 header('location:'.$_SERVER['PHP_SELF']);
120 120
                 break;
121 121
             case 503:
122
-                error_log('Error 503 - ' . print_r($result, true));
123
-                $result = json_decode($result->body, true);
122
+                error_log('Error 503 - ' . print_r($result, TRUE));
123
+                $result = json_decode($result->body, TRUE);
124 124
 
125 125
                 if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
126 126
                 {
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
                 break;
130 130
             default:
131 131
                 error_log('Error '.$result->status_code.' - unknown error');
132
-                $result = json_decode($result->body, true);
132
+                $result = json_decode($result->body, TRUE);
133 133
         }
134 134
 
135 135
         //important for account refresh
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      */
154 154
     private function getSignHeaders()
155 155
     {
156
-			if($this->getAccessToken() == null) {
156
+			if($this->getAccessToken() == NULL) {
157 157
 				$payload_accessToken = "";
158 158
 			}
159 159
 			else {
Please login to merge, or discard this patch.
php/View.php 2 patches
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -2,112 +2,112 @@  discard block
 block discarded – undo
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;
12
-    public $rights;
9
+	public $postId;
10
+	public $isDetailedView;
11
+	public $baseUrl;
12
+	public $rights;
13 13
 
14 14
 	public $lastPostId = '';
15 15
 
16
-    function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '')
17
-    {
18
-        $this->baseUrl = $baseUrl;
19
-        $this->country = $country;
20
-        $this->city = $city;
21
-        $this->hashtag = urldecode($hashtag);
22
-        $this->view = $view;
23
-        $this->postId = $postId;
16
+	function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '')
17
+	{
18
+		$this->baseUrl = $baseUrl;
19
+		$this->country = $country;
20
+		$this->city = $city;
21
+		$this->hashtag = urldecode($hashtag);
22
+		$this->view = $view;
23
+		$this->postId = $postId;
24 24
 
25
-        if(isUserAdmin())
26
-        {
27
-            $this->rights = 'admin';
28
-        }
29
-        else if(isUserVoter())
30
-        {
31
-            $this->rights = 'voter';
32
-        }
33
-        else
34
-        {
35
-            $this->rights = 'user';
36
-        }
25
+		if(isUserAdmin())
26
+		{
27
+			$this->rights = 'admin';
28
+		}
29
+		else if(isUserVoter())
30
+		{
31
+			$this->rights = 'voter';
32
+		}
33
+		else
34
+		{
35
+			$this->rights = 'user';
36
+		}
37 37
 
38
-        if($postId == '')
39
-        {
40
-            $this->isDetailedView = FALSE;
41
-        }
42
-        else
43
-        {
44
-            $this->isDetailedView = TRUE;
45
-        }
46
-    }
38
+		if($postId == '')
39
+		{
40
+			$this->isDetailedView = FALSE;
41
+		}
42
+		else
43
+		{
44
+			$this->isDetailedView = TRUE;
45
+		}
46
+	}
47 47
 	/**
48 48
 	 * Compute HTML Code
49 49
 	 */
50 50
  	function jodelToHtml($post)
51
-    {   //ToDO
52
-        //Replace # with link
53
-        //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
51
+	{   //ToDO
52
+		//Replace # with link
53
+		//preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
54 54
 
55
-        //Time to time difference
56
-        $now = new DateTime();
57
-        $d = new DateTime($post['created_at']);
58
-        $timediff = $now->diff($d);
55
+		//Time to time difference
56
+		$now = new DateTime();
57
+		$d = new DateTime($post['created_at']);
58
+		$timediff = $now->diff($d);
59 59
 
60
-        $timediff_inSeconds = (string)$timediff->format('%s');
61
-        $timediff_inMinutes = (string)$timediff->format('%i');
62
-        $timediff_inHours = (string)$timediff->format('%h');
63
-        $timediff_inDays = (string)$timediff->format('%d');
64
-        $timediff_inMonth = (string)$timediff->format('%m');
60
+		$timediff_inSeconds = (string)$timediff->format('%s');
61
+		$timediff_inMinutes = (string)$timediff->format('%i');
62
+		$timediff_inHours = (string)$timediff->format('%h');
63
+		$timediff_inDays = (string)$timediff->format('%d');
64
+		$timediff_inMonth = (string)$timediff->format('%m');
65 65
 
66
-        if($timediff_inMonth!=0)
67
-        {
68
-                $timediff = $timediff_inMonth . "m";
69
-        }
70
-        else
71
-        {
72
-            if($timediff_inDays!=0)
73
-            {
74
-                $timediff = $timediff_inDays . "d";
75
-            }
76
-            else
77
-            {
78
-                if($timediff_inHours!=0)
79
-                {
80
-                    $timediff = $timediff_inHours . "h";
81
-                }
82
-                else
83
-                {
84
-                    if($timediff_inMinutes!=0)
85
-                    {
86
-                        $timediff = $timediff_inMinutes . "m";
87
-                    }
88
-                    else
89
-                    {
90
-                        $timediff = $timediff_inSeconds . "s";
91
-                    }
92
-                }
93
-            }
94
-        }
66
+		if($timediff_inMonth!=0)
67
+		{
68
+				$timediff = $timediff_inMonth . "m";
69
+		}
70
+		else
71
+		{
72
+			if($timediff_inDays!=0)
73
+			{
74
+				$timediff = $timediff_inDays . "d";
75
+			}
76
+			else
77
+			{
78
+				if($timediff_inHours!=0)
79
+				{
80
+					$timediff = $timediff_inHours . "h";
81
+				}
82
+				else
83
+				{
84
+					if($timediff_inMinutes!=0)
85
+					{
86
+						$timediff = $timediff_inMinutes . "m";
87
+					}
88
+					else
89
+					{
90
+						$timediff = $timediff_inSeconds . "s";
91
+					}
92
+				}
93
+			}
94
+		}
95 95
 
96 96
 
97
-        ?>
97
+		?>
98 98
         <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;">
99 99
             <content>
100 100
                 <?php 
101
-                if(isset($post['image_url']))
102
-                {
103
-                    $regexRest = '/[^\w$ .!?-]+/u';
101
+				if(isset($post['image_url']))
102
+				{
103
+					$regexRest = '/[^\w$ .!?-]+/u';
104 104
 
105
-                    echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
106
-                }
107
-                else {
108
-                    echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
109
-                }
110
-                ?>
105
+					echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
106
+				}
107
+				else {
108
+					echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
109
+				}
110
+				?>
111 111
             </content>
112 112
             <aside>                    
113 113
                 <button onclick="vote('<?php echo $post['post_id'];?>', 'up', this)">
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
                                 <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>">
137 137
                                     <i class="fa fa-commenting-o"></i>
138 138
                                     <?php if(array_key_exists("child_count", $post))
139
-                                    {
140
-                                        echo $post["child_count"];
141
-                                    } else echo "0";
142
-                                    ?>
139
+									{
140
+										echo $post["child_count"];
141
+									} else echo "0";
142
+									?>
143 143
                                 </a>
144 144
                             </span>
145 145
                             
@@ -159,18 +159,18 @@  discard block
 block discarded – undo
159 159
 						?>
160 160
                         <span class="distance">
161 161
                             <?php
162
-                                if($this->isDetailedView)
163
-                                {
164
-                                    if(isset($post['user_handle']) && $post['user_handle'] == 'OJ')
165
-                                    {
166
-                                        ?>
162
+								if($this->isDetailedView)
163
+								{
164
+									if(isset($post['user_handle']) && $post['user_handle'] == 'OJ')
165
+									{
166
+										?>
167 167
                                         <span data-tooltip="Author">
168 168
                                             <i class="fa fa-user-o"></i> OJ |
169 169
                                         </span>
170 170
                                         <?php 
171
-                                    }
172
-                                }
173
-                                ?>
171
+									}
172
+								}
173
+								?>
174 174
 
175 175
                             <span class="tip" data-tooltip="Distance">
176 176
                                 <i class="fa fa-map-marker"></i>
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             </footer>
184 184
         </article>
185 185
     <?php
186
-    }
186
+	}
187 187
 
188 188
 
189 189
 	/**
@@ -220,147 +220,147 @@  discard block
 block discarded – undo
220 220
 		return $description;
221 221
 	}
222 222
 
223
-    function toUrl($msg = '')
224
-    {
225
-        $url = $this->baseUrl . 'index.php?country=DE' .
226
-                            '&city=' . urlencode($this->city) .
227
-                            '&hashtag=' . urlencode($this->hashtag) . 
228
-                            '&view=' . $this->view;
229
-        if($this->postId != '')
230
-        {
231
-            $url .= '&postId=' . $this->postId . 
232
-                    '&getPostDetails=TRUE';
233
-        }
223
+	function toUrl($msg = '')
224
+	{
225
+		$url = $this->baseUrl . 'index.php?country=DE' .
226
+							'&city=' . urlencode($this->city) .
227
+							'&hashtag=' . urlencode($this->hashtag) . 
228
+							'&view=' . $this->view;
229
+		if($this->postId != '')
230
+		{
231
+			$url .= '&postId=' . $this->postId . 
232
+					'&getPostDetails=TRUE';
233
+		}
234 234
 
235
-        if($msg != '')
236
-        {
237
-            $url .= '&msg=' . urlencode($msg);
238
-        }
235
+		if($msg != '')
236
+		{
237
+			$url .= '&msg=' . urlencode($msg);
238
+		}
239 239
 
240
-        return $url;
241
-    }
240
+		return $url;
241
+	}
242 242
 
243
-    function changePostId($postId)
244
-    {
245
-        $tempView = clone $this;
246
-        $tempView->postId = $postId;
247
-        $tempView->isDetailedView = TRUE;
248
-        return $tempView;
249
-    }
243
+	function changePostId($postId)
244
+	{
245
+		$tempView = clone $this;
246
+		$tempView->postId = $postId;
247
+		$tempView->isDetailedView = TRUE;
248
+		return $tempView;
249
+	}
250 250
 
251
-    function back()
252
-    {
253
-        $tempView = clone $this;
254
-        $tempView->postId = '';
255
-        return $tempView;
256
-    }
251
+	function back()
252
+	{
253
+		$tempView = clone $this;
254
+		$tempView->postId = '';
255
+		return $tempView;
256
+	}
257 257
 
258
-    function changeView($view)
259
-    {
260
-        $tempView = clone $this;
261
-        $tempView->view = $view;
262
-        return $tempView;
263
-    }
258
+	function changeView($view)
259
+	{
260
+		$tempView = clone $this;
261
+		$tempView->view = $view;
262
+		return $tempView;
263
+	}
264 264
 
265 265
 	function getPosts($jodelAccount)
266 266
 	{
267
-        if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL)
268
-        {
269
-            $accountCreator = new GetChannel();
270
-            $accountCreator->view = $this->view;
271
-            $accountCreator->setAccessToken($jodelAccount->accessToken);
272
-            $accountCreator->channel = $this->hashtag;
273
-            $accountCreator->lastPostId = $this->lastPostId;
274
-            $data = $accountCreator->execute();
275
-        }
276
-        else
277
-        {
278
-            if($this->lastPostId == '' && $this->view == 'combo')
279
-            {
280
-                $url = "/v3/posts/location/combo";
281
-            }
282
-            else
283
-            {
284
-                if($this->view == 'discussed')
285
-                {
286
-                    $url = "/v2/posts/location/discussed/";
287
-                }
288
-                else
289
-                {
290
-                    if($this->view == 'popular')
291
-                    {
292
-                        $url = "/v2/posts/location/popular/";
293
-                    }
294
-                    else
295
-                    {
296
-                        $url = "/v2/posts/location/";
297
-                    }
298
-                }
299
-            }
267
+		if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL)
268
+		{
269
+			$accountCreator = new GetChannel();
270
+			$accountCreator->view = $this->view;
271
+			$accountCreator->setAccessToken($jodelAccount->accessToken);
272
+			$accountCreator->channel = $this->hashtag;
273
+			$accountCreator->lastPostId = $this->lastPostId;
274
+			$data = $accountCreator->execute();
275
+		}
276
+		else
277
+		{
278
+			if($this->lastPostId == '' && $this->view == 'combo')
279
+			{
280
+				$url = "/v3/posts/location/combo";
281
+			}
282
+			else
283
+			{
284
+				if($this->view == 'discussed')
285
+				{
286
+					$url = "/v2/posts/location/discussed/";
287
+				}
288
+				else
289
+				{
290
+					if($this->view == 'popular')
291
+					{
292
+						$url = "/v2/posts/location/popular/";
293
+					}
294
+					else
295
+					{
296
+						$url = "/v2/posts/location/";
297
+					}
298
+				}
299
+			}
300 300
 
301
-            $accountCreator = new GetPosts();
302
-            $accountCreator->setLastPostId($this->lastPostId);
303
-            $accountCreator->setAccessToken($jodelAccount->accessToken);
304
-            $accountCreator->setUrl($url);
305
-            $accountCreator->version = 'v3';
301
+			$accountCreator = new GetPosts();
302
+			$accountCreator->setLastPostId($this->lastPostId);
303
+			$accountCreator->setAccessToken($jodelAccount->accessToken);
304
+			$accountCreator->setUrl($url);
305
+			$accountCreator->version = 'v3';
306 306
 
307
-            $config = parse_ini_file('config/config.ini.php');
308
-            $location = new Location();
309
-            $location->setLat($config['default_lat']);
310
-            $location->setLng($config['default_lng']);
311
-            $location->setCityName($config['default_location']);
312
-            $accountCreator->location = $location;
313
-            $data = $accountCreator->execute();
314
-        }
315
-    	if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent']))
316
-        {
317
-            return $data['recent'];
318
-        }
319
-        else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts']))
320
-        {
321
-            return $data['posts'];
322
-        }
323
-        else
324
-        {
325
-            if($this->lastPostId == '')
326
-            {
327
-                error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true));
328
-                //error_log(print_r($data, true));
307
+			$config = parse_ini_file('config/config.ini.php');
308
+			$location = new Location();
309
+			$location->setLat($config['default_lat']);
310
+			$location->setLng($config['default_lng']);
311
+			$location->setCityName($config['default_location']);
312
+			$accountCreator->location = $location;
313
+			$data = $accountCreator->execute();
314
+		}
315
+		if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent']))
316
+		{
317
+			return $data['recent'];
318
+		}
319
+		else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts']))
320
+		{
321
+			return $data['posts'];
322
+		}
323
+		else
324
+		{
325
+			if($this->lastPostId == '')
326
+			{
327
+				error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true));
328
+				//error_log(print_r($data, true));
329 329
 
330
-                $notFound[0] = array(
331
-                    "post_id" => "0",
332
-                    "discovered_by" => 0,
333
-                    "message" => "No more Posts found",
334
-                    "created_at" => "2017-02-11T16:44:50.385Z",
335
-                    "updated_at" => "2017-02-11T16:44:50.385Z",
336
-                    "pin_count" => 0,
337
-                    "color" => "5682a3",
338
-                    "got_thanks" => FALSE,
339
-                    "post_own" => "friend",
340
-                    "discovered" => 0,
341
-                    "distance" => 9,
342
-                    "vote_count" => 0,
343
-                    "location" =>
344
-                    array("name" => "Berlin",
345
-                      "loc_coordinates" =>
346
-                      array(
347
-                        "lat" => 0,
348
-                        "lng" => 0
349
-                      ),
350
-                      "loc_accuracy" => 0,
351
-                      "country" => "",
352
-                      "city" => "",
353
-                    ),
354
-                    "tags" =>
355
-                    array(),
356
-                    "user_handle" => "0"
357
-                );
358
-                return $notFound;
359
-            }
360
-            else
361
-            {
362
-                return FALSE;
363
-            }
364
-        }
330
+				$notFound[0] = array(
331
+					"post_id" => "0",
332
+					"discovered_by" => 0,
333
+					"message" => "No more Posts found",
334
+					"created_at" => "2017-02-11T16:44:50.385Z",
335
+					"updated_at" => "2017-02-11T16:44:50.385Z",
336
+					"pin_count" => 0,
337
+					"color" => "5682a3",
338
+					"got_thanks" => FALSE,
339
+					"post_own" => "friend",
340
+					"discovered" => 0,
341
+					"distance" => 9,
342
+					"vote_count" => 0,
343
+					"location" =>
344
+					array("name" => "Berlin",
345
+					  "loc_coordinates" =>
346
+					  array(
347
+						"lat" => 0,
348
+						"lng" => 0
349
+					  ),
350
+					  "loc_accuracy" => 0,
351
+					  "country" => "",
352
+					  "city" => "",
353
+					),
354
+					"tags" =>
355
+					array(),
356
+					"user_handle" => "0"
357
+				);
358
+				return $notFound;
359
+			}
360
+			else
361
+			{
362
+				return FALSE;
363
+			}
364
+		}
365 365
 	}
366 366
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -63,25 +63,25 @@  discard block
 block discarded – undo
63 63
         $timediff_inDays = (string)$timediff->format('%d');
64 64
         $timediff_inMonth = (string)$timediff->format('%m');
65 65
 
66
-        if($timediff_inMonth!=0)
66
+        if($timediff_inMonth != 0)
67 67
         {
68 68
                 $timediff = $timediff_inMonth . "m";
69 69
         }
70 70
         else
71 71
         {
72
-            if($timediff_inDays!=0)
72
+            if($timediff_inDays != 0)
73 73
             {
74 74
                 $timediff = $timediff_inDays . "d";
75 75
             }
76 76
             else
77 77
             {
78
-                if($timediff_inHours!=0)
78
+                if($timediff_inHours != 0)
79 79
                 {
80 80
                     $timediff = $timediff_inHours . "h";
81 81
                 }
82 82
                 else
83 83
                 {
84
-                    if($timediff_inMinutes!=0)
84
+                    if($timediff_inMinutes != 0)
85 85
                     {
86 86
                         $timediff = $timediff_inMinutes . "m";
87 87
                     }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
 
97 97
         ?>
98
-        <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;">
98
+        <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color']; ?>;">
99 99
             <content>
100 100
                 <?php 
101 101
                 if(isset($post['image_url']))
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
                 ?>
111 111
             </content>
112 112
             <aside>                    
113
-                <button onclick="vote('<?php echo $post['post_id'];?>', 'up', this)">
113
+                <button onclick="vote('<?php echo $post['post_id']; ?>', 'up', this)">
114 114
                     <i class="fa fa-angle-up fa-3x"></i>
115 115
                 </button>    
116
-                <br><span><?php echo $post["vote_count"];?></span><br>
116
+                <br><span><?php echo $post["vote_count"]; ?></span><br>
117 117
 
118
-                <button onclick="vote('<?php echo $post['post_id'];?>', 'down', this)">
118
+                <button onclick="vote('<?php echo $post['post_id']; ?>', 'down', this)">
119 119
                     <i class="fa fa-angle-down fa-3x"></i>
120 120
                 </button>
121 121
             </aside>
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
                         <span class="time">
127 127
                             <span class="tip" data-tooltip="Time">
128 128
                                 <i class="fa fa-clock-o"></i>
129
-                                <?php echo $timediff;?>
130
-                                <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span>
129
+                                <?php echo $timediff; ?>
130
+                                <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span>
131 131
                             </span> 
132 132
                         </span>
133 133
 						<?php if(!$this->isDetailedView) {?>
134 134
                         <span class="comments">
135 135
                             <span data-tooltip="Comments">
136
-                                <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>">
136
+                                <a href="<?php echo $this->changePostId($post['post_id'])->toUrl(); ?>">
137 137
                                     <i class="fa fa-commenting-o"></i>
138 138
                                     <?php if(array_key_exists("child_count", $post))
139 139
                                     {
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 
175 175
                             <span class="tip" data-tooltip="Distance">
176 176
                                 <i class="fa fa-map-marker"></i>
177
-                                <?php echo $post['distance'];?> km
178
-                                <span class="tiptext"><?php echo $post['location']['name'];?></span>
177
+                                <?php echo $post['distance']; ?> km
178
+                                <span class="tiptext"><?php echo $post['location']['name']; ?></span>
179 179
                             </span>
180 180
                         </span>
181 181
                     
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 		if($post != '' && array_key_exists('message', $post) && $post['message'] != '' && $this->isDetailedView)
216 216
 		{
217
-			$description = 'On JodelBlue in ' . htmlspecialchars($this->city) .  ' with ' . htmlspecialchars($post['vote_count']) . ' Upvotes: ' . substr(htmlspecialchars($post['message']), 0, 130);
217
+			$description = 'On JodelBlue in ' . htmlspecialchars($this->city) . ' with ' . htmlspecialchars($post['vote_count']) . ' Upvotes: ' . substr(htmlspecialchars($post['message']), 0, 130);
218 218
 		}
219 219
 
220 220
 		return $description;
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         {
317 317
             return $data['recent'];
318 318
         }
319
-        else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts']))
319
+        else if(array_key_exists('posts', $data) && array_key_exists(0, $data['posts']))
320 320
         {
321 321
             return $data['posts'];
322 322
         }
Please login to merge, or discard this patch.