Completed
Pull Request — master (#8)
by
unknown
02:39
created
php/Requests/UpdateLocation.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -3,37 +3,37 @@
 block discarded – undo
3 3
 
4 4
 class UpdateLocation extends AbstractRequest {
5 5
 		 /**
6
-     * @var Location
7
-     */
8
-    public $location;
9
-    /**
10
-     * @return Location
11
-     */
12
-    public function getLocation()
13
-    {
14
-        return $this->location;
15
-    }
16
-    /**
17
-     * @param Location $location
18
-     */
19
-    public function setLocation($location)
20
-    {
21
-        $this->location = $location;
22
-    }
6
+		  * @var Location
7
+		  */
8
+	public $location;
9
+	/**
10
+	 * @return Location
11
+	 */
12
+	public function getLocation()
13
+	{
14
+		return $this->location;
15
+	}
16
+	/**
17
+	 * @param Location $location
18
+	 */
19
+	public function setLocation($location)
20
+	{
21
+		$this->location = $location;
22
+	}
23 23
 		
24
-    function getApiEndPoint()
25
-    {
26
-        return '/v2/users/location';
27
-    }
28
-    function getPayload()
29
-    {
30
-        return array(
24
+	function getApiEndPoint()
25
+	{
26
+		return '/v2/users/location';
27
+	}
28
+	function getPayload()
29
+	{
30
+		return array(
31 31
 			"location" => $this->getLocation()->toArray(),
32
-        );
33
-    }
34
-    function getMethod()
35
-    {
36
-        return 'PUT';
37
-    }
32
+		);
33
+	}
34
+	function getMethod()
35
+	{
36
+		return 'PUT';
37
+	}
38 38
 }
39 39
 
Please login to merge, or discard this patch.
php/Requests/AbstractRequest.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -2,19 +2,19 @@  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 = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG';
8
-    const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
-    const CLIENT_TYPE = 'android_4.32.2';
5
+	const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26';
6
+	const APIURL = 'https://api.go-tellm.com/api';
7
+	const SECRET = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG';
8
+	const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
+	const CLIENT_TYPE = 'android_4.32.2';
10 10
     
11
-    private $accessToken = null;
12
-    private $payLoad;
13
-    public $expects = '';
14
-    public $version = 'v2';
11
+	private $accessToken = null;
12
+	private $payLoad;
13
+	public $expects = '';
14
+	public $version = 'v2';
15 15
 
16
-    public function execute()
17
-    {
16
+	public function execute()
17
+	{
18 18
 		$result = new \stdClass();
19 19
 		        
20 20
 		$this->payLoad = $this->getPayload();
@@ -24,96 +24,96 @@  discard block
 block discarded – undo
24 24
 		}
25 25
 				
26 26
 				
27
-        $this->payLoad = json_encode($this->payLoad);
28
-        $header = $this->getSignHeaders();
29
-        $url = $this->getFullUrl();
27
+		$this->payLoad = json_encode($this->payLoad);
28
+		$header = $this->getSignHeaders();
29
+		$url = $this->getFullUrl();
30 30
 
31
-        if ($this->getAccessToken()) {
32
-            $header['Authorization'] = "Bearer " . $this->getAccessToken();
33
-        }
34
-        //Comment out to debug the Request:
31
+		if ($this->getAccessToken()) {
32
+			$header['Authorization'] = "Bearer " . $this->getAccessToken();
33
+		}
34
+		//Comment out to debug the Request:
35 35
         
36
-        /*
36
+		/*
37 37
         var_dump($url);
38 38
         var_dump($header);
39 39
         var_dump($this->payLoad);
40 40
         */
41
-        /*
41
+		/*
42 42
         $options = array(
43 43
             'timeout' => 100,
44 44
             'connect_timeout' => 100,
45 45
             'proxy' => '186.103.169.165:8080',
46 46
         );*/
47 47
 
48
-        switch ($this->getMethod()) {
49
-            case 'POST':
50
-                $result = Requests::post($url, $header, $this->payLoad);
51
-                break;
52
-            case 'GET':
53
-                if($this->version == 'v3')
54
-                {
55
-                    $result = Requests::get($url, $header);
56
-                }
57
-                else
58
-                {
59
-                    $result = Requests::get($url, $header);
60
-                }
61
-                break;
62
-            case 'PUT':
63
-                $result = Requests::put($url, $header, $this->payLoad);
64
-                break;
65
-        }
66
-        switch ($result->status_code) {
67
-            case 200:
68
-                $result = json_decode($result->body, true);
69
-                break;
70
-            case 204:
71
-                $result = "Success";
72
-                break;
73
-            case 401:
48
+		switch ($this->getMethod()) {
49
+			case 'POST':
50
+				$result = Requests::post($url, $header, $this->payLoad);
51
+				break;
52
+			case 'GET':
53
+				if($this->version == 'v3')
54
+				{
55
+					$result = Requests::get($url, $header);
56
+				}
57
+				else
58
+				{
59
+					$result = Requests::get($url, $header);
60
+				}
61
+				break;
62
+			case 'PUT':
63
+				$result = Requests::put($url, $header, $this->payLoad);
64
+				break;
65
+		}
66
+		switch ($result->status_code) {
67
+			case 200:
68
+				$result = json_decode($result->body, true);
69
+				break;
70
+			case 204:
71
+				$result = "Success";
72
+				break;
73
+			case 401:
74 74
 				//throw new \Exception('Unauthorized');
75
-                error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
76
-                break;
77
-            case 404:
78
-                //echo "Es wurde bereits gevoted";
79
-                error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid);
75
+				error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
76
+				break;
77
+			case 404:
78
+				//echo "Es wurde bereits gevoted";
79
+				error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid);
80 80
 			case 477:
81
-                //echo "Es wurde bereits gevoted";
82
-                //throw  new \Exception('Signing failed!');
83
-                error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid);
84
-                break;
85
-            case 429:
86
-                error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid);
87
-            	exit("Error 429: Too Many Requests");
88
-            	break;
89
-            case 403:
90
-                error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid);
91
-                exit("Error 403: Access denied");
92
-                break;
93
-            default:
94
-                error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
95
-                throw  new \Exception('Unknown Error: '.$result->status_code);
96
-        }
81
+				//echo "Es wurde bereits gevoted";
82
+				//throw  new \Exception('Signing failed!');
83
+				error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid);
84
+				break;
85
+			case 429:
86
+				error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid);
87
+				exit("Error 429: Too Many Requests");
88
+				break;
89
+			case 403:
90
+				error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid);
91
+				exit("Error 403: Access denied");
92
+				break;
93
+			default:
94
+				error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
95
+				throw  new \Exception('Unknown Error: '.$result->status_code);
96
+		}
97 97
 
