Completed
Push — master ( 925f8b...411610 )
by mains
03:48
created
php/Requests/AbstractRequest.php 2 patches
Indentation   +166 added lines, -166 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,124 +45,124 @@  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:
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 89
 
90
-                if($result == "Unauthorized")
91
-                {
92
-                    error_log("Error 401: Unauthorized");
93
-                }
94
-                else
95
-                {
96
-                    $result = json_decode($result->body, true);
90
+				if($result == "Unauthorized")
91
+				{
92
+					error_log("Error 401: Unauthorized");
93
+				}
94
+				else
95
+				{
96
+					$result = json_decode($result->body, true);
97 97
 
98
-                    if(is_array($result) && $result['error'] == 'length')
99
-                    {
98
+					if(is_array($result) && $result['error'] == 'length')
99
+					{
100 100
 
101
-                    }
102
-                    else
103
-                    {
104
-                        error_log('Error 401 - ' . print_r($result, true));
105
-                    }
106
-                }
101
+					}
102
+					else
103
+					{
104
+						error_log('Error 401 - ' . print_r($result, true));
105
+					}
106
+				}
107 107
 
108 108
 
109
-                break;
110
-            case 404:
111
-                error_log('Error 404 - ' . print_r($result, true));
112
-                $result = json_decode($result->body, true);
113
-                break;
109
+				break;
110
+			case 404:
111
+				error_log('Error 404 - ' . print_r($result, true));
112
+				$result = json_decode($result->body, true);
113
+				break;
114 114
 			case 477:
115
-                $result = json_decode($result->body, true);
116
-                error_log('Error 477 - ' . print_r($result, true));
117
-                break;
118
-            case 429:
119
-                error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true));
120
-            	exit("Error 429: Too Many Requests");
121
-            	break;
122
-            case 403:
123
-                error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true));
124
-                $result = json_decode($result->body, true);
125
-                break;
126
-            case 502:
127
-                error_log('Error 502 - ' . print_r($result, true));
128
-                $result = json_decode($result->body, true);
129
-                header('location:'.$_SERVER['PHP_SELF']);
130
-                break;
131
-            case 503:
132
-                error_log('Error 503 - ' . print_r($result, true));
133
-                $result = json_decode($result->body, true);
115
+				$result = json_decode($result->body, true);
116
+				error_log('Error 477 - ' . print_r($result, true));
117
+				break;
118
+			case 429:
119
+				error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true));
120
+				exit("Error 429: Too Many Requests");
121
+				break;
122
+			case 403:
123
+				error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true));
124
+				$result = json_decode($result->body, true);
125
+				break;
126
+			case 502:
127
+				error_log('Error 502 - ' . print_r($result, true));
128
+				$result = json_decode($result->body, true);
129
+				header('location:'.$_SERVER['PHP_SELF']);
130
+				break;
131
+			case 503:
132
+				error_log('Error 503 - ' . print_r($result, true));
133
+				$result = json_decode($result->body, true);
134 134
 
135
-                if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
136
-                {
137
-                    header('location:'.$_SERVER['PHP_SELF']); 
138
-                }
139
-                break;
140
-            default:
141
-                error_log('Error '.$result->status_code.' - unknown error');
142
-                $result = json_decode($result->body, true);
143
-        }
135
+				if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
136
+				{
137
+					header('location:'.$_SERVER['PHP_SELF']); 
138
+				}
139
+				break;
140
+			default:
141
+				error_log('Error '.$result->status_code.' - unknown error');
142
+				$result = json_decode($result->body, true);
143
+		}
144 144
 
145
-        //important for account refresh
146
-        if($device_uid != '')
147
-        {
145
+		//important for account refresh
146
+		if($device_uid != '')
147
+		{
148 148
 			$result[0] = $result;
149 149
 			$result[1] = $device_uid;
150
-        }
150
+		}
151 151
 
152 152
         
153
-        /*
153
+		/*
154 154
         var_dump($result);
155 155
         */
156 156
         
157
-        return $result;
158
-    }
159
-    abstract function getPayload();
160
-    /**
161
-     * Gets Sign headers
162
-     * @return array headers
163
-     */
164
-    private function getSignHeaders()
165
-    {
157
+		return $result;
158
+	}
159
+	abstract function getPayload();
160
+	/**
161
+	 * Gets Sign headers
162
+	 * @return array headers
163
+	 */
164
+	private function getSignHeaders()
165
+	{
166 166
 			if($this->getAccessToken() == null) {
167 167
 				$payload_accessToken = "";
168 168
 			}
@@ -171,54 +171,54 @@  discard block
 block discarded – undo
171 171
 			}
