Completed
Branch master (9c4346)
by Patrick
10:57
created
class.FlipSession.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -26,6 +26,7 @@  discard block
 block discarded – undo
26 26
      * Get a variable from the session
27 27
      *
28 28
      * @SuppressWarnings(PHPMD.Superglobals)
29
+     * @param string $name
29 30
      */
30 31
     static function getVar($name, $default = false)
31 32
     {
@@ -43,6 +44,7 @@  discard block
 block discarded – undo
43 44
      * Set a variable in the session
44 45
      *
45 46
      * @SuppressWarnings(PHPMD.Superglobals)
47
+     * @param string $name
46 48
      */
47 49
     static function setVar($name, $value)
48 50
     {
@@ -146,6 +148,9 @@  discard block
 block discarded – undo
146 148
         }
147 149
     }
148 150
 
151
+    /**
152
+     * @param string $sessionData
153
+     */
149 154
     static function unserializePhpSession($sessionData)
150 155
     {
151 156
         $res = array();
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@
 block discarded – undo
204 204
 
205 205
     static function deleteSessionById($sid)
206 206
     {
207
-       return unlink(ini_get('session.save_path').'/sess_'.$sid); 
207
+        return unlink(ini_get('session.save_path').'/sess_'.$sid); 
208 208
     }
209 209
 }
210 210
 /* vim: set tabstop=4 shiftwidth=4 expandtab: */
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once('Autoload.php');
3
-if(!isset($_SESSION) && php_sapi_name() !== 'cli') { session_start(); }
4
-if(!isset($_SESSION['ip_address']) && isset($_SERVER['REMOTE_ADDR']))
3
+if (!isset($_SESSION) && php_sapi_name() !== 'cli') { session_start(); }
4
+if (!isset($_SESSION['ip_address']) && isset($_SERVER['REMOTE_ADDR']))
5 5
 {
6 6
     $_SESSION['ip_address'] = $_SERVER['REMOTE_ADDR'];
7 7
 }
