Completed
Branch master (a5e97c)
by mains
02:13
created
php/Requests/libary/Requests/Response.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -108,12 +108,12 @@
 block discarded – undo
108 108
 	 * @param boolean $allow_redirects Set to false to throw on a 3xx as well
109 109
 	 */
110 110
 	public function throw_for_status($allow_redirects = true) {
111
-		if ($this->is_redirect()) {
112
-			if (!$allow_redirects) {
111
+		if($this->is_redirect()) {
112
+			if(!$allow_redirects) {
113 113
 				throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this);
114 114
 			}
115 115
 		}
116
-		elseif (!$this->success) {
116
+		elseif(!$this->success) {
117 117
 			$exception = Requests_Exception_HTTP::get_class($this->status_code);
118 118
 			throw new $exception(null, $this);
119 119
 		}
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,11 +12,13 @@  discard block
 block discarded – undo
12 12
  * Contains a response from Requests::request()
13 13
  * @package Requests
14 14
  */
15
-class Requests_Response {
15
+class Requests_Response
16
+{
16 17
 	/**
17 18
 	 * Constructor
18 19
 	 */
19
-	public function __construct() {
20
+	public function __construct()
21
+	{
20 22
 		$this->headers = new Requests_Response_Headers();
21 23
 		$this->cookies = new Requests_Cookie_Jar();
22 24
 	}
@@ -95,7 +97,8 @@  discard block
 block discarded – undo
95 97
 	 *
96 98
 	 * @return boolean True if redirect (3xx status), false if not.
97 99
 	 */
98
-	public function is_redirect() {
100
+	public function is_redirect()
101
+	{
99 102
 		$code = $this->status_code;
100 103
 		return in_array($code, array(300, 301, 302, 303, 307)) || $code > 307 && $code < 400;
101 104
 	}
@@ -107,13 +110,17 @@  discard block
 block discarded – undo
107 110
 	 * @throws Requests_Exception_HTTP On non-successful status code. Exception class corresponds to code (e.g. {@see Requests_Exception_HTTP_404})
108 111
 	 * @param boolean $allow_redirects Set to false to throw on a 3xx as well
109 112
 	 */
110
-	public function throw_for_status($allow_redirects = true) {
111
-		if ($this->is_redirect()) {
112
-			if (!$allow_redirects) {
113
+	public function throw_for_status($allow_redirects = true)
114
+	{
115
+		if ($this->is_redirect())
116
+		{
117
+			if (!$allow_redirects)
118
+			{
113 119
 				throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this);
114 120
 			}
115 121
 		}
116
-		elseif (!$this->success) {
122
+		elseif (!$this->success)
123
+		{
117 124
 			$exception = Requests_Exception_HTTP::get_class($this->status_code);
118 125
 			throw new $exception(null, $this);
119 126
 		}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @var integer|boolean
49 49
 	 */
50
-	public $status_code = false;
50
+	public $status_code = FALSE;
51 51
 
52 52
 	/**
53 53
 	 * Protocol version, false if non-blocking
54 54
 	 * @var float|boolean
55 55
 	 */
56
-	public $protocol_version = false;
56
+	public $protocol_version = FALSE;
57 57
 
58 58
 	/**
59 59
 	 * Whether the request succeeded or not
60 60
 	 *
61 61
 	 * @var boolean
62 62
 	 */
63
-	public $success = false;
63
+	public $success = FALSE;
64 64
 
65 65
 	/**
66 66
 	 * Number of redirects the request used
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @throws Requests_Exception_HTTP On non-successful status code. Exception class corresponds to code (e.g. {@see Requests_Exception_HTTP_404})
108 108
 	 * @param boolean $allow_redirects Set to false to throw on a 3xx as well
109 109
 	 */
110
-	public function throw_for_status($allow_redirects = true) {
110
+	public function throw_for_status($allow_redirects = TRUE) {
111 111
 		if ($this->is_redirect()) {
112 112
 			if (!$allow_redirects) {
113 113
 				throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this);
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		}
116 116
 		elseif (!$this->success) {
117 117
 			$exception = Requests_Exception_HTTP::get_class($this->status_code);
118
-			throw new $exception(null, $this);
118
+			throw new $exception(NULL, $this);
119 119
 		}
120 120
 	}
121 121
 }
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception.php 2 patches
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@  discard block
 block discarded – undo
10 10
  *
11 11
  * @package Requests
12 12
  */
13
-class Requests_Exception extends Exception {
13
+class Requests_Exception extends Exception
14
+{
14 15
 	/**
15 16
 	 * Type of exception
16 17
 	 *
@@ -33,7 +34,8 @@  discard block
 block discarded – undo
33 34
 	 * @param mixed $data Associated data
34 35
 	 * @param integer $code Exception numerical code, if applicable
35 36
 	 */
36
-	public function __construct($message, $type, $data = null, $code = 0) {
37
+	public function __construct($message, $type, $data = null, $code = 0)
38
+	{
37 39
 		parent::__construct($message, $code);
38 40
 
39 41
 		$this->type = $type;
@@ -46,7 +48,8 @@  discard block
 block discarded – undo
46 48
 	 * @codeCoverageIgnore
47 49
 	 * @return string
48 50
 	 */
49
-	public function getType() {
51
+	public function getType()
52
+	{
50 53
 		return $this->type;
51 54
 	}
52 55
 
@@ -56,7 +59,8 @@  discard block
 block discarded – undo
56 59
 	 * @codeCoverageIgnore
57 60
 	 * @return mixed
58 61
 	 */
59
-	public function getData() {
62
+	public function getData()
63
+	{
60 64
 		return $this->data;
61 65
 	}
62 66
 }
63 67
\ No newline at end of file
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * @param mixed $data Associated data
34 34
 	 * @param integer $code Exception numerical code, if applicable
35 35
 	 */
36
-	public function __construct($message, $type, $data = null, $code = 0) {
36
+	public function __construct($message, $type, $data = NULL, $code = 0) {
37 37
 		parent::__construct($message, $code);
38 38
 
39 39
 		$this->type = $type;
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Auth/Basic.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	 * @param array|null $args Array of user and password. Must have exactly two elements
38 38
 	 */
39 39
 	public function __construct($args = null) {
40
-		if (is_array($args)) {
41
-			if (count($args) !== 2) {
40
+		if(is_array($args)) {
41
+			if(count($args) !== 2) {
42 42
 				throw new Requests_Exception('Invalid number of arguments', 'authbasicbadargs');
43 43
 			}
44 44
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @see fsockopen_header
54 54
 	 * @param Requests_Hooks $hooks Hook system
55 55
 	 */
56
-	public function register(Requests_Hooks &$hooks) {
56
+	public function register(Requests_Hooks&$hooks) {
57 57
 		$hooks->register('curl.before_send', array(&$this, 'curl_before_send'));
58 58
 		$hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header'));
59 59
 	}
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
  * @package Requests
16 16
  * @subpackage Authentication
17 17
  */
18
-class Requests_Auth_Basic implements Requests_Auth {
18
+class Requests_Auth_Basic implements Requests_Auth
19
+{
19 20
 	/**
20 21
 	 * Username
21 22
 	 *
@@ -36,9 +37,12 @@  discard block
 block discarded – undo
36 37
 	 * @throws Requests_Exception On incorrect number of arguments (`authbasicbadargs`)
37 38
 	 * @param array|null $args Array of user and password. Must have exactly two elements
38 39
 	 */
39
-	public function __construct($args = null) {
40
-		if (is_array($args)) {
41
-			if (count($args) !== 2) {
40
+	public function __construct($args = null)
41
+	{
42
+		if (is_array($args))
43
+		{
44
+			if (count($args) !== 2)
45
+			{
42 46
 				throw new Requests_Exception('Invalid number of arguments', 'authbasicbadargs');
43 47
 			}
44 48
 
@@ -53,7 +57,8 @@  discard block
 block discarded – undo
53 57
 	 * @see fsockopen_header
54 58
 	 * @param Requests_Hooks $hooks Hook system
55 59
 	 */
56
-	public function register(Requests_Hooks &$hooks) {
60
+	public function register(Requests_Hooks &$hooks)
61
+	{
57 62
 		$hooks->register('curl.before_send', array(&$this, 'curl_before_send'));
58 63
 		$hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header'));
59 64
 	}
@@ -63,7 +68,8 @@  discard block
 block discarded – undo
63 68
 	 *
64 69
 	 * @param resource $handle cURL resource
65 70
 	 */
66
-	public function curl_before_send(&$handle) {
71
+	public function curl_before_send(&$handle)
72
+	{
67 73
 		curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
68 74
 		curl_setopt($handle, CURLOPT_USERPWD, $this->getAuthString());
69 75
 	}
@@ -73,7 +79,8 @@  discard block
 block discarded – undo
73 79
 	 *
74 80
 	 * @param string $out HTTP header string
75 81
 	 */
76
-	public function fsockopen_header(&$out) {
82
+	public function fsockopen_header(&$out)
83
+	{
77 84
 		$out .= sprintf("Authorization: Basic %s\r\n", base64_encode($this->getAuthString()));
78 85
 	}
79 86
 
@@ -82,7 +89,8 @@  discard block
 block discarded – undo
82 89
 	 *
83 90
 	 * @return string
84 91
 	 */
85
-	public function getAuthString() {
92
+	public function getAuthString()
93
+	{
86 94
 		return $this->user . ':' . $this->pass;
87 95
 	}
88 96
 }
89 97
\ No newline at end of file
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 	 * @throws Requests_Exception On incorrect number of arguments (`authbasicbadargs`)
37 37
 	 * @param array|null $args Array of user and password. Must have exactly two elements
38 38
 	 */
39
-	public function __construct($args = null) {
39
+	public function __construct($args = NULL) {
40 40
 		if (is_array($args)) {
41 41
 			if (count($args) !== 2) {
42 42
 				throw new Requests_Exception('Invalid number of arguments', 'authbasicbadargs');
Please login to merge, or discard this patch.
php/jodel-web.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	$expiration_date;
27 27
 	$deviceUid;
28 28
 	
29
-	if ($result->num_rows > 0)
29
+	if($result->num_rows > 0)
30 30
 	{
31 31
 			// output data of each row
32 32
 			while($row = $result->fetch_assoc()) {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 	if($expiration_date <= time()) {
45 45
 		$accountCreator = new CreateUser();
46
-		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
46
+		$accountCreator->setAccessToken($access_token); //$accountData->getAccessToken());
47 47
 		$accountCreator->setDeviceUid($deviceUid);
48 48
 		$accountCreator->setLocation($location);
49 49
 		$data = $accountCreator->execute();
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 								WHERE device_uid='" . $device_uid . "'");
64 64
 
65 65
 		$success = TRUE;
66
-		if($result === false){
66
+		if($result === false) {
67 67
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
68 68
 				$success = FALSE;
69 69
 		}	
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	$result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
103 103
 					expires_in, expiration_date, distinct_id, device_uid)
104 104
 					VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type .
105
-					"','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
105
+					"','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id .
106 106
 					"','" . $device_uid . "') ");
107 107
 
108 108
 	$success = TRUE;
109
-	if($result === false){
109
+	if($result === false) {
110 110
 			$error = db_error();
111 111
 			echo $error;
112 112
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
Please login to merge, or discard this patch.
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,7 +18,8 @@  discard block
 block discarded – undo
18 18
 
19 19
 $lastPostId = "";
20 20
 
21
-function isTokenFresh(Location $location) {
21
+function isTokenFresh(Location $location)
22
+{
22 23
 	$db = new DatabaseConnect();  
23 24
 	$result = $db->query("SELECT * FROM accounts WHERE id='1'");
24 25
 	
@@ -29,7 +30,8 @@  discard block
 block discarded – undo
29 30
 	if ($result->num_rows > 0)
30 31
 	{
31 32
 			// output data of each row
32
-			while($row = $result->fetch_assoc()) {
33
+			while($row = $result->fetch_assoc())
34
+			{
33 35
 					//$access_token = $row["access_token"];
34 36
 					$expiration_date = $row["expiration_date"];
35 37
 					$deviceUid = $row["device_uid"];
@@ -41,7 +43,8 @@  discard block
 block discarded – undo
41 43
 			echo "0 results";
42 44
 	}
43 45
 
44
-	if($expiration_date <= time()) {
46
+	if($expiration_date <= time())
47
+	{
45 48
 		$accountCreator = new CreateUser();
46 49
 		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
47 50
 		$accountCreator->setDeviceUid($deviceUid);
@@ -63,7 +66,8 @@  discard block
 block discarded – undo
63 66
 								WHERE device_uid='" . $device_uid . "'");
64 67
 
65 68
 		$success = TRUE;
66
-		if($result === false){
69
+		if($result === false)
70
+		{
67 71
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
68 72
 				$success = FALSE;
69 73
 		}	
@@ -85,7 +89,8 @@  discard block
 block discarded – undo
85 89
 	return $data["karma"];
86 90
 }
87 91
 
88
-function registerAccount(Location $location) {
92
+function registerAccount(Location $location)
93
+{
89 94
 	$accountCreator = new CreateUser();
90 95
 	$accountCreator->setLocation($location);
91 96
 	$data = $accountCreator->execute();
@@ -106,7 +111,8 @@  discard block
 block discarded – undo
106 111
 					"','" . $device_uid . "') ");
107 112
 
108 113
 	$success = TRUE;
109
-	if($result === false){
114
+	if($result === false)
115
+	{
110 116
 			$error = db_error();
111 117
 			echo $error;
112 118
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
@@ -117,7 +123,7 @@  discard block
 block discarded – undo
117 123
 }
118 124
 
119 125
 function getPosts($lastPostId, $accessToken, $url)
120
-{	
126
+{
121 127
 	$accountCreator = new GetPosts();
122 128
 	$accountCreator->setLastPostId($lastPostId);
123 129
 	$accountCreator->setAccessToken($accessToken);
@@ -127,7 +133,8 @@  discard block
 block discarded – undo
127 133
 	return $data;
128 134
 }
129 135
 
130
-function createAccount() {
136
+function createAccount()
137
+{
131 138
 	$location = new Location();
132 139
 	$location->setLat(50.690399);
133 140
 	$location->setLng(10.918175);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 								WHERE device_uid='" . $device_uid . "'");
64 64
 
65 65
 		$success = TRUE;
66
-		if($result === false){
66
+		if($result === FALSE){
67 67
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
68 68
 				$success = FALSE;
69 69
 		}	
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 					"','" . $device_uid . "') ");
107 107
 
108 108
 	$success = TRUE;
109
-	if($result === false){
109
+	if($result === FALSE){
110 110
 			$error = db_error();
111 111
 			echo $error;
112 112
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
Please login to merge, or discard this patch.