Completed
Push — master ( 3c0e9a...ccb03a )
by mains
02:54
created
php/Requests/AbstractRequest.php 3 patches
Indentation   +149 added lines, -149 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 = 'SDydTnTdqqaiAMfneLkqXYxamvNuUYOmkqpdiZTu';
8
-    const USERAGENT = 'Jodel/4.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
-    const CLIENT_TYPE = 'android_4.34.2';
5
+	const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26';
6
+	const APIURL = 'https://api.go-tellm.com/api';
7
+	const SECRET = 'SDydTnTdqqaiAMfneLkqXYxamvNuUYOmkqpdiZTu';
8
+	const USERAGENT = 'Jodel/4.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
+	const CLIENT_TYPE = 'android_4.34.2';
10 10
     
11
-    private $accessToken = null;
12
-    private $payLoad;
13
-    public $expects = '';
14
-    public $version = 'v2';
15
-    public $hasPayload = FALSE;
11
+	private $accessToken = null;
12
+	private $payLoad;
13
+	public $expects = '';
14
+	public $version = 'v2';
15
+	public $hasPayload = FALSE;
16 16
 
17
-    public function execute()
18
-    {
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,99 +45,99 @@  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
-                $result = json_decode($result->body, true);
82
-                error_log('Error 400 - ' . print_r($result, true));
83
-                break;
84
-            case 401:
85
-                $result = json_decode($result->body, true);
86
-                error_log('Error 401 - ' . print_r($result, true));
87
-                break;
88
-            case 404:
89
-                error_log('Error 404 - ' . print_r($result, true));
90
-                $result = json_decode($result->body, true);
91
-                break;
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
+				$result = json_decode($result->body, true);
82
+				error_log('Error 400 - ' . print_r($result, true));
83
+				break;
84
+			case 401:
85
+				$result = json_decode($result->body, true);
86
+				error_log('Error 401 - ' . print_r($result, true));
87
+				break;
88
+			case 404:
89
+				error_log('Error 404 - ' . print_r($result, true));
90
+				$result = json_decode($result->body, true);
91
+				break;
92 92
 			case 477:
93
-                $result = json_decode($result->body, true);
94
-                error_log('Error 477 - ' . print_r($result, true));
95
-                break;
96
-            case 429:
97
-                error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true));
98
-            	exit("Error 429: Too Many Requests");
99
-            	break;
100
-            case 403:
101
-                error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true));
102
-                $result = json_decode($result->body, true);
103
-                break;
104
-            case 502:
105
-                error_log('Error 502 - ' . print_r($result, true));
106
-                $result = json_decode($result->body, true);
107
-                break;
108
-            case 503:
109
-                error_log('Error 503 - ' . print_r($result, true));
110
-                $result = json_decode($result->body, true);
93
+				$result = json_decode($result->body, true);
94
+				error_log('Error 477 - ' . print_r($result, true));
95
+				break;
96
+			case 429:
97
+				error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true));
98
+				exit("Error 429: Too Many Requests");
99
+				break;
100
+			case 403:
101
+				error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true));
102
+				$result = json_decode($result->body, true);
103
+				break;
104
+			case 502:
105
+				error_log('Error 502 - ' . print_r($result, true));
106
+				$result = json_decode($result->body, true);
107
+				break;
108
+			case 503:
109
+				error_log('Error 503 - ' . print_r($result, true));
110
+				$result = json_decode($result->body, true);
111 111
 
112
-                if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable"')
113
-                {
114
-                    header('location:'.$_SERVER['PHP_SELF']); 
115
-                }
116
-                break;
117
-            default:
118
-                error_log('Error '.$result->status_code.' - unknown error');
119
-                $result = json_decode($result->body, true);
120
-        }
112
+				if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable"')
113
+				{
114
+					header('location:'.$_SERVER['PHP_SELF']); 
115
+				}
116
+				break;
117
+			default:
118
+				error_log('Error '.$result->status_code.' - unknown error');
119
+				$result = json_decode($result->body, true);
120
+		}
121 121
 
122
-        //important for account refresh
123
-        if($device_uid != '')
124
-        {
122
+		//important for account refresh
123
+		if($device_uid != '')
124
+		{
125 125
 			$result[0] = $result;
126 126
 			$result[1] = $device_uid;
127
-        }
127
+		}
128 128
 
129 129
         
130
-        /* var_dump($result); */
130
+		/* var_dump($result); */
131 131
         