172 172
 			
173 173
 			
174
-        $headers = array(
175
-            "Connection" => "keep-alive",
176
-            "Accept-Encoding" => "gzip",
177
-            "Content-Type" => "application/json; charset=UTF-8",
178
-            "User-Agent" => self::USERAGENT
179
-        );
180
-        $timestamp = new DateTime();
181
-        $timestamp = $timestamp->format(DateTime::ATOM);
182
-        $timestamp = substr($timestamp, 0, -6);
183
-        $timestamp .= "Z";
184
-        $urlParts = parse_url($this->getFullUrl());
185
-        $url2 = "";
186
-        $req = [$this->getMethod(),
187
-            $urlParts['host'],
188
-            "443",
189
-            $urlParts['path'],
190
-            $payload_accessToken,
191
-            $timestamp,
192
-            $url2,
193
-            $this->payLoad];
194
-        $reqString = implode("%", $req);
195
-        $secret = self::SECRET;
196
-        $signature = hash_hmac('sha1', $reqString, $secret);
197
-        $signature = strtoupper($signature);
198
-        $headers['X-Authorization'] = 'HMAC ' . $signature;
199
-        $headers['X-Client-Type'] = self::CLIENT_TYPE;
200
-        $headers['X-Timestamp'] = $timestamp;
201
-        $headers['X-Api-Version'] = '0.2';
202
-        return $headers;
203
-    }
204
-    private function getFullUrl()
205
-    {
206
-        return self::APIURL . $this->getApiEndPoint();
207
-    }
208
-    abstract function getApiEndPoint();
209
-    abstract function getMethod();
210
-    /**
211
-     * @return string
212
-     */
213
-    private function getAccessToken()
214
-    {
215
-        return $this->accessToken;
216
-    }
217
-    /**
218
-     * @param string $accessToken
219
-     */
220
-    public function setAccessToken($accessToken)
221
-    {
222
-        $this->accessToken = $accessToken;
223
-    }
174
+		$headers = array(
175
+			"Connection" => "keep-alive",
176
+			"Accept-Encoding" => "gzip",
177
+			"Content-Type" => "application/json; charset=UTF-8",
178
+			"User-Agent" => self::USERAGENT
179
+		);
180
+		$timestamp = new DateTime();
181
+		$timestamp = $timestamp->format(DateTime::ATOM);
182
+		$timestamp = substr($timestamp, 0, -6);
183
+		$timestamp .= "Z";
184
+		$urlParts = parse_url($this->getFullUrl());
185
+		$url2 = "";
186
+		$req = [$this->getMethod(),
187
+			$urlParts['host'],
188
+			"443",
189
+			$urlParts['path'],
190
+			$payload_accessToken,
191
+			$timestamp,
192
+			$url2,
193
+			$this->payLoad];
194
+		$reqString = implode("%", $req);
195
+		$secret = self::SECRET;
196
+		$signature = hash_hmac('sha1', $reqString, $secret);
197
+		$signature = strtoupper($signature);
198
+		$headers['X-Authorization'] = 'HMAC ' . $signature;
199
+		$headers['X-Client-Type'] = self::CLIENT_TYPE;
200
+		$headers['X-Timestamp'] = $timestamp;
201
+		$headers['X-Api-Version'] = '0.2';
202
+		return $headers;
203
+	}
204
+	private function getFullUrl()
205
+	{
206
+		return self::APIURL . $this->getApiEndPoint();
207
+	}
208
+	abstract function getApiEndPoint();
209
+	abstract function getMethod();
210
+	/**
211
+	 * @return string
212
+	 */
213
+	private function getAccessToken()
214
+	{
215
+		return $this->accessToken;
216
+	}
217
+	/**
218
+	 * @param string $accessToken
219
+	 */
220
+	public function setAccessToken($accessToken)
221
+	{
222
+		$this->accessToken = $accessToken;
223
+	}
224 224
 }
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,15 +75,15 @@  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 89
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                 }
94 94
                 else
95 95
                 {
96
-                    $result = json_decode($result->body, true);
96
+                    $result = json_decode($result->body, TRUE);
97 97
 
98 98
                     if(is_array($result) && $result['error'] == 'length')
99 99
                     {
@@ -101,36 +101,36 @@  discard block
 block discarded – undo
101 101
                     }
102 102
                     else
103 103
                     {
104
-                        error_log('Error 401 - ' . print_r($result, true));
104
+                        error_log('Error 401 - ' . print_r($result, TRUE));
105 105
                     }
106 106
                 }
107 107
 
108 108
 
109 109
                 break;
110 110
             case 404:
111
-                error_log('Error 404 - ' . print_r($result, true));
112
-                $result = json_decode($result->body, true);
111
+                error_log('Error 404 - ' . print_r($result, TRUE));
112
+                $result = json_decode($result->body, TRUE);
113 113
                 break;
114 114
 			case 477:
115
-                $result = json_decode($result->body, true);
116
-                error_log('Error 477 - ' . print_r($result, true));
115
+                $result = json_decode($result->body, TRUE);
116
+                error_log('Error 477 - ' . print_r($result, TRUE));
117 117
                 break;
118 118
             case 429:
119
-                error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true));
119
+                error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, TRUE), TRUE));
120 120
             	exit("Error 429: Too Many Requests");
121 121
             	break;
122 122
             case 403:
123
-                error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true));
124
-                $result = json_decode($result->body, true);
123
+                error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, TRUE), TRUE));
124
+                $result = json_decode($result->body, TRUE);
125 125
                 break;
126 126
             case 502:
127
-                error_log('Error 502 - ' . print_r($result, true));
128
-                $result = json_decode($result->body, true);
127
+                error_log('Error 502 - ' . print_r($result, TRUE));
128
+                $result = json_decode($result->body, TRUE);
129 129
                 header('location:'.$_SERVER['PHP_SELF']);
130 130
                 break;
131 131
             case 503:
132
-                error_log('Error 503 - ' . print_r($result, true));
133
-                $result = json_decode($result->body, true);
132
+                error_log('Error 503 - ' . print_r($result, TRUE));
133
+                $result = json_decode($result->body, TRUE);
134 134
 
135 135
                 if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
136 136
                 {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                 break;
140 140
             default:
141 141
                 error_log('Error '.$result->status_code.' - unknown error');
142
-                $result = json_decode($result->body, true);
142
+                $result = json_decode($result->body, TRUE);
143 143
         }
144 144
 
145 145
         //important for account refresh
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      */
164 164
     private function getSignHeaders()
165 165
     {
166
-			if($this->getAccessToken() == null) {
166
+			if($this->getAccessToken() == NULL) {
167 167
 				$payload_accessToken = "";
168 168
 			}
169 169
 			else {
Please login to merge, or discard this patch.
php/View.php 3 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(is_array($data) && array_key_exists('recent', $data) && array_key_exists(0, $data['recent']))
316
-        {
317
-            return $data['recent'];
318
-        }
319
-        else if(is_array($data) && 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(is_array($data) && array_key_exists('recent', $data) && array_key_exists(0, $data['recent']))
316
+		{
317
+			return $data['recent'];
318
+		}
319
+		else if(is_array($data) && 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(is_array($data) && array_key_exists('posts', $data)&& array_key_exists(0, $data['posts']))
319
+        else if(is_array($data) && 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.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@  discard block
 block discarded – undo
48 48
 	 * Compute HTML Code
49 49
 	 */
50 50
  	function jodelToHtml($post)
51
-    {   //ToDO
51
+ 	{
52
+//ToDO
52 53
         //Replace # with link
53 54
         //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
54 55
 
@@ -104,7 +105,8 @@  discard block
 block discarded – undo
104 105
 
105 106
                     echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
106 107
                 }
107
-                else {
108
+                else
109
+                {
108 110
                     echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
109 111
                 }
110 112
                 ?>
@@ -130,15 +132,20 @@  discard block
 block discarded – undo
130 132
                                 <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span>
131 133
                             </span> 
132 134
                         </span>
133
-						<?php if(!$this->isDetailedView) {?>
135
+						<?php if(!$this->isDetailedView)
136
+{
137
+?>
134 138
                         <span class="comments">
135 139
                             <span data-tooltip="Comments">
136 140
                                 <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>">
137 141
                                     <i class="fa fa-commenting-o"></i>
138 142
                                     <?php if(array_key_exists("child_count", $post))
139
-                                    {
143
+{
140 144
                                         echo $post["child_count"];
141
-                                    } else echo "0";
145
+                                    }
146
+                                    else {
147
+                                    	echo "0";
148
+                                    }
142 149
                                     ?>
143 150
                                 </a>
144 151
                             </span>
@@ -313,7 +320,7 @@  discard block
 block discarded – undo
313 320
             $data = $accountCreator->execute();
314 321
         }
315 322
     	if(is_array($data) && array_key_exists('recent', $data) && array_key_exists(0, $data['recent']))
316
-        {
323
+    	{
317 324
             return $data['recent'];
318 325
         }
319 326
         else if(is_array($data) && array_key_exists('posts', $data)&& array_key_exists(0, $data['posts']))
Please login to merge, or discard this patch.