Completed
Push — master ( ccb03a...769cd4 )
by mains
02:58
created
vote-ajax.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
 if(isset($_GET['postId']) && $_GET['vote'])
6 6
 {
7 7
 	header('Content-Type: application/json');
8
-    echo json_encode($jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']));
9
-    die();
8
+	echo json_encode($jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']));
9
+	die();
10 10
 }
11 11
 
12 12
 if(isset($_GET['solution']) && isset($_POST['deviceUid']))
Please login to merge, or discard this patch.
templates/footer.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 			  crossorigin="anonymous"></script>
6 6
 	    <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
7 7
 	    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
8
-	    <script src="<?php echo $baseUrl;?>js/jQueryEmoji.js"></script>
8
+	    <script src="<?php echo $baseUrl; ?>js/jQueryEmoji.js"></script>
9 9
 	    <script src="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.1.1/ekko-lightbox.min.js" integrity="sha256-1odJPEl+KoMUaA1T7QNMGSSU/r5LCKCRC6SL8P0r2gY=" crossorigin="anonymous"></script>
10 10
 
11 11
 		<script>
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			console.log(solution);
38 38
 			$.ajax({
39 39
 			  type: "POST",
40
-			  url: "<?php echo $baseUrl;?>vote-ajax.php?solution=" + solution + "&key="+key,
40
+			  url: "<?php echo $baseUrl; ?>vote-ajax.php?solution=" + solution + "&key="+key,
41 41
 			  data: {"deviceUid" : deviceUid},
42 42
 			  success: function(result){
43 43
 				  	var response = JSON.parse(result);
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 			{
62 62
 				window.history.back();
63 63
 			}
64
-		<?php if(isset($includeEmojiAndAjax)){ ?>
64
+		<?php if(isset($includeEmojiAndAjax)) { ?>
65 65
 
66 66
 			function vote(postId, vote, obj)
67 67
 			{
68 68
 				$.ajax({
69
-					url: '<?php echo $baseUrl;?>vote-ajax.php?postId=' + postId + '&vote=' + vote,
69
+					url: '<?php echo $baseUrl; ?>vote-ajax.php?postId=' + postId + '&vote=' + vote,
70 70
 					dataType: 'json',
71 71
 					async: true,
72 72
 					success: function(json)
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 			{
94 94
 				<?php if(isset($errorMsg)) { ?>
95 95
 				//Error Msg
96
-				if('<?php echo $errorMsg;?>' != '')
96
+				if('<?php echo $errorMsg; ?>' != '')
97 97
 				{
98
-					alert('<?php echo $errorMsg;?>');
98
+					alert('<?php echo $errorMsg; ?>');
99 99
 				}
100 100
 				<?php } ?>
101 101
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				function getMorePosts(lastPostId, view, hashtag, old_lastPostId)
129 129
 				{
130 130
 					$.ajax({
131
-						url: '<?php echo $baseUrl;?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURIComponent(hashtag),
131
+						url: '<?php echo $baseUrl; ?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURIComponent(hashtag),
132 132
 						dataType: 'html',
133 133
 						async: false,
134 134
 						success: function(html) {
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,7 +61,9 @@  discard block
 block discarded – undo
61 61
 			{
62 62
 				window.history.back();
63 63
 			}
64
-		<?php if(isset($includeEmojiAndAjax)){ ?>
64
+		<?php if(isset($includeEmojiAndAjax))
65
+{
66
+?>
65 67
 
66 68
 			function vote(postId, vote, obj)
67 69
 			{
@@ -91,7 +93,9 @@  discard block
 block discarded – undo
91 93
 
92 94
 			$(document).ready(function()
93 95
 			{
94
-				<?php if(isset($errorMsg)) { ?>
96
+				<?php if(isset($errorMsg))
97
+{
98
+?>
95 99
 				//Error Msg
96 100
 				if('<?php echo $errorMsg;?>' != '')
97 101
 				{
@@ -155,7 +159,9 @@  discard block
 block discarded – undo
155 159
 					return {"lastPostId":lastPostId, "old_lastPostId":old_lastPostId};
156 160
 				}
157 161
 
158
-				<?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?>
162
+				<?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails']))
163
+{
164
+?>
159 165
 
160 166
 				if(window.location.hash)
161 167
 				{
Please login to merge, or discard this patch.
php/Requests/AbstractRequest.php 4 patches
Indentation   +158 added lines, -158 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 = 'SDydTnTdqqaiAMfneLkqXYxamvNuUYOmkqpdiZTu';
8
-    const USERAGENT = 'Jodel/4.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
-    const CLIENT_TYPE = 'android_4.34.2';
5
+	const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26';
6
+	const APIURL = 'https://api.go-tellm.com/api';
7
+	const SECRET = 'SDydTnTdqqaiAMfneLkqXYxamvNuUYOmkqpdiZTu';
8
+	const USERAGENT = 'Jodel/4.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
+	const CLIENT_TYPE = 'android_4.34.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
-    {
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,111 +45,111 @@  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
-                break;
120
-            case 503:
121
-                error_log('Error 503 - ' . print_r($result, true));
122
-                $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
+				break;
120
+			case 503:
121
+				error_log('Error 503 - ' . print_r($result, true));
122
+				$result = json_decode($result->body, true);
123 123
 
124
-                if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
125
-                {
126
-                    header('location:'.$_SERVER['PHP_SELF']); 
127
-                }
128
-                break;
129
-            default:
130
-                error_log('Error '.$result->status_code.' - unknown error');
131
-                $result = json_decode($result->body, true);
132
-        }
124
+				if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
125
+				{
126
+					header('location:'.$_SERVER['PHP_SELF']); 
127
+				}
128
+				break;
129
+			default:
130
+				error_log('Error '.$result->status_code.' - unknown error');
131
+				$result = json_decode($result->body, true);
132
+		}
133 133
 
134
-        //important for account refresh
135
-        if($device_uid != '')
136
-        {
134
+		//important for account refresh
135
+		if($device_uid != '')
136
+		{
137 137
 			$result[0] = $result;
138 138
 			$result[1] = $device_uid;
139
-        }
139
+		}
140 140
 
141 141
         
142
-        /* var_dump($result); */
142
+		/* var_dump($result); */
143 143
         
144
-        return $result;
145
-    }
146
-    abstract function getPayload();
147
-    /**
148
-     * Gets Sign headers
149
-     * @return array headers
150
-     */
151
-    private function getSignHeaders()
152
-    {
144
+		return $result;
145
+	}
146
+	abstract function getPayload();
147
+	/**
148
+	 * Gets Sign headers
149
+	 * @return array headers
150
+	 */
151
+	private function getSignHeaders()
152
+	{
153 153
 			if($this->getAccessToken() == null) {
154 154
 				$payload_accessToken = "";
155 155
 			}
@@ -158,54 +158,54 @@  discard block
 block discarded – undo
158 158
 			}
159 159
 			
160 160
 			
161
-        $headers = array(
162
-            "Connection" => "keep-alive",
163
-            "Accept-Encoding" => "gzip",
164
-            "Content-Type" => "application/json; charset=UTF-8",
165
-            "User-Agent" => self::USERAGENT
166
-        );
167
-        $timestamp = new DateTime();
168
-        $timestamp = $timestamp->format(DateTime::ATOM);
169
-        $timestamp = substr($timestamp, 0, -6);
170
-        $timestamp .= "Z";
171
-        $urlParts = parse_url($this->getFullUrl());
172
-        $url2 = "";
173
-        $req = [$this->getMethod(),
174
-            $urlParts['host'],
175
-            "443",
176
-            $urlParts['path'],
177
-            $payload_accessToken,
178
-            $timestamp,
179
-            $url2,
180
-            $this->payLoad];
181
-        $reqString = implode("%", $req);
182
-        $secret = self::SECRET;
183
-        $signature = hash_hmac('sha1', $reqString, $secret);
184
-        $signature = strtoupper($signature);
185
-        $headers['X-Authorization'] = 'HMAC ' . $signature;
186
-        $headers['X-Client-Type'] = self::CLIENT_TYPE;
187
-        $headers['X-Timestamp'] = $timestamp;
188
-        $headers['X-Api-Version'] = '0.2';
189
-        return $headers;
190
-    }
191
-    private function getFullUrl()
192
-    {
193
-        return self::APIURL . $this->getApiEndPoint();
194
-    }
195
-    abstract function getApiEndPoint();
196
-    abstract function getMethod();
197
-    /**
198
-     * @return string
199
-     */
200
-    private function getAccessToken()
201
-    {
202
-        return $this->accessToken;
203
-    }
204
-    /**
205
-     * @param string $accessToken
206
-     */
207
-    public function setAccessToken($accessToken)
208
-    {
209
-        $this->accessToken = $accessToken;
210
-    }
161
+		$headers = array(
162
+			"Connection" => "keep-alive",
163
+			"Accept-Encoding" => "gzip",
164
+			"Content-Type" => "application/json; charset=UTF-8",
165
+			"User-Agent" => self::USERAGENT
166
+		);
167
+		$timestamp = new DateTime();
168
+		$timestamp = $timestamp->format(DateTime::ATOM);
169
+		$timestamp = substr($timestamp, 0, -6);
170
+		$timestamp .= "Z";
171
+		$urlParts = parse_url($this->getFullUrl());
172
+		$url2 = "";
173
+		$req = [$this->getMethod(),
174
+			$urlParts['host'],
175
+			"443",
176
+			$urlParts['path'],
177
+			$payload_accessToken,
178
+			$timestamp,
179
+			$url2,
180
+			$this->payLoad];
181
+		$reqString = implode("%", $req);
182
+		$secret = self::SECRET;
183
+		$signature = hash_hmac('sha1', $reqString, $secret);
184
+		$signature = strtoupper($signature);
185
+		$headers['X-Authorization'] = 'HMAC ' . $signature;
186
+		$headers['X-Client-Type'] = self::CLIENT_TYPE;
187
+		$headers['X-Timestamp'] = $timestamp;
188
+		$headers['X-Api-Version'] = '0.2';
189
+		return $headers;
190
+	}
191
+	private function getFullUrl()
192
+	{
193
+		return self::APIURL . $this->getApiEndPoint();
194
+	}
195
+	abstract function getApiEndPoint();
196
+	abstract function getMethod();
197
+	/**
198
+	 * @return string
199
+	 */
200
+	private function getAccessToken()
201
+	{
202
+		return $this->accessToken;
203
+	}
204
+	/**
205
+	 * @param string $accessToken
206
+	 */
207
+	public function setAccessToken($accessToken)
208
+	{
209
+		$this->accessToken = $accessToken;
210
+	}
211 211
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         $header = $this->getSignHeaders();
30 30
         $url = $this->getFullUrl();
31 31
 
32
-        if ($this->getAccessToken()) {
32
+        if($this->getAccessToken()) {
33 33
             $header['Authorization'] = "Bearer " . $this->getAccessToken();
34 34
         }
35 35
         //Comment out to debug the Request:
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             'proxy' => '186.103.169.165:8080',
53 53
         );*/
54 54
 
55
-        switch ($this->getMethod()) {
55
+        switch($this->getMethod()) {
56 56
             case 'POST':
57 57
                 $result = Requests::post($url, $header, $this->payLoad);
58 58
                 break;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
         http_response_code($result->status_code);
75 75
 
76
-        switch ($result->status_code) {
76
+        switch($result->status_code) {
77 77
             case 200:
78 78
                 $result = json_decode($result->body, true);
79 79
                 break;
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 
124 124
                 if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
125 125
                 {
126
-                    header('location:'.$_SERVER['PHP_SELF']); 
126
+                    header('location:' . $_SERVER['PHP_SELF']); 
127 127
                 }
128 128
                 break;
129 129
             default:
130
-                error_log('Error '.$result->status_code.' - unknown error');
130
+                error_log('Error ' . $result->status_code . ' - unknown error');
131 131
                 $result = json_decode($result->body, true);
132 132
         }
133 133
 
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 = 'SDydTnTdqqaiAMfneLkqXYxamvNuUYOmkqpdiZTu';
@@ -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;
@@ -150,10 +154,12 @@  discard block
 block discarded – undo
150 154
      */
151 155
     private function getSignHeaders()
152 156
     {
153
-			if($this->getAccessToken() == null) {
157
+			if($this->getAccessToken() == null)
158
+			{
154 159
 				$payload_accessToken = "";
155 160
 			}
156
-			else {
161
+			else
162
+			{
157 163
 				$payload_accessToken = $this->getAccessToken();
158 164
 			}
159 165
 			
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.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9 9
     const CLIENT_TYPE = 'android_4.34.2';
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,32 +94,32 @@  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
                 break;
120 120
             case 503:
121
-                error_log('Error 503 - ' . print_r($result, true));
122
-                $result = json_decode($result->body, true);
121
+                error_log('Error 503 - ' . print_r($result, TRUE));
122
+                $result = json_decode($result->body, TRUE);
123 123
 
124 124
                 if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable')
125 125
                 {
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                 break;
129 129
             default:
130 130
                 error_log('Error '.$result->status_code.' - unknown error');
131
-                $result = json_decode($result->body, true);
131
+                $result = json_decode($result->body, TRUE);
132 132
         }
133 133
 
134 134
         //important for account refresh
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     private function getSignHeaders()
152 152
     {
153
-			if($this->getAccessToken() == null) {
153
+			if($this->getAccessToken() == NULL) {
154 154
 				$payload_accessToken = "";
155 155
 			}
156 156
 			else {
Please login to merge, or discard this patch.
php/JodelAccount.php 2 patches
Indentation   +479 added lines, -479 removed lines patch added patch discarded remove patch
@@ -2,571 +2,571 @@
 block discarded – undo
2 2
 
3 3
 class JodelAccount
4 4
 {
5
-    public $accessToken;
6
-    public $expirationDate;
7
-    public $refreshToken;
8
-    public $distinctId;
9
-    public $deviceUid;
10
-
11
-    //is the Account a Bot or Spider?
12
-    public $isBot;
5
+	public $accessToken;
6
+	public $expirationDate;
7
+	public $refreshToken;
8
+	public $distinctId;
9
+	public $deviceUid;
10
+
11
+	//is the Account a Bot or Spider?
12
+	public $isBot;
13 13
     
14
-    // array of voted Jodels
15
-    public $votes;
14
+	// array of voted Jodels
15
+	public $votes;
16 16
 
17
-    //Location of the Account
18
-    public $location;
17
+	//Location of the Account
18
+	public $location;
19 19
 
20
-    function __construct($deviceUid = NULL, $isBot = FALSE)
21
-    {
22
-        if($deviceUid == NULL)
23
-        {
24
-            $this->deviceUid = $this->createAccount();
25
-        }
26
-        else
27
-        {
28
-            $this->deviceUid = $deviceUid;
29
-        }
20
+	function __construct($deviceUid = NULL, $isBot = FALSE)
21
+	{
22
+		if($deviceUid == NULL)
23
+		{
24
+			$this->deviceUid = $this->createAccount();
25
+		}
26
+		else
27
+		{
28
+			$this->deviceUid = $deviceUid;
29
+		}
30 30
 
31
-        $this->isBot        = $isBot;
32
-        $this->location     = $this->getLocation();
31
+		$this->isBot        = $isBot;
32
+		$this->location     = $this->getLocation();
33 33
 
34
-        if(!$this->isTokenFresh())
35
-        {
36
-            $this->refreshToken();
37
-        }
38
-        $this->accessToken  = $this->getAccessToken();
34
+		if(!$this->isTokenFresh())
35
+		{
36
+			$this->refreshToken();
37
+		}
38
+		$this->accessToken  = $this->getAccessToken();
39 39
 
40
-       /* if($this->isAccountVerified() != 1)
40
+	   /* if($this->isAccountVerified() != 1)
41 41
         {
42 42
             $this->showCaptcha();
43 43
             //$this->verifyCaptcha();
44 44
         }*/
45
-    }
45
+	}
46 46
 
47
-    function showCaptcha()
48
-    {
49
-        $accountCreator = new GetCaptcha();
50
-        $accountCreator->setAccessToken($this->accessToken);
51
-        $captcha = $accountCreator->execute();
47
+	function showCaptcha()
48
+	{
49
+		$accountCreator = new GetCaptcha();
50
+		$accountCreator->setAccessToken($this->accessToken);
51
+		$captcha = $accountCreator->execute();
52 52
 
53
-        echo $captcha['image_url'];
54
-        echo('<br><img width="100%" src="' . $captcha['image_url'] . '">');
55
-        echo "<br>Key: " . $captcha['key'];
56
-        echo "<br>";
53
+		echo $captcha['image_url'];
54
+		echo('<br><img width="100%" src="' . $captcha['image_url'] . '">');
55
+		echo "<br>Key: " . $captcha['key'];
56
+		echo "<br>";
57 57
 
58
-        //Form
58
+		//Form
59 59
         
60
-        echo '<form method="get">';
61
-        echo    '<p>Enter Key (copy pasta from top): <input type="text" value="' . $captcha['key'] . '" name="key" /></p>';
62
-        echo    '<p>Find the Coons (example: they are on picture 3, 4 and 5. You enter 2-3-4. Becouse we start counting at 0): <input type="text" name="solution" /></p>';
63
-        echo    '<input type="hidden" name="deviceUid" value="' . $this->deviceUid . '">';
64
-        echo    '<input type="hidden" name="pw" value="upVote">';
65
-        echo    '<p><input type="submit" /></p>';
66
-        echo '</form>';
67
-
68
-        die();
60
+		echo '<form method="get">';
61
+		echo    '<p>Enter Key (copy pasta from top): <input type="text" value="' . $captcha['key'] . '" name="key" /></p>';
62
+		echo    '<p>Find the Coons (example: they are on picture 3, 4 and 5. You enter 2-3-4. Becouse we start counting at 0): <input type="text" name="solution" /></p>';
63
+		echo    '<input type="hidden" name="deviceUid" value="' . $this->deviceUid . '">';
64
+		echo    '<input type="hidden" name="pw" value="upVote">';
65
+		echo    '<p><input type="submit" /></p>';
66
+		echo '</form>';
67
+
68
+		die();
69 69
         
70
-    }
70
+	}
71 71
 
72
-    function getCaptcha()
73
-    {
74
-        $accountCreator = new GetCaptcha();
75
-        $accountCreator->setAccessToken($this->accessToken);
76
-        $captcha = $accountCreator->execute();
72
+	function getCaptcha()
73
+	{
74
+		$accountCreator = new GetCaptcha();
75
+		$accountCreator->setAccessToken($this->accessToken);
76
+		$captcha = $accountCreator->execute();
77 77
 
78
-        return array("image_url" => $captcha['image_url'], "key" => $captcha['key']);
79
-    }
78
+		return array("image_url" => $captcha['image_url'], "key" => $captcha['key']);
79
+	}
80 80
 
81
-    function isAccountVerified()
82
-    {
83
-        $accountCreator = new GetUserConfig();
84
-        $accountCreator->setAccessToken($this->accessToken);
85
-        $data = $accountCreator->execute();
81
+	function isAccountVerified()
82
+	{
83
+		$accountCreator = new GetUserConfig();
84
+		$accountCreator->setAccessToken($this->accessToken);
85
+		$data = $accountCreator->execute();
86 86
 
87
-        //error_log(print_r($data, true));
87
+		//error_log(print_r($data, true));
88 88
 
89
-        return $data['verified'];
90
-    }
89
+		return $data['verified'];
90
+	}
91 91
 
92
-    function locationEquals($city)
93
-    {
94
-        $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
95
-        $result = Requests::post($url);
96
-        if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
97
-        {
98
-            error_log('Error locationEquals');
99
-            return FALSE;
100
-        }
101
-        else
102
-        {
103
-            $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
104
-            $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
105
-            $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
106
-        }
92
+	function locationEquals($city)
93
+	{
94
+		$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
95
+		$result = Requests::post($url);
96
+		if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
97
+		{
98
+			error_log('Error locationEquals');
99
+			return FALSE;
100
+		}
101
+		else
102
+		{
103
+			$name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
104
+			$lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
105
+			$lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
106
+		}
107 107
 
108
-        $db = new DatabaseConnect();
109
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
108
+		$db = new DatabaseConnect();
109
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
110 110
         
111
-        $location = new Location();
111
+		$location = new Location();
112 112
         
113
-        if ($result->num_rows > 0)
114
-        {
115
-            // output data of each row
116
-            while($row = $result->fetch_assoc())
117
-            {
118
-                $location->setLat($row['lat']);
119
-                $location->setLng($row['lng']);
120
-                $location->setCityName($row['name']);
121
-            }
122
-        }
123
-        else
124
-        {
125
-            error_log("Error no Location found - getLocation");
126
-        }
113
+		if ($result->num_rows > 0)
114
+		{
115
+			// output data of each row
116
+			while($row = $result->fetch_assoc())
117
+			{
118
+				$location->setLat($row['lat']);
119
+				$location->setLng($row['lng']);
120
+				$location->setCityName($row['name']);
121
+			}
122
+		}
123
+		else
124
+		{
125
+			error_log("Error no Location found - getLocation");
126
+		}
127 127
 
128
-        if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name)
129
-        {
130
-            return TRUE;
131
-        }  
132
-        else
133
-        {
134
-            return FALSE;
135
-        }
136
-    }
137
-
138
-    function setLocation()
139
-    {
140
-        //Is Channel or City
141
-        if(substr($_GET['city'], 0, 1) === '#')
142
-        {
143
-            return htmlspecialchars($_GET['city']) . " " . $this->location->cityName;
144
-        }                
145
-        else
146
-        {
147
-            $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
148
-            $result = Requests::post($url);
149
-            if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
150
-            {
151
-                return "0 results";
152
-            }
153
-            else
154
-            {
155
-                $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
156
-                $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
157
-                $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
158
-
159
-                $location = new Location();
160
-                $location->setLat($lat);
161
-                $location->setLng($lng);
162
-                $location->setCityName($name);
163
-                $accountCreator = new UpdateLocation();
164
-                $accountCreator->setLocation($location);
165
-                $accountCreator->setAccessToken($this->accessToken);
166
-                $data = $accountCreator->execute();
167
-
168
-                //safe location to db
169
-                $db = new DatabaseConnect();
170
-
171
-                if($data == 'Success')
172
-                {
173
-                    $result = $db->query("UPDATE accounts 
128
+		if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name)
129
+		{
130
+			return TRUE;
131
+		}  
132
+		else
133
+		{
134
+			return FALSE;
135
+		}
136
+	}
137
+
138
+	function setLocation()
139
+	{
140
+		//Is Channel or City
141
+		if(substr($_GET['city'], 0, 1) === '#')
142
+		{
143
+			return htmlspecialchars($_GET['city']) . " " . $this->location->cityName;
144
+		}                
145
+		else
146
+		{
147
+			$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
148
+			$result = Requests::post($url);
149
+			if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
150
+			{
151
+				return "0 results";
152
+			}
153
+			else
154
+			{
155
+				$name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
156
+				$lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
157
+				$lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
158
+
159
+				$location = new Location();
160
+				$location->setLat($lat);
161
+				$location->setLng($lng);
162
+				$location->setCityName($name);
163
+				$accountCreator = new UpdateLocation();
164
+				$accountCreator->setLocation($location);
165
+				$accountCreator->setAccessToken($this->accessToken);
166
+				$data = $accountCreator->execute();
167
+
168
+				//safe location to db
169
+				$db = new DatabaseConnect();
170
+
171
+				if($data == 'Success')
172
+				{
173
+					$result = $db->query("UPDATE accounts 
174 174
                             SET name='" . $name . "',
175 175
                                 lat='" . $lat . "',
176 176
                                 lng='" . $lng . "'
177 177
                             WHERE access_token='" . $this->accessToken . "'");
178 178
 
179
-                    if($result === false)
180
-                    {
181
-                            echo "Updating location failed: (" . $db->errno . ") " . $db->error;
182
-                    }
183
-                    else
184
-                    {
185
-                        user_log('User with JodelDeviceId:' . $this->deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
186
-                    }
187
-                }
188
-
189
-                return $name;
190
-            }
191
-        }
192
-    }
193
-
194
-    function getLocation()
195
-    {
196
-        $db = new DatabaseConnect();
197
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
179
+					if($result === false)
180
+					{
181
+							echo "Updating location failed: (" . $db->errno . ") " . $db->error;
182
+					}
183
+					else
184
+					{
185
+						user_log('User with JodelDeviceId:' . $this->deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
186
+					}
187
+				}
188
+
189
+				return $name;
190
+			}
191
+		}
192
+	}
193
+
194
+	function getLocation()
195
+	{
196
+		$db = new DatabaseConnect();
197
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
198 198
         
199
-        $location = new Location();
199
+		$location = new Location();
200 200
         
201
-        if ($result->num_rows > 0)
202
-        {
203
-            // output data of each row
204
-            while($row = $result->fetch_assoc())
205
-            {
206
-                $location->setLat($row['lat']);
207
-                $location->setLng($row['lng']);
208
-                $location->setCityName($row['name']);
209
-            }
210
-        }
211
-        else
212
-        {
213
-            echo "Error: 0 results";
214
-            error_log("Error no Location found - getLocation");
215
-        }
201
+		if ($result->num_rows > 0)
202
+		{
203
+			// output data of each row
204
+			while($row = $result->fetch_assoc())
205
+			{
206
+				$location->setLat($row['lat']);
207
+				$location->setLng($row['lng']);
208
+				$location->setCityName($row['name']);
209
+			}
210
+		}
211
+		else
212
+		{
213
+			echo "Error: 0 results";
214
+			error_log("Error no Location found - getLocation");
215
+		}
216 216
 
217
-        return $location;
218
-    }
217
+		return $location;
218
+	}
219 219
 
220
-    function verifyCaptcha()
221
-    {
222
-        if(isset($_GET['deviceUid']))
223
-        {
224
-            $deviceUid = $_GET['deviceUid'];
225
-            $jodelAccountForVerify = new JodelAccount($deviceUid);
226
-        }
227
-        else if(isset($_POST['deviceUid']))
228
-        {
229
-            $deviceUid = $_POST['deviceUid'];
230
-            $jodelAccountForVerify = new JodelAccount($deviceUid);
231
-        }
232
-        else
233
-        {
234
-            $deviceUid = $this->deviceUid;
235
-            $jodelAccountForVerify = $this;
236
-        }
220
+	function verifyCaptcha()
221
+	{
222
+		if(isset($_GET['deviceUid']))
223
+		{
224
+			$deviceUid = $_GET['deviceUid'];
225
+			$jodelAccountForVerify = new JodelAccount($deviceUid);
226
+		}
227
+		else if(isset($_POST['deviceUid']))
228
+		{
229
+			$deviceUid = $_POST['deviceUid'];
230
+			$jodelAccountForVerify = new JodelAccount($deviceUid);
231
+		}
232
+		else
233
+		{
234
+			$deviceUid = $this->deviceUid;
235
+			$jodelAccountForVerify = $this;
236
+		}
237 237
 
238
-        $solution = $_GET['solution'];
239
-        $solution = array_map('intval', explode('-', $solution));
238
+		$solution = $_GET['solution'];
239
+		$solution = array_map('intval', explode('-', $solution));
240 240
 
241
-        $accountCreator = new PostCaptcha();
242
-        $accountCreator->setAccessToken($jodelAccountForVerify->accessToken);
243
-        $accountCreator->captchaKey = $_GET['key'];
244
-        $accountCreator->captchaSolution = $solution;
245
-        $verified = $accountCreator->execute();
241
+		$accountCreator = new PostCaptcha();
242
+		$accountCreator->setAccessToken($jodelAccountForVerify->accessToken);
243
+		$accountCreator->captchaKey = $_GET['key'];
244
+		$accountCreator->captchaSolution = $solution;
245
+		$verified = $accountCreator->execute();
246 246
 
247
-        if(isset($verified->status_code))
248
-        {
249
-            return $verified->status_code;
250
-        }
251
-        return $verified['verified'];
252
-    }
253
-
254
-    //ToDo Spider Check
255
-    function votePostId($postId, $vote)
256
-    {
257
-        if(!$this->isBot)
258
-        {
259
-            if(!$this->isAccountVerified())
260
-            {
261
-                $view = new View();
262
-                $this->showCaptcha();
263
-            }
264
-
265
-            if(!$this->hasVoted($postId))
266
-            {
267
-                if($vote == "up")
268
-                {
269
-                    $accountCreator = new Upvote();
270
-                }
271
-                else if($vote == "down")
272
-                {
273
-                    $accountCreator = new Downvote();
274
-                }
275
-
276
-                $accountCreator->setAccessToken($this->accessToken);
277
-                $accountCreator->postId = htmlspecialchars($postId);
278
-                $data = $accountCreator->execute();
279
-
280
-                error_log('Could not vote: ' . print_r($data, true));
281
-
282
-                if(array_key_exists('post', $data))
283
-                {
284
-                    $this->addVoteWithPostIdAndType($postId, $vote);
285
-                    return TRUE;
286
-                }
287
-                else if(array_key_exists('error', $data))
288
-                {
289
-                    error_log('Could not vote - Error: ' . $data['error']);
290
-                }
291
-                else
292
-                {
293
-                    error_log('Could not vote: ' . print_r($data, true));
294
-                    return FALSE;
295
-                } 
296
-            }
297
-            else
298
-            {
299
-                return FALSE;
300
-            }
301
-        }
302
-
303
-        return FALSE;
304
-    }
305
-
306
-    //ToDo Spider Check
307
-    function sendJodel($location, $view)
308
-    {
309
-        if($this->isAccountVerified() != 1)
310
-        {
311
-            $this->showCaptcha();
312
-            //$this->verifyCaptcha();
313
-        }
247
+		if(isset($verified->status_code))
248
+		{
249
+			return $verified->status_code;
250
+		}
251
+		return $verified['verified'];
252
+	}
314 253
 
315
-        $accountCreator = new SendJodel();
254
+	//ToDo Spider Check
255
+	function votePostId($postId, $vote)
256
+	{
257
+		if(!$this->isBot)
258
+		{
259
+			if(!$this->isAccountVerified())
260
+			{
261
+				$view = new View();
262
+				$this->showCaptcha();
263
+			}
264
+
265
+			if(!$this->hasVoted($postId))
266
+			{
267
+				if($vote == "up")
268
+				{
269
+					$accountCreator = new Upvote();
270
+				}
271
+				else if($vote == "down")
272
+				{
273
+					$accountCreator = new Downvote();
274
+				}
275
+
276
+				$accountCreator->setAccessToken($this->accessToken);
277
+				$accountCreator->postId = htmlspecialchars($postId);
278
+				$data = $accountCreator->execute();
279
+
280
+				error_log('Could not vote: ' . print_r($data, true));
281
+
282
+				if(array_key_exists('post', $data))
283
+				{
284
+					$this->addVoteWithPostIdAndType($postId, $vote);
285
+					return TRUE;
286
+				}
287
+				else if(array_key_exists('error', $data))
288
+				{
289
+					error_log('Could not vote - Error: ' . $data['error']);
290
+				}
291
+				else
292
+				{
293
+					error_log('Could not vote: ' . print_r($data, true));
294
+					return FALSE;
295
+				} 
296
+			}
297
+			else
298
+			{
299
+				return FALSE;
300
+			}
301
+		}
316 302
 
317
-        if(isset($_POST['ancestor']))
318
-        {
319
-            $ancestor = $_POST['ancestor'];
320
-            $accountCreator->ancestor = $ancestor;
321
-        }
322
-        if(isset($_POST['color']))
323
-        {
324
-            $color = $_POST['color'];
325
-            switch ($color) {
326
-                case '8ABDB0':
327
-                    $color = '8ABDB0';
328
-                    break;
329
-                case '9EC41C':
330
-                    $color = '9EC41C';
331
-                    break;
332
-                case '06A3CB':
333
-                    $color = '06A3CB';
334
-                    break;
335
-                case 'FFBA00':
336
-                    $color = 'FFBA00';
337
-                    break;
338
-                case 'DD5F5F':
339
-                    $color = 'DD5F5F';
340
-                    break;
341
-                case 'FF9908':
342
-                    $color = 'FF9908';
343
-                    break;
344
-                default:
345
-                    $color = '8ABDB0';
346
-                    break;
347
-            }
348
-            $accountCreator->color = $color;
349
-        }
350
-
351
-        $accountCreatorLocation = new UpdateLocation();
352
-        $accountCreatorLocation->setLocation($location);
353
-        $accountCreatorLocation->setAccessToken($this->accessToken);
354
-        $data = $accountCreatorLocation->execute();
303
+		return FALSE;
304
+	}
305
+
306
+	//ToDo Spider Check
307
+	function sendJodel($location, $view)
308
+	{
309
+		if($this->isAccountVerified() != 1)
310
+		{
311
+			$this->showCaptcha();
312
+			//$this->verifyCaptcha();
313
+		}
314
+
315
+		$accountCreator = new SendJodel();
316
+
317
+		if(isset($_POST['ancestor']))
318
+		{
319
+			$ancestor = $_POST['ancestor'];
320
+			$accountCreator->ancestor = $ancestor;
321
+		}
322
+		if(isset($_POST['color']))
323
+		{
324
+			$color = $_POST['color'];
325
+			switch ($color) {
326
+				case '8ABDB0':
327
+					$color = '8ABDB0';
328
+					break;
329
+				case '9EC41C':
330
+					$color = '9EC41C';
331
+					break;
332
+				case '06A3CB':
333
+					$color = '06A3CB';
334
+					break;
335
+				case 'FFBA00':
336
+					$color = 'FFBA00';
337
+					break;
338
+				case 'DD5F5F':
339
+					$color = 'DD5F5F';
340
+					break;
341
+				case 'FF9908':
342
+					$color = 'FF9908';
343
+					break;
344
+				default:
345
+					$color = '8ABDB0';
346
+					break;
347
+			}
348
+			$accountCreator->color = $color;
349
+		}
350
+
351
+		$accountCreatorLocation = new UpdateLocation();
352
+		$accountCreatorLocation->setLocation($location);
353
+		$accountCreatorLocation->setAccessToken($this->accessToken);
354
+		$data = $accountCreatorLocation->execute();
355 355
         
356 356
 		if($data != 'Success')
357 357
 		{
358 358
 			error_log('Could not set location befor Post: ' . print_r($data, true));
359 359
 		}
360 360
 
361
-        $accountCreator->location = $this->location;
361
+		$accountCreator->location = $this->location;
362 362
 
363
-        $image = '';
364
-        if(isset($_FILES['image']) && $_FILES['image']['size'] > 0)
365
-        {
366
-            $image = file_get_contents($_FILES['image']['tmp_name']);
367
-        }
363
+		$image = '';
364
+		if(isset($_FILES['image']) && $_FILES['image']['size'] > 0)
365
+		{
366
+			$image = file_get_contents($_FILES['image']['tmp_name']);
367
+		}
368 368
         
369
-        $accountCreator->image = $image;
369
+		$accountCreator->image = $image;
370 370
         
371
-        $accountCreator->setAccessToken($this->accessToken);
372
-        $data = $accountCreator->execute();
371
+		$accountCreator->setAccessToken($this->accessToken);
372
+		$data = $accountCreator->execute();
373 373
 
374
-        if(isset($data['error']) && $data['error'] == 'length')
375
-        {
376
-            $errorMsg = 'Error: The input was to long';
377
-            return $errorMsg;
378
-        }
374
+		if(isset($data['error']) && $data['error'] == 'length')
375
+		{
376
+			$errorMsg = 'Error: The input was to long';
377
+			return $errorMsg;
378
+		}
379 379
 
380
-        error_log(print_r($data, true));
380
+		error_log(print_r($data, true));
381 381
 
382
-        if(isset($_POST['ancestor']))
383
-        {
384
-            header('Location: ' . $view->toUrl());
385
-            exit;
386
-        }
387
-        else
388
-        {
389
-            header('Location: ' . $view->baseUrl);
390
-            exit;
391
-        }
392
-    }
382
+		if(isset($_POST['ancestor']))
383
+		{
384
+			header('Location: ' . $view->toUrl());
385
+			exit;
386
+		}
387
+		else
388
+		{
389
+			header('Location: ' . $view->baseUrl);
390
+			exit;
391
+		}
392
+	}
393 393
 
394
-    function isTokenFresh()
395
-    {
396
-        $db = new DatabaseConnect();  
397
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
394
+	function isTokenFresh()
395
+	{
396
+		$db = new DatabaseConnect();  
397
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
398 398
 
399
-        if ($result->num_rows > 0)
400
-        {
401
-            // output data of each row
402
-            while($row = $result->fetch_assoc())
403
-            {
404
-                    $expiration_date = $row["expiration_date"];
405
-            }
406
-        }
407
-        else
408
-        {
409
-            error_log('0 results');
410
-        }
399
+		if ($result->num_rows > 0)
400
+		{
401
+			// output data of each row
402
+			while($row = $result->fetch_assoc())
403
+			{
404
+					$expiration_date = $row["expiration_date"];
405
+			}
406
+		}
407
+		else
408
+		{
409
+			error_log('0 results');
410
+		}
411 411
 
412
-        if($expiration_date <= time())
413
-        {
414
-           return FALSE;
415
-        }
412
+		if($expiration_date <= time())
413
+		{
414
+		   return FALSE;
415
+		}
416 416
         
417
-        return TRUE;
418
-    }
419
-
420
-    function refreshToken()
421
-    {
422
-        $accountCreator = new CreateUser();
423
-        $accountCreator->setAccessToken($this->accessToken);
424
-        $accountCreator->setDeviceUid($this->deviceUid);
425
-        $accountCreator->setLocation($this->location);
426
-        $data = $accountCreator->execute();
427
-
428
-        $access_token = (string)$data[0]['access_token'];
429
-        $expiration_date = $data[0]['expiration_date'];
430
-        $device_uid = (string)$data[1];
417
+		return TRUE;
418
+	}
419
+
420
+	function refreshToken()
421
+	{
422
+		$accountCreator = new CreateUser();
423
+		$accountCreator->setAccessToken($this->accessToken);
424
+		$accountCreator->setDeviceUid($this->deviceUid);
425
+		$accountCreator->setLocation($this->location);
426
+		$data = $accountCreator->execute();
427
+
428
+		$access_token = (string)$data[0]['access_token'];
429
+		$expiration_date = $data[0]['expiration_date'];
430
+		$device_uid = (string)$data[1];
431 431
         
432
-        $db = new DatabaseConnect();  
433
-        $result = $db->query("UPDATE accounts 
432
+		$db = new DatabaseConnect();  
433
+		$result = $db->query("UPDATE accounts 
434 434
                                 SET access_token='" . $access_token . "',
435 435
                                     expiration_date='" . $expiration_date . "'
436 436
                                 WHERE device_uid='" . $device_uid . "'");
437 437
 
438
-        if($result === false){
439
-                error_log("Adding account failed: (" . $db->errno . ") " . $db->error);
440
-        }   
441
-    }
438
+		if($result === false){
439
+				error_log("Adding account failed: (" . $db->errno . ") " . $db->error);
440
+		}   
441
+	}
442 442
 
443 443
 
444 444
 
445
-    function getAccessToken()
446
-    {
447
-        $db = new DatabaseConnect();
448
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
445
+	function getAccessToken()
446
+	{
447
+		$db = new DatabaseConnect();
448
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
449 449
         
450
-        $accessToken;
450
+		$accessToken;
451 451
         
452
-        if ($result->num_rows > 0)
453
-        {
454
-            // output data of each row
455
-            while($row = $result->fetch_assoc())
456
-            {
457
-                $accessToken = $row['access_token'];
458
-            }
459
-        }
460
-        else
461
-        {
462
-            error_log('Error: 0 results');
463
-        }
452
+		if ($result->num_rows > 0)
453
+		{
454
+			// output data of each row
455
+			while($row = $result->fetch_assoc())
456
+			{
457
+				$accessToken = $row['access_token'];
458
+			}
459
+		}
460
+		else
461
+		{
462
+			error_log('Error: 0 results');
463
+		}
464 464
 
465
-        return $accessToken;
466
-    }
465
+		return $accessToken;
466
+	}
467 467
 
468 468
 
469
-    function getKarma()
470
-    {
471
-        $accountCreator = new GetKarma();
472
-        $accountCreator->setAccessToken($this->accessToken);
473
-        $data = $accountCreator->execute();
469
+	function getKarma()
470
+	{
471
+		$accountCreator = new GetKarma();
472
+		$accountCreator->setAccessToken($this->accessToken);
473
+		$data = $accountCreator->execute();
474 474
         
475
-        return $data['karma'];
476
-    }
475
+		return $data['karma'];
476
+	}
477 477
 
478
-    function hasVoted($postId)
479
-    {
480
-        $db = new DatabaseConnect();
478
+	function hasVoted($postId)
479
+	{
480
+		$db = new DatabaseConnect();
481 481
 
482
-        $postId = $db->real_escape_string($postId);
482
+		$postId = $db->real_escape_string($postId);
483 483
 
484
-        $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')");
484
+		$result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')");
485 485
         
486
-        if($result === false)
487
-        {
488
-            $error = db_error();
489
-            echo $error;
490
-            error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error);
491
-        }
486
+		if($result === false)
487
+		{
488
+			$error = db_error();
489
+			echo $error;
490
+			error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error);
491
+		}
492 492
 
493
-        if($result->num_rows == 0)
494
-        {
495
-            return FALSE;
496
-        }
497
-        else
498
-        {
499
-            return TRUE;
500
-        }
501
-    }
493
+		if($result->num_rows == 0)
494
+		{
495
+			return FALSE;
496
+		}
497
+		else
498
+		{
499
+			return TRUE;
500
+		}
501
+	}
502 502
 
503
-    function addVoteWithPostIdAndType($postId, $voteType)
504
-    {
505
-        $db = new DatabaseConnect();  
503
+	function addVoteWithPostIdAndType($postId, $voteType)
504
+	{
505
+		$db = new DatabaseConnect();  
506 506
 
507
-        $postId = $db->real_escape_string($postId);
508
-        $voteType = $db->real_escape_string($voteType);
507
+		$postId = $db->real_escape_string($postId);
508
+		$voteType = $db->real_escape_string($voteType);
509 509
         
510
-        if($this->hasVoted($postId))
511
-        {
512
-            return "Already voted";
513
-        }
510
+		if($this->hasVoted($postId))
511
+		{
512
+			return "Already voted";
513
+		}
514 514
 
515
-        $result = $db->query("INSERT INTO votes (device_uid, postId, type)
515
+		$result = $db->query("INSERT INTO votes (device_uid, postId, type)
516 516
                         VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')");
517 517
         
518
-        if($result === false){
519
-                $error = db_error();
520
-                echo $error;
521
-                echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
522
-        }       
523
-    }
524
-
525
-    function registerAccount($location) {
526
-        $accountCreator = new CreateUser();
527
-        $accountCreator->setLocation($location);
528
-        $data = $accountCreator->execute();
518
+		if($result === false){
519
+				$error = db_error();
520
+				echo $error;
521
+				echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
522
+		}       
523
+	}
524
+
525
+	function registerAccount($location) {
526
+		$accountCreator = new CreateUser();
527
+		$accountCreator->setLocation($location);
528
+		$data = $accountCreator->execute();
529 529
         
530
-        $access_token = (string)$data[0]['access_token'];
531
-        $refresh_token = (string)$data[0]['refresh_token'];
532
-        $token_type = (string)$data[0]['token_type'];
533
-        $expires_in = $data[0]['expires_in'];
534
-        $expiration_date = $data[0]['expiration_date'];
535
-        $distinct_id = (string)$data[0]['distinct_id'];
536
-        $device_uid = (string)$data[1];
537
-
538
-        $name = $location->cityName;
539
-        $lat = $location->lat;
540
-        $lng = $location->lng;
530
+		$access_token = (string)$data[0]['access_token'];
531
+		$refresh_token = (string)$data[0]['refresh_token'];
532
+		$token_type = (string)$data[0]['token_type'];
533
+		$expires_in = $data[0]['expires_in'];
534
+		$expiration_date = $data[0]['expiration_date'];
535
+		$distinct_id = (string)$data[0]['distinct_id'];
536
+		$device_uid = (string)$data[1];
537
+
538
+		$name = $location->cityName;
539
+		$lat = $location->lat;
540
+		$lng = $location->lng;
541 541
         
542
-        $db = new DatabaseConnect();  
543
-        $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
542
+		$db = new DatabaseConnect();  
543
+		$result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
544 544
                         expires_in, expiration_date, distinct_id, device_uid, name, lat, lng)
545 545
                         VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type .
546
-                        "','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
547
-                        "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
548
-
549
-        $success = TRUE;
550
-        if($result === false){
551
-                $error = $db->error();
552
-                echo $error;
553
-                echo "Adding account failed: (" . $result->errno . ") " . $result->error;
554
-                $success = FALSE;
555
-        }   
546
+						"','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
547
+						"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
548
+
549
+		$success = TRUE;
550
+		if($result === false){
551
+				$error = $db->error();
552
+				echo $error;
553
+				echo "Adding account failed: (" . $result->errno . ") " . $result->error;
554
+				$success = FALSE;
555
+		}   
556 556
         
557
-        return $device_uid;
558
-    }
557
+		return $device_uid;
558
+	}
559 559
 
560
-    function createAccount()
561
-    {
562
-        $config = parse_ini_file('config/config.ini.php');
563
-        $location = new Location();
564
-        $location->setLat($config['default_lat']);
565
-        $location->setLng($config['default_lng']);
566
-        $location->setCityName($config['default_location']);
560
+	function createAccount()
561
+	{
562
+		$config = parse_ini_file('config/config.ini.php');
563
+		$location = new Location();
564
+		$location->setLat($config['default_lat']);
565
+		$location->setLng($config['default_lng']);
566
+		$location->setCityName($config['default_location']);
567 567
 
568
-        $deviceUid = $this->registerAccount($location);
568
+		$deviceUid = $this->registerAccount($location);
569 569
 
570
-        return $deviceUid;
571
-    }
570
+		return $deviceUid;
571
+	}
572 572
 }
573 573
\ No newline at end of file
Please login to merge, or discard this patch.
Upper-Lower-Casing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
95 95
         $result = Requests::post($url);
96
-        if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
96
+        if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST')
97 97
         {
98 98
             error_log('Error locationEquals');
99 99
             return FALSE;
100 100
         }
101 101
         else
102 102
         {
103
-            $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
104
-            $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
105
-            $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
103
+            $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name'];
104
+            $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat'];
105
+            $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng'];
106 106
         }
107 107
 
108 108
         $db = new DatabaseConnect();
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
         {
147 147
             $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
148 148
             $result = Requests::post($url);
149
-            if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
149
+            if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST')
150 150
             {
151 151
                 return "0 results";
152 152
             }
153 153
             else
154 154
             {
155
-                $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
156
-                $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
157
-                $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
155
+                $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name'];
156
+                $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat'];
157
+                $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng'];
158 158
 
159 159
                 $location = new Location();
160 160
                 $location->setLat($lat);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                                 lng='" . $lng . "'
177 177
                             WHERE access_token='" . $this->accessToken . "'");
178 178
 
179
-                    if($result === false)
179
+                    if($result === FALSE)
180 180
                     {
181 181
                             echo "Updating location failed: (" . $db->errno . ") " . $db->error;
182 182
                     }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                 $accountCreator->postId = htmlspecialchars($postId);
278 278
                 $data = $accountCreator->execute();
279 279
 
280
-                error_log('Could not vote: ' . print_r($data, true));
280
+                error_log('Could not vote: ' . print_r($data, TRUE));
281 281
 
282 282
                 if(array_key_exists('post', $data))
283 283
                 {
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                 }
291 291
                 else
292 292
                 {
293
-                    error_log('Could not vote: ' . print_r($data, true));
293
+                    error_log('Could not vote: ' . print_r($data, TRUE));
294 294
                     return FALSE;
295 295
                 } 
296 296
             }
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         
356 356
 		if($data != 'Success')
357 357
 		{
358
-			error_log('Could not set location befor Post: ' . print_r($data, true));
358
+			error_log('Could not set location befor Post: ' . print_r($data, TRUE));
359 359
 		}
360 360
 
361 361
         $accountCreator->location = $this->location;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
             return $errorMsg;
378 378
         }
379 379
 
380
-        error_log(print_r($data, true));
380
+        error_log(print_r($data, TRUE));
381 381
 
382 382
         if(isset($_POST['ancestor']))
383 383
         {
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
                                     expiration_date='" . $expiration_date . "'
436 436
                                 WHERE device_uid='" . $device_uid . "'");
437 437
 
438
-        if($result === false){
438
+        if($result === FALSE){
439 439
                 error_log("Adding account failed: (" . $db->errno . ") " . $db->error);
440 440
         }   
441 441
     }
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 
484 484
         $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')");
485 485
         
486
-        if($result === false)
486
+        if($result === FALSE)
487 487
         {
488 488
             $error = db_error();
489 489
             echo $error;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
         $result = $db->query("INSERT INTO votes (device_uid, postId, type)
516 516
                         VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')");
517 517
         
518
-        if($result === false){
518
+        if($result === FALSE){
519 519
                 $error = db_error();
520 520
                 echo $error;
521 521
                 echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
                         "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
548 548
 
549 549
         $success = TRUE;
550
-        if($result === false){
550
+        if($result === FALSE){
551 551
                 $error = $db->error();
552 552
                 echo $error;
553 553
                 echo "Adding account failed: (" . $result->errno . ") " . $result->error;
Please login to merge, or discard this patch.
php/View.php 1 patch
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -2,98 +2,98 @@  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;
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;
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 23
 
24
-        if($postId == '')
25
-        {
26
-            $this->isDetailedView = FALSE;
27
-        }
28
-        else
29
-        {
30
-            $this->isDetailedView = TRUE;
31
-        }
32
-    }
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);
37
+	{   //ToDO
38
+		//Replace # with link
39
+		//preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
40 40
 
41
-        //Time to time difference
42
-        $now = new DateTime();
43
-        $d = new DateTime($post['created_at']);
44
-        $timediff = $now->diff($d);
41
+		//Time to time difference
42
+		$now = new DateTime();
43
+		$d = new DateTime($post['created_at']);
44
+		$timediff = $now->diff($d);
45 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');
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 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
-        }
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 81
 
82 82
 
83
-        ?>
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';
87
+				if(isset($post['image_url']))
88
+				{
89
+					$regexRest = '/[^\w$ .!?-]+/u';
90 90
 
91
-                    echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
92
-                }
93
-                else {
94
-                    echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
95
-                }
96
-                ?>
91
+					echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
92
+				}
93
+				else {
94
+					echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
95
+				}
96
+				?>
97 97
             </content>
98 98
             <aside>                    
99 99
                 <button onclick="vote('<?php echo $post['post_id'];?>', 'up', this)">
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
                                 <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>">
123 123
                                     <i class="fa fa-commenting-o"></i>
124 124
                                     <?php if(array_key_exists("child_count", $post))
125
-                                    {
126
-                                        echo $post["child_count"];
127
-                                    } else echo "0";
128
-                                    ?>
125
+									{
126
+										echo $post["child_count"];
127
+									} else echo "0";
128
+									?>
129 129
                                 </a>
130 130
                             </span>
131 131
                             
@@ -145,30 +145,30 @@  discard block
 block discarded – undo
145 145
 						?>
146 146
                         <span class="distance">
147 147
                             <?php
148
-                                if($this->isDetailedView)
149
-                                {
150
-                                    if(isset($post['user_handle']) && $post['user_handle'] == 'OJ')
151
-                                    {
152
-                                        ?>
148
+								if($this->isDetailedView)
149
+								{
150
+									if(isset($post['user_handle']) && $post['user_handle'] == 'OJ')
151
+									{
152
+										?>
153 153
                                         <span data-tooltip="Author">
154 154
                                             <i class="fa fa-user-o"></i> OJ |
155 155
                                         </span>
156 156
                                         <?php 
157
-                                    }
158
-                                    else
159
-                                    {
160
-                                        //Is not parent Jodel in detailed View
161
-                                        if(!array_key_exists('child_count', $post))
162
-                                        {
163
-                                            ?>
157
+									}
158
+									else
159
+									{
160
+										//Is not parent Jodel in detailed View
161
+										if(!array_key_exists('child_count', $post))
162
+										{
163
+											?>
164 164
                                             <span data-tooltip="Author">
165 165
                                                 <i class="fa fa-user-o"></i> #<?php echo $post['user_handle'];?> |
166 166
                                             </span>
167 167
                                             <?php
168
-                                        }
169
-                                    }
170
-                                }
171
-                                ?>
168
+										}
169
+									}
170
+								}
171
+								?>
172 172
 
173 173
                             <span class="tip" data-tooltip="Distance">
174 174
                                 <i class="fa fa-map-marker"></i>
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             </footer>
182 182
         </article>
183 183
     <?php
184
-    }
184
+	}
185 185
 
186 186
 
187 187
 	/**
@@ -218,147 +218,147 @@  discard block
 block discarded – undo
218 218
 		return $description;
219 219
 	}
220 220
 
221
-    function toUrl($msg = '')
222
-    {
223
-        $url = $this->baseUrl . 'index.php?country=DE' .
224
-                            '&city=' . urlencode($this->city) .
225
-                            '&hashtag=' . urlencode($this->hashtag) . 
226
-                            '&view=' . $this->view;
227
-        if($this->postId != '')
228
-        {
229
-            $url .= '&postId=' . $this->postId . 
230
-                    '&getPostDetails=TRUE';
231
-        }
221
+	function toUrl($msg = '')
222
+	{
223
+		$url = $this->baseUrl . 'index.php?country=DE' .
224
+							'&city=' . urlencode($this->city) .
225
+							'&hashtag=' . urlencode($this->hashtag) . 
226
+							'&view=' . $this->view;
227
+		if($this->postId != '')
228
+		{
229
+			$url .= '&postId=' . $this->postId . 
230
+					'&getPostDetails=TRUE';
231
+		}
232 232
 
233
-        if($msg != '')
234
-        {
235
-            $url .= '&msg=' . urlencode($msg);
236
-        }
233
+		if($msg != '')
234
+		{
235
+			$url .= '&msg=' . urlencode($msg);
236
+		}
237 237
 
238
-        return $url;
239
-    }
238
+		return $url;
239
+	}
240 240
 
241
-    function changePostId($postId)
242
-    {
243
-        $tempView = clone $this;
244
-        $tempView->postId = $postId;
245
-        $tempView->isDetailedView = TRUE;
246
-        return $tempView;
247
-    }
241
+	function changePostId($postId)
242
+	{
243
+		$tempView = clone $this;
244
+		$tempView->postId = $postId;
245
+		$tempView->isDetailedView = TRUE;
246
+		return $tempView;
247
+	}
248 248
 
249
-    function back()
250
-    {
251
-        $tempView = clone $this;
252
-        $tempView->postId = '';
253
-        return $tempView;
254
-    }
249
+	function back()
250
+	{
251
+		$tempView = clone $this;
252
+		$tempView->postId = '';
253
+		return $tempView;
254
+	}
255 255
 
256
-    function changeView($view)
257
-    {
258
-        $tempView = clone $this;
259
-        $tempView->view = $view;
260
-        return $tempView;
261
-    }
256
+	function changeView($view)
257
+	{
258
+		$tempView = clone $this;
259
+		$tempView->view = $view;
260
+		return $tempView;
261
+	}
262 262
 
263 263
 	function getPosts($jodelAccount)
264 264
 	{
265
-        if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL)
266
-        {
267
-            $accountCreator = new GetChannel();
268
-            $accountCreator->view = $this->view;
269
-            $accountCreator->setAccessToken($jodelAccount->accessToken);
270
-            $accountCreator->channel = $this->hashtag;
271
-            $accountCreator->lastPostId = $this->lastPostId;
272
-            $data = $accountCreator->execute();
273
-        }
274
-        else
275
-        {
276
-            if($this->lastPostId == '' && $this->view == 'combo')
277
-            {
278
-                $url = "/v3/posts/location/combo";
279
-            }
280
-            else
281
-            {
282
-                if($this->view == 'discussed')
283
-                {
284
-                    $url = "/v2/posts/location/discussed/";
285
-                }
286
-                else
287
-                {
288
-                    if($this->view == 'popular')
289
-                    {
290
-                        $url = "/v2/posts/location/popular/";
291
-                    }
292
-                    else
293
-                    {
294
-                        $url = "/v2/posts/location/";
295
-                    }
296
-                }
297
-            }
265
+		if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL)
266
+		{
267
+			$accountCreator = new GetChannel();
268
+			$accountCreator->view = $this->view;
269
+			$accountCreator->setAccessToken($jodelAccount->accessToken);
270
+			$accountCreator->channel = $this->hashtag;
271
+			$accountCreator->lastPostId = $this->lastPostId;
272
+			$data = $accountCreator->execute();
273
+		}
274
+		else
275
+		{
276
+			if($this->lastPostId == '' && $this->view == 'combo')
277
+			{
278
+				$url = "/v3/posts/location/combo";
279
+			}
280
+			else
281
+			{
282
+				if($this->view == 'discussed')
283
+				{
284
+					$url = "/v2/posts/location/discussed/";
285
+				}
286
+				else
287
+				{
288
+					if($this->view == 'popular')
289
+					{
290
+						$url = "/v2/posts/location/popular/";
291
+					}
292
+					else
293
+					{
294
+						$url = "/v2/posts/location/";
295
+					}
296
+				}
297
+			}
298 298
 
299
-            $accountCreator = new GetPosts();
300
-            $accountCreator->setLastPostId($this->lastPostId);
301
-            $accountCreator->setAccessToken($jodelAccount->accessToken);
302
-            $accountCreator->setUrl($url);
303
-            $accountCreator->version = 'v3';
299
+			$accountCreator = new GetPosts();
300
+			$accountCreator->setLastPostId($this->lastPostId);
301
+			$accountCreator->setAccessToken($jodelAccount->accessToken);
302
+			$accountCreator->setUrl($url);
303
+			$accountCreator->version = 'v3';
304 304
 
305
-            $config = parse_ini_file('config/config.ini.php');
306
-            $location = new Location();
307
-            $location->setLat($config['default_lat']);
308
-            $location->setLng($config['default_lng']);
309
-            $location->setCityName($config['default_location']);
310
-            $accountCreator->location = $location;
311
-            $data = $accountCreator->execute();
312
-        }
313
-    	if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent']))
314
-        {
315
-            return $data['recent'];
316
-        }
317
-        else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts']))
318
-        {
319
-            return $data['posts'];
320
-        }
321
-        else
322
-        {
323
-            if($this->lastPostId == '')
324
-            {
325
-                error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true));
326
-                //error_log(print_r($data, true));
305
+			$config = parse_ini_file('config/config.ini.php');
306
+			$location = new Location();
307
+			$location->setLat($config['default_lat']);
308
+			$location->setLng($config['default_lng']);
309
+			$location->setCityName($config['default_location']);
310
+			$accountCreator->location = $location;
311
+			$data = $accountCreator->execute();
312
+		}
313
+		if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent']))
314
+		{
315
+			return $data['recent'];
316
+		}
317
+		else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts']))
318
+		{
319
+			return $data['posts'];
320
+		}
321
+		else
322
+		{
323
+			if($this->lastPostId == '')
324
+			{
325
+				error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true));
326
+				//error_log(print_r($data, true));
327 327
 
328
-                $notFound[0] = array(
329
-                    "post_id" => "0",
330
-                    "discovered_by" => 0,
331
-                    "message" => "No more Posts found",
332
-                    "created_at" => "2017-02-11T16:44:50.385Z",
333
-                    "updated_at" => "2017-02-11T16:44:50.385Z",
334
-                    "pin_count" => 0,
335
-                    "color" => "5682a3",
336
-                    "got_thanks" => FALSE,
337
-                    "post_own" => "friend",
338
-                    "discovered" => 0,
339
-                    "distance" => 9,
340
-                    "vote_count" => 0,
341
-                    "location" =>
342
-                    array("name" => "Berlin",
343
-                      "loc_coordinates" =>
344
-                      array(
345
-                        "lat" => 0,
346
-                        "lng" => 0
347
-                      ),
348
-                      "loc_accuracy" => 0,
349
-                      "country" => "",
350
-                      "city" => "",
351
-                    ),
352
-                    "tags" =>
353
-                    array(),
354
-                    "user_handle" => "0"
355
-                );
356
-                return $notFound;
357
-            }
358
-            else
359
-            {
360
-                return FALSE;
361
-            }
362
-        }
328
+				$notFound[0] = array(
329
+					"post_id" => "0",
330
+					"discovered_by" => 0,
331
+					"message" => "No more Posts found",
332
+					"created_at" => "2017-02-11T16:44:50.385Z",
333
+					"updated_at" => "2017-02-11T16:44:50.385Z",
334
+					"pin_count" => 0,
335
+					"color" => "5682a3",
336
+					"got_thanks" => FALSE,
337
+					"post_own" => "friend",
338
+					"discovered" => 0,
339
+					"distance" => 9,
340
+					"vote_count" => 0,
341
+					"location" =>
342
+					array("name" => "Berlin",
343
+					  "loc_coordinates" =>
344
+					  array(
345
+						"lat" => 0,
346
+						"lng" => 0
347
+					  ),
348
+					  "loc_accuracy" => 0,
349
+					  "country" => "",
350
+					  "city" => "",
351
+					),
352
+					"tags" =>
353
+					array(),
354
+					"user_handle" => "0"
355
+				);
356
+				return $notFound;
357
+			}
358
+			else
359
+			{
360
+				return FALSE;
361
+			}
362
+		}
363 363
 	}
364 364
 }
Please login to merge, or discard this patch.