132
-        return $result;
133
-    }
134
-    abstract function getPayload();
135
-    /**
136
-     * Gets Sign headers
137
-     * @return array headers
138
-     */
139
-    private function getSignHeaders()
140
-    {
132
+		return $result;
133
+	}
134
+	abstract function getPayload();
135
+	/**
136
+	 * Gets Sign headers
137
+	 * @return array headers
138
+	 */
139
+	private function getSignHeaders()
140
+	{
141 141
 			if($this->getAccessToken() == null) {
142 142
 				$payload_accessToken = "";
143 143
 			}
@@ -146,54 +146,54 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 			
148 148
 			
149
-        $headers = array(
150
-            "Connection" => "keep-alive",
151
-            "Accept-Encoding" => "gzip",
152
-            "Content-Type" => "application/json; charset=UTF-8",
153
-            "User-Agent" => self::USERAGENT
154
-        );
155
-        $timestamp = new DateTime();
156
-        $timestamp = $timestamp->format(DateTime::ATOM);
157
-        $timestamp = substr($timestamp, 0, -6);
158
-        $timestamp .= "Z";
159
-        $urlParts = parse_url($this->getFullUrl());
160
-        $url2 = "";
161
-        $req = [$this->getMethod(),
162
-            $urlParts['host'],
163
-            "443",
164
-            $urlParts['path'],
165
-            $payload_accessToken,
166
-            $timestamp,
167
-            $url2,
168
-            $this->payLoad];
169
-        $reqString = implode("%", $req);
170
-        $secret = self::SECRET;
171
-        $signature = hash_hmac('sha1', $reqString, $secret);
172
-        $signature = strtoupper($signature);
173
-        $headers['X-Authorization'] = 'HMAC ' . $signature;
174
-        $headers['X-Client-Type'] = self::CLIENT_TYPE;
175
-        $headers['X-Timestamp'] = $timestamp;
176
-        $headers['X-Api-Version'] = '0.2';
177
-        return $headers;
178
-    }
179
-    private function getFullUrl()
180
-    {
181
-        return self::APIURL . $this->getApiEndPoint();
182
-    }
183
-    abstract function getApiEndPoint();
184
-    abstract function getMethod();
185
-    /**
186
-     * @return string
187
-     */
188
-    private function getAccessToken()
189
-    {
190
-        return $this->accessToken;
191
-    }
192
-    /**
193
-     * @param string $accessToken
194
-     */
195
-    public function setAccessToken($accessToken)
196
-    {
197
-        $this->accessToken = $accessToken;
198
-    }
149
+		$headers = array(
150
+			"Connection" => "keep-alive",
151
+			"Accept-Encoding" => "gzip",
152
+			"Content-Type" => "application/json; charset=UTF-8",
153
+			"User-Agent" => self::USERAGENT
154
+		);
155
+		$timestamp = new DateTime();
156
+		$timestamp = $timestamp->format(DateTime::ATOM);
157
+		$timestamp = substr($timestamp, 0, -6);
158
+		$timestamp .= "Z";
159
+		$urlParts = parse_url($this->getFullUrl());
160
+		$url2 = "";
161
+		$req = [$this->getMethod(),
162
+			$urlParts['host'],
163
+			"443",
164
+			$urlParts['path'],
165
+			$payload_accessToken,
166
+			$timestamp,
167
+			$url2,
168
+			$this->payLoad];
169
+		$reqString = implode("%", $req);
170
+		$secret = self::SECRET;
171
+		$signature = hash_hmac('sha1', $reqString, $secret);
172
+		$signature = strtoupper($signature);
173
+		$headers['X-Authorization'] = 'HMAC ' . $signature;
174
+		$headers['X-Client-Type'] = self::CLIENT_TYPE;
175
+		$headers['X-Timestamp'] = $timestamp;
176
+		$headers['X-Api-Version'] = '0.2';
177
+		return $headers;
178
+	}
179
+	private function getFullUrl()
180
+	{
181
+		return self::APIURL . $this->getApiEndPoint();
182
+	}
183
+	abstract function getApiEndPoint();
184
+	abstract function getMethod();
185
+	/**
186
+	 * @return string
187
+	 */
188
+	private function getAccessToken()
189
+	{
190
+		return $this->accessToken;
191
+	}
192
+	/**
193
+	 * @param string $accessToken
194
+	 */
195
+	public function setAccessToken($accessToken)
196
+	{
197
+		$this->accessToken = $accessToken;
198
+	}
199 199
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         $header = $this->getSignHeaders();
30 30
         $url = $this->getFullUrl();
31 31
 
32
-        if ($this->getAccessToken()) {
32
+        if($this->getAccessToken()) {
33 33
             $header['Authorization'] = "Bearer " . $this->getAccessToken();
34 34
         }
35 35
         //Comment out to debug the Request:
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             'proxy' => '186.103.169.165:8080',
53 53
         );*/
54 54
 
