Completed
Push — master ( 1ba5c4...027077 )
by mains
03:02
created
php/Requests/AbstractRequest.php 4 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $header = $this->getSignHeaders();
29 29
         $url = $this->getFullUrl();
30 30
 
31
-        if ($this->getAccessToken()) {
31
+        if($this->getAccessToken()) {
32 32
             $header['Authorization'] = "Bearer " . $this->getAccessToken();
33 33
         }
34 34
         //Comment out to debug the Request:
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             'proxy' => '186.103.169.165:8080',
51 51
         );*/
52 52
 
53
-        switch ($this->getMethod()) {
53
+        switch($this->getMethod()) {
54 54
             case 'POST':
55 55
                 $result = Requests::post($url, $header, $this->payLoad);
56 56
                 break;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                 $result = Requests::put($url, $header, $this->payLoad);
69 69
                 break;
70 70
         }
71
-        switch ($result->status_code) {
71
+        switch($result->status_code) {
72 72
             case 200:
73 73
                 $result = json_decode($result->body, true);
74 74
                 break;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
                 exit("Error 403: Access denied");
97 97
                 break;
98 98
             default:
99
-                error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
99
+                error_log('Error ' . $result->status_code . ' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
100 100
                 //throw  new \Exception('Unknown Error: '.$result->status_code);
101 101
         }
102 102
 
Please login to merge, or discard this patch.
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -2,20 +2,20 @@  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 = 'LDWWpuUigOnKCbCLpoNMDHCqHCWbLKPzHbnIUKIf';
8
-    const USERAGENT = 'Jodel/4.33.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
-    const CLIENT_TYPE = 'android_4.33.2';
5
+	const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26';
6
+	const APIURL = 'https://api.go-tellm.com/api';
7
+	const SECRET = 'LDWWpuUigOnKCbCLpoNMDHCqHCWbLKPzHbnIUKIf';
8
+	const USERAGENT = 'Jodel/4.33.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
+	const CLIENT_TYPE = 'android_4.33.2';
10 10
     
11
-    private $accessToken = null;
12
-    private $payLoad;
13
-    public $expects = '';
14
-    public $version = 'v2';
15
-    public $hasPayload = FALSE;
11
+	private $accessToken = null;
12
+	private $payLoad;
13
+	public $expects = '';
14
+	public $version = 'v2';
15
+	public $hasPayload = FALSE;
16 16
 
17
-    public function execute()
18
-    {
17
+	public function execute()
18
+	{
19 19
 		$result = new \stdClass();
20 20
 		        
21 21
 		$this->payLoad = $this->getPayload();
@@ -25,16 +25,16 @@  discard block
 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,86 +45,86 @@  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
-        }
73
-        switch ($result->status_code) {
74
-            case 200:
75
-                $result = json_decode($result->body, true);
76
-                break;
77
-            case 204:
78
-                $result = "Success";
79
-                break;
80
-            case 400:
81
-                //throw new \Exception('Unauthorized');
82
-                error_log('Error 400 - Fehlerhafte Anfrage'); // - JodelDeviceId:' . $deviceUid);
83
-                break;
84
-            case 401:
55
+		switch ($this->getMethod()) {
56
+			case 'POST':
57
+				$result = Requests::post($url, $header, $this->payLoad);
58
+				break;
59
+			case 'GET':
60
+				if($this->hasPayload)
61
+				{
62
+					$result = Requests::get($url, $header, $this->payLoad);
63
+				}
64
+				else
65
+				{
66
+					$result = Requests::get($url, $header);
67
+				}
68
+				break;
69
+			case 'PUT':
70
+				$result = Requests::put($url, $header, $this->payLoad);
71
+				break;
72
+		}
73
+		switch ($result->status_code) {
74
+			case 200:
75
+				$result = json_decode($result->body, true);
76
+				break;
77
+			case 204:
78
+				$result = "Success";
79
+				break;
80
+			case 400:
81
+				//throw new \Exception('Unauthorized');
82
+				error_log('Error 400 - Fehlerhafte Anfrage'); // - JodelDeviceId:' . $deviceUid);
83
+				break;
84
+			case 401:
85 85
 				//throw new \Exception('Unauthorized');
86
-                error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
87
-                break;
88
-            case 404:
89
-                //echo "Es wurde bereits gevoted";
90
-                error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid);
86
+				error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
87
+				break;
88
+			case 404:
89
+				//echo "Es wurde bereits gevoted";
90
+				error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid);
91 91
 			case 477:
92
-                //echo "Es wurde bereits gevoted";
93
-                //throw  new \Exception('Signing failed!');
94
-                error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid);
95
-                break;
96
-            case 429:
97
-                error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid);
98
-            	exit("Error 429: Too Many Requests");
99
-            	break;
100
-            case 403:
101
-                error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid);
102
-                exit("Error 403: Access denied");
103
-                break;
104
-            default:
105
-                error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
106
-                //throw  new \Exception('Unknown Error: '.$result->status_code);
107
-        }
92
+				//echo "Es wurde bereits gevoted";
93
+				//throw  new \Exception('Signing failed!');
94
+				error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid);
95
+				break;
96
+			case 429:
97
+				error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid);
98
+				exit("Error 429: Too Many Requests");
99
+				break;
100
+			case 403:
101
+				error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid);
102
+				exit("Error 403: Access denied");
103
+				break;
104
+			default:
105
+				error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
106
+				//throw  new \Exception('Unknown Error: '.$result->status_code);
107
+		}
108 108
 
109
-        if($device_uid != '')
110
-        {
109
+		if($device_uid != '')
110
+		{
111 111
 			$result[0] = $result;
112 112
 			$result[1] = $device_uid;
113 113
 	}
114 114
 
115
-        /*
115
+		/*
116 116
         var_dump($result);
117 117
         */
118 118
 
119
-        return $result;
120
-    }
121
-    abstract function getPayload();
122
-    /**
123
-     * Gets Sign headers
124
-     * @return array headers
125
-     */
126
-    private function getSignHeaders()
127
-    {
119
+		return $result;
120
+	}
121
+	abstract function getPayload();
122
+	/**
123
+	 * Gets Sign headers
124
+	 * @return array headers
125
+	 */
126
+	private function getSignHeaders()
127
+	{
128 128
 			if($this->getAccessToken() == null) {
129 129
 				$payload_accessToken = "";
130 130
 			}
@@ -133,54 +133,54 @@  discard block
 block discarded – undo
133 133
 			}
134 134
 			
135 135
 			
136
-        $headers = array(
137
-            "Connection" => "keep-alive",
138
-            "Accept-Encoding" => "gzip",
139
-            "Content-Type" => "application/json; charset=UTF-8",
140
-            "User-Agent" => self::USERAGENT
141
-        );
142
-        $timestamp = new DateTime();
143
-        $timestamp = $timestamp->format(DateTime::ATOM);
144
-        $timestamp = substr($timestamp, 0, -6);
145
-        $timestamp .= "Z";
146
-        $urlParts = parse_url($this->getFullUrl());
147
-        $url2 = "";
148
-        $req = [$this->getMethod(),
149
-            $urlParts['host'],
150
-            "443",
151
-            $urlParts['path'],
152
-            $payload_accessToken,
153
-            $timestamp,
154
-            $url2,
155
-            $this->payLoad];
156
-        $reqString = implode("%", $req);
157
-        $secret = self::SECRET;
158
-        $signature = hash_hmac('sha1', $reqString, $secret);
159
-        $signature = strtoupper($signature);
160
-        $headers['X-Authorization'] = 'HMAC ' . $signature;
161
-        $headers['X-Client-Type'] = self::CLIENT_TYPE;
162
-        $headers['X-Timestamp'] = $timestamp;
163
-        $headers['X-Api-Version'] = '0.2';
164
-        return $headers;
165
-    }
166
-    private function getFullUrl()
167
-    {
168
-        return self::APIURL . $this->getApiEndPoint();
169
-    }
170
-    abstract function getApiEndPoint();
171
-    abstract function getMethod();
172
-    /**
173
-     * @return string
174
-     */
175
-    private function getAccessToken()
176
-    {
177
-        return $this->accessToken;
178
-    }
179
-    /**
180
-     * @param string $accessToken
181
-     */
182
-    public function setAccessToken($accessToken)
183
-    {
184
-        $this->accessToken = $accessToken;
185
-    }
136
+		$headers = array(
137
+			"Connection" => "keep-alive",
138
+			"Accept-Encoding" => "gzip",
139
+			"Content-Type" => "application/json; charset=UTF-8",
140
+			"User-Agent" => self::USERAGENT
141
+		);
142
+		$timestamp = new DateTime();
143
+		$timestamp = $timestamp->format(DateTime::ATOM);
144
+		$timestamp = substr($timestamp, 0, -6);
145
+		$timestamp .= "Z";
146
+		$urlParts = parse_url($this->getFullUrl());
147
+		$url2 = "";
148
+		$req = [$this->getMethod(),
149
+			$urlParts['host'],
150
+			"443",
151
+			$urlParts['path'],
152
+			$payload_accessToken,
153
+			$timestamp,
154
+			$url2,
155
+			$this->payLoad];
156
+		$reqString = implode("%", $req);
157
+		$secret = self::SECRET;
158
+		$signature = hash_hmac('sha1', $reqString, $secret);
159
+		$signature = strtoupper($signature);
160
+		$headers['X-Authorization'] = 'HMAC ' . $signature;
161
+		$headers['X-Client-Type'] = self::CLIENT_TYPE;
162
+		$headers['X-Timestamp'] = $timestamp;
163
+		$headers['X-Api-Version'] = '0.2';
164
+		return $headers;
165
+	}
166
+	private function getFullUrl()
167
+	{
168
+		return self::APIURL . $this->getApiEndPoint();
169
+	}
170
+	abstract function getApiEndPoint();
171
+	abstract function getMethod();
172
+	/**
173
+	 * @return string
174
+	 */
175
+	private function getAccessToken()
176
+	{
177
+		return $this->accessToken;
178
+	}
179
+	/**
180
+	 * @param string $accessToken
181
+	 */
182
+	public function setAccessToken($accessToken)
183
+	{
184
+		$this->accessToken = $accessToken;
185
+	}
186 186
 }
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 = 'LDWWpuUigOnKCbCLpoNMDHCqHCWbLKPzHbnIUKIf';
@@ -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;
@@ -70,7 +73,8 @@  discard block
 block discarded – undo