98
-        if($device_uid != '')
99
-        {
98
+		if($device_uid != '')
99
+		{
100 100
 			$result[0] = $result;
101 101
 			$result[1] = $device_uid;
102 102
 	}
103 103
 
104 104
         
105
-        /*var_dump($result);*/
105
+		/*var_dump($result);*/
106 106
         
107 107
 
108
-        return $result;
109
-    }
110
-    abstract function getPayload();
111
-    /**
112
-     * Gets Sign headers
113
-     * @return array headers
114
-     */
115
-    private function getSignHeaders()
116
-    {
108
+		return $result;
109
+	}
110
+	abstract function getPayload();
111
+	/**
112
+	 * Gets Sign headers
113
+	 * @return array headers
114
+	 */
115
+	private function getSignHeaders()
116
+	{
117 117
 			if($this->getAccessToken() == null) {
118 118
 				$payload_accessToken = "";
119 119
 			}
@@ -122,54 +122,54 @@  discard block
 block discarded – undo
122 122
 			}
123 123
 			
124 124
 			
125
-        $headers = array(
126
-            "Connection" => "keep-alive",
127
-            "Accept-Encoding" => "gzip",
128
-            "Content-Type" => "application/json; charset=UTF-8",
129
-            "User-Agent" => self::USERAGENT
130
-        );
131
-        $timestamp = new DateTime();
132
-        $timestamp = $timestamp->format(DateTime::ATOM);
133
-        $timestamp = substr($timestamp, 0, -6);
134
-        $timestamp .= "Z";
135
-        $urlParts = parse_url($this->getFullUrl());
136
-        $url2 = "";
137
-        $req = [$this->getMethod(),
138
-            $urlParts['host'],
139
-            "443",
140
-            $urlParts['path'],
141
-            $payload_accessToken,
142
-            $timestamp,
143
-            $url2,
144
-            $this->payLoad];
145
-        $reqString = implode("%", $req);
146
-        $secret = self::SECRET;
147
-        $signature = hash_hmac('sha1', $reqString, $secret);
148
-        $signature = strtoupper($signature);
149
-        $headers['X-Authorization'] = 'HMAC ' . $signature;
150
-        $headers['X-Client-Type'] = self::CLIENT_TYPE;
151
-        $headers['X-Timestamp'] = $timestamp;
152
-        $headers['X-Api-Version'] = '0.2';
153
-        return $headers;
154
-    }
155
-    private function getFullUrl()
156
-    {
157
-        return self::APIURL . $this->getApiEndPoint();
158
-    }
159
-    abstract function getApiEndPoint();
160
-    abstract function getMethod();
161
-    /**
162
-     * @return string
163
-     */
164
-    private function getAccessToken()
165
-    {
166
-        return $this->accessToken;
167
-    }
168
-    /**
169
-     * @param string $accessToken
170
-     */
171
-    public function setAccessToken($accessToken)
172
-    {
173
-        $this->accessToken = $accessToken;
174
-    }
125
+		$headers = array(
126
+			"Connection" => "keep-alive",
127
+			"Accept-Encoding" => "gzip",
128
+			"Content-Type" => "application/json; charset=UTF-8",
129
+			"User-Agent" => self::USERAGENT
130
+		);
131
+		$timestamp = new DateTime();
132
+		$timestamp = $timestamp->format(DateTime::ATOM);
133
+		$timestamp = substr($timestamp, 0, -6);
134
+		$timestamp .= "Z";
135
+		$urlParts = parse_url($this->getFullUrl());
136
+		$url2 = "";
137
+		$req = [$this->getMethod(),
138
+			$urlParts['host'],
139
+			"443",
140
+			$urlParts['path'],
141
+			$payload_accessToken,
142
+			$timestamp,
143
+			$url2,
144
+			$this->payLoad];
145
+		$reqString = implode("%", $req);
146
+		$secret = self::SECRET;
147
+		$signature = hash_hmac('sha1', $reqString, $secret);
148
+		$signature = strtoupper($signature);
149
+		$headers['X-Authorization'] = 'HMAC ' . $signature;
150
+		$headers['X-Client-Type'] = self::CLIENT_TYPE;
151
+		$headers['X-Timestamp'] = $timestamp;
152
+		$headers['X-Api-Version'] = '0.2';
153
+		return $headers;
154
+	}
155
+	private function getFullUrl()
156
+	{
157
+		return self::APIURL . $this->getApiEndPoint();
158
+	}
159
+	abstract function getApiEndPoint();
160
+	abstract function getMethod();
161
+	/**
162
+	 * @return string
163
+	 */
164
+	private function getAccessToken()
165
+	{
166
+		return $this->accessToken;
167
+	}
168
+	/**
169
+	 * @param string $accessToken
170
+	 */
171
+	public function setAccessToken($accessToken)
172
+	{
173
+		$this->accessToken = $accessToken;
174
+	}
175 175
 }
Please login to merge, or discard this patch.
php/DatabaseConnect.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,6 +47,6 @@
 block discarded – undo
47 47
 		 
48 48
   if(!$db->query($query) || !$db->query($query2))
49 49
   {
50
-    throw new Exception($db->error($mysqli));
50
+	throw new Exception($db->error($mysqli));
51 51
   }
52 52
 
Please login to merge, or discard this patch.
php/jodel-web.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 
295 295
 	if($result->num_rows == 0)
296 296
 	{
297
-	    return FALSE;
297
+		return FALSE;
298 298
 	}
299 299
 	else
300 300
 	{
301
-	    return TRUE;
301
+		return TRUE;
302 302
 	}
303 303
 }
304 304
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 {
393 393
 	preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
394 394
 
395
-    return (isset($matches[0])) ? true : false;
395
+	return (isset($matches[0])) ? true : false;
396 396
 }
397 397
 
398 398
 function botDeviceUidIsSet($config)
Please login to merge, or discard this patch.