55
-        switch ($this->getMethod()) {
55
+        switch($this->getMethod()) {
56 56
             case 'POST':
57 57
                 $result = Requests::post($url, $header, $this->payLoad);
58 58
                 break;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                 $result = Requests::put($url, $header, $this->payLoad);
71 71
                 break;
72 72
         }
73
-        switch ($result->status_code) {
73
+        switch($result->status_code) {
74 74
             case 200:
75 75
                 $result = json_decode($result->body, true);
76 76
                 break;
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 
112 112
                 if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable"')
113 113
                 {
114
-                    header('location:'.$_SERVER['PHP_SELF']); 
114
+                    header('location:' . $_SERVER['PHP_SELF']); 
115 115
                 }
116 116
                 break;
117 117
             default:
118
-                error_log('Error '.$result->status_code.' - unknown error');
118
+                error_log('Error ' . $result->status_code . ' - unknown error');
119 119
                 $result = json_decode($result->body, true);
120 120
         }
121 121
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     const USERAGENT = 'Jodel/4.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9 9
     const CLIENT_TYPE = 'android_4.34.2';
10 10
     
11
-    private $accessToken = null;
11
+    private $accessToken = NULL;
12 12
     private $payLoad;
13 13
     public $expects = '';
14 14
     public $version = 'v2';
@@ -72,42 +72,42 @@  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';
79 79
                 break;
80 80
             case 400:
81
-                $result = json_decode($result->body, true);
82
-                error_log('Error 400 - ' . print_r($result, true));
81
+                $result = json_decode($result->body, TRUE);
82
+                error_log('Error 400 - ' . print_r($result, TRUE));
83 83
                 break;
84 84
             case 401:
85
-                $result = json_decode($result->body, true);
86
-                error_log('Error 401 - ' . print_r($result, true));
85
+                $result = json_decode($result->body, TRUE);
86
+                error_log('Error 401 - ' . print_r($result, TRUE));
87 87
                 break;
88 88
             case 404:
89
-                error_log('Error 404 - ' . print_r($result, true));
90
-                $result = json_decode($result->body, true);
89
+                error_log('Error 404 - ' . print_r($result, TRUE));
90
+                $result = json_decode($result->body, TRUE);
91 91
                 break;
92 92
 			case 477:
93
-                $result = json_decode($result->body, true);
94
-                error_log('Error 477 - ' . print_r($result, true));
93
+                $result = json_decode($result->body, TRUE);
94
+                error_log('Error 477 - ' . print_r($result, TRUE));
95 95
                 break;
96 96
             case 429:
97
-                error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true));
97
+                error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, TRUE), TRUE));
98 98
             	exit("Error 429: Too Many Requests");
99 99
             	break;
100 100
             case 403:
101
-                error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true));
102
-                $result = json_decode($result->body, true);
101
+                error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, TRUE), TRUE));
102
+                $result = json_decode($result->body, TRUE);
103 103
                 break;
104 104
             case 502:
105
-                error_log('Error 502 - ' . print_r($result, true));
106
-                $result = json_decode($result->body, true);
105
+                error_log('Error 502 - ' . print_r($result, TRUE));
106
+                $result = json_decode($result->body, TRUE);
107 107
                 break;
108 108
             case 503:
109
-                error_log('Error 503 - ' . print_r($result, true));
110
-                $result = json_decode($result->body, true);
109
+                error_log('Error 503 - ' . print_r($result, TRUE));
110
+                $result = json_decode($result->body, TRUE);
111 111
 
112 112
                 if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable"')
113 113
                 {
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 break;
117 117
             default:
118 118
                 error_log('Error '.$result->status_code.' - unknown error');
119
-                $result = json_decode($result->body, true);
119
+                $result = json_decode($result->body, TRUE);
120 120
         }
121 121
 
122 122
         //important for account refresh
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      */
139 139
     private function getSignHeaders()
140 140
     {
141
-			if($this->getAccessToken() == null) {
141
+			if($this->getAccessToken() == NULL) {
142 142
 				$payload_accessToken = "";
143 143
 			}
144 144
 			else {
Please login to merge, or discard this patch.
vote-ajax.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 
21 21
 if((!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) && !isUserAdmin())
22 22
 {
23
-	error_log($_SERVER['REMOTE_ADDR']  . ' used a wrong password on vote-ajax.php');
24
-	$response = array("message" => $_SERVER['REMOTE_ADDR']  . ' used a wrong password on vote-ajax.php',"success" => false);
23
+	error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php');
24
+	$response = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php', "success" => false);
25 25
 	echo json_encode($response);
26 26
 	die();
27 27
 }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		}
112 112
 	}
113 113
 
114
-if (isset($captcha))
114
+if(isset($captcha))
115 115
 {
116 116
 	$response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid);
117 117
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 if((!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) && !isUserAdmin())
22 22
 {
23 23
 	error_log($_SERVER['REMOTE_ADDR']  . ' used a wrong password on vote-ajax.php');
24
-	$response = array("message" => $_SERVER['REMOTE_ADDR']  . ' used a wrong password on vote-ajax.php',"success" => false);
24
+	$response = array("message" => $_SERVER['REMOTE_ADDR']  . ' used a wrong password on vote-ajax.php',"success" => FALSE);
25 25
 	echo json_encode($response);
26 26
 	die();
27 27
 }
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 {
30 30
 
31 31
 $message = "";
32
-$success = true;
32
+$success = TRUE;
33 33
 $token = "";
34 34
 	if(isset($_POST['vote']) && isset($_POST['postId']))
35 35
 	{
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 					$response = array("success" => $jodelAccount->verifyCaptcha());
98 98
 					echo json_encode($response);
99 99
 					die();
100
-				$success = false;
100
+				$success = FALSE;
101 101
 			}
102 102
 			else
103 103
 			{
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		else
108 108
 		{
109 109
 			$message = 'There is no account available for this jodel. Please create at least one new account to vote this jodel.';
110
-			$success = false;
110
+			$success = FALSE;
111 111
 		}
112 112
 	}
113 113
 
Please login to merge, or discard this patch.