70 73
                 $result = Requests::put($url, $header, $this->payLoad);
71 74
                 break;
72 75
         }
73
-        switch ($result->status_code) {
76
+        switch ($result->status_code)
77
+        {
74 78
             case 200:
75 79
                 $result = json_decode($result->body, true);
76 80
                 break;
@@ -125,10 +129,12 @@  discard block
 block discarded – undo
125 129
      */
126 130
     private function getSignHeaders()
127 131
     {
128
-			if($this->getAccessToken() == null) {
132
+			if($this->getAccessToken() == null)
133
+			{
129 134
 				$payload_accessToken = "";
130 135
 			}
131
-			else {
136
+			else
137
+			{
132 138
 				$payload_accessToken = $this->getAccessToken();
133 139
 			}
134 140
 			
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     const USERAGENT = 'Jodel/4.33.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9 9
     const CLIENT_TYPE = 'android_4.33.2';
10 10
     
11
-    private $accessToken = null;
11
+    private $accessToken = NULL;
12 12
     private $payLoad;
13 13
     public $expects = '';
14 14
     public $version = 'v2';
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         }
73 73
         switch ($result->status_code) {
74 74
             case 200:
75
-                $result = json_decode($result->body, true);
75
+                $result = json_decode($result->body, TRUE);
76 76
                 break;
77 77
             case 204:
78 78
                 $result = "Success";
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     private function getSignHeaders()
127 127
     {
128
-			if($this->getAccessToken() == null) {
128
+			if($this->getAccessToken() == NULL) {
129 129
 				$payload_accessToken = "";
130 130
 			}
131 131
 			else {
Please login to merge, or discard this patch.
php/Requests/PostCaptcha.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2,22 +2,22 @@
 block discarded – undo
2 2
 class PostCaptcha extends AbstractRequest
3 3
 {
4 4
 	public $captchaKey;
5
-    public $captchaSolution;
5
+	public $captchaSolution;
6 6
 
7
-    function getApiEndPoint()
8
-    {
9
-        return '/v3/user/verification/imageCaptcha/';
10
-    }
11
-    function getPayload()
12
-    {
13
-        return array(
14
-            'key' => $this->captchaKey,
15
-            'answer' => $this->captchaSolution,
16
-        );
17
-    }
18
-    function getMethod()
19
-    {
20
-        return 'POST';
21
-    }
7
+	function getApiEndPoint()
8
+	{
9
+		return '/v3/user/verification/imageCaptcha/';
10
+	}
11
+	function getPayload()
12
+	{
13
+		return array(
14
+			'key' => $this->captchaKey,
15
+			'answer' => $this->captchaSolution,
16
+		);
17
+	}
18
+	function getMethod()
19
+	{
20
+		return 'POST';
21
+	}
22 22
 }
23 23
 
Please login to merge, or discard this patch.
php/Requests/GetUserConfig.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@
 block discarded – undo
2 2
 class GetUserConfig extends AbstractRequest
3 3
 {
4 4
 		
5
-    function getApiEndPoint()
6
-    {
7
-        return '/v3/user/config/';
8
-    }
9
-    function getPayload()
10
-    {
11
-        return array(
12
-        );
13
-    }
14
-    function getMethod()
15
-    {
16
-        return 'GET';
17
-    }
5
+	function getApiEndPoint()
6
+	{
7
+		return '/v3/user/config/';
8
+	}
9
+	function getPayload()
10
+	{
11
+		return array(
12
+		);
13
+	}
14
+	function getMethod()
15
+	{
16
+		return 'GET';
17
+	}
18 18
 }
19 19
 
Please login to merge, or discard this patch.
php/Requests/GetCaptcha.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 class GetCaptcha extends AbstractRequest
3 3
 {		
4
-    function getApiEndPoint()
5
-    {
6
-        return '/v3/user/verification/imageCaptcha/';
7
-    }
8
-    function getPayload()
9
-    {
10
-        return array(
11
-        );
12
-    }
13
-    function getMethod()
14
-    {
15
-        return 'GET';
16
-    }
4
+	function getApiEndPoint()
5
+	{
6
+		return '/v3/user/verification/imageCaptcha/';
7
+	}
8
+	function getPayload()
9
+	{
10
+		return array(
11
+		);
12
+	}
13
+	function getMethod()
14
+	{
15
+		return 'GET';
16
+	}
17 17
 }
18 18
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 class GetCaptcha extends AbstractRequest
3
-{		
3
+{
4 4
     function getApiEndPoint()
5 5
     {
6 6
         return '/v3/user/verification/imageCaptcha/';
Please login to merge, or discard this patch.
php/Requests/GetChannel.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@
 block discarded – undo
2 2
 
3 3
 class GetChannel extends AbstractRequest
4 4
 {
5
-    /**
6
-     * @var Location
7
-     */
8
-    public $location;
9
-    public $channel;
10
-    public $hasPayload = FALSE;
5
+	/**
6
+	 * @var Location
7
+	 */
8
+	public $location;
9
+	public $channel;
10
+	public $hasPayload = FALSE;
11 11
 		
12
-    function getApiEndPoint()
13
-    {
14
-        $apiEndPoint = '/v3/posts/hashtag/combo?hashtag=' . $this->channel;
15
-        return $apiEndPoint;
16
-    }
17
-    function getPayload()
18
-    {
19
-        return array(
20
-        );
21
-    }
22
-    function getMethod()
23
-    {
24
-        return 'GET';
25
-    }
12
+	function getApiEndPoint()
13
+	{
14
+		$apiEndPoint = '/v3/posts/hashtag/combo?hashtag=' . $this->channel;
15
+		return $apiEndPoint;
16
+	}
17
+	function getPayload()
18
+	{
19
+		return array(
20
+		);
21
+	}
22
+	function getMethod()
23
+	{
24
+		return 'GET';
25
+	}
26 26
 }
Please login to merge, or discard this patch.
php/Jodel.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 class Jodel
4 4
 {
5
-    public $jodel;
5
+	public $jodel;
6 6
 
7 7
    
8 8
 }
9 9
\ No newline at end of file
Please login to merge, or discard this patch.
php/jodel-web.php 4 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
 {
44 44
     preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
45 45
 
46
-    return (isset($matches[0])) ? true : false;
46
+    return (isset($matches[0])) ? TRUE : FALSE;
47 47
 }
48 48
 
49 49
 function configPropertyExists($config, $property)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 {
44 44
     preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
45 45
 
46
-    return (isset($matches[0])) ? true : false;
46
+    return (isset($matches[0]))?true : false;
47 47
 }
48 48
 
49 49
 function configPropertyExists($config, $property)
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 function isDeviceUidInDatabase($deviceUid)
62 62
 {
63 63
     $db = new DatabaseConnect();  
64
-    $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
64
+    $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'");
65 65
 
66
-    if ($result->num_rows > 0)
66
+    if($result->num_rows > 0)
67 67
     {
68 68
         return TRUE;
69 69
     }
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 		if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId']))
86 86
 		{
87 87
 			$jodelAccountForView = new JodelAccount();
88
-			setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time()+60*60*24*365*10);
89
-			error_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid .  ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
88
+			setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time() + 60 * 60 * 24 * 365 * 10);
89
+			error_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
90 90
 			
91 91
 		}
92 92
 		else
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	//Set View
115 115
 	if(isset($_GET['view']))
116 116
 	{
117
-		switch ($_GET['view']) {
117
+		switch($_GET['view']) {
118 118
 			case 'comment':
119 119
 				$view = 'comment';
120 120
 				break;
@@ -312,13 +312,13 @@  discard block
 block discarded – undo
312 312
 		else
313 313
 		{
314 314
 			$version = 'v2';
315
-			if($view=='comment')
315
+			if($view == 'comment')
316 316
 			{
317 317
 				$url = "/v2/posts/location/discussed/";
318 318
 			}
319 319
 			else
320 320
 			{
321
-				if($view=='upVote')
321
+				if($view == 'upVote')
322 322
 				{
323 323
 					$url = "/v2/posts/location/popular/";
324 324
 				}
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 	
99 99
 	if(configPropertyExists($config, 'karmaDeviceUid'))
100
-    {
100
+	{
101 101
     	$jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']);
102 102
     }
103 103
     else
@@ -114,7 +114,8 @@  discard block
 block discarded – undo
114 114
 	//Set View
115 115
 	if(isset($_GET['view']))
116 116
 	{
117
-		switch ($_GET['view']) {
117
+		switch ($_GET['view'])
118
+		{
118 119
 			case 'comment':
119 120
 				$view = 'comment';
120 121
 				break;
@@ -151,7 +152,7 @@  discard block
 block discarded – undo
151 152
 	{
152 153
 		$jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']);
153 154
 		if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails']))
154
-        {
155
+		{
155 156
             header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId']));
156 157
         }
157 158
         else
@@ -169,7 +170,7 @@  discard block
 block discarded – undo
169 170
 
170 171
 
171 172
 	function getPosts($lastPostId, $accessToken, $url, $version = 'v2')
172
-	{	
173
+	{
173 174
 		$accountCreator = new GetPosts();
174 175
 		$accountCreator->setLastPostId($lastPostId);
175 176
 		$accountCreator->setAccessToken($accessToken);
@@ -290,7 +291,8 @@  discard block
 block discarded – undo
290 291
 
291 292
 			$posts[0] = $data;
292 293
 
293
-			if(array_key_exists('children', $data)) {
294
+			if(array_key_exists('children', $data))
295
+			{
294 296
 				foreach($data['children'] as $key => $child)
295 297
 				{
296 298
 					
Please login to merge, or discard this patch.
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -43,36 +43,36 @@  discard block
 block discarded – undo
43 43
 
44 44
 function isUserBot()
45 45
 {
46
-    preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
46
+	preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
47 47
 
48
-    return (isset($matches[0])) ? true : false;
48
+	return (isset($matches[0])) ? true : false;
49 49
 }
50 50
 
51 51
 function configPropertyExists($config, $property)
52 52
 {
53
-    if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
54
-    {
55
-        return FALSE;
56
-    }
57
-    else
58
-    {
59
-        return TRUE;
60
-    }
53
+	if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
54
+	{
55
+		return FALSE;
56
+	}
57
+	else
58
+	{
59
+		return TRUE;
60
+	}
61 61
 }
62 62
 
63 63
 function isDeviceUidInDatabase($deviceUid)
64 64
 {
65
-    $db = new DatabaseConnect();  
66
-    $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
67
-
68
-    if ($result->num_rows > 0)
69
-    {
70
-        return TRUE;
71
-    }
72
-    else
73
-    {
74
-        return FALSE;
75
-    }
65
+	$db = new DatabaseConnect();  
66
+	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
67
+
68
+	if ($result->num_rows > 0)
69
+	{
70
+		return TRUE;
71
+	}
72
+	else
73
+	{
74
+		return FALSE;
75
+	}
76 76
 }
77 77
 
78 78
 	//Check if it's a Spider or Google Bot
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 	
101 101
 	if(configPropertyExists($config, 'karmaDeviceUid'))
102
-    {
103
-    	$jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']);
104
-    }
105
-    else
106
-    {
107
-    	error_log("No Karma deviceUid set in config file");
102
+	{
103
+		$jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']);
104
+	}
105
+	else
106
+	{
107
+		error_log("No Karma deviceUid set in config file");
108 108
 		$jodelAccountForKarma = new JodelAccount($deviceUid);
109
-    }
109
+	}
110 110
 
111 111
 	$newPositionStatus = $jodelAccountForView->location->getCityName();
112 112
 
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 	{
154 154
 		$jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']);
155 155
 		if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails']))
156
-        {
157
-            header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId']));
158
-        }
159
-        else
160
-        {
161
-            header("Location: index.php#postId-" . htmlspecialchars($_GET['postId']));
162
-        }   
163
-        die();
156
+		{
157
+			header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId']));
158
+		}
159
+		else
160
+		{
161
+			header("Location: index.php#postId-" . htmlspecialchars($_GET['postId']));
162
+		}   
163
+		die();
164 164
 	}
165 165
 	
166 166
 	//SendJodel
@@ -205,32 +205,32 @@  discard block
 block discarded – undo
205 205
 			if(!array_key_exists(0, $posts))
206 206
 			{
207 207
 				$posts[0] = array(
208
-			    "post_id" => "0",
209
-			    "discovered_by" => 0,
210
-			    "message" => "Not found",
211
-			    "created_at" => "2017-02-11T16:44:50.385Z",
212
-			    "updated_at" => "2017-02-11T16:44:50.385Z",
213
-			    "pin_count" => 0,
214
-			    "color" => "FFBA00",
215
-			    "got_thanks" => FALSE,
216
-			    "post_own" => "friend",
217
-			    "discovered" => 0,
218
-			    "distance" => 9,
219
-			    "vote_count" => 0,
220
-			    "location" =>
221
-			    array("name" => "Berlin",
222
-			      "loc_coordinates" =>
223
-			      array(
224
-			        "lat" => 0,
225
-			        "lng" => 0
226
-			      ),
227
-			      "loc_accuracy" => 0,
228
-			      "country" => "",
229
-			      "city" => "",
230
-			    ),
231
-			    "tags" =>
232
-			    array(),
233
-			    "user_handle" => "0"
208
+				"post_id" => "0",
209
+				"discovered_by" => 0,
210
+				"message" => "Not found",
211
+				"created_at" => "2017-02-11T16:44:50.385Z",
212
+				"updated_at" => "2017-02-11T16:44:50.385Z",
213
+				"pin_count" => 0,
214
+				"color" => "FFBA00",
215
+				"got_thanks" => FALSE,
216
+				"post_own" => "friend",
217
+				"discovered" => 0,
218
+				"distance" => 9,
219
+				"vote_count" => 0,
220
+				"location" =>
221
+				array("name" => "Berlin",
222
+				  "loc_coordinates" =>
223
+				  array(
224
+					"lat" => 0,
225
+					"lng" => 0
226
+				  ),
227
+				  "loc_accuracy" => 0,
228
+				  "country" => "",
229
+				  "city" => "",
230
+				),
231
+				"tags" =>
232
+				array(),
233
+				"user_handle" => "0"
234 234
 			 );
235 235
 			}
236 236
 		}
@@ -239,32 +239,32 @@  discard block
 block discarded – undo
239 239
 			$posts = array();
240 240
 			$posts[0] = 
241 241
 			array(
242
-			    "post_id" => "0",
243
-			    "discovered_by" => 0,
244
-			    "message" => "Bad Request",
245
-			    "created_at" => "2017-02-11T16:44:50.385Z",
246
-			    "updated_at" => "2017-02-11T16:44:50.385Z",
247
-			    "pin_count" => 0,
248
-			    "color" => "FFBA00",
249
-			    "got_thanks" => FALSE,
250
-			    "post_own" => "friend",
251
-			    "discovered" => 0,
252
-			    "distance" => 9,
253
-			    "vote_count" => 0,
254
-			    "location" =>
255
-			    array("name" => "Berlin",
256
-			      "loc_coordinates" =>
257
-			      array(
258
-			        "lat" => 0,
259
-			        "lng" => 0
260
-			      ),
261
-			      "loc_accuracy" => 0,
262
-			      "country" => "",
263
-			      "city" => "",
264
-			    ),
265
-			    "tags" =>
266
-			    array(),
267
-			    "user_handle" => "0"
242
+				"post_id" => "0",
243
+				"discovered_by" => 0,
244
+				"message" => "Bad Request",
245
+				"created_at" => "2017-02-11T16:44:50.385Z",
246
+				"updated_at" => "2017-02-11T16:44:50.385Z",
247
+				"pin_count" => 0,
248
+				"color" => "FFBA00",
249
+				"got_thanks" => FALSE,
250
+				"post_own" => "friend",
251
+				"discovered" => 0,
252
+				"distance" => 9,
253
+				"vote_count" => 0,
254
+				"location" =>
255
+				array("name" => "Berlin",
256
+				  "loc_coordinates" =>
257
+				  array(
258
+					"lat" => 0,
259
+					"lng" => 0
260
+				  ),
261
+				  "loc_accuracy" => 0,
262
+				  "country" => "",
263
+				  "city" => "",
264
+				),
265
+				"tags" =>
266
+				array(),
267
+				"user_handle" => "0"
268 268
 			 );
269 269
 
270 270
 
Please login to merge, or discard this patch.
php/JodelAccount.php 5 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -385,6 +385,9 @@
 block discarded – undo
385 385
         }       
386 386
     }
387 387
 
388
+    /**
389
+     * @param Location $location
390
+     */
388 391
     function registerAccount($location) {
389 392
         $accountCreator = new CreateUser();
390 393
         $accountCreator->setLocation($location);
Please login to merge, or discard this patch.
Indentation   +447 added lines, -447 removed lines patch added patch discarded remove patch
@@ -2,491 +2,491 @@
 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;
16
-
17
-    //Location of the Account
18
-    public $location;
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
-        }
30
-
31
-        $this->isBot        = $isBot;
32
-        $this->location     = $this->getLocation();
33
-
34
-        if(!$this->isTokenFresh())
35
-        {
36
-            $this->refreshToken();
37
-        }
38
-        $this->accessToken  = $this->getAccessToken();
39
-    }
40
-
41
-    function isAccountVerified()
42
-    {
43
-        $accountCreator = new GetUserConfig();
44
-        $accountCreator->setAccessToken($this->accessToken);
45
-        $data = $accountCreator->execute();
46
-
47
-        return $data['verified'];
48
-    }
49
-
50
-    function locationEquals($city)
51
-    {
52
-        $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
53
-        $result = Requests::post($url);
54
-        if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
55
-        {
56
-            error_log('Error locationEquals');
57
-            return FALSE;
58
-        }
59
-        else
60
-        {
61
-            $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
62
-            $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
63
-            $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
64
-        }
65
-
66
-        $db = new DatabaseConnect();
67
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
14
+	// array of voted Jodels
15
+	public $votes;
16
+
17
+	//Location of the Account
18
+	public $location;
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
+		}
30
+
31
+		$this->isBot        = $isBot;
32
+		$this->location     = $this->getLocation();
33
+
34
+		if(!$this->isTokenFresh())
35
+		{
36
+			$this->refreshToken();
37
+		}
38
+		$this->accessToken  = $this->getAccessToken();
39
+	}
40
+
41
+	function isAccountVerified()
42
+	{
43
+		$accountCreator = new GetUserConfig();
44
+		$accountCreator->setAccessToken($this->accessToken);
45
+		$data = $accountCreator->execute();
46
+
47
+		return $data['verified'];
48
+	}
49
+
50
+	function locationEquals($city)
51
+	{
52
+		$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
53
+		$result = Requests::post($url);
54
+		if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
55
+		{
56
+			error_log('Error locationEquals');
57
+			return FALSE;
58
+		}
59
+		else
60
+		{
61
+			$name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
62
+			$lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
63
+			$lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
64
+		}
65
+
66
+		$db = new DatabaseConnect();
67
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
68 68
         
69
-        $location = new Location();
69
+		$location = new Location();
70 70
         
71
-        if ($result->num_rows > 0)
72
-        {
73
-            // output data of each row
74
-            while($row = $result->fetch_assoc())
75
-            {
76
-                $location->setLat($row['lat']);
77
-                $location->setLng($row['lng']);
78
-                $location->setCityName($row['name']);
79
-            }
80
-        }
81
-        else
82
-        {
83
-            echo "Error: 0 results";
84
-            error_log("Error no Location found - getLocation");
85
-        }
86
-
87
-        if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name)
88
-        {
89
-            return TRUE;
90
-        }  
91
-        else
92
-        {
93
-            return FALSE;
94
-        }
95
-    }
96
-
97
-    function setLocation()
98
-    {
99
-        //Is Channel or City
100
-        if(substr($_GET['city'], 0, 1) === '#')
101
-        {
102
-            return htmlspecialchars($_GET['city']) . " " . $this->location->cityName;
103
-        }                
104
-        else
105
-        {
106
-            $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
107
-            $result = Requests::post($url);
108
-            if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
109
-            {
110
-                return "0 results";
111
-            }
112
-            else
113
-            {
114
-                $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
115
-                $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
116
-                $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
117
-
118
-                $location = new Location();
119
-                $location->setLat($lat);
120
-                $location->setLng($lng);
121
-                $location->setCityName($name);
122
-                $accountCreator = new UpdateLocation();
123
-                $accountCreator->setLocation($location);
124
-                $accountCreator->setAccessToken($this->accessToken);
125
-                $data = $accountCreator->execute();
126
-
127
-                //safe location to db
128
-                $db = new DatabaseConnect();
129
-
130
-                if($data == 'Success')
131
-                {
132
-                    $result = $db->query("UPDATE accounts 
71
+		if ($result->num_rows > 0)
72
+		{
73
+			// output data of each row
74
+			while($row = $result->fetch_assoc())
75
+			{
76
+				$location->setLat($row['lat']);
77
+				$location->setLng($row['lng']);
78
+				$location->setCityName($row['name']);
79
+			}
80
+		}
81
+		else
82
+		{
83
+			echo "Error: 0 results";
84
+			error_log("Error no Location found - getLocation");
85
+		}
86
+
87
+		if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name)
88
+		{
89
+			return TRUE;
90
+		}  
91
+		else
92
+		{
93
+			return FALSE;
94
+		}
95
+	}
96
+
97
+	function setLocation()
98
+	{
99
+		//Is Channel or City
100
+		if(substr($_GET['city'], 0, 1) === '#')
101
+		{
102
+			return htmlspecialchars($_GET['city']) . " " . $this->location->cityName;
103
+		}                
104
+		else
105
+		{
106
+			$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
107
+			$result = Requests::post($url);
108
+			if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
109
+			{
110
+				return "0 results";
111
+			}
112
+			else
113
+			{
114
+				$name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
115
+				$lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
116
+				$lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
117
+
118
+				$location = new Location();
119
+				$location->setLat($lat);
120
+				$location->setLng($lng);
121
+				$location->setCityName($name);
122
+				$accountCreator = new UpdateLocation();
123
+				$accountCreator->setLocation($location);
124
+				$accountCreator->setAccessToken($this->accessToken);
125
+				$data = $accountCreator->execute();
126
+
127
+				//safe location to db
128
+				$db = new DatabaseConnect();
129
+
130
+				if($data == 'Success')
131
+				{
132
+					$result = $db->query("UPDATE accounts 
133 133
                             SET name='" . $name . "',
134 134
                                 lat='" . $lat . "',
135 135
                                 lng='" . $lng . "'
136 136
                             WHERE access_token='" . $this->accessToken . "'");
137 137
 
138
-                    if($result === false)
139
-                    {
140
-                            echo "Updating location failed: (" . $db->errno . ") " . $db->error;
141
-                    }
142
-                    else
143
-                    {
144
-                        error_log('User with JodelDeviceId:' . $this->deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
145
-                    }
146
-                }
147
-
148
-                return $name;
149
-            }
150
-        }
151
-    }
152
-
153
-    function getLocation()
154
-    {
155
-        $db = new DatabaseConnect();
156
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
138
+					if($result === false)
139
+					{
140
+							echo "Updating location failed: (" . $db->errno . ") " . $db->error;
141
+					}
142
+					else
143
+					{
144
+						error_log('User with JodelDeviceId:' . $this->deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
145
+					}
146
+				}
147
+
148
+				return $name;
149
+			}
150
+		}
151
+	}
152
+
153
+	function getLocation()
154
+	{
155
+		$db = new DatabaseConnect();
156
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
157 157
         
158
-        $location = new Location();
158
+		$location = new Location();
159 159
         
160
-        if ($result->num_rows > 0)
161
-        {
162
-            // output data of each row
163
-            while($row = $result->fetch_assoc())
164
-            {
165
-                $location->setLat($row['lat']);
166
-                $location->setLng($row['lng']);
167
-                $location->setCityName($row['name']);
168
-            }
169
-        }
170
-        else
171
-        {
172
-            echo "Error: 0 results";
173
-            error_log("Error no Location found - getLocation");
174
-        }
175
-
176
-        return $location;
177
-    }
178
-
179
-    function verifyCaptcha()
180
-    {
181
-        if(isset($_GET['deviceUid']))
182
-        {
183
-            $deviceUid = $_GET['deviceUid'];
184
-        }
185
-        if(isset($_POST['deviceUid']))
186
-        {
187
-            $deviceUid = $_POST['deviceUid'];
188
-        }
189
-        $jodelAccountForVerify = new JodelAccount($deviceUid);
190
-
191
-        $solution = $_GET['solution'];
192
-        $solution = array_map('intval', explode('-', $solution));
193
-
194
-        $accountCreator = new PostCaptcha();
195
-        $accountCreator->setAccessToken($jodelAccountForVerify->accessToken);
196
-        $accountCreator->captchaKey = $_GET['key'];
197
-        $accountCreator->captchaSolution = $solution;
198
-        $verified = $accountCreator->execute();
199
-
200
-        if(isset($verified->status_code))
201
-        {
202
-            return $verified->status_code;
203
-        }
204
-        return $verified['verified'];
205
-    }
206
-
207
-    //ToDo Spider Check
208
-    function votePostId($postId, $vote)
209
-    {
210
-        if(!$this->isAccountVerified())
211
-        {
212
-            $view = new View();
213
-            $view->showCaptcha($this->accessToken, $this->deviceUid);
214
-        }
215
-
216
-        if(!$this->hasVoted($postId))
217
-        {
218
-            if($vote == "up")
219
-            {
220
-                $accountCreator = new Upvote();
221
-            }
222
-            else if($vote == "down")
223
-            {
224
-                $accountCreator = new Downvote();
225
-            }
226
-            $accountCreator->setAccessToken($this->accessToken);
227
-            $accountCreator->postId = htmlspecialchars($postId);
228
-            $data = $accountCreator->execute();
229
-
230
-            if(array_key_exists('post', $data))
231
-            {
232
-                $this->addVoteWithPostIdAndType($postId, $vote);
233
-                return TRUE;
234
-            }
235
-            else
236
-            {
237
-                error_log("Could not vote: " . var_dump($data));
238
-                return FALSE;
239
-            } 
240
-        }
241
-        else
242
-        {
243
-            return FALSE;
244
-        }
245
-    }
246
-
247
-    //ToDo Spider Check
248
-    function sendJodel()
249
-    {
250
-        if(!$this->isAccountVerified())
251
-        {
252
-            showCaptcha($this->accessToken);
253
-        }
254
-
255
-        $accountCreator = new SendJodel();
256
-
257
-        if(isset($_POST['ancestor']))
258
-        {
259
-            $ancestor = $_POST['ancestor'];
260
-            $accountCreator->ancestor = $ancestor;
261
-        }
262
-        if(isset($_POST['color']))
263
-        {
264
-            $color = $_POST['color'];
265
-            switch ($color) {
266
-                case '8ABDB0':
267
-                    $color = '8ABDB0';
268
-                    break;
269
-                case '9EC41C':
270
-                    $color = '9EC41C';
271
-                    break;
272
-                case '06A3CB':
273
-                    $color = '06A3CB';
274
-                    break;
275
-                case 'FFBA00':
276
-                    $color = 'FFBA00';
277
-                    break;
278
-                case 'DD5F5F':
279
-                    $color = 'DD5F5F';
280
-                    break;
281
-                case 'FF9908':
282
-                    $color = 'FF9908';
283
-                    break;
284
-                default:
285
-                    $color = '8ABDB0';
286
-                    break;
287
-            }
288
-            $accountCreator->color = $color;
289
-        }
290
-
291
-        $accountCreatorLocation = new UpdateLocation();
292
-        $accountCreatorLocation->setLocation($this->location);
293
-        $accountCreatorLocation->setAccessToken($this->accessToken);
294
-        $data = $accountCreatorLocation->execute();
160
+		if ($result->num_rows > 0)
161
+		{
162
+			// output data of each row
163
+			while($row = $result->fetch_assoc())
164
+			{
165
+				$location->setLat($row['lat']);
166
+				$location->setLng($row['lng']);
167
+				$location->setCityName($row['name']);
168
+			}
169
+		}
170
+		else
171
+		{
172
+			echo "Error: 0 results";
173
+			error_log("Error no Location found - getLocation");
174
+		}
175
+
176
+		return $location;
177
+	}
178
+
179
+	function verifyCaptcha()
180
+	{
181
+		if(isset($_GET['deviceUid']))
182
+		{
183
+			$deviceUid = $_GET['deviceUid'];
184
+		}
185
+		if(isset($_POST['deviceUid']))
186
+		{
187
+			$deviceUid = $_POST['deviceUid'];
188
+		}
189
+		$jodelAccountForVerify = new JodelAccount($deviceUid);
190
+
191
+		$solution = $_GET['solution'];
192
+		$solution = array_map('intval', explode('-', $solution));
193
+
194
+		$accountCreator = new PostCaptcha();
195
+		$accountCreator->setAccessToken($jodelAccountForVerify->accessToken);
196
+		$accountCreator->captchaKey = $_GET['key'];
197
+		$accountCreator->captchaSolution = $solution;
198
+		$verified = $accountCreator->execute();
199
+
200
+		if(isset($verified->status_code))
201
+		{
202
+			return $verified->status_code;
203
+		}
204
+		return $verified['verified'];
205
+	}
206
+
207
+	//ToDo Spider Check
208
+	function votePostId($postId, $vote)
209
+	{
210
+		if(!$this->isAccountVerified())
211
+		{
212
+			$view = new View();
213
+			$view->showCaptcha($this->accessToken, $this->deviceUid);
214
+		}
215
+
216
+		if(!$this->hasVoted($postId))
217
+		{
218
+			if($vote == "up")
219
+			{
220
+				$accountCreator = new Upvote();
221
+			}
222
+			else if($vote == "down")
223
+			{
224
+				$accountCreator = new Downvote();
225
+			}
226
+			$accountCreator->setAccessToken($this->accessToken);
227
+			$accountCreator->postId = htmlspecialchars($postId);
228
+			$data = $accountCreator->execute();
229
+
230
+			if(array_key_exists('post', $data))
231
+			{
232
+				$this->addVoteWithPostIdAndType($postId, $vote);
233
+				return TRUE;
234
+			}
235
+			else
236
+			{
237
+				error_log("Could not vote: " . var_dump($data));
238
+				return FALSE;
239
+			} 
240
+		}
241
+		else
242
+		{
243
+			return FALSE;
244
+		}
245
+	}
246
+
247
+	//ToDo Spider Check
248
+	function sendJodel()
249
+	{
250
+		if(!$this->isAccountVerified())
251
+		{
252
+			showCaptcha($this->accessToken);
253
+		}
254
+
255
+		$accountCreator = new SendJodel();
256
+
257
+		if(isset($_POST['ancestor']))
258
+		{
259
+			$ancestor = $_POST['ancestor'];
260
+			$accountCreator->ancestor = $ancestor;
261
+		}
262
+		if(isset($_POST['color']))
263
+		{
264
+			$color = $_POST['color'];
265
+			switch ($color) {
266
+				case '8ABDB0':
267
+					$color = '8ABDB0';
268
+					break;
269
+				case '9EC41C':
270
+					$color = '9EC41C';
271
+					break;
272
+				case '06A3CB':
273
+					$color = '06A3CB';
274
+					break;
275
+				case 'FFBA00':
276
+					$color = 'FFBA00';
277
+					break;
278
+				case 'DD5F5F':
279
+					$color = 'DD5F5F';
280
+					break;
281
+				case 'FF9908':
282
+					$color = 'FF9908';
283
+					break;
284
+				default:
285
+					$color = '8ABDB0';
286
+					break;
287
+			}
288
+			$accountCreator->color = $color;
289
+		}
290
+
291
+		$accountCreatorLocation = new UpdateLocation();
292
+		$accountCreatorLocation->setLocation($this->location);
293
+		$accountCreatorLocation->setAccessToken($this->accessToken);
294
+		$data = $accountCreatorLocation->execute();
295 295
         
296
-        $accountCreator->location = $this->location;
296
+		$accountCreator->location = $this->location;
297 297
         
298
-        $accountCreator->setAccessToken($this->accessToken);
299
-        $data = $accountCreator->execute();
300
-
301
-        if(isset($_POST['ancestor']))
302
-        {
303
-            $actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
304
-            header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id']));
305
-            exit;
306
-        }
307
-        else
308
-        {
309
-            header('Location: ./#');
310
-            exit;
311
-        }
312
-    }
313
-
314
-    function isTokenFresh()
315
-    {
316
-        $db = new DatabaseConnect();  
317
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
318
-
319
-        if ($result->num_rows > 0)
320
-        {
321
-            // output data of each row
322
-            while($row = $result->fetch_assoc())
323
-            {
324
-                    $expiration_date = $row["expiration_date"];
325
-            }
326
-        }
327
-        else
328
-        {
329
-            error_log('0 results');
330
-        }
331
-
332
-        if($expiration_date <= time())
333
-        {
334
-           return FLASE;
335
-        }
298
+		$accountCreator->setAccessToken($this->accessToken);
299
+		$data = $accountCreator->execute();
300
+
301
+		if(isset($_POST['ancestor']))
302
+		{
303
+			$actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
304
+			header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id']));
305
+			exit;
306
+		}
307
+		else
308
+		{
309
+			header('Location: ./#');
310
+			exit;
311
+		}
312
+	}
313
+
314
+	function isTokenFresh()
315
+	{
316
+		$db = new DatabaseConnect();  
317
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
318
+
319
+		if ($result->num_rows > 0)
320
+		{
321
+			// output data of each row
322
+			while($row = $result->fetch_assoc())
323
+			{
324
+					$expiration_date = $row["expiration_date"];
325
+			}
326
+		}
327
+		else
328
+		{
329
+			error_log('0 results');
330
+		}
331
+
332
+		if($expiration_date <= time())
333
+		{
334
+		   return FLASE;
335
+		}
336 336
         
337
-        return TRUE;
338
-    }
339
-
340
-    function refreshToken()
341
-    {
342
-        $accountCreator = new CreateUser();
343
-        $accountCreator->setAccessToken($this->accessToken);
344
-        $accountCreator->setDeviceUid($this->deviceUid);
345
-        $accountCreator->setLocation($this->location);
346
-        $data = $accountCreator->execute();
347
-
348
-        $access_token = (string)$data[0]['access_token'];
349
-        $expiration_date = $data[0]['expiration_date'];
350
-        $device_uid = (string)$data[1];
337
+		return TRUE;
338
+	}
339
+
340
+	function refreshToken()
341
+	{
342
+		$accountCreator = new CreateUser();
343
+		$accountCreator->setAccessToken($this->accessToken);
344
+		$accountCreator->setDeviceUid($this->deviceUid);
345
+		$accountCreator->setLocation($this->location);
346
+		$data = $accountCreator->execute();
347
+
348
+		$access_token = (string)$data[0]['access_token'];
349
+		$expiration_date = $data[0]['expiration_date'];
350
+		$device_uid = (string)$data[1];
351 351
         
352
-        $db = new DatabaseConnect();  
353
-        $result = $db->query("UPDATE accounts 
352
+		$db = new DatabaseConnect();  
353
+		$result = $db->query("UPDATE accounts 
354 354
                                 SET access_token='" . $access_token . "',
355 355
                                     expiration_date='" . $expiration_date . "'
356 356
                                 WHERE device_uid='" . $device_uid . "'");
357 357
 
358
-        if($result === false){
359
-                error_log("Adding account failed: (" . $db->errno . ") " . $db->error);
360
-        }   
361
-    }
358
+		if($result === false){
359
+				error_log("Adding account failed: (" . $db->errno . ") " . $db->error);
360
+		}   
361
+	}
362 362
 
363 363
 
364 364
 
365
-    function getAccessToken()
366
-    {
367
-        $db = new DatabaseConnect();
368
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
365
+	function getAccessToken()
366
+	{
367
+		$db = new DatabaseConnect();
368
+		$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
369 369
         
370
-        $accessToken;
370
+		$accessToken;
371 371
         
372
-        if ($result->num_rows > 0)
373
-        {
374
-            // output data of each row
375
-            while($row = $result->fetch_assoc())
376
-            {
377
-                $accessToken = $row['access_token'];
378
-            }
379
-        }
380
-        else
381
-        {
382
-            error_log('Error: 0 results');
383
-        }
384
-
385
-        return $accessToken;
386
-    }
387
-
388
-
389
-    function getKarma()
390
-    {
391
-        $accountCreator = new GetKarma();
392
-        $accountCreator->setAccessToken($this->accessToken);
393
-        $data = $accountCreator->execute();
372
+		if ($result->num_rows > 0)
373
+		{
374
+			// output data of each row
375
+			while($row = $result->fetch_assoc())
376
+			{
377
+				$accessToken = $row['access_token'];
378
+			}
379
+		}
380
+		else
381
+		{
382
+			error_log('Error: 0 results');
383
+		}
384
+
385
+		return $accessToken;
386
+	}
387
+
388
+
389
+	function getKarma()
390
+	{
391
+		$accountCreator = new GetKarma();
392
+		$accountCreator->setAccessToken($this->accessToken);
393
+		$data = $accountCreator->execute();
394 394
         
395
-        return $data["karma"];
396
-    }
395
+		return $data["karma"];
396
+	}
397 397
 
398
-    function hasVoted($postId)
399
-    {
400
-        $db = new DatabaseConnect();
398
+	function hasVoted($postId)
399
+	{
400
+		$db = new DatabaseConnect();
401 401
 
402
-        $postId = $db->real_escape_string($postId);
402
+		$postId = $db->real_escape_string($postId);
403 403
 
404
-        $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')");
404
+		$result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')");
405 405
         
406
-        if($result === false)
407
-        {
408
-            $error = db_error();
409
-            echo $error;
410
-            error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error);
411
-        }
412
-
413
-        if($result->num_rows == 0)
414
-        {
415
-            return FALSE;
416
-        }
417
-        else
418
-        {
419
-            return TRUE;
420
-        }
421
-    }
422
-
423
-    function addVoteWithPostIdAndType($postId, $voteType)
424
-    {
425
-        $db = new DatabaseConnect();  
426
-
427
-        $postId = $db->real_escape_string($postId);
428
-        $voteType = $db->real_escape_string($voteType);
406
+		if($result === false)
407
+		{
408
+			$error = db_error();
409
+			echo $error;
410
+			error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error);
411
+		}
412
+
413
+		if($result->num_rows == 0)
414
+		{
415
+			return FALSE;
416
+		}
417
+		else
418
+		{
419
+			return TRUE;
420
+		}
421
+	}
422
+
423
+	function addVoteWithPostIdAndType($postId, $voteType)
424
+	{
425
+		$db = new DatabaseConnect();  
426
+
427
+		$postId = $db->real_escape_string($postId);
428
+		$voteType = $db->real_escape_string($voteType);
429 429
         
430
-        if($this->hasVoted($postId))
431
-        {
432
-            return "Already voted";
433
-        }
430
+		if($this->hasVoted($postId))
431
+		{
432
+			return "Already voted";
433
+		}
434 434
 
435
-        $result = $db->query("INSERT INTO votes (device_uid, postId, type)
435
+		$result = $db->query("INSERT INTO votes (device_uid, postId, type)
436 436
                         VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')");
437 437
         
438
-        if($result === false){
439
-                $error = db_error();
440
-                echo $error;
441
-                echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
442
-        }       
443
-    }
444
-
445
-    function registerAccount($location) {
446
-        $accountCreator = new CreateUser();
447
-        $accountCreator->setLocation($location);
448
-        $data = $accountCreator->execute();
438
+		if($result === false){
439
+				$error = db_error();
440
+				echo $error;
441
+				echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
442
+		}       
443
+	}
444
+
445
+	function registerAccount($location) {
446
+		$accountCreator = new CreateUser();
447
+		$accountCreator->setLocation($location);
448
+		$data = $accountCreator->execute();
449 449
         
450
-        $access_token = (string)$data[0]['access_token'];
451
-        $refresh_token = (string)$data[0]['refresh_token'];
452
-        $token_type = (string)$data[0]['token_type'];
453
-        $expires_in = $data[0]['expires_in'];
454
-        $expiration_date = $data[0]['expiration_date'];
455
-        $distinct_id = (string)$data[0]['distinct_id'];
456
-        $device_uid = (string)$data[1];
457
-
458
-        $name = $location->cityName;
459
-        $lat = $location->lat;
460
-        $lng = $location->lng;
450
+		$access_token = (string)$data[0]['access_token'];
451
+		$refresh_token = (string)$data[0]['refresh_token'];
452
+		$token_type = (string)$data[0]['token_type'];
453
+		$expires_in = $data[0]['expires_in'];
454
+		$expiration_date = $data[0]['expiration_date'];
455
+		$distinct_id = (string)$data[0]['distinct_id'];
456
+		$device_uid = (string)$data[1];
457
+
458
+		$name = $location->cityName;
459
+		$lat = $location->lat;
460
+		$lng = $location->lng;
461 461
         
462
-        $db = new DatabaseConnect();  
463
-        $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
462
+		$db = new DatabaseConnect();  
463
+		$result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
464 464
                         expires_in, expiration_date, distinct_id, device_uid, name, lat, lng)
465 465
                         VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type .
466
-                        "','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
467
-                        "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
468
-
469
-        $success = TRUE;
470
-        if($result === false){
471
-                $error = db_error();
472
-                echo $error;
473
-                echo "Adding account failed: (" . $result->errno . ") " . $result->error;
474
-                $success = FALSE;
475
-        }   
466
+						"','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
467
+						"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
468
+
469
+		$success = TRUE;
470
+		if($result === false){
471
+				$error = db_error();
472
+				echo $error;
473
+				echo "Adding account failed: (" . $result->errno . ") " . $result->error;
474
+				$success = FALSE;
475
+		}   
476 476
         
477
-        return $device_uid;
478
-    }
477
+		return $device_uid;
478
+	}
479 479
 
480
-    function createAccount()
481
-    {
482
-        $config = parse_ini_file('config/config.ini.php');
483
-        $location = new Location();
484
-        $location->setLat($config['default_lat']);
485
-        $location->setLng($config['default_lng']);
486
-        $location->setCityName($config['default_location']);
480
+	function createAccount()
481
+	{
482
+		$config = parse_ini_file('config/config.ini.php');
483
+		$location = new Location();
484
+		$location->setLat($config['default_lat']);
485
+		$location->setLng($config['default_lng']);
486
+		$location->setCityName($config['default_location']);
487 487
 
488
-        $deviceUid = $this->registerAccount($location);
488
+		$deviceUid = $this->registerAccount($location);
489 489
 
490
-        return $deviceUid;
491
-    }
490
+		return $deviceUid;
491
+	}
492 492
 }
493 493
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         {
36 36
             $this->refreshToken();
37 37
         }
38
-        $this->accessToken  = $this->getAccessToken();
38
+        $this->accessToken = $this->getAccessToken();
39 39
     }
40 40
 
41 41
     function isAccountVerified()
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
         }
65 65
 
66 66
         $db = new DatabaseConnect();
67
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
67
+        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
68 68
         
69 69
         $location = new Location();
70 70
         
71
-        if ($result->num_rows > 0)
71
+        if($result->num_rows > 0)
72 72
         {
73 73
             // output data of each row
74 74
             while($row = $result->fetch_assoc())
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                     }
142 142
                     else
143 143
                     {
144
-                        error_log('User with JodelDeviceId:' . $this->deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
144
+                        error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
145 145
                     }
146 146
                 }
147 147
 
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
     function getLocation()
154 154
     {
155 155
         $db = new DatabaseConnect();
156
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
156
+        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
157 157
         
158 158
         $location = new Location();
159 159
         
160
-        if ($result->num_rows > 0)
160
+        if($result->num_rows > 0)
161 161
         {
162 162
             // output data of each row
163 163
             while($row = $result->fetch_assoc())
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         if(isset($_POST['color']))
263 263
         {
264 264
             $color = $_POST['color'];
265
-            switch ($color) {
265
+            switch($color) {
266 266
                 case '8ABDB0':
267 267
                     $color = '8ABDB0';
268 268
                     break;
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         $db = new DatabaseConnect();  
317 317
         $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
318 318
 
319
-        if ($result->num_rows > 0)
319
+        if($result->num_rows > 0)
320 320
         {
321 321
             // output data of each row
322 322
             while($row = $result->fetch_assoc())
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                                     expiration_date='" . $expiration_date . "'
356 356
                                 WHERE device_uid='" . $device_uid . "'");
357 357
 
358
-        if($result === false){
358
+        if($result === false) {
359 359
                 error_log("Adding account failed: (" . $db->errno . ") " . $db->error);
360 360
         }   
361 361
     }
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
     function getAccessToken()
366 366
     {
367 367
         $db = new DatabaseConnect();
368
-        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid  . "'");
368
+        $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'");
369 369
         
370 370
         $accessToken;
371 371
         
372
-        if ($result->num_rows > 0)
372
+        if($result->num_rows > 0)
373 373
         {
374 374
             // output data of each row
375 375
             while($row = $result->fetch_assoc())
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
         $result = $db->query("INSERT INTO votes (device_uid, postId, type)
436 436
                         VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')");
437 437
         
438
-        if($result === false){
438
+        if($result === false) {
439 439
                 $error = db_error();
440 440
                 echo $error;
441 441
                 echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
         $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
464 464
                         expires_in, expiration_date, distinct_id, device_uid, name, lat, lng)
465 465
                         VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type .
466
-                        "','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
466
+                        "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id .
467 467
                         "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
468 468
 
469 469
         $success = TRUE;
470
-        if($result === false){
470
+        if($result === false) {
471 471
                 $error = db_error();
472 472
                 echo $error;
473 473
                 echo "Adding account failed: (" . $result->errno . ") " . $result->error;
Please login to merge, or discard this patch.
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name)
88 88
         {
89 89
             return TRUE;
90
-        }  
90
+        }
91 91
         else
92 92
         {
93 93
             return FALSE;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         if(substr($_GET['city'], 0, 1) === '#')
101 101
         {
102 102
             return htmlspecialchars($_GET['city']) . " " . $this->location->cityName;
103
-        }                
103
+        }
104 104
         else
105 105
         {
106 106
             $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
@@ -262,7 +262,8 @@  discard block
 block discarded – undo
262 262
         if(isset($_POST['color']))
263 263
         {
264 264
             $color = $_POST['color'];
265
-            switch ($color) {
265
+            switch ($color)
266
+            {
266 267
                 case '8ABDB0':
267 268
                     $color = '8ABDB0';
268 269
                     break;
@@ -355,7 +356,8 @@  discard block
 block discarded – undo
355 356
                                     expiration_date='" . $expiration_date . "'
356 357
                                 WHERE device_uid='" . $device_uid . "'");
357 358
 
358
-        if($result === false){
359
+        if($result === false)
360
+        {
359 361
                 error_log("Adding account failed: (" . $db->errno . ") " . $db->error);
360 362
         }   
361 363
     }
@@ -435,14 +437,16 @@  discard block
 block discarded – undo
435 437
         $result = $db->query("INSERT INTO votes (device_uid, postId, type)
436 438
                         VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')");
437 439
         
438
-        if($result === false){
440
+        if($result === false)
441
+        {
439 442
                 $error = db_error();
440 443
                 echo $error;
441 444
                 echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
442 445
         }       
443 446
     }
444 447
 
445
-    function registerAccount($location) {
448
+    function registerAccount($location)
449
+    {
446 450
         $accountCreator = new CreateUser();
447 451
         $accountCreator->setLocation($location);
448 452
         $data = $accountCreator->execute();
@@ -467,7 +471,8 @@  discard block
 block discarded – undo
467 471
                         "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
468 472
 
469 473
         $success = TRUE;
470
-        if($result === false){
474
+        if($result === false)
475
+        {
471 476
                 $error = db_error();
472 477
                 echo $error;
473 478
                 echo "Adding account failed: (" . $result->errno . ") " . $result->error;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -51,16 +51,16 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
53 53
         $result = Requests::post($url);
54
-        if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
54
+        if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST')
55 55
         {
56 56
             error_log('Error locationEquals');
57 57
             return FALSE;
58 58
         }
59 59
         else
60 60
         {
61
-            $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
62
-            $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
63
-            $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
61
+            $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name'];
62
+            $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat'];
63
+            $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng'];
64 64
         }
65 65
 
66 66
         $db = new DatabaseConnect();
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
         {
106 106
             $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
107 107
             $result = Requests::post($url);
108
-            if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
108
+            if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST')
109 109
             {
110 110
                 return "0 results";
111 111
             }
112 112
             else
113 113
             {
114
-                $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
115
-                $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
116
-                $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
114
+                $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name'];
115
+                $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat'];
116
+                $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng'];
117 117
 
118 118
                 $location = new Location();
119 119
                 $location->setLat($lat);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                                 lng='" . $lng . "'
136 136
                             WHERE access_token='" . $this->accessToken . "'");
137 137
 
138
-                    if($result === false)
138
+                    if($result === FALSE)
139 139
                     {
140 140
                             echo "Updating location failed: (" . $db->errno . ") " . $db->error;
141 141
                     }
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                                     expiration_date='" . $expiration_date . "'
356 356
                                 WHERE device_uid='" . $device_uid . "'");
357 357
 
358
-        if($result === false){
358
+        if($result === FALSE){
359 359
                 error_log("Adding account failed: (" . $db->errno . ") " . $db->error);
360 360
         }   
361 361
     }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
         $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')");
405 405
         
406
-        if($result === false)
406
+        if($result === FALSE)
407 407
         {
408 408
             $error = db_error();
409 409
             echo $error;
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
         $result = $db->query("INSERT INTO votes (device_uid, postId, type)
436 436
                         VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')");
437 437
         
438
-        if($result === false){
438
+        if($result === FALSE){
439 439
                 $error = db_error();
440 440
                 echo $error;
441 441
                 echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
                         "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
468 468
 
469 469
         $success = TRUE;
470
-        if($result === false){
470
+        if($result === FALSE){
471 471
                 $error = db_error();
472 472
                 echo $error;
473 473
                 echo "Adding account failed: (" . $result->errno . ") " . $result->error;
Please login to merge, or discard this patch.
php/View.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -204,6 +204,9 @@
 block discarded – undo
204 204
 		return array("image_url" => $captcha['image_url'], "key" => $captcha['key']);
205 205
 	}
206 206
 
207
+	/**
208
+	 * @param string $deviceUid
209
+	 */
207 210
 	function showCaptcha($accessToken, $deviceUid)
208 211
 	{
209 212
 		$accountCreator = new GetCaptcha();
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -9,75 +9,75 @@  discard block
 block discarded – undo
9 9
 	 * Compute HTML Code
10 10
 	 */
11 11
  	function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE)
12
-    {   //ToDO
13
-        //Replace # with link
14
-        //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
15
-
16
-        //Time to time difference
17
-        $now = new DateTime();
18
-        $d = new DateTime($post['created_at']);
19
-        $timediff = $now->diff($d);
20
-
21
-        $timediff_inSeconds = (string)$timediff->format('%s');
22
-        $timediff_inMinutes = (string)$timediff->format('%i');
23
-        $timediff_inHours = (string)$timediff->format('%h');
24
-        $timediff_inDays = (string)$timediff->format('%d');
25
-        $timediff_inMonth = (string)$timediff->format('%m');
26
-
27
-        if($timediff_inMonth!=0)
28
-        {
29
-                $timediff = $timediff_inMonth . "m";
30
-        }
31
-        else
32
-        {
33
-            if($timediff_inDays!=0)
34
-            {
35
-                $timediff = $timediff_inDays . "d";
36
-            }
37
-            else
38
-            {
39
-                if($timediff_inHours!=0)
40
-                {
41
-                    $timediff = $timediff_inHours . "h";
42
-                }
43
-                else
44
-                {
45
-                    if($timediff_inMinutes!=0)
46
-                    {
47
-                        $timediff = $timediff_inMinutes . "m";
48
-                    }
49
-                    else
50
-                    {
51
-                        $timediff = $timediff_inSeconds . "s";
52
-                    }
53
-                }
54
-            }
55
-        }
56
-
57
-
58
-        ?>
12
+	{   //ToDO
13
+		//Replace # with link
14
+		//preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
15
+
16
+		//Time to time difference
17
+		$now = new DateTime();
18
+		$d = new DateTime($post['created_at']);
19
+		$timediff = $now->diff($d);
20
+
21
+		$timediff_inSeconds = (string)$timediff->format('%s');
22
+		$timediff_inMinutes = (string)$timediff->format('%i');
23
+		$timediff_inHours = (string)$timediff->format('%h');
24
+		$timediff_inDays = (string)$timediff->format('%d');
25
+		$timediff_inMonth = (string)$timediff->format('%m');
26
+
27
+		if($timediff_inMonth!=0)
28
+		{
29
+				$timediff = $timediff_inMonth . "m";
30
+		}
31
+		else
32
+		{
33
+			if($timediff_inDays!=0)
34
+			{
35
+				$timediff = $timediff_inDays . "d";
36
+			}
37
+			else
38
+			{
39
+				if($timediff_inHours!=0)
40
+				{
41
+					$timediff = $timediff_inHours . "h";
42
+				}
43
+				else
44
+				{
45
+					if($timediff_inMinutes!=0)
46
+					{
47
+						$timediff = $timediff_inMinutes . "m";
48
+					}
49
+					else
50
+					{
51
+						$timediff = $timediff_inSeconds . "s";
52
+					}
53
+				}
54
+			}
55
+		}
56
+
57
+
58
+		?>
59 59
         <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;">
60 60
             <content>
61 61
                 <?php 
62
-                if(isset($post['image_url']))
63
-                {
64
-                    $regexRest = '/[^\w$ .!?-]+/u';
65
-
66
-                    echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
67
-                }
68
-                else {
69
-                    echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
70
-                }
71
-                ?>
62
+				if(isset($post['image_url']))
63
+				{
64
+					$regexRest = '/[^\w$ .!?-]+/u';
65
+
66
+					echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
67
+				}
68
+				else {
69
+					echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
70
+				}
71
+				?>
72 72
             </content>
73 73
             <aside>
74 74
                 <?php
75
-                    if($isDetailedView)
76
-                    {?>
75
+					if($isDetailedView)
76
+					{?>
77 77
                         <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow">
78 78
               <?php }
79
-                    else
80
-                    {?>
79
+					else
80
+					{?>
81 81
                         <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow">
82 82
               <?php } ?>
83 83
                             <i class="fa fa-angle-up fa-3x"></i>
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
                             <br />
86 86
                         <?php echo $post["vote_count"];?><br />
87 87
                 <?php
88
-                    if($isDetailedView)
89
-                    {?>
88
+					if($isDetailedView)
89
+					{?>
90 90
                         <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow">
91 91
               <?php }
92
-                    else
93
-                    {?>
92
+					else
93
+					{?>
94 94
                         <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow">
95 95
               <?php } ?>
96 96
                             <i class="fa fa-angle-down fa-3x"></i>
@@ -113,39 +113,39 @@  discard block
 block discarded – undo
113 113
                                 <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postId=<?php echo $post["post_id"];?>">
114 114
                                     <i class="fa fa-commenting-o"></i>
115 115
                                     <?php if(array_key_exists("child_count", $post)) {
116
-                                                echo $post["child_count"];
117
-                                            } else echo "0";
118
-                                    ?>
116
+												echo $post["child_count"];
117
+											} else echo "0";
118
+									?>
119 119
                                     </a>
120 120
                             </span>
121 121
                             <?php } ?>
122 122
                         </td>
123 123
                         <td class="distance">
124 124
                             <?php
125
-                                if($isDetailedView)
126
-                                {
127
-                                    if(isset($post["parent_creator"]) && $post["parent_creator"] == 1)
128
-                                    {
129
-                                        ?>
125
+								if($isDetailedView)
126
+								{
127
+									if(isset($post["parent_creator"]) && $post["parent_creator"] == 1)
128
+									{
129
+										?>
130 130
                                         <span data-tooltip="Author">
131 131
                                             <i class="fa fa-user-o"></i> OJ |
132 132
                                         </span>
133 133
                                         <?php 
134
-                                    }
135
-                                    else
136
-                                    {
137
-                                        //Is not parent Jodel in detailed View
138
-                                        if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post))
139
-                                        {
140
-                                            ?>
134
+									}
135
+									else
136
+									{
137
+										//Is not parent Jodel in detailed View
138
+										if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post))
139
+										{
140
+											?>
141 141
                                             <span data-tooltip="Author">
142 142
                                                 <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> |
143 143
                                             </span>
144 144
                                             <?php
145
-                                        }
146
-                                    }
147
-                                }
148
-                                ?>
145
+										}
146
+									}
147
+								}
148
+								?>
149 149
 
150 150
                             <span class="tip" data-tooltip="Distance">
151 151
                                 <i class="fa fa-map-marker"></i>
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             </footer>
159 159
         </article>
160 160
     <?php
161
-    }
161
+	}
162 162
 
163 163
 
164 164
 	/**
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,25 +24,25 @@  discard block
 block discarded – undo
24 24
         $timediff_inDays = (string)$timediff->format('%d');
25 25
         $timediff_inMonth = (string)$timediff->format('%m');
26 26
 
27
-        if($timediff_inMonth!=0)
27
+        if($timediff_inMonth != 0)
28 28
         {
29 29
                 $timediff = $timediff_inMonth . "m";
30 30
         }
31 31
         else
32 32
         {
33
-            if($timediff_inDays!=0)
33
+            if($timediff_inDays != 0)
34 34
             {
35 35
                 $timediff = $timediff_inDays . "d";
36 36
             }
37 37
             else
38 38
             {
39
-                if($timediff_inHours!=0)
39
+                if($timediff_inHours != 0)
40 40
                 {
41 41
                     $timediff = $timediff_inHours . "h";
42 42
                 }
43 43
                 else
44 44
                 {
45
-                    if($timediff_inMinutes!=0)
45
+                    if($timediff_inMinutes != 0)
46 46
                     {
47 47
                         $timediff = $timediff_inMinutes . "m";
48 48
                     }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 
58 58
         ?>
59
-        <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;">
59
+        <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color']; ?>;">
60 60
             <content>
61 61
                 <?php 
62 62
                 if(isset($post['image_url']))
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
                 <?php
75 75
                     if($isDetailedView)
76 76
                     {?>
77
-                        <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow">
77
+                        <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id']; ?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']); ?>" rel="nofollow">
78 78
               <?php }
79 79
                     else
80 80
                     {?>
81
-                        <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow">
81
+                        <a href="index.php?vote=up&postId=<?php echo $post['post_id']; ?>" rel="nofollow">
82 82
               <?php } ?>
83 83
                             <i class="fa fa-angle-up fa-3x"></i>
84 84
                         </a>    
85 85
                             <br />
86
-                        <?php echo $post["vote_count"];?><br />
86
+                        <?php echo $post["vote_count"]; ?><br />
87 87
                 <?php
88 88
                     if($isDetailedView)
89 89
                     {?>
90
-                        <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow">
90
+                        <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id']; ?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']); ?>" rel="nofollow">
91 91
               <?php }
92 92
                     else
93 93
                     {?>
94
-                        <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow">
94
+                        <a href="index.php?vote=down&postId=<?php echo $post['post_id']; ?>" rel="nofollow">
95 95
               <?php } ?>
96 96
                             <i class="fa fa-angle-down fa-3x"></i>
97 97
                         </a>
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
                         <td class="time">
104 104
                             <span class="tip" data-tooltip="Time">
105 105
                                 <i class="fa fa-clock-o"></i>
106
-                                <?php echo $timediff;?>
107
-                                <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span>
106
+                                <?php echo $timediff; ?>
107
+                                <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span>
108 108
                             </span> 
109 109
                         </td>
110 110
                         <td class="comments">
111 111
                             <?php if(!$isDetailedView) {?>
112 112
                             <span data-tooltip="Comments">
113
-                                <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postId=<?php echo $post["post_id"];?>">
113
+                                <a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postId=<?php echo $post["post_id"]; ?>">
114 114
                                     <i class="fa fa-commenting-o"></i>
115 115
                                     <?php if(array_key_exists("child_count", $post)) {
116 116
                                                 echo $post["child_count"];
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                                         {
140 140
                                             ?>
141 141
                                             <span data-tooltip="Author">
142
-                                                <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> |
142
+                                                <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> |
143 143
                                             </span>
144 144
                                             <?php
145 145
                                         }
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 
150 150
                             <span class="tip" data-tooltip="Distance">
151 151
                                 <i class="fa fa-map-marker"></i>
152
-                                <?php echo $post['distance'];?> km
153
-                                <span class="tiptext"><?php echo $post['location']['name'];?></span>
152
+                                <?php echo $post['distance']; ?> km
153
+                                <span class="tiptext"><?php echo $post['location']['name']; ?></span>
154 154
                             </span>
155 155
                         </td>
156 156
                     </tr>
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,7 +9,8 @@  discard block
 block discarded – undo
9 9
 	 * Compute HTML Code
10 10
 	 */
11 11
  	function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE)
12
-    {   //ToDO
12
+ 	{
13
+//ToDO
13 14
         //Replace # with link
14 15
         //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
15 16
 
@@ -65,7 +66,8 @@  discard block
 block discarded – undo
65 66
 
66 67
                     echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
67 68
                 }
68
-                else {
69
+                else
70
+                {
69 71
                     echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
70 72
                 }
71 73
                 ?>
@@ -73,11 +75,13 @@  discard block
 block discarded – undo
73 75
             <aside>
74 76
                 <?php
75 77
                     if($isDetailedView)
76
-                    {?>
78
+                    {
79
+?>
77 80
                         <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow">
78 81
               <?php }
79
-                    else
80
-                    {?>
82
+else
83
+                    {
84
+?>
81 85
                         <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow">
82 86
               <?php } ?>
83 87
                             <i class="fa fa-angle-up fa-3x"></i>
@@ -86,11 +90,13 @@  discard block
 block discarded – undo
86 90
                         <?php echo $post["vote_count"];?><br />
87 91
                 <?php
88 92
                     if($isDetailedView)
89
-                    {?>
93
+                    {
94
+?>
90 95
                         <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow">
91 96
               <?php }
92
-                    else
93
-                    {?>
97
+else
98
+                    {
99
+?>
94 100
                         <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow">
95 101
               <?php } ?>
96 102
                             <i class="fa fa-angle-down fa-3x"></i>
@@ -108,13 +114,19 @@  discard block
 block discarded – undo
108 114
                             </span> 
109 115
                         </td>
110 116
                         <td class="comments">
111
-                            <?php if(!$isDetailedView) {?>
117
+                            <?php if(!$isDetailedView)
118
+{
119
+?>
112 120
                             <span data-tooltip="Comments">
113 121
                                 <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postId=<?php echo $post["post_id"];?>">
114 122
                                     <i class="fa fa-commenting-o"></i>
115
-                                    <?php if(array_key_exists("child_count", $post)) {
123
+                                    <?php if(array_key_exists("child_count", $post))
124
+{
116 125
                                                 echo $post["child_count"];
117
-                                            } else echo "0";
126
+                                            }
127
+                                            else {
128
+                                            	echo "0";
129
+                                            }
118 130
                                     ?>
119 131
                                     </a>
120 132
                             </span>
@@ -230,7 +242,7 @@  discard block
 block discarded – undo
230 242
 	}
231 243
 
232 244
 	function getPosts($lastPostId, $accessToken, $url, $version = 'v2')
233
-	{	
245
+	{
234 246
 		$accountCreator = new GetPosts();
235 247
 		$accountCreator->setLastPostId($lastPostId);
236 248
 		$accountCreator->setAccessToken($accessToken);
Please login to merge, or discard this patch.