8
-if(!isset($_SESSION['init_time']))
8
+if (!isset($_SESSION['init_time']))
9 9
 {
10 10
     $_SESSION['init_time'] = date('c');
11 11
 }
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     static function getVar($name, $default = false)
31 31
     {
32
-        if(FlipSession::doesVarExist($name))
32
+        if (FlipSession::doesVarExist($name))
33 33
         {
34 34
             return $_SESSION[$name];
35 35
         }
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
      */
57 57
     static function isLoggedIn()
58 58
     {
59
-        if(isset($_SESSION['flipside_user']))
59
+        if (isset($_SESSION['flipside_user']))
60 60
         {
61 61
             return true;
62 62
         }
63
-        else if(isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData']))
63
+        else if (isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData']))
64 64
         {
65 65
             $auth = AuthProvider::getInstance();
66 66
             return $auth->isLoggedIn($_SESSION['AuthData'], $_SESSION['AuthMethod']);
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
      */
79 79
     static function getUser()
80 80
     {
81
-        if(isset($_SESSION['flipside_user']))
81
+        if (isset($_SESSION['flipside_user']))
82 82
         {
83 83
             return $_SESSION['flipside_user'];
84 84
         }
85
-        else if(isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData']))
85
+        else if (isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData']))
86 86
         {
87 87
             $auth = AuthProvider::getInstance();
88 88
             $user = $auth->getUser($_SESSION['AuthData'], $_SESSION['AuthMethod']);
89
-            if($user !== null)
89
+            if ($user !== null)
90 90
             {
91 91
                 $_SESSION['flipside_user'] = $user;
92 92
             }
@@ -115,16 +115,16 @@  discard block
 block discarded – undo
115 115
      */
116 116
     static function getUserEmail()
117 117
     {
118
-        if(isset($_SESSION['flipside_email']))
118
+        if (isset($_SESSION['flipside_email']))
119 119
         {
120 120
             return $_SESSION['flipside_email'];
121 121
         }
122 122
         $user = FlipSession::getUser();
123
-        if($user === false || $user === null)
123
+        if ($user === false || $user === null)
124 124
         {
125 125
             return false;
126 126
         }
127
-        if(isset($user->mail) && isset($user->mail[0]))
127
+        if (isset($user->mail) && isset($user->mail[0]))
128 128
         {
129 129
             $_SESSION['flipside_email'] = $user->mail[0];
130 130
             return $_SESSION['flipside_email'];
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      */
140 140
     static function end()
141 141
     {
142
-        if(isset($_SESSION) && !empty($_SESSION))
142
+        if (isset($_SESSION) && !empty($_SESSION))
143 143
         {
144 144
             $_SESSION = array();
145 145
             session_destroy();
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
         $res = array();
152 152
         $offset = 0;
153 153
         $length = strlen($sessionData);
154
-        while($offset < $length)
154
+        while ($offset < $length)
155 155
         {
156 156
             $pos = strpos($sessionData, "|", $offset);
157 157
             $len = $pos - $offset;
158 158
             $name = substr($sessionData, $offset, $len);
159
-            if($name === false) break;
160
-            $offset += $len+1;
159
+            if ($name === false) break;
160
+            $offset += $len + 1;
161 161
             $data = @unserialize(substr($sessionData, $offset));
162 162
             $res[$name] = $data;
163 163
             $offset += strlen(serialize($data));
@@ -170,26 +170,26 @@  discard block
 block discarded – undo
170 170
         $res = array();
171 171
         $sessFiles = scandir(ini_get('session.save_path'));
172 172
         $count = count($sessFiles);
173
-        for($i = 0; $i < $count; $i++)
173
+        for ($i = 0; $i < $count; $i++)
174 174
         {
175
-            if($sessFiles[$i][0] === '.')
175
+            if ($sessFiles[$i][0] === '.')
176 176
             {
177 177
                 continue;
178 178
             }
179 179
             $sessionId = substr($sessFiles[$i], 5);
180 180
             $sessionData = file_get_contents(ini_get('session.save_path').'/'.$sessFiles[$i]);
181
-            if($sessionData === false)
181
+            if ($sessionData === false)
182 182
             {
183 183
                 array_push($res, array('sid' => $sessionId));
184 184
             }
185 185
             else
186 186
             {
187 187
                 $tmp = FlipSession::unserializePhpSession($sessionData);
188
-                $tmp['sid' ] = $sessionId;
188
+                $tmp['sid'] = $sessionId;
189 189
                 array_push($res, $tmp);
190 190
             }
191 191
         }
192
-        if(count($res) == 0)
192
+        if (count($res) == 0)
193 193
         {
194 194
             return false;
195 195
         }
Please login to merge, or discard this patch.
Braces   +9 added lines, -13 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@  discard block
 block discarded – undo
32 32
         if(FlipSession::doesVarExist($name))
33 33
         {
34 34
             return $_SESSION[$name];
35
-        }
36
-        else
35
+        } else
37 36
         {
38 37
             return $default;
39 38
         }
@@ -59,13 +58,11 @@  discard block
 block discarded – undo
59 58
         if(isset($_SESSION['flipside_user']))
60 59
         {
61 60
             return true;
62
-        }
63
-        else if(isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData']))
61
+        } else if(isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData']))
64 62
         {
65 63
             $auth = AuthProvider::getInstance();
66 64
             return $auth->isLoggedIn($_SESSION['AuthData'], $_SESSION['AuthMethod']);
67
-        }
68
-        else
65
+        } else
69 66
         {
70 67
             return false;
71 68
         }
@@ -81,8 +78,7 @@  discard block
 block discarded – undo
81 78
         if(isset($_SESSION['flipside_user']))
82 79
         {
83 80
             return $_SESSION['flipside_user'];
84
-        }
85
-        else if(isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData']))
81
+        } else if(isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData']))
86 82
         {
87 83
             $auth = AuthProvider::getInstance();
88 84
             $user = $auth->getUser($_SESSION['AuthData'], $_SESSION['AuthMethod']);
@@ -91,8 +87,7 @@  discard block
 block discarded – undo
91 87
                 $_SESSION['flipside_user'] = $user;
92 88
             }
93 89
             return $user;
94
-        }
95
-        else
90
+        } else
96 91
         {
97 92
             return null;
98 93
         }
@@ -156,7 +151,9 @@  discard block
 block discarded – undo
156 151
             $pos = strpos($sessionData, "|", $offset);
157 152
             $len = $pos - $offset;
158 153
             $name = substr($sessionData, $offset, $len);
159
-            if($name === false) break;
154
+            if($name === false) {
155
+                break;
156
+            }
160 157
             $offset += $len+1;
161 158
             $data = @unserialize(substr($sessionData, $offset));
162 159
             $res[$name] = $data;
@@ -181,8 +178,7 @@  discard block
 block discarded – undo
181 178
             if($sessionData === false)
182 179
             {
183 180
                 array_push($res, array('sid' => $sessionId));
184
-            }
185
-            else
181
+            } else
186 182
             {
187 183
                 $tmp = FlipSession::unserializePhpSession($sessionData);
188 184
                 $tmp['sid' ] = $sessionId;
Please login to merge, or discard this patch.
class.FlipsideCAPTCHA.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -69,6 +69,9 @@
 block discarded – undo
69 69
         return $data[0]['hint'];
70 70
     }
71 71
 
72
+    /**
73
+     * @return string
74
+     */
72 75
     private function get_answer()
73 76
     {
74 77
         $dataset = DataSetFactory::get_data_set('profiles');
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
         $datatable = $dataset['captcha'];
12 12
         $data = $datatable->read(false, array('id'));
13 13
         $count = count($data);
14
-        for($i = 0; $i < $count; $i++)
14
+        for ($i = 0; $i < $count; $i++)
15 15
         {
16 16
             $data[$i] = $data[$i]['id'];
17 17
         }
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $res = array();
24 24
         $ids = FlipsideCAPTCHA::get_valid_captcha_ids();
25
-        for($i = 0; $i < count($ids); $i++)
25
+        for ($i = 0; $i < count($ids); $i++)
26 26
         {
27 27
             $captcha = new FlipsideCAPTCHA();
28 28
             $captcha->random_id = $ids[$i]; 
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $dataset = DataSetFactory::get_data_set('profiles');
37 37
         $datatable = $dataset['captcha'];
38
-        return $datatable->create(array('question'=>$question,'hint'=>$hint,'answer'=>$answer));
38
+        return $datatable->create(array('question'=>$question, 'hint'=>$hint, 'answer'=>$answer));
39 39
     }
40 40
 
41 41
     public function __construct()
42 42
     {
43 43
         $this->validIDs = FlipsideCAPTCHA::get_valid_captcha_ids();
44
-        $this->random_id = mt_rand(0, count($this->validIDs)-1);
44
+        $this->random_id = mt_rand(0, count($this->validIDs) - 1);
45 45
         $this->random_id = $this->validIDs[$this->random_id];
46 46
     }
47 47
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $dataset = DataSetFactory::get_data_set('profiles');
51 51
         $datatable = $dataset['captcha'];
52 52
         $data = $datatable->read(new \Data\Filter('id eq '.$this->random_id), array('question'));
53
-        if($data === false)
53
+        if ($data === false)
54 54
         {
55 55
             return false;
56 56
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         $dataset = DataSetFactory::get_data_set('profiles');
63 63
         $datatable = $dataset['captcha'];
64 64
         $data = $datatable->read(new \Data\Filter('id eq '.$this->random_id), array('hint'));
65
-        if($data === false)
65
+        if ($data === false)
66 66
         {
67 67
             return false;
68 68
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         $dataset = DataSetFactory::get_data_set('profiles');
75 75
         $datatable = $dataset['captcha'];
76 76
         $data = $datatable->read(new \Data\Filter('id eq '.$this->random_id), array('answer'));
77
-        if($data === false)
77
+        if ($data === false)
78 78
         {
79 79
             return false;
80 80
         }
@@ -83,29 +83,29 @@  discard block
 block discarded – undo
83 83
 
84 84
     public function is_answer_right($answer)
85 85
     {
86
-        return strcasecmp($this->get_answer(),$answer) == 0;
86
+        return strcasecmp($this->get_answer(), $answer) == 0;
87 87
     }
88 88
 
89
-    public function draw_captcha($explination=true, $return=false, $ownForm=false)
89
+    public function draw_captcha($explination = true, $return = false, $ownForm = false)
90 90
     {
91 91
         $string = '';
92 92
 
93
-        if($ownForm)
93
+        if ($ownForm)
94 94
         {
95
-            $string.= '<form id="flipcaptcha" name="flipcaptcha">';
95
+            $string .= '<form id="flipcaptcha" name="flipcaptcha">';
96 96
         }
97 97
 
98 98
         $string .= '<label for="captcha" class="col-sm-2 control-label">'.$this->get_question().'</label><div class="col-sm-10"><input class="form-control" type="text" id="captcha" name="captcha" placeholder="'.$this->get_hint().'" required/></div>';
99
-        if($ownForm)
99
+        if ($ownForm)
100 100
         {
101
-            $string.='</form>';
101
+            $string .= '</form>';
102 102
         }
103
-        if($explination)
103
+        if ($explination)
104 104
         {
105 105
             $string .= '<div class="col-sm-10">The answer to this question may be found in the Burning Flipside Survival Guide. It may be found <a href="http://www.burningflipside.com/sg">here</a>.</div>';
106 106
         }
107 107
         
108
-        if(!$return)
108
+        if (!$return)
109 109
         {
110 110
             echo $string;
111 111
         }
Please login to merge, or discard this patch.
class.SerializableObject.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
     /**
38 38
      * Serialize the object into a format consumable by json_encode
39 39
      *
40
-     * @return mixed The object in a more serialized format
40
+     * @return SerializableObject The object in a more serialized format
41 41
      */
42 42
     public function jsonSerialize()
43 43
     {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             {
87 87
                 $xml->startElement($key);
88 88
                 $this->object2XML($xml, $value);
89
-		$xml->endElement();
89
+        $xml->endElement();
90 90
             }
91 91
             else
92 92
             {
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     {
115 115
         foreach($data as $key => $value)
116 116
         {
117
-	    if(is_string($value))
117
+        if(is_string($value))
118 118
             {
119 119
                 $xml->writeElement($keyParent, $value);
120 120
                 continue;
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -16,18 +16,18 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * This class can be serialized to various formats
18 18
  */
19
-class SerializableObject implements ArrayAccess,JsonSerializable
19
+class SerializableObject implements ArrayAccess, JsonSerializable
20 20
 {
21 21
     /**
22 22
      * Create the object from an array
23 23
      *
24 24
      * @param array $array The array of object properties
25 25
      */
26
-    public function __construct($array=false)
26
+    public function __construct($array = false)
27 27
     {
28
-        if($array !== false && is_array($array))
28
+        if ($array !== false && is_array($array))
29 29
         {
30
-            foreach($array as $key => $value)
30
+            foreach ($array as $key => $value)
31 31
             {
32 32
                 $this->{$key} = $value;
33 33
             }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $xml = new XmlWriter();
55 55
         $xml->openMemory();
56 56
         $xml->startDocument('1.0');
57
-        if(isset($this[0]))
57
+        if (isset($this[0]))
58 58
         {
59 59
             $xml->startElement('Array');
60 60
             $this->array2XML($xml, 'Entity', (array)$this);
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
      */
77 77
     private function object2XML(XMLWriter $xml, $data)
78 78
     {
79
-        foreach($data as $key => $value)
79
+        foreach ($data as $key => $value)
80 80
         {
81
-            if(is_array($value) || is_numeric($key))
81
+            if (is_array($value) || is_numeric($key))
82 82
             {
83 83
                 $this->array2XML($xml, $key, (array)$value);
84 84
             }
85
-            else if(is_object($value))
85
+            else if (is_object($value))
86 86
             {
87 87
                 $xml->startElement($key);
88 88
                 $this->object2XML($xml, $value);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             }
91 91
             else
92 92
             {
93
-                if($key[0] === '$')
93
+                if ($key[0] === '$')
94 94
                 {
95 95
                     $xml->writeElement(substr($key, 1), $value);
96 96
                 }
@@ -112,29 +112,29 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function array2XML(XMLWriter $xml, $keyParent, $data)
114 114
     {
115
-        foreach($data as $key => $value)
115
+        foreach ($data as $key => $value)
116 116
         {
117
-	    if(is_string($value))
117
+	    if (is_string($value))
118 118
             {
119 119
                 $xml->writeElement($keyParent, $value);
120 120
                 continue;
121 121
             }
122
-            if(is_numeric($key))
122
+            if (is_numeric($key))
123 123
             {
124 124
                 $xml->startElement($keyParent);
125 125
             }
126 126
  
127
-            if(is_object($value))
127
+            if (is_object($value))
128 128
             {
129 129
                 $this->object2XML($xml, $value);
130 130
             }
131
-            else if(is_array($value))
131
+            else if (is_array($value))
132 132
             {
133 133
                 $this->array2XML($xml, $key, $value);
134 134
                 continue;
135 135
             }
136 136
  
137
-            if(is_numeric($key))
137
+            if (is_numeric($key))
138 138
             {
139 139
                 $xml->endElement();
140 140
             }
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
     public function serializeObject($fmt = 'json', $select = false)
166 166
     {
167 167
         $copy = $this;
168
-        if($select !== false)
168
+        if ($select !== false)
169 169
         {
170 170
             $copy = new self();
171 171
             $count = count($select);
172
-            for($i = 0; $i < $count; $i++)
172
+            for ($i = 0; $i < $count; $i++)
173 173
             {
174 174
                 $copy->{$select[$i]} = $this->offsetGet($select[$i]);
175 175
             }
176 176
         }
177
-        switch($fmt)
177
+        switch ($fmt)
178 178
         {
179 179
             case 'json':
180 180
                 return json_encode($copy);
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -59,8 +59,7 @@  discard block
 block discarded – undo
59 59
             $xml->startElement('Array');
60 60
             $this->array2XML($xml, 'Entity', (array)$this);
61 61
             $xml->endElement();
62
-        }
63
-        else
62
+        } else
64 63
         {
65 64
             $this->object2XML($xml, $this);
66 65
         }
@@ -81,20 +80,17 @@  discard block
 block discarded – undo
81 80
             if(is_array($value) || is_numeric($key))
82 81
             {
83 82
                 $this->array2XML($xml, $key, (array)$value);
84
-            }
85
-            else if(is_object($value))
83
+            } else if(is_object($value))
86 84
             {
87 85
                 $xml->startElement($key);
88 86
                 $this->object2XML($xml, $value);
89 87
 		$xml->endElement();
90
-            }
91
-            else
88
+            } else
92 89
             {
93 90
                 if($key[0] === '$')
94 91
                 {
95 92
                     $xml->writeElement(substr($key, 1), $value);
96
-                }
97
-                else
93
+                } else
98 94
                 {
99 95
                     $key = strtr($key, array(' '=>'', ','=>''));
100 96
                     $xml->writeElement($key, $value);
@@ -127,8 +123,7 @@  discard block
 block discarded – undo
127 123
             if(is_object($value))
128 124
             {
129 125
                 $this->object2XML($xml, $value);
130
-            }
131
-            else if(is_array($value))
126
+            } else if(is_array($value))
132 127
             {
133 128
                 $this->array2XML($xml, $key, $value);
134 129
                 continue;
Please login to merge, or discard this patch.
Data/class.FilterClause.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -12,11 +12,17 @@
 block discarded – undo
12 12
         if($string !== false) $this->process_filter_string($string);
13 13
     }
14 14
 
15
+    /**
16
+     * @param string $needle
17
+     */
15 18
     static function str_startswith($haystack, $needle)
16 19
     {
17 20
         return substr($haystack, 0, strlen($needle)) === $needle;
18 21
     }
19 22
 
23
+    /**
24
+     * @param boolean $string
25
+     */
20 26
     protected function process_filter_string($string)
21 27
     {
22 28
         if(self::str_startswith($string, 'substringof') || self::str_startswith($string, 'contains') || 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
     public $var2;
8 8
     public $op;
9 9
 
10
-    function __construct($string=false)
10
+    function __construct($string = false)
11 11
     {
12
-        if($string !== false) $this->process_filter_string($string);
12
+        if ($string !== false) $this->process_filter_string($string);
13 13
     }
14 14
 
15 15
     static function str_startswith($haystack, $needle)
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
     protected function process_filter_string($string)
21 21
     {
22
-        if(self::str_startswith($string, 'substringof') || self::str_startswith($string, 'contains') || 
22
+        if (self::str_startswith($string, 'substringof') || self::str_startswith($string, 'contains') || 
23 23
            self::str_startswith($string, 'indexof'))
24 24
         {
25 25
             $this->op   = strtok($string, '(');
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         $field = strtok($string, ' ');
31 31
         $op = strtok(' ');
32 32
         $rest = strtok("\0");
33
-        switch($op)
33
+        switch ($op)
34 34
         {
35 35
             case 'ne':
36 36
                 $op = '!=';
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
     function to_sql_string()
60 60
     {
61 61
         $str = '';
62
-        switch($this->op)
62
+        switch ($this->op)
63 63
         {
64 64
             case 'substringof':
65 65
             case 'contains':
66
-                $str = $this->var1.' LIKE \'%'.trim($this->var2,"'").'%\'';
66
+                $str = $this->var1.' LIKE \'%'.trim($this->var2, "'").'%\'';
67 67
                 break;
68 68
             default:
69 69
                 $str = $this->var1.$this->op.$this->var2;
@@ -75,17 +75,17 @@  discard block
 block discarded – undo
75 75
     function to_ldap_string()
76 76
     {
77 77
         $str = '(';
78
-        switch($this->op)
78
+        switch ($this->op)
79 79
         {
80 80
             case 'substringof':
81 81
             case 'contains':
82
-                $str.=$this->var1.$this->op.'*'.trim($this->var2,"'").'*';
82
+                $str .= $this->var1.$this->op.'*'.trim($this->var2, "'").'*';
83 83
                 break;
84 84
             case '!=':
85
-                $str.='!('.$this->var1.'='.$this->var2.')';
85
+                $str .= '!('.$this->var1.'='.$this->var2.')';
86 86
                 break;
87 87
             default:
88
-                $str.=$this->var1.$this->op.$this->var2;
88
+                $str .= $this->var1.$this->op.$this->var2;
89 89
                 break;
90 90
         }
91 91
         return $str.')';
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
     function to_mongo_filter()
95 95
     {
96 96
         $this->var2 = trim($this->var2, "'");
97
-        if($this->var1 === '_id')
97
+        if ($this->var1 === '_id')
98 98
         {
99 99
             $this->var2 = new \MongoId($this->var2);
100 100
         }
101
-        switch($this->op)
101
+        switch ($this->op)
102 102
         {
103 103
             case '!=':
104 104
                 return array($this->var1=>array('$ne'=>$this->var2));
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
             case 'indexof':
118 118
                 $field = $this->var1;
119 119
                 $case  = false;
120
-                if(self::str_startswith($this->var1, 'tolower'))
120
+                if (self::str_startswith($this->var1, 'tolower'))
121 121
                 {
122
-                    $field = substr($this->var1, strpos($this->var1, '(')+1);
122
+                    $field = substr($this->var1, strpos($this->var1, '(') + 1);
123 123
                     $field = substr($field, 0, strpos($field, ')'));
124 124
                     $case = true;
125 125
                 }
126
-                if($case)
126
+                if ($case)
127 127
                 {
128 128
                     return array($field=>array('$regex'=>new \MongoRegex('/'.$this->var2.'/i')));
129 129
                 }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
     function php_compare($value)
138 138
     {
139
-        switch($this->op)
139
+        switch ($this->op)
140 140
         {
141 141
             case '!=':
142 142
                 return $value != $this->var2;
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 
10 10
     function __construct($string=false)
11 11
     {
12
-        if($string !== false) $this->process_filter_string($string);
12
+        if($string !== false) {
13
+            $this->process_filter_string($string);
14
+        }
13 15
     }
14 16
 
15 17
     static function str_startswith($haystack, $needle)
@@ -126,8 +128,7 @@  discard block
 block discarded – undo
126 128
                 if($case)
127 129
                 {
128 130
                     return array($field=>array('$regex'=>new \MongoRegex('/'.$this->var2.'/i')));
129
-                }
130
-                else
131
+                } else
131 132
                 {
132 133
                     return array($field=>$this->var2);
133 134
                 }
Please login to merge, or discard this patch.
Data/class.SQLDataSet.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -17,6 +17,9 @@
 block discarded – undo
17 17
         }
18 18
     }
19 19
 
20
+    /**
21
+     * @param string $sql
22
+     */
20 23
     function _get_row_count_for_query($sql)
21 24
     {
22 25
         $stmt = $this->pdo->query($sql);
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
     function __construct($params)
9 9
     {
10
-        if(isset($params['user']))
10
+        if (isset($params['user']))
11 11
         {
12 12
             $this->pdo = new \PDO($params['dsn'], $params['user'], $params['pass']);
13 13
         }
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
     function _get_row_count_for_query($sql)
21 21
     {
22 22
         $stmt = $this->pdo->query($sql);
23
-        if($stmt === false)
23
+        if ($stmt === false)
24 24
         {
25 25
             return 0;
26 26
         }
27 27
         $count = $stmt->rowCount();
28
-        if($count === 0)
28
+        if ($count === 0)
29 29
         {
30 30
             $array = $stmt->fetchAll();
31 31
             $count = count($array);
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 
36 36
     function _tableExistsNoPrefix($name)
37 37
     {
38
-        if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote($name)) > 0)
38
+        if ($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote($name)) > 0)
39 39
         {
40 40
             return true;
41 41
         }
42
-        else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote($name)) > 0)
42
+        else if ($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote($name)) > 0)
43 43
         {
44 44
             return true;
45 45
         }
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 
49 49
     function _tableExists($name)
50 50
     {
51
-        if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('tbl'.$name)) > 0)
51
+        if ($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('tbl'.$name)) > 0)
52 52
         {
53 53
             return true;
54 54
         }
55
-        else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('tbl'.$name)) > 0)
55
+        else if ($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('tbl'.$name)) > 0)
56 56
         {
57 57
             return true;
58 58
         }
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 
62 62
     function _viewExists($name)
63 63
     {
64
-        if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('v'.$name)) > 0)
64
+        if ($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('v'.$name)) > 0)
65 65
         {
66 66
             return true;
67 67
         }
68
-        else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('v'.$name)) > 0)
68
+        else if ($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('v'.$name)) > 0)
69 69
         {
70 70
             return true;
71 71
         }
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
 
75 75
     function tableExists($name)
76 76
     {
77
-        if($this->_tableExists($name))
77
+        if ($this->_tableExists($name))
78 78
         {
79 79
             return true;
80 80
         }
81
-        if($this->_tableExistsNoPrefix($name))
81
+        if ($this->_tableExistsNoPrefix($name))
82 82
         {
83 83
             return true;
84 84
         }
85
-        if($this->_viewExists($name))
85
+        if ($this->_viewExists($name))
86 86
         {
87 87
             return true;
88 88
         }
@@ -91,60 +91,60 @@  discard block
 block discarded – undo
91 91
 
92 92
     function getTable($name)
93 93
     {
94
-        if($this->_tableExists($name))
94
+        if ($this->_tableExists($name))
95 95
         {
96 96
             return new SQLDataTable($this, 'tbl'.$name);
97 97
         }
98
-        if($this->_viewExists($name))
98
+        if ($this->_viewExists($name))
99 99
         {
100 100
             return new SQLDataTable($this, 'v'.$name);
101 101
         }
102
-        if($this->_tableExistsNoPrefix($name))
102
+        if ($this->_tableExistsNoPrefix($name))
103 103
         {
104 104
             return new SQLDataTable($this, $name);
105 105
         }
106 106
         throw new \Exception('No such table '.$name);
107 107
     }
108 108
 
109
-    function read($tablename, $where=false, $select='*', $count=false, $skip=false, $sort=false)
109
+    function read($tablename, $where = false, $select = '*', $count = false, $skip = false, $sort = false)
110 110
     {
111
-        if($select === false)
111
+        if ($select === false)
112 112
         {
113 113
             $select = '*';
114 114
         }
115 115
         $sql = "SELECT $select FROM $tablename";
116
-        if($where !== false)
116
+        if ($where !== false)
117 117
         {
118
-            $sql.=' WHERE '.$where;
118
+            $sql .= ' WHERE '.$where;
119 119
         }
120
-        if($count !== false)
120
+        if ($count !== false)
121 121
         {
122
-            if($skip === false)
122
+            if ($skip === false)
123 123
             {
124
-                $sql.=' LIMIT '.(int)$count;
124
+                $sql .= ' LIMIT '.(int)$count;
125 125
             }
126 126
             else
127 127
             {
128
-                $sql.=" LIMIT $skip, $count";
128
+                $sql .= " LIMIT $skip, $count";
129 129
             }
130 130
         }
131
-        if($sort !== false)
131
+        if ($sort !== false)
132 132
         {
133
-            $sql.=' ORDER BY ';
133
+            $sql .= ' ORDER BY ';
134 134
             $tmp = array();
135
-            foreach($sort as $sort_col=>$dir)
135
+            foreach ($sort as $sort_col=>$dir)
136 136
             {
137
-                array_push($tmp, $sort_col.' '.($dir === 1?'ASC':'DESC'));
137
+                array_push($tmp, $sort_col.' '.($dir === 1 ? 'ASC' : 'DESC'));
138 138
             }
139
-            $sql.=implode($tmp,',');
139
+            $sql .= implode($tmp, ',');
140 140
         }
141 141
         $stmt = $this->pdo->query($sql, \PDO::FETCH_ASSOC);
142
-        if($stmt === false)
142
+        if ($stmt === false)
143 143
         {
144 144
             return false;
145 145
         }
146 146
         $ret = $stmt->fetchAll();
147
-        if($ret === false || empty($ret))
147
+        if ($ret === false || empty($ret))
148 148
         {
149 149
             return false;
150 150
         }
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
     function update($tablename, $where, $data)
155 155
     {
156 156
         $set = array();
157
-        if(is_object($data))
157
+        if (is_object($data))
158 158
         {
159 159
             $data = (array)$data;
160 160
         }
161 161
         $cols = array_keys($data);
162 162
         $count = count($cols);
163
-        for($i = 0; $i < $count; $i++)
163
+        for ($i = 0; $i < $count; $i++)
164 164
         {
165 165
             array_push($set, $cols[$i].'='.$this->pdo->quote($data[$cols[$i]]));
166 166
         }
167 167
         $set = implode(',', $set);
168 168
         $sql = "UPDATE $tablename SET $set WHERE $where";
169
-        if($this->pdo->exec($sql) === false)
169
+        if ($this->pdo->exec($sql) === false)
170 170
         {
171 171
             return false;
172 172
         }
@@ -176,20 +176,20 @@  discard block
 block discarded – undo
176 176
     function create($tablename, $data)
177 177
     {
178 178
         $set = array();
179
-        if(is_object($data))
179
+        if (is_object($data))
180 180
         {
181 181
             $data = (array)$data;
182 182
         }
183 183
         $cols = array_keys($data);
184 184
         $count = count($cols);
185
-        for($i = 0; $i < $count; $i++)
185
+        for ($i = 0; $i < $count; $i++)
186 186
         {
187 187
             array_push($set, $this->pdo->quote($data[$cols[$i]]));
188 188
         }
189 189
         $cols = implode(',', $cols);
190 190
         $set = implode(',', $set);
191 191
         $sql = "INSERT INTO $tablename ($cols) VALUES ($set);";
192
-        if($this->pdo->exec($sql) === false)
192
+        if ($this->pdo->exec($sql) === false)
193 193
         {
194 194
             return false;
195 195
         }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     function delete($tablename, $where)
200 200
     {
201 201
         $sql = "DELETE FROM $tablename WHERE $where";
202
-        if($this->pdo->exec($sql) === false)
202
+        if ($this->pdo->exec($sql) === false)
203 203
         {
204 204
             return false;
205 205
         }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     function raw_query($sql)
210 210
     {
211 211
         $stmt = $this->pdo->query($sql, \PDO::FETCH_ASSOC);
212
-        if($stmt === false)
212
+        if ($stmt === false)
213 213
         {
214 214
             return false;
215 215
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
         if(isset($params['user']))
11 11
         {
12 12
             $this->pdo = new \PDO($params['dsn'], $params['user'], $params['pass']);
13
-        }
14
-        else
13
+        } else
15 14
         {
16 15
             $this->pdo = new \PDO($params['dsn']);
17 16
         }
@@ -38,8 +37,7 @@  discard block
 block discarded – undo
38 37
         if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote($name)) > 0)
39 38
         {
40 39
             return true;
41
-        }
42
-        else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote($name)) > 0)
40
+        } else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote($name)) > 0)
43 41
         {
44 42
             return true;
45 43
         }
@@ -51,8 +49,7 @@  discard block
 block discarded – undo
51 49
         if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('tbl'.$name)) > 0)
52 50
         {
53 51
             return true;
54
-        }
55
-        else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('tbl'.$name)) > 0)
52
+        } else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('tbl'.$name)) > 0)
56 53
         {
57 54
             return true;
58 55
         }
@@ -64,8 +61,7 @@  discard block
 block discarded – undo
64 61
         if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('v'.$name)) > 0)
65 62
         {
66 63
             return true;
67
-        }
68
-        else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('v'.$name)) > 0)
64
+        } else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('v'.$name)) > 0)
69 65
         {
70 66
             return true;
71 67
         }
@@ -122,8 +118,7 @@  discard block
 block discarded – undo
122 118
             if($skip === false)
123 119
             {
124 120
                 $sql.=' LIMIT '.(int)$count;
125
-            }
126
-            else
121
+            } else
127 122
             {
128 123
                 $sql.=" LIMIT $skip, $count";
129 124
             }
Please login to merge, or discard this patch.
Data/class.SQLDataTable.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -6,6 +6,9 @@
 block discarded – undo
6 6
     protected $dataset;
7 7
     protected $tablename;
8 8
 
9
+    /**
10
+     * @param SQLDataSet $dataset
11
+     */
9 12
     function __construct($dataset, $tablename)
10 13
     {
11 14
         $this->dataset   = $dataset;
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
         $ret = $this->dataset->read($this->tablename, $where, 'COUNT(*)');
66 66
         if($ret === false || !isset($ret[0]) || !isset($ret[0]['COUNT(*)']))
67 67
         {
68
-             return false;
68
+                return false;
69 69
         }
70 70
         else
71 71
         {
72
-             return $ret[0]['COUNT(*)'];
72
+                return $ret[0]['COUNT(*)'];
73 73
         }
74 74
     }
75 75
   
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 
94 94
     function update($filter, $data)
95 95
     {
96
-         $where = $filter->to_sql_string();
97
-         return $this->dataset->update($this->tablename, $where, $data);
96
+            $where = $filter->to_sql_string();
97
+            return $this->dataset->update($this->tablename, $where, $data);
98 98
     }
99 99
 
100 100
     function create($data)
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     function get_primary_key()
16 16
     {
17 17
         $res = $this->dataset->raw_query("SHOW INDEX FROM $this->tablename WHERE Key_name='PRIMARY'");
18
-        if($res === false)
18
+        if ($res === false)
19 19
         {
20 20
             return false;
21 21
         }
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
     function prefetch_all($key = false)
26 26
     {
27 27
         $array = $this->read(false, false);
28
-        if($key === false)
28
+        if ($key === false)
29 29
         {
30 30
             $key = $this->get_primary_key();
31 31
         }
32 32
         $count = count($array);
33 33
         $this->data = array();
34
-        for($i = 0; $i < $count; $i++)
34
+        for ($i = 0; $i < $count; $i++)
35 35
         {
36
-            if(isset($this->data[$array[$i][$key]]))
36
+            if (isset($this->data[$array[$i][$key]]))
37 37
             {
38
-                if(isset($this->data[$array[$i][$key]][0]))
38
+                if (isset($this->data[$array[$i][$key]][0]))
39 39
                 {
40 40
                     array_push($this->data[$array[$i][$key]], $array[$i]);
41 41
                 }
@@ -51,19 +51,19 @@  discard block
 block discarded – undo
51 51
         }
52 52
     }
53 53
 
54
-    function count($filter=false)
54
+    function count($filter = false)
55 55
     {
56
-        if($this->data !== null)
56
+        if ($this->data !== null)
57 57
         {
58 58
             return parent::count($filter);
59 59
         }
60 60
         $where = false;
61
-        if($filter !== false)
61
+        if ($filter !== false)
62 62
         {
63 63
             $where = $filter->to_sql_string();
64 64
         }
65 65
         $ret = $this->dataset->read($this->tablename, $where, 'COUNT(*)');
66
-        if($ret === false || !isset($ret[0]) || !isset($ret[0]['COUNT(*)']))
66
+        if ($ret === false || !isset($ret[0]) || !isset($ret[0]['COUNT(*)']))
67 67
         {
68 68
              return false;
69 69
         }
@@ -73,18 +73,18 @@  discard block
 block discarded – undo
73 73
         }
74 74
     }
75 75
   
76
-    function search($filter=false, $select=false, $count=false, $skip=false, $sort=false, $params=false)
76
+    function search($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false)
77 77
     {
78
-        if($this->data !== null)
78
+        if ($this->data !== null)
79 79
         {
80 80
             return parent::search($filter, $select);
81 81
         }
82 82
         $where = false;
83
-        if($filter !== false)
83
+        if ($filter !== false)
84 84
         {
85 85
             $where = $filter->to_sql_string();
86 86
         }
87
-        if($select !== false && is_array($select))
87
+        if ($select !== false && is_array($select))
88 88
         {
89 89
             $select = implode(',', $select);
90 90
         }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     function delete($filter)
106 106
     {
107 107
         $where = false;
108
-        if($filter !== false)
108
+        if ($filter !== false)
109 109
         {
110 110
             $where = $filter->to_sql_string();
111 111
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,13 +38,11 @@  discard block
 block discarded – undo
38 38
                 if(isset($this->data[$array[$i][$key]][0]))
39 39
                 {
40 40
                     array_push($this->data[$array[$i][$key]], $array[$i]);
41
-                }
42
-                else
41
+                } else
43 42
                 {
44 43
                     $this->data[$array[$i][$key]] = array($array[$i]);
45 44
                 }
46
-            }
47
-            else
45
+            } else
48 46
             {
49 47
                 $this->data[$array[$i][$key]] = $array[$i];
50 48
             }
@@ -66,8 +64,7 @@  discard block
 block discarded – undo
66 64
         if($ret === false || !isset($ret[0]) || !isset($ret[0]['COUNT(*)']))
67 65
         {
68 66
              return false;
69
-        }
70
-        else
67
+        } else
71 68
         {
72 69
              return $ret[0]['COUNT(*)'];
73 70
         }
Please login to merge, or discard this patch.
Email/class.Email.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * Who is this email going to
74 74
      *
75
-     * @return array The recipients of the email
75
+     * @return string The recipients of the email
76 76
      */
77 77
     public function getToAddresses()
78 78
     {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     /**
83 83
      * Who is this email going to (CC)
84 84
      *
85
-     * @return array The recipients of the email
85
+     * @return string The recipients of the email
86 86
      */
87 87
     public function getCCAddresses()
88 88
     {
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     /**
93 93
      * Who is this email going to (BCC)
94 94
      *
95
-     * @return array The recipients of the email
95
+     * @return string The recipients of the email
96 96
      */
97 97
     public function getBCCAddresses()
98 98
     {
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function getFromAddress()
64 64
     {
65
-        if($this->sender === false)
65
+        if ($this->sender === false)
66 66
         {
67 67
             return 'Burning Flipside <[email protected]>';
68 68
         }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function getReplyTo()
108 108
     {
109
-        if($this->replyTo === false)
109
+        if ($this->replyTo === false)
110 110
         {
111 111
             return $this->getFromAddress();
112 112
         }
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
      * @param string $email The email address to send from
150 150
      * @param string $name  The name to associate with the from address
151 151
      */
152
-    public function setFromAddress($email, $name=false)
152
+    public function setFromAddress($email, $name = false)
153 153
     {
154 154
         $address = $email;
155
-        if($name !== false)
155
+        if ($name !== false)
156 156
         {
157 157
             $address = $name.' <'.$email.'>';
158 158
         }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      * @param string $email The email address to send to
166 166
      * @param string $name  The name to associate with the address
167 167
      */
168
-    public function addToAddress($email, $name=false)
168
+    public function addToAddress($email, $name = false)
169 169
     {
170 170
         $this->addAddress($this->to, $email, $name);
171 171
     }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
      * @param string $email The email address to send to
177 177
      * @param string $name  The name to associate with the address
178 178
      */
179
-    public function addCCAddress($email, $name=false)
179
+    public function addCCAddress($email, $name = false)
180 180
     {
181 181
         $this->addAddress($this->cc, $email, $name);
182 182
     }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      * @param string $email The email address to send to
188 188
      * @param string $name  The name to associate with the address
189 189
      */
190
-    public function addBCCAddress($email, $name=false)
190
+    public function addBCCAddress($email, $name = false)
191 191
     {
192 192
         $this->addAddress($this->bcc, $email, $name);
193 193
     }
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
      * @param string $email The email address to send to
200 200
      * @param string $name  The name to associate with the address
201 201
      */
202
-    protected function addAddress(&$list, $email, $name=false)
202
+    protected function addAddress(&$list, $email, $name = false)
203 203
     {
204 204
         $address = $email;
205
-        if($name !== false)
205
+        if ($name !== false)
206 206
         {
207 207
             $address = $name.' <'.$email.'>';
208 208
         }
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
      * @param string $email The email address to reply to
216 216
      * @param string $name  The name to associate with the from address
217 217
      */
218
-    public function setReplyTo($email, $name=false)
218
+    public function setReplyTo($email, $name = false)
219 219
     {
220 220
         $address = $email;
221
-        if($name !== false)
221
+        if ($name !== false)
222 222
         {
223 223
             $address = $name.' <'.$email.'>';
224 224
         }
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public function appendToHTMLBody($body)
264 264
     {
265
-        $this->htmlBody.= $body;
265
+        $this->htmlBody .= $body;
266 266
     }
267 267
 
268 268
     /**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
      */
273 273
     public function appendToTextBody($body)
274 274
     {
275
-        $this->textBody.= $body;
275
+        $this->textBody .= $body;
276 276
     }
277 277
 
278 278
     /**
@@ -295,17 +295,17 @@  discard block
 block discarded – undo
295 295
      */
296 296
     public function addAttachmentFromFile($filename, $name = false)
297 297
     {
298
-        if($name === false)
298
+        if ($name === false)
299 299
         {
300 300
             $name = basename($filename);
301 301
         }
302 302
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
303 303
         $mimeType = finfo_file($finfo, $filename);
304
-        if($mimeType === false)
304
+        if ($mimeType === false)
305 305
         {
306 306
             $mimeType = 'application/octet-stream';
307 307
         }
308
-        if(file_exists($filename) && is_file($filename) && is_readable($filename))
308
+        if (file_exists($filename) && is_file($filename) && is_readable($filename))
309 309
         {
310 310
             $this->addAttachmentFromBuffer($name, file_get_contents($filename), $mimeType);
311 311
         }
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
     {
331 331
         $boundary = uniqid(rand(), true);
332 332
         $rawMessage = 'To: '.$this->encodeRecipients($this->getToAddresses())."\n";
333
-        $rawMessage.= 'From: '.$this->encodeRecipients($this->getFromAddress())."\n";
334
-        if(!empty($this->cc))
333
+        $rawMessage .= 'From: '.$this->encodeRecipients($this->getFromAddress())."\n";
334
+        if (!empty($this->cc))
335 335
         {
336
-            $rawMessage.= 'CC: '. $this->encodeRecipients($this->getCCAddresses())."\n";
336
+            $rawMessage .= 'CC: '.$this->encodeRecipients($this->getCCAddresses())."\n";
337 337
         }
338
-        if(!empty($this->bcc))
338
+        if (!empty($this->bcc))
339 339
         {
340
-            $rawMessage.= 'BCC: '. $this->encodeRecipients($this->getBCCAddresses())."\n";
340
+            $rawMessage .= 'BCC: '.$this->encodeRecipients($this->getBCCAddresses())."\n";
341 341
         }
342 342
         $rawMessage .= 'Subject: '.$this->getSubject()."\n";
343 343
         $rawMessage .= 'MIME-Version: 1.0'."\n";
@@ -345,27 +345,27 @@  discard block
 block discarded – undo
345 345
         $rawMessage .= "\n--{$boundary}\n";
346 346
         $rawMessage .= 'Content-type: Multipart/Alternative; boundary="alt-'.$boundary.'"'."\n";
347 347
         $textBody    = $this->getTextBody();
348
-        if($textBody !== false && strlen($textBody) > 0)
348
+        if ($textBody !== false && strlen($textBody) > 0)
349 349
         {
350
-            $rawMessage.= "\n--alt-{$boundary}\n";
351
-            $rawMessage.= "Content-Type: text/plain\n\n";
352
-            $rawMessage.= $textBody."\n";
350
+            $rawMessage .= "\n--alt-{$boundary}\n";
351
+            $rawMessage .= "Content-Type: text/plain\n\n";
352
+            $rawMessage .= $textBody."\n";
353 353
         }
354
-        $htmlBody    = $this->getHTMLBody();
355
-        if($htmlBody !== false && strlen($htmlBody) > 0)
354
+        $htmlBody = $this->getHTMLBody();
355
+        if ($htmlBody !== false && strlen($htmlBody) > 0)
356 356
         {
357 357
             $rawMessage .= "\n--alt-{$boundary}\n";
358 358
             $rawMessage .= 'Content-Type: text/html; charset="UTF-8"'."\n\n";
359 359
             $rawMessage .= $htmlBody."\n";
360 360
         }
361
-        $rawMessage.= "\n--alt-{$boundary}--\n";
362
-        foreach($this->attachments as $attachment)
361
+        $rawMessage .= "\n--alt-{$boundary}--\n";
362
+        foreach ($this->attachments as $attachment)
363 363
         {
364
-            $rawMessage.= "\n--{$boundary}\n";
365
-            $rawMessage.= 'Content-Type: '. $attachment['mimeType'].'; name="'.$attachment['name']."\"\n";
366
-            $rawMessage.= 'Content-Disposition: attachment'."\n";
367
-            $rawMessage.= 'Content-Transfer-Encoding: base64'."\n\n";
368
-            $rawMessage.= chunk_split(base64_encode($attachment['data']), 76, "\n")."\n";
364
+            $rawMessage .= "\n--{$boundary}\n";
365
+            $rawMessage .= 'Content-Type: '.$attachment['mimeType'].'; name="'.$attachment['name']."\"\n";
366
+            $rawMessage .= 'Content-Disposition: attachment'."\n";
367
+            $rawMessage .= 'Content-Transfer-Encoding: base64'."\n\n";
368
+            $rawMessage .= chunk_split(base64_encode($attachment['data']), 76, "\n")."\n";
369 369
         }
370 370
         $rawMessage .= "\n--{$boundary}--\n";
371 371
         return $rawMessage;
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
      */
381 381
     public function encodeRecipients($recipient)
382 382
     {
383
-        if(is_array($recipient))
383
+        if (is_array($recipient))
384 384
         {
385 385
             return join(', ', array_map(array($this, 'encodeRecipients'), $recipient));
386 386
         }
387
-        if(preg_match("/(.*)<(.*)>/", $recipient, $regs))
387
+        if (preg_match("/(.*)<(.*)>/", $recipient, $regs))
388 388
         {
389 389
             $recipient = '=?UTF-8?B?'.base64_encode($regs[1]).'?= <'.$regs[2].'>';
390 390
         }
Please login to merge, or discard this patch.
Email/class.EmailService.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -12,6 +12,9 @@
 block discarded – undo
12 12
         return false;
13 13
     }
14 14
 
15
+    /**
16
+     * @param Email $email
17
+     */
15 18
     public function sendEmail($email)
16 19
     {
17 20
         return false;
Please login to merge, or discard this patch.
LDAP/class.LDAPServer.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -117,6 +117,9 @@  discard block
 block discarded – undo
117 117
         $this->connect = false;
118 118
     }
119 119
 
120
+    /**
121
+     * @param string $password
122
+     */
120 123
     function bind($cn=null, $password=null)
121 124
     {
122 125
         $res = false;
@@ -199,6 +202,9 @@  discard block
 block discarded – undo
199 202
         return $ret;
200 203
     }
201 204
 
205
+    /**
206
+     * @param boolean $filter
207
+     */
202 208
     private function filterToString($filter)
203 209
     {
204 210
         if($filter === false)
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
     $search = array_flip($dn ? array('\\', '+', '<', '>', ';', '"', '#') : array('\\', '*', '(', ')', "\x00"));
18 18
 
19 19
     // Process characters to ignore
20
-    if(is_array($ignore))
20
+    if (is_array($ignore))
21 21
     {
22 22
         $ignore = array_values($ignore);
23 23
     }
24
-    for($char = 0; isset($ignore[$char]); $char++)
24
+    for ($char = 0; isset($ignore[$char]); $char++)
25 25
     {
26 26
         unset($search[$ignore[$char]]);
27 27
     }
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     // Flip $search back to values and build $replace array
30 30
     $search = array_keys($search); 
31 31
     $replace = array();
32
-    foreach($search as $char)
32
+    foreach ($search as $char)
33 33
     {
34 34
         $replace[] = sprintf('\\%02x', ord($char));
35 35
     }
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
     $result = str_replace($search, $replace, $subject);
39 39
 
40 40
     // Encode leading/trailing spaces in DN values
41
-    if($dn)
41
+    if ($dn)
42 42
     {
43
-        if($result[0] == ' ')
43
+        if ($result[0] == ' ')
44 44
         {
45 45
             $result = '\\20'.substr($result, 1);
46 46
         }
47
-        if($result[strlen($result) - 1] == ' ')
47
+        if ($result[strlen($result) - 1] == ' ')
48 48
         {
49 49
             $result = substr($result, 0, -1).'\\20';
50 50
         }
@@ -76,29 +76,29 @@  discard block
 block discarded – undo
76 76
         $this->ds = ldap_connect($this->connect);
77 77
     }
78 78
 
79
-    private function getConnectString($name, $proto=false)
79
+    private function getConnectString($name, $proto = false)
80 80
     {
81
-        if(strstr($name, ':') !== false)
81
+        if (strstr($name, ':') !== false)
82 82
         {
83 83
             return $name;
84 84
         }
85
-        if($proto !== 'ldap')
85
+        if ($proto !== 'ldap')
86 86
         {
87 87
             return $proto.'://'.$name;
88 88
         }
89 89
         return $name;
90 90
     }
91 91
 
92
-    function connect($name, $proto=false)
92
+    function connect($name, $proto = false)
93 93
     {
94 94
         $connectStr = $this->getConnectString($name, $proto);
95
-        if($this->ds !== null)
95
+        if ($this->ds !== null)
96 96
         {
97 97
             ldap_close($this->ds);
98 98
         }
99 99
         $this->connect = $connectStr;
100 100
         $this->ds      = ldap_connect($this->connect);
101
-        if($this->ds === false)
101
+        if ($this->ds === false)
102 102
         {
103 103
             $this->ds = null;
104 104
             return false;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
     function disconnect()
111 111
     {
112
-        if($this->ds !== null)
112
+        if ($this->ds !== null)
113 113
         {
114 114
             ldap_close($this->ds);
115 115
             $this->ds = null;
@@ -117,15 +117,15 @@  discard block
 block discarded – undo
117 117
         $this->connect = false;
118 118
     }
119 119
 
120
-    function bind($cn=null, $password=null)
120
+    function bind($cn = null, $password = null)
121 121
     {
122 122
         $res = false;
123
-        if($this->ds === null)
123
+        if ($this->ds === null)
124 124
         {
125 125
             throw new \Exception('Not connected');
126 126
         }
127 127
         $this->binder = $cn;
128
-        if($cn === null || $password === null)
128
+        if ($cn === null || $password === null)
129 129
         {
130 130
             return @ldap_bind($this->ds);
131 131
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         {
134 134
             $res = ldap_bind($this->ds, $cn, $password);
135 135
         }
136
-        catch(\Exception $ex)
136
+        catch (\Exception $ex)
137 137
         {
138 138
             $this->ds = ldap_connect($this->connect);
139 139
             $res = @ldap_bind($this->ds, $cn, $password);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
     function unbind()
145 145
     {
146
-        if($this->ds === null)
146
+        if ($this->ds === null)
147 147
         {
148 148
             return true;
149 149
         }
@@ -158,27 +158,27 @@  discard block
 block discarded – undo
158 158
     private function _fix_object($object, &$delete = false)
159 159
     {
160 160
         $entity = $object;
161
-        if(!is_array($object))
161
+        if (!is_array($object))
162 162
         {
163 163
             $entity = $object->to_array();
164 164
         }
165 165
         unset($entity['dn']);
166 166
         $keys = array_keys($entity);
167
-        for($i = 0; $i < count($keys); $i++)
167
+        for ($i = 0; $i < count($keys); $i++)
168 168
         {
169
-            if(is_array($entity[$keys[$i]]))
169
+            if (is_array($entity[$keys[$i]]))
170 170
             {
171 171
                 $array = $entity[$keys[$i]];
172 172
                 unset($entity[$keys[$i]]);
173
-                for($j = 0; $j < count($array); $j++)
173
+                for ($j = 0; $j < count($array); $j++)
174 174
                 {
175
-                    if(isset($array[$j]))
175
+                    if (isset($array[$j]))
176 176
                     {
177 177
                         $entity[$keys[$i]][$j] = $array[$j];
178 178
                     }
179 179
                 }
180 180
             }
181
-            else if($delete !== false && $entity[$keys[$i]] === null)
181
+            else if ($delete !== false && $entity[$keys[$i]] === null)
182 182
             {
183 183
                 $delete[$keys[$i]] = array();
184 184
                 unset($entity[$keys[$i]]);
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         $dn = ldap_escape($object['dn'], true);
193 193
         $entity = $this->_fix_object($object);
194 194
         $ret = ldap_add($this->ds, $dn, $entity);
195
-        if($ret === false)
195
+        if ($ret === false)
196 196
         {
197 197
             throw new \Exception('Failed to create object with dn='.$dn);
198 198
         }
@@ -201,34 +201,34 @@  discard block
 block discarded – undo
201 201
 
202 202
     private function filterToString($filter)
203 203
     {
204
-        if($filter === false)
204
+        if ($filter === false)
205 205
         {
206 206
             return '(objectclass=*)';
207 207
         }
208
-        if(is_string($filter))
208
+        if (is_string($filter))
209 209
         {
210 210
             return $filter;
211 211
         }
212 212
         return $filter->to_ldap_string();
213 213
     }
214 214
 
215
-    function read($baseDN, $filter=false, $single=false, $attributes=false)
215
+    function read($baseDN, $filter = false, $single = false, $attributes = false)
216 216
     {
217 217
         $filterStr = $this->filterToString($filter);
218
-        if($this->ds === null)
218
+        if ($this->ds === null)
219 219
         {
220 220
             throw new \Exception('Not connected');
221 221
         }
222 222
         $sr = false;
223 223
         try
224 224
         {
225
-            if($single === true)
225
+            if ($single === true)
226 226
             {
227 227
                 $sr = @ldap_read($this->ds, $baseDN, $filterStr);
228 228
             }
229 229
             else
230 230
             {
231
-                if($attributes !== false)
231
+                if ($attributes !== false)
232 232
                 {
233 233
                     $sr = @ldap_list($this->ds, $baseDN, $filterStr, $attributes);
234 234
                 }
@@ -238,20 +238,20 @@  discard block
 block discarded – undo
238 238
                 }
239 239
             }
240 240
         }
241
-        catch(\Exception $e)
241
+        catch (\Exception $e)
242 242
         {
243 243
             throw new \Exception($e->getMessage().' '.$filterStr, $e->getCode(), $e);
244 244
         }
245
-        if($sr === false)
245
+        if ($sr === false)
246 246
         {
247 247
             return false;
248 248
         }
249 249
         $res = ldap_get_entries($this->ds, $sr);
250
-        if(is_array($res))
250
+        if (is_array($res))
251 251
         {
252 252
             $ldap = $res;
253 253
             $res = array();
254
-            for($i = 0; $i < $ldap['count']; $i++)
254
+            for ($i = 0; $i < $ldap['count']; $i++)
255 255
             {
256 256
                 array_push($res, new LDAPObject($ldap[$i], $this));
257 257
             }
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
         return $res;
260 260
     }
261 261
 
262
-    function count($baseDN, $filter=false)
262
+    function count($baseDN, $filter = false)
263 263
     {
264 264
         $filterStr = $this->filterToString($filter);
265
-        if($this->ds === null)
265
+        if ($this->ds === null)
266 266
         {
267 267
             throw new \Exception('Not connected');
268 268
         }
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
         {
271 271
             $sr = ldap_list($this->ds, $baseDN, $filterStr, array('dn'));
272 272
         }
273
-        catch(\Exception $e)
273
+        catch (\Exception $e)
274 274
         {
275 275
             throw new \Exception($e->getMessage().' '.$filterStr, $e->getCode(), $e);
276 276
         }
277
-        if($sr === false)
277
+        if ($sr === false)
278 278
         {
279 279
             return false;
280 280
         }
@@ -286,15 +286,15 @@  discard block
 block discarded – undo
286 286
         $dn = ldap_escape($object['dn'], true);
287 287
         $delete = array();
288 288
         $entity = $this->_fix_object($object, $delete);
289
-        if(!empty($entity))
289
+        if (!empty($entity))
290 290
         {
291 291
             $ret = @ldap_mod_replace($this->ds, $dn, $entity);
292
-            if($ret === false)
292
+            if ($ret === false)
293 293
             {
294 294
                 throw new \Exception('Failed to update object with dn='.$dn.'('.ldap_errno($this->ds).':'.ldap_error($this->ds).') '.print_r($entity, true));
295 295
             }
296 296
         }
297
-        if(!empty($delete))
297
+        if (!empty($delete))
298 298
         {
299 299
             $ret = @ldap_mod_del($this->ds, $dn, $delete);
300 300
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -132,8 +132,7 @@  discard block
 block discarded – undo
132 132
         try
133 133
         {
134 134
             $res = ldap_bind($this->ds, $cn, $password);
135
-        }
136
-        catch(\Exception $ex)
135
+        } catch(\Exception $ex)
137 136
         {
138 137
             $this->ds = ldap_connect($this->connect);
139 138
             $res = @ldap_bind($this->ds, $cn, $password);
@@ -177,8 +176,7 @@  discard block
 block discarded – undo
177 176
                         $entity[$keys[$i]][$j] = $array[$j];
178 177
                     }
179 178
                 }
180
-            }
181
-            else if($delete !== false && $entity[$keys[$i]] === null)
179
+            } else if($delete !== false && $entity[$keys[$i]] === null)
182 180
             {
183 181
                 $delete[$keys[$i]] = array();
184 182
                 unset($entity[$keys[$i]]);
@@ -225,20 +223,17 @@  discard block
 block discarded – undo
225 223
             if($single === true)
226 224
             {
227 225
                 $sr = @ldap_read($this->ds, $baseDN, $filterStr);
228
-            }
229
-            else
226
+            } else
230 227
             {
231 228
                 if($attributes !== false)
232 229
                 {
233 230
                     $sr = @ldap_list($this->ds, $baseDN, $filterStr, $attributes);
234
-                }
235
-                else
231
+                } else
236 232
                 {
237 233
                     $sr = @ldap_list($this->ds, $baseDN, $filterStr);
238 234
                 }
239 235
             }
240
-        }
241
-        catch(\Exception $e)
236
+        } catch(\Exception $e)
242 237
         {
243 238
             throw new \Exception($e->getMessage().' '.$filterStr, $e->getCode(), $e);
244 239
         }
@@ -269,8 +264,7 @@  discard block
 block discarded – undo
269 264
         try
270 265
         {
271 266
             $sr = ldap_list($this->ds, $baseDN, $filterStr, array('dn'));
272
-        }
273
-        catch(\Exception $e)
267
+        } catch(\Exception $e)
274 268
         {
275 269
             throw new \Exception($e->getMessage().' '.$filterStr, $e->getCode(), $e);
276 270
         }
Please login to merge, or discard this patch.