Completed
Branch master (9528ad)
by Michael
04:32
created
plugins/actions/twitter/bitly.class.php 3 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -28,6 +28,10 @@  discard block
 block discarded – undo
28 28
         'expand'
29 29
         );
30 30
 
31
+    /**
32
+     * @param string $login
33
+     * @param string $apiKey
34
+     */
31 35
     public function Bitly($login, $apiKey)
32 36
     {
33 37
         $this->login = $login;
@@ -115,6 +119,10 @@  discard block
 block discarded – undo
115 119
         return $this->process('stats', $postFields);
116 120
     }
117 121
 
122
+    /**
123
+     * @param string $action
124
+     * @param string $postFields
125
+     */
118 126
     protected function process($action, $postFields) {
119 127
         $ch = curl_init( $this->api . $action);
120 128
 
@@ -134,6 +142,9 @@  discard block
 block discarded – undo
134 142
         return $response;
135 143
     }
136 144
 
145
+    /**
146
+     * @param string $format
147
+     */
137 148
     public function setReturnFormat($format)
138 149
     {
139 150
         // needed for restoration
Please login to merge, or discard this patch.
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -18,211 +18,211 @@
 block discarded – undo
18 18
 
19 19
 class Bitly {
20 20
 
21
-    protected $api = 'http://api.bit.ly/';
22
-    private $format = 'json';
23
-    private $version = '2.0.1';
24
-    private $validActions = array(
25
-        'shorten',
26
-        'stats',
27
-        'info',
28
-        'expand'
29
-        );
30
-
31
-    public function Bitly($login, $apiKey)
32
-    {
33
-        $this->login = $login;
34
-        $this->apiKey = $apiKey;
35
-        $this->statusCode = 'OK';
36
-        $this->errorMessage = '';
37
-        $this->errorCode = '';
38
-    	return true;
39
-    }
40
-
41
-    private function setError($message, $code = 101)
42
-    {
43
-    	$this->errorCode = $code;
44
-        $this->errorMessage = $message;
45
-        $this->statusCode = 'ERROR';
46
-    }
47
-
48
-    public function validAction($action)
49
-    {
50
-        if( in_array($action, $this->validActions)) {
51
-            return true;
52
-        }
53
-        $this->setError("Undefined method $action", 202);
54
-    	return false;
55
-    }
56
-
57
-    public function error()
58
-    {
59
-        $ret = array(
60
-            "errorCode" => $this->errorCode,
61
-            "errorMessage" => $this->errorMessage,
62
-            "statusCode" => $this->statusCode
63
-            );
64
-
65
-        // Function used for passing empty result sometimes.
66
-        if( $this->statusCode == 'OK') {
67
-            $ret['results'] = array();
68
-        }
69
-        if( $this->format == 'json') {
70
-            return json_encode($ret);
71
-        } else {
72
-            throw new Exception('Unsupported format');
73
-        }
74
-    }
75
-
76
-    public function shorten($message)
77
-    {
78
-
79
-        $postFields = '';
80
-        preg_match_all("/http(s?):\/\/[^( |$|\]|,|\\\)]+/i", $message, $matches);
81
-
82
-        for($i=0;$i<sizeof( $matches[0]);$i++) {
83
-            $curr = $matches[0][$i];
84
-            // ignore bitly urls
85
-            if( !strstr($curr, 'http://bit.ly')) {
86
-                $postFields .= '&longUrl=' . urlencode( $curr);
87
-            }
88
-        }
89
-
90
-        // nothing to shorten, return empty result
91
-        if( !strlen($postFields)) {
92
-            return $this->error();
93
-        }
94
-        return $this->process('shorten', $postFields);
95
-    }
96
-
97
-    public function expand($message)
98
-    {
99
-        $postFields = '&hash=' . $this->getHash($message);
100
-    	return $this->process('expand', $postFields);
101
-    }
102
-
103
-    public function info($bitlyUrl)
104
-    {
105
-        $hash = $this->getHash($bitlyUrl);
106
-        $postFields = '&hash=' . $hash;
107
-        return $this->process('info', $postFields);
108
-    }
109
-
110
-    public function stats($bitlyUrl)
111
-    {
112
-        // Take only first hash or url. Ignore others.
113
-        $a = split(',', $bitlyUrl);
114
-        $postFields = '&hash=' . $this->getHash($a[0]);
115
-        return $this->process('stats', $postFields);
116
-    }
117
-
118
-    protected function process($action, $postFields) {
119
-        $ch = curl_init( $this->api . $action);
120
-
121
-        $postFields = 'version=' . $this->version . $postFields;
122
-        $postFields .= '&format=' . $this->format;
123
-        $postFields .= '&history=1';
124
-
125
-        curl_setopt($ch, CURLOPT_USERPWD, $this->login . ':' . $this->apiKey);
126
-        curl_setopt($ch, CURLOPT_POST, 1);
127
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
128
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
129
-
130
-        $response = curl_exec($ch);
131
-
132
-        curl_close($ch);
133
-
134
-        return $response;
135
-    }
136
-
137
-    public function setReturnFormat($format)
138
-    {
139
-        // needed for restoration
140
-        $this->oldFormat = $this->format;
141
-    	$this->format = $format;
142
-        return $this->format;
143
-    }
144
-
145
-    private function restoreFormat()
146
-    {
147
-        if( !empty( $this->oldFormat)) {
148
-            $this->format = $this->oldFormat;
149
-        }
150
-        return $this->format;
151
-    }
152
-
153
-    // expect url, shortened url or hash
154
-    public function getHash($message)
155
-    {
156
-        // if url and not bit.ly get shortened first
157
-        if( strstr($message, 'http://') && !strstr($message, 'http://bit.ly')) {
158
-            $message = $this->shortenSingle($message);
159
-        }
160
-        $hash = str_replace('http://bit.ly/', '', $message);
161
-        return $hash;
162
-    }
163
-
164
-    public function shortenSingle($message)
165
-    {
166
-        $this->setReturnFormat('json');
167
-    	$data = json_decode( $this->shorten($message), true);
168
-        // return to previous state.
169
-        $this->restoreFormat();
170
-
171
-        // replace every long url with short one
172
-        foreach($data['results'] as $url => $d) {
173
-            $message = str_replace($url, $d['shortUrl'], $message);
174
-        }
175
-        return $message;
176
-    }
177
-
178
-    public function expandSingle($shortUrl)
179
-    {
180
-        $this->setReturnFormat('json');
181
-    	$data = json_decode( $this->expand($shortUrl), true);
182
-        $this->restoreFormat();
183
-        return $data['results'][ $this->getHash($shortUrl)]['longUrl'];
184
-    }
185
-
186
-    public function getInfoArray($url)
187
-    {
188
-        $this->setReturnFormat('json');
189
-    	$json = $this->info($url);
190
-        $this->restoreFormat();
191
-        $data = json_decode($json, true);
192
-
193
-        $this->infoArray = array_pop( $data['results']);
194
-        return $this->infoArray;
195
-    }
196
-
197
-    public function getStatsArray($url)
198
-    {
199
-        $this->setReturnFormat('json');
200
-    	$json = $this->stats($url);
201
-        $this->restoreFormat();
202
-        $data = json_decode($json, true);
203
-        $this->statsArray = $data['results'];
204
-        return $this->statsArray;
205
-    }
206
-
207
-    public function getClicks()
208
-    {
209
-    	return $this->statsArray['clicks'];
210
-    }
211
-    // get thumbnail (small, middle, large)
212
-    public function getThumbnail($size = 'small')
213
-    {
214
-        if( !in_array($size, array('small', 'medium', 'large'))) {
215
-            throw new Exception('Invalid size value');
216
-        }
217
-        if( empty( $this->infoArray)) {
218
-            throw new Exception('Info not loaded');
219
-        }
220
-    	return $this->infoArray['thumbnail'][$size];
221
-    }
222
-
223
-    public function getTitle()
224
-    {
225
-    	return $this->infoArray['htmlTitle'];
226
-    }
21
+	protected $api = 'http://api.bit.ly/';
22
+	private $format = 'json';
23
+	private $version = '2.0.1';
24
+	private $validActions = array(
25
+		'shorten',
26
+		'stats',
27
+		'info',
28
+		'expand'
29
+		);
30
+
31
+	public function Bitly($login, $apiKey)
32
+	{
33
+		$this->login = $login;
34
+		$this->apiKey = $apiKey;
35
+		$this->statusCode = 'OK';
36
+		$this->errorMessage = '';
37
+		$this->errorCode = '';
38
+		return true;
39
+	}
40
+
41
+	private function setError($message, $code = 101)
42
+	{
43
+		$this->errorCode = $code;
44
+		$this->errorMessage = $message;
45
+		$this->statusCode = 'ERROR';
46
+	}
47
+
48
+	public function validAction($action)
49
+	{
50
+		if( in_array($action, $this->validActions)) {
51
+			return true;
52
+		}
53
+		$this->setError("Undefined method $action", 202);
54
+		return false;
55
+	}
56
+
57
+	public function error()
58
+	{
59
+		$ret = array(
60
+			"errorCode" => $this->errorCode,
61
+			"errorMessage" => $this->errorMessage,
62
+			"statusCode" => $this->statusCode
63
+			);
64
+
65
+		// Function used for passing empty result sometimes.
66
+		if( $this->statusCode == 'OK') {
67
+			$ret['results'] = array();
68
+		}
69
+		if( $this->format == 'json') {
70
+			return json_encode($ret);
71
+		} else {
72
+			throw new Exception('Unsupported format');
73
+		}
74
+	}
75
+
76
+	public function shorten($message)
77
+	{
78
+
79
+		$postFields = '';
80
+		preg_match_all("/http(s?):\/\/[^( |$|\]|,|\\\)]+/i", $message, $matches);
81
+
82
+		for($i=0;$i<sizeof( $matches[0]);$i++) {
83
+			$curr = $matches[0][$i];
84
+			// ignore bitly urls
85
+			if( !strstr($curr, 'http://bit.ly')) {
86
+				$postFields .= '&longUrl=' . urlencode( $curr);
87
+			}
88
+		}
89
+
90
+		// nothing to shorten, return empty result
91
+		if( !strlen($postFields)) {
92
+			return $this->error();
93
+		}
94
+		return $this->process('shorten', $postFields);
95
+	}
96
+
97
+	public function expand($message)
98
+	{
99
+		$postFields = '&hash=' . $this->getHash($message);
100
+		return $this->process('expand', $postFields);
101
+	}
102
+
103
+	public function info($bitlyUrl)
104
+	{
105
+		$hash = $this->getHash($bitlyUrl);
106
+		$postFields = '&hash=' . $hash;
107
+		return $this->process('info', $postFields);
108
+	}
109
+
110
+	public function stats($bitlyUrl)
111
+	{
112
+		// Take only first hash or url. Ignore others.
113
+		$a = split(',', $bitlyUrl);
114
+		$postFields = '&hash=' . $this->getHash($a[0]);
115
+		return $this->process('stats', $postFields);
116
+	}
117
+
118
+	protected function process($action, $postFields) {
119
+		$ch = curl_init( $this->api . $action);
120
+
121
+		$postFields = 'version=' . $this->version . $postFields;
122
+		$postFields .= '&format=' . $this->format;
123
+		$postFields .= '&history=1';
124
+
125
+		curl_setopt($ch, CURLOPT_USERPWD, $this->login . ':' . $this->apiKey);
126
+		curl_setopt($ch, CURLOPT_POST, 1);
127
+		curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
128
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
129
+
130
+		$response = curl_exec($ch);
131
+
132
+		curl_close($ch);
133
+
134
+		return $response;
135
+	}
136
+
137
+	public function setReturnFormat($format)
138
+	{
139
+		// needed for restoration
140
+		$this->oldFormat = $this->format;
141
+		$this->format = $format;
142
+		return $this->format;
143
+	}
144
+
145
+	private function restoreFormat()
146
+	{
147
+		if( !empty( $this->oldFormat)) {
148
+			$this->format = $this->oldFormat;
149
+		}
150
+		return $this->format;
151
+	}
152
+
153
+	// expect url, shortened url or hash
154
+	public function getHash($message)
155
+	{
156
+		// if url and not bit.ly get shortened first
157
+		if( strstr($message, 'http://') && !strstr($message, 'http://bit.ly')) {
158
+			$message = $this->shortenSingle($message);
159
+		}
160
+		$hash = str_replace('http://bit.ly/', '', $message);
161
+		return $hash;
162
+	}
163
+
164
+	public function shortenSingle($message)
165
+	{
166
+		$this->setReturnFormat('json');
167
+		$data = json_decode( $this->shorten($message), true);
168
+		// return to previous state.
169
+		$this->restoreFormat();
170
+
171
+		// replace every long url with short one
172
+		foreach($data['results'] as $url => $d) {
173
+			$message = str_replace($url, $d['shortUrl'], $message);
174
+		}
175
+		return $message;
176
+	}
177
+
178
+	public function expandSingle($shortUrl)
179
+	{
180
+		$this->setReturnFormat('json');
181
+		$data = json_decode( $this->expand($shortUrl), true);
182
+		$this->restoreFormat();
183
+		return $data['results'][ $this->getHash($shortUrl)]['longUrl'];
184
+	}
185
+
186
+	public function getInfoArray($url)
187
+	{
188
+		$this->setReturnFormat('json');
189
+		$json = $this->info($url);
190
+		$this->restoreFormat();
191
+		$data = json_decode($json, true);
192
+
193
+		$this->infoArray = array_pop( $data['results']);
194
+		return $this->infoArray;
195
+	}
196
+
197
+	public function getStatsArray($url)
198
+	{
199
+		$this->setReturnFormat('json');
200
+		$json = $this->stats($url);
201
+		$this->restoreFormat();
202
+		$data = json_decode($json, true);
203
+		$this->statsArray = $data['results'];
204
+		return $this->statsArray;
205
+	}
206
+
207
+	public function getClicks()
208
+	{
209
+		return $this->statsArray['clicks'];
210
+	}
211
+	// get thumbnail (small, middle, large)
212
+	public function getThumbnail($size = 'small')
213
+	{
214
+		if( !in_array($size, array('small', 'medium', 'large'))) {
215
+			throw new Exception('Invalid size value');
216
+		}
217
+		if( empty( $this->infoArray)) {
218
+			throw new Exception('Info not loaded');
219
+		}
220
+		return $this->infoArray['thumbnail'][$size];
221
+	}
222
+
223
+	public function getTitle()
224
+	{
225
+		return $this->infoArray['htmlTitle'];
226
+	}
227 227
 }
228 228
 ?>
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 */
14 14
 
15
-if(class_exists("Bitly")) {
15
+if (class_exists("Bitly")) {
16 16
 	return true;
17 17
 }
18 18
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
     public function validAction($action)
49 49
     {
50
-        if( in_array($action, $this->validActions)) {
50
+        if (in_array($action, $this->validActions)) {
51 51
             return true;
52 52
         }
53 53
         $this->setError("Undefined method $action", 202);
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
             );
64 64
 
65 65
         // Function used for passing empty result sometimes.
66
-        if( $this->statusCode == 'OK') {
66
+        if ($this->statusCode == 'OK') {
67 67
             $ret['results'] = array();
68 68
         }
69
-        if( $this->format == 'json') {
69
+        if ($this->format == 'json') {
70 70
             return json_encode($ret);
71 71
         } else {
72 72
             throw new Exception('Unsupported format');
@@ -79,16 +79,16 @@  discard block
 block discarded – undo
79 79
         $postFields = '';
80 80
         preg_match_all("/http(s?):\/\/[^( |$|\]|,|\\\)]+/i", $message, $matches);
81 81
 
82
-        for($i=0;$i<sizeof( $matches[0]);$i++) {
82
+        for ($i = 0; $i < sizeof($matches[0]); $i++) {
83 83
             $curr = $matches[0][$i];
84 84
             // ignore bitly urls
85
-            if( !strstr($curr, 'http://bit.ly')) {
86
-                $postFields .= '&longUrl=' . urlencode( $curr);
85
+            if (!strstr($curr, 'http://bit.ly')) {
86
+                $postFields .= '&longUrl='.urlencode($curr);
87 87
             }
88 88
         }
89 89
 
90 90
         // nothing to shorten, return empty result
91
-        if( !strlen($postFields)) {
91
+        if (!strlen($postFields)) {
92 92
             return $this->error();
93 93
         }
94 94
         return $this->process('shorten', $postFields);
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 
97 97
     public function expand($message)
98 98
     {
99
-        $postFields = '&hash=' . $this->getHash($message);
99
+        $postFields = '&hash='.$this->getHash($message);
100 100
     	return $this->process('expand', $postFields);
101 101
     }
102 102
 
103 103
     public function info($bitlyUrl)
104 104
     {
105 105
         $hash = $this->getHash($bitlyUrl);
106
-        $postFields = '&hash=' . $hash;
106
+        $postFields = '&hash='.$hash;
107 107
         return $this->process('info', $postFields);
108 108
     }
109 109
 
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
     {
112 112
         // Take only first hash or url. Ignore others.
113 113
         $a = split(',', $bitlyUrl);
114
-        $postFields = '&hash=' . $this->getHash($a[0]);
114
+        $postFields = '&hash='.$this->getHash($a[0]);
115 115
         return $this->process('stats', $postFields);
116 116
     }
117 117
 
118 118
     protected function process($action, $postFields) {
119
-        $ch = curl_init( $this->api . $action);
119
+        $ch = curl_init($this->api.$action);
120 120
 
121
-        $postFields = 'version=' . $this->version . $postFields;
122
-        $postFields .= '&format=' . $this->format;
121
+        $postFields = 'version='.$this->version.$postFields;
122
+        $postFields .= '&format='.$this->format;
123 123
         $postFields .= '&history=1';
124 124
 
125
-        curl_setopt($ch, CURLOPT_USERPWD, $this->login . ':' . $this->apiKey);
125
+        curl_setopt($ch, CURLOPT_USERPWD, $this->login.':'.$this->apiKey);
126 126
         curl_setopt($ch, CURLOPT_POST, 1);
127 127
         curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
128 128
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
     private function restoreFormat()
146 146
     {
147
-        if( !empty( $this->oldFormat)) {
147
+        if (!empty($this->oldFormat)) {
148 148
             $this->format = $this->oldFormat;
149 149
         }
150 150
         return $this->format;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     public function getHash($message)
155 155
     {
156 156
         // if url and not bit.ly get shortened first
157
-        if( strstr($message, 'http://') && !strstr($message, 'http://bit.ly')) {
157
+        if (strstr($message, 'http://') && !strstr($message, 'http://bit.ly')) {
158 158
             $message = $this->shortenSingle($message);
159 159
         }
160 160
         $hash = str_replace('http://bit.ly/', '', $message);
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
     public function shortenSingle($message)
165 165
     {
166 166
         $this->setReturnFormat('json');
167
-    	$data = json_decode( $this->shorten($message), true);
167
+    	$data = json_decode($this->shorten($message), true);
168 168
         // return to previous state.
169 169
         $this->restoreFormat();
170 170
 
171 171
         // replace every long url with short one
172
-        foreach($data['results'] as $url => $d) {
172
+        foreach ($data['results'] as $url => $d) {
173 173
             $message = str_replace($url, $d['shortUrl'], $message);
174 174
         }
175 175
         return $message;
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     public function expandSingle($shortUrl)
179 179
     {
180 180
         $this->setReturnFormat('json');
181
-    	$data = json_decode( $this->expand($shortUrl), true);
181
+    	$data = json_decode($this->expand($shortUrl), true);
182 182
         $this->restoreFormat();
183
-        return $data['results'][ $this->getHash($shortUrl)]['longUrl'];
183
+        return $data['results'][$this->getHash($shortUrl)]['longUrl'];
184 184
     }
185 185
 
186 186
     public function getInfoArray($url)
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         $this->restoreFormat();
191 191
         $data = json_decode($json, true);
192 192
 
193
-        $this->infoArray = array_pop( $data['results']);
193
+        $this->infoArray = array_pop($data['results']);
194 194
         return $this->infoArray;
195 195
     }
196 196
 
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
     // get thumbnail (small, middle, large)
212 212
     public function getThumbnail($size = 'small')
213 213
     {
214
-        if( !in_array($size, array('small', 'medium', 'large'))) {
214
+        if (!in_array($size, array('small', 'medium', 'large'))) {
215 215
             throw new Exception('Invalid size value');
216 216
         }
217
-        if( empty( $this->infoArray)) {
217
+        if (empty($this->infoArray)) {
218 218
             throw new Exception('Info not loaded');
219 219
         }
220 220
     	return $this->infoArray['thumbnail'][$size];
Please login to merge, or discard this patch.
plugins/actions/twitter/Twitter.class.php 3 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -15,12 +15,19 @@
 block discarded – undo
15 15
 	private $debug = false;
16 16
 	public  $error = false;
17 17
 
18
+	/**
19
+	 * @param string $user
20
+	 * @param string $pass
21
+	 */
18 22
 	function __construct($user, $pass, $debug=false) {
19 23
 		// Store an auth key for the HTTP Authorization: header
20 24
 		$this->auth = base64_encode($user . ':' . $pass);
21 25
 		$this->debug = $debug;
22 26
 	}
23 27
 
28
+	/**
29
+	 * @param string $new_status
30
+	 */
24 31
 	function update($new_status) {
25 32
 		if (strlen($new_status) > 140) {
26 33
 			$this->error = "Status too long: {$new_status}.";
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * Author: Felix Oghina
6 6
  */
7 7
 
8
-if(class_exists("Twitter")) {
8
+if (class_exists("Twitter")) {
9 9
 	return true;
10 10
 }
11 11
 
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 	private $debug = false;
16 16
 	public  $error = false;
17 17
 
18
-	function __construct($user, $pass, $debug=false) {
18
+	function __construct($user, $pass, $debug = false) {
19 19
 		// Store an auth key for the HTTP Authorization: header
20
-		$this->auth = base64_encode($user . ':' . $pass);
20
+		$this->auth = base64_encode($user.':'.$pass);
21 21
 		$this->debug = $debug;
22 22
 	}
23 23
 
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 			$this->error = "Socket error #{$errno}: {$errstr}";
32 32
 			return false;
33 33
 		}
34
-		$post_data = "status=" . urlencode($new_status);
34
+		$post_data = "status=".urlencode($new_status);
35 35
 		$to_send  = "POST /statuses/update.xml HTTP/1.1\r\n";
36 36
 		$to_send .= "Host: twitter.com\r\n";
37
-		$to_send .= "Content-Length: " . strlen($post_data) . "\r\n";
37
+		$to_send .= "Content-Length: ".strlen($post_data)."\r\n";
38 38
 		$to_send .= "Authorization: Basic {$this->auth}\r\n\r\n";
39
-		$to_send .= $post_data . "\r\n\r\n";
39
+		$to_send .= $post_data."\r\n\r\n";
40 40
 		$bytes = fwrite($fp, $to_send);
41 41
 		if ($bytes === false) {
42 42
 			$this->error = "Socket error: Error sending data.";
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 		}
59 59
 		if ($this->debug) echo "Received:\n{$response}";
60 60
 		$was_error = preg_match(
61
-			"#" .
62
-			preg_quote("<error>") .
63
-			"(.+)" .
64
-			preg_quote("</error>") .
61
+			"#".
62
+			preg_quote("<error>").
63
+			"(.+)".
64
+			preg_quote("</error>").
65 65
 			"#i",
66 66
 			$response, $matches);
67 67
 		if ($was_error) {
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,12 +41,13 @@  discard block
 block discarded – undo
41 41
 		if ($bytes === false) {
42 42
 			$this->error = "Socket error: Error sending data.";
43 43
 			return false;
44
-		}
45
-		elseif ($bytes < strlen($to_send)) {
44
+		} elseif ($bytes < strlen($to_send)) {
46 45
 			$this->error = "Socket error: Could not send all data.";
47 46
 			return false;
48 47
 		}
49
-		if ($this->debug) echo "Sent:\n{$to_send}\n\n";
48
+		if ($this->debug) {
49
+			echo "Sent:\n{$to_send}\n\n";
50
+		}
50 51
 		$response = '';
51 52
 		while (!feof($fp)) {
52 53
 			$buf = fread($fp, 1024);
@@ -56,7 +57,9 @@  discard block
 block discarded – undo
56 57
 			}
57 58
 			$response .= $buf;
58 59
 		}
59
-		if ($this->debug) echo "Received:\n{$response}";
60
+		if ($this->debug) {
61
+			echo "Received:\n{$response}";
62
+		}
60 63
 		$was_error = preg_match(
61 64
 			"#" .
62 65
 			preg_quote("<error>") .
Please login to merge, or discard this patch.
class/wideimage/Exception.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-	* @package Exceptions
23
-  **/
21
+	 * @package Exceptions
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Base Exception class
Please login to merge, or discard this patch.
class/wideimage/Mapper/GIF.php 2 patches
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Mapper class for GIF files
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,10 +42,11 @@
 block discarded – undo
42 42
 			// then trying to save an image to a '' location (which results in an
43 43
 			// error, of course). And the same thing works fine for imagepng() and 
44 44
 			// imagejpeg(). It's a bug! ;)
45
-			if ($uri)
46
-				imagegif($handle, $uri);
47
-			else
48
-				imagegif($handle);
45
+			if ($uri) {
46
+							imagegif($handle, $uri);
47
+			} else {
48
+							imagegif($handle);
49
+			}
49 50
 		}
50 51
 	}
51 52
 ?>
52 53
\ No newline at end of file
Please login to merge, or discard this patch.
class/wideimage/Mapper/JPEG.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Mapper class for JPEG files
Please login to merge, or discard this patch.
class/wideimage/Mapper/GD2.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Mapper class for GD2 files
Please login to merge, or discard this patch.
class/wideimage/Mapper/PNG.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Mapper class for PNG files
Please login to merge, or discard this patch.
class/wideimage/Mapper/BMP.php 3 patches
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	include_once(WideImage::path() . '/vendor/JPEXS/bmp.php');
26 25
 	
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
     * @package Internal/Mappers
23 23
   **/
24 24
 	
25
-	include_once(WideImage::path() . '/vendor/JPEXS/bmp.php');
25
+	include_once(WideImage::path().'/vendor/JPEXS/bmp.php');
26 26
 	
27 27
 	/**
28 28
 	 * Mapper support for BMP
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,10 +41,11 @@
 block discarded – undo
41 41
 		
42 42
 		function save($handle, $uri = null)
43 43
 		{
44
-			if ($uri == null)
45
-				imagebmp($handle);
46
-			else
47
-				imagebmp($handle, $uri);
44
+			if ($uri == null) {
45
+							imagebmp($handle);
46
+			} else {
47
+							imagebmp($handle, $uri);
48
+			}
48 49
 		}
49 50
 	}
50 51
 ?>
51 52
\ No newline at end of file
Please login to merge, or discard this patch.
class/wideimage/Mapper/GD.php 2 patches
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Mappers
23
-  **/
21
+	 * @package Internal/Mappers
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Mapper class for GD files
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,10 +36,11 @@
 block discarded – undo
36 36
 		
37 37
 		function save($handle, $uri = null)
38 38
 		{
39
-			if ($uri == null)
40
-				imagegd($handle);
41
-			else
42
-				imagegd($handle, $uri);
39
+			if ($uri == null) {
40
+							imagegd($handle);
41
+			} else {
42
+							imagegd($handle, $uri);
43
+			}
43 44
 		}
44 45
 	}
45 46
 ?>
46 47
\ No newline at end of file
Please login to merge, or discard this patch.