@@ -34,8 +34,7 @@ discard block |
||
| 34 | 34 | if($this->user === false || $this->user === null) |
| 35 | 35 | { |
| 36 | 36 | $this->add_link('<i class="fa fa-sign-in"></i> Login', $this->loginUrl); |
| 37 | - } |
|
| 38 | - else |
|
| 37 | + } else |
|
| 39 | 38 | { |
| 40 | 39 | $this->add_links(); |
| 41 | 40 | $this->add_link('<i class="fa fa-sign-out"></i> Logout', $this->logoutUrl); |
@@ -166,8 +165,7 @@ discard block |
||
| 166 | 165 | <h1 class="page-header">You must <a href="'.$this->loginUrl.'?return='.$this->current_url().'">log in <span class="glyphicon glyphicon-log-in"></span></a> to access the '.$this->title.' Admin system!</h1> |
| 167 | 166 | </div> |
| 168 | 167 | </div>'; |
| 169 | - } |
|
| 170 | - else if($this->is_admin === false) |
|
| 168 | + } else if($this->is_admin === false) |
|
| 171 | 169 | { |
| 172 | 170 | $this->body = ' |
| 173 | 171 | <div class="row"> |
@@ -86,12 +86,13 @@ |
||
| 86 | 86 | { |
| 87 | 87 | $isLast = true; |
| 88 | 88 | } |
| 89 | - if(!isset($group->member[$i]->type)) continue; |
|
| 89 | + if(!isset($group->member[$i]->type)) { |
|
| 90 | + continue; |
|
| 91 | + } |
|
| 90 | 92 | if($group->member[$i]->type === 'Group') |
| 91 | 93 | { |
| 92 | 94 | $this->addMember($group->member[$i]->cn, true, $isLast); |
| 93 | - } |
|
| 94 | - else |
|
| 95 | + } else |
|
| 95 | 96 | { |
| 96 | 97 | $this->addMember($group->member[$i]->uid, false, $isLast); |
| 97 | 98 | } |
@@ -264,7 +264,7 @@ |
||
| 264 | 264 | throw new \Exception('data must be set for LDAPGroup'); |
| 265 | 265 | } |
| 266 | 266 | $filter = new \Data\Filter("cn eq $name"); |
| 267 | - $group = $data->read($data->group_base, $filter); |
|
| 267 | + $group = $data->read($data->group_base, $filter); |
|
| 268 | 268 | if($group === false || !isset($group[0])) |
| 269 | 269 | { |
| 270 | 270 | return false; |
@@ -3,8 +3,7 @@ discard block |
||
| 3 | 3 | if(isset($GLOBALS['FLIPSIDE_SETTINGS_LOC'])) |
| 4 | 4 | { |
| 5 | 5 | require_once($GLOBALS['FLIPSIDE_SETTINGS_LOC'].'/class.FlipsideSettings.php'); |
| 6 | -} |
|
| 7 | -else |
|
| 6 | +} else |
|
| 8 | 7 | { |
| 9 | 8 | require_once('/var/www/secure_settings/class.FlipsideSettings.php'); |
| 10 | 9 | } |
@@ -85,8 +84,7 @@ discard block |
||
| 85 | 84 | { |
| 86 | 85 | $members = array_merge($members, $child->members()); |
| 87 | 86 | } |
| 88 | - } |
|
| 89 | - else |
|
| 87 | + } else |
|
| 90 | 88 | { |
| 91 | 89 | array_push($members, $rawMembers[$i]); |
| 92 | 90 | } |
@@ -130,12 +128,10 @@ discard block |
||
| 130 | 128 | { |
| 131 | 129 | $members = array_merge($members, $child->members()); |
| 132 | 130 | } |
| 133 | - } |
|
| 134 | - else if($includeGroups === false && strncmp($rawMembers[$i], 'cn=', 3) === 0) |
|
| 131 | + } else if($includeGroups === false && strncmp($rawMembers[$i], 'cn=', 3) === 0) |
|
| 135 | 132 | { |
| 136 | 133 | //Drop this member |
| 137 | - } |
|
| 138 | - else |
|
| 134 | + } else |
|
| 139 | 135 | { |
| 140 | 136 | array_push($members, $rawMembers[$i]); |
| 141 | 137 | } |
@@ -167,8 +163,7 @@ discard block |
||
| 167 | 163 | if(strncmp($members[$i], "uid=", 4) == 0) |
| 168 | 164 | { |
| 169 | 165 | $userFilter.='(!('.$dnComps[0].'))'; |
| 170 | - } |
|
| 171 | - else |
|
| 166 | + } else |
|
| 172 | 167 | { |
| 173 | 168 | $groupFilter.='(!('.$dnComps[0].'))'; |
| 174 | 169 | } |
@@ -179,7 +174,9 @@ discard block |
||
| 179 | 174 | $count = count($groups); |
| 180 | 175 | for($i = 0; $i < $count; $i++) |
| 181 | 176 | { |
| 182 | - if($groups[$i] === false || $groups[$i] === null) continue; |
|
| 177 | + if($groups[$i] === false || $groups[$i] === null) { |
|
| 178 | + continue; |
|
| 179 | + } |
|
| 183 | 180 | array_push($data, new LDAPGroup($groups[$i])); |
| 184 | 181 | } |
| 185 | 182 | $users = $this->server->read($this->server->user_base, $userFilter, false, $select); |
@@ -196,12 +193,10 @@ discard block |
||
| 196 | 193 | if(isset($this->ldapObj['member'])) |
| 197 | 194 | { |
| 198 | 195 | $this->ldapObj['member'] = array(); |
| 199 | - } |
|
| 200 | - else if(isset($this->ldapObj['uniquemember'])) |
|
| 196 | + } else if(isset($this->ldapObj['uniquemember'])) |
|
| 201 | 197 | { |
| 202 | 198 | $this->ldapObj['uniquemember'] = array(); |
| 203 | - } |
|
| 204 | - else if(isset($this->ldapObj['memberuid'])) |
|
| 199 | + } else if(isset($this->ldapObj['memberuid'])) |
|
| 205 | 200 | { |
| 206 | 201 | $this->ldapObj['memberuid'] = array(); |
| 207 | 202 | } |
@@ -213,8 +208,7 @@ discard block |
||
| 213 | 208 | if($isGroup) |
| 214 | 209 | { |
| 215 | 210 | $dn = 'cn='.$name.','.$this->server->group_base; |
| 216 | - } |
|
| 217 | - else |
|
| 211 | + } else |
|
| 218 | 212 | { |
| 219 | 213 | $dn = 'uid='.$name.','.$this->server->user_base; |
| 220 | 214 | } |
@@ -231,8 +225,7 @@ discard block |
||
| 231 | 225 | throw new \Exception('Unable to add a group as a child of this group type'); |
| 232 | 226 | } |
| 233 | 227 | array_push($rawMembers, $name); |
| 234 | - } |
|
| 235 | - else |
|
| 228 | + } else |
|
| 236 | 229 | { |
| 237 | 230 | array_push($rawMembers, $dn); |
| 238 | 231 | } |
@@ -243,8 +236,7 @@ discard block |
||
| 243 | 236 | $obj = array('dn'=>$this->ldapObj->dn); |
| 244 | 237 | $obj[$propName] = $rawMembers; |
| 245 | 238 | return $this->server->update($obj); |
| 246 | - } |
|
| 247 | - else |
|
| 239 | + } else |
|
| 248 | 240 | { |
| 249 | 241 | return true; |
| 250 | 242 | } |
@@ -241,7 +241,7 @@ |
||
| 241 | 241 | $obj['userPassword'] = $this->generateLDAPPass($password); |
| 242 | 242 | if(isset($this->ldap_obj->uniqueidentifier)) |
| 243 | 243 | { |
| 244 | - $obj['uniqueIdentifier'] = null; |
|
| 244 | + $obj['uniqueIdentifier'] = null; |
|
| 245 | 245 | } |
| 246 | 246 | //Make sure we are bound in write mode |
| 247 | 247 | $auth = \AuthProvider::getInstance(); |
@@ -21,14 +21,12 @@ discard block |
||
| 21 | 21 | throw new \Exception('No such LDAP User!'); |
| 22 | 22 | } |
| 23 | 23 | $this->ldapObj = $users[0]; |
| 24 | - } |
|
| 25 | - else |
|
| 24 | + } else |
|
| 26 | 25 | { |
| 27 | 26 | if(isset($data['extended'])) |
| 28 | 27 | { |
| 29 | 28 | $this->ldapObj = $data['extended']; |
| 30 | - } |
|
| 31 | - else |
|
| 29 | + } else |
|
| 32 | 30 | { |
| 33 | 31 | $this->ldapObj = $data; |
| 34 | 32 | } |
@@ -44,7 +42,9 @@ discard block |
||
| 44 | 42 | { |
| 45 | 43 | $dn = explode(',', $array[$i]); |
| 46 | 44 | $res = $this->isInGroupNamed(substr($dn[0], 3)); |
| 47 | - if($res) return $res; |
|
| 45 | + if($res) { |
|
| 46 | + return $res; |
|
| 47 | + } |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | return $res; |
@@ -206,8 +206,7 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | return $res; |
| 209 | - } |
|
| 210 | - else |
|
| 209 | + } else |
|
| 211 | 210 | { |
| 212 | 211 | return false; |
| 213 | 212 | } |
@@ -231,8 +230,7 @@ discard block |
||
| 231 | 230 | if(!is_object($this->ldapObj)) |
| 232 | 231 | { |
| 233 | 232 | return $this->setFieldLocal('userPassword', $this->generateLDAPPass($password)); |
| 234 | - } |
|
| 235 | - else |
|
| 233 | + } else |
|
| 236 | 234 | { |
| 237 | 235 | $obj = array('dn'=>$this->ldapObj->dn); |
| 238 | 236 | $obj['userPassword'] = $this->generateLDAPPass($password); |
@@ -321,8 +319,7 @@ discard block |
||
| 321 | 319 | if(!is_object($this->ldapObj)) |
| 322 | 320 | { |
| 323 | 321 | return $this->setFieldLocal('uid', $uid); |
| 324 | - } |
|
| 325 | - else |
|
| 322 | + } else |
|
| 326 | 323 | { |
| 327 | 324 | throw new \Exception('Unsupported!'); |
| 328 | 325 | } |
@@ -416,8 +413,7 @@ discard block |
||
| 416 | 413 | if(isset($ldapObj->userpassword)) |
| 417 | 414 | { |
| 418 | 415 | $hash = hash('sha512', $ldapObj->dn.';'.$ldapObj->userpassword[0].';'.$ldapObj->mail[0]); |
| 419 | - } |
|
| 420 | - else |
|
| 416 | + } else |
|
| 421 | 417 | { |
| 422 | 418 | $hash = hash('sha512', $ldapObj->dn.';'.openssl_random_pseudo_bytes(10).';'.$ldapObj->mail[0]); |
| 423 | 419 | } |
@@ -116,26 +116,26 @@ |
||
| 116 | 116 | |
| 117 | 117 | private function getDataTable($name, $pending=false) |
| 118 | 118 | { |
| 119 | - if(isset($this->dataTables[$name]) && isset($this->dataTables[$name][$pending])) |
|
| 120 | - { |
|
| 121 | - return $this->dataTables[$name][$pending]; |
|
| 122 | - } |
|
| 123 | - $dataSet = $this->dataSet; |
|
| 124 | - if($pending) |
|
| 125 | - { |
|
| 126 | - $dataSet = $this->pendingDataSet; |
|
| 127 | - } |
|
| 128 | - if($dataSet === null) |
|
| 129 | - { |
|
| 130 | - throw new \Exception('Unable to obtain dataset for SQL Authentication!'); |
|
| 131 | - } |
|
| 132 | - $dataTable = $dataSet[$name]; |
|
| 133 | - if(!isset($this->dataTables[$name])) |
|
| 134 | - { |
|
| 135 | - $this->dataTables[$name] = array(); |
|
| 136 | - } |
|
| 137 | - $this->dataTables[$name][$pending] = $dataTable; |
|
| 138 | - return $dataTable; |
|
| 119 | + if(isset($this->dataTables[$name]) && isset($this->dataTables[$name][$pending])) |
|
| 120 | + { |
|
| 121 | + return $this->dataTables[$name][$pending]; |
|
| 122 | + } |
|
| 123 | + $dataSet = $this->dataSet; |
|
| 124 | + if($pending) |
|
| 125 | + { |
|
| 126 | + $dataSet = $this->pendingDataSet; |
|
| 127 | + } |
|
| 128 | + if($dataSet === null) |
|
| 129 | + { |
|
| 130 | + throw new \Exception('Unable to obtain dataset for SQL Authentication!'); |
|
| 131 | + } |
|
| 132 | + $dataTable = $dataSet[$name]; |
|
| 133 | + if(!isset($this->dataTables[$name])) |
|
| 134 | + { |
|
| 135 | + $this->dataTables[$name] = array(); |
|
| 136 | + } |
|
| 137 | + $this->dataTables[$name][$pending] = $dataTable; |
|
| 138 | + return $dataTable; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | private function getPendingUserDataTable() |
@@ -149,7 +149,9 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | public function login($username, $password) |
| 151 | 151 | { |
| 152 | - if($this->current === false) return false; |
|
| 152 | + if($this->current === false) { |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 153 | 155 | $userDataTable = $this->getDataTable('user'); |
| 154 | 156 | $filter = new \Data\Filter("uid eq '$username'"); |
| 155 | 157 | $users = $userDataTable->read($filter, 'uid,pass'); |
@@ -235,9 +237,13 @@ discard block |
||
| 235 | 237 | |
| 236 | 238 | public function getPendingUserCount() |
| 237 | 239 | { |
| 238 | - if($this->pending === false) return 0; |
|
| 240 | + if($this->pending === false) { |
|
| 241 | + return 0; |
|
| 242 | + } |
|
| 239 | 243 | $dataTable = $this->getPendingUserDataTable(); |
| 240 | - if($dataTable === null) return 0; |
|
| 244 | + if($dataTable === null) { |
|
| 245 | + return 0; |
|
| 246 | + } |
|
| 241 | 247 | return $dataTable->count(); |
| 242 | 248 | } |
| 243 | 249 | |
@@ -275,7 +281,9 @@ discard block |
||
| 275 | 281 | public function getPendingUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
| 276 | 282 | |
| 277 | 283 | { |
| 278 | - if($this->pending === false) return false; |
|
| 284 | + if($this->pending === false) { |
|
| 285 | + return false; |
|
| 286 | + } |
|
| 279 | 287 | if($filter !== false && !$filter->contains('hash')) |
| 280 | 288 | { |
| 281 | 289 | return $this->searchPendingUsers($filter, $select, $top, $skip, $orderby); |
@@ -296,7 +304,9 @@ discard block |
||
| 296 | 304 | |
| 297 | 305 | public function createPendingUser($user) |
| 298 | 306 | { |
| 299 | - if($this->pending === false) return false; |
|
| 307 | + if($this->pending === false) { |
|
| 308 | + return false; |
|
| 309 | + } |
|
| 300 | 310 | $userDataTable = $this->getPendingUserDataTable(); |
| 301 | 311 | if(isset($user->password2)) |
| 302 | 312 | { |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | $ret = $auth->activatePendingUser($user); |
| 67 | 67 | if($ret === false) |
| 68 | 68 | {
|
| 69 | - throw new \Exception('Unable to create user! '.$res);
|
|
| 69 | + throw new \Exception('Unable to create user! '.$res);
|
|
| 70 | 70 | } |
| 71 | 71 | return self::SUCCESS; |
| 72 | 72 | } |
@@ -55,8 +55,7 @@ |
||
| 55 | 55 | } |
| 56 | 56 | $currentUser = $localUsers[0]; |
| 57 | 57 | return self::ALREADY_PRESENT; |
| 58 | - } |
|
| 59 | - else |
|
| 58 | + } else |
|
| 60 | 59 | {
|
| 61 | 60 | $user = new PendingUser(); |
| 62 | 61 | $user->setEmail($googleUser->email); |
@@ -280,11 +280,15 @@ discard block |
||
| 280 | 280 | function canLoginWith($provider) |
| 281 | 281 | { |
| 282 | 282 | $hosts = $this->getLoginProviders(); |
| 283 | - if($hosts === false) return false; |
|
| 283 | + if($hosts === false) { |
|
| 284 | + return false; |
|
| 285 | + } |
|
| 284 | 286 | $count = count($hosts); |
| 285 | 287 | for($i = 0; $i < $count; $i++) |
| 286 | 288 | { |
| 287 | - if(strcasecmp($hosts[$i], $provider) === 0) return true; |
|
| 289 | + if(strcasecmp($hosts[$i], $provider) === 0) { |
|
| 290 | + return true; |
|
| 291 | + } |
|
| 288 | 292 | } |
| 289 | 293 | return false; |
| 290 | 294 | } |
@@ -607,8 +611,7 @@ discard block |
||
| 607 | 611 | $this->change_pass($data->oldpass, $data->password); |
| 608 | 612 | unset($data->oldpass); |
| 609 | 613 | unset($data->password); |
| 610 | - } |
|
| 611 | - else if(isset($data->hash) && isset($data->password)) |
|
| 614 | + } else if(isset($data->hash) && isset($data->password)) |
|
| 612 | 615 | { |
| 613 | 616 | $this->change_pass($data->hash, $data->password, true); |
| 614 | 617 | return; |
@@ -75,8 +75,7 @@ discard block |
||
| 75 | 75 | if(!isset($this->headers['Authorization'])) |
| 76 | 76 | { |
| 77 | 77 | $this->app->user = $this->getUserFromSession(); |
| 78 | - } |
|
| 79 | - else |
|
| 78 | + } else |
|
| 80 | 79 | { |
| 81 | 80 | $header = $this->headers['Authorization']; |
| 82 | 81 | $this->app->user = $this->getUserFromHeader($header); |
@@ -99,16 +98,13 @@ discard block |
||
| 99 | 98 | if(is_array($value)) |
| 100 | 99 | { |
| 101 | 100 | $array[$key] = implode(';', $value); |
| 102 | - } |
|
| 103 | - else if($key === '_id' && is_object($value)) |
|
| 101 | + } else if($key === '_id' && is_object($value)) |
|
| 104 | 102 | { |
| 105 | 103 | $array[$key] = $value->{'$id'}; |
| 106 | - } |
|
| 107 | - else if(is_object($value)) |
|
| 104 | + } else if(is_object($value)) |
|
| 108 | 105 | { |
| 109 | 106 | $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key; |
| 110 | - } |
|
| 111 | - else if(strncmp($value, 'data:', 5) === 0) |
|
| 107 | + } else if(strncmp($value, 'data:', 5) === 0) |
|
| 112 | 108 | { |
| 113 | 109 | $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key; |
| 114 | 110 | } |
@@ -129,8 +125,7 @@ discard block |
||
| 129 | 125 | if(is_array($first)) |
| 130 | 126 | { |
| 131 | 127 | $keys = array_keys($first); |
| 132 | - } |
|
| 133 | - else if(is_object($first)) |
|
| 128 | + } else if(is_object($first)) |
|
| 134 | 129 | { |
| 135 | 130 | $keys = array_keys(get_object_vars($first)); |
| 136 | 131 | } |
@@ -145,8 +140,7 @@ discard block |
||
| 145 | 140 | $this->fix_encoded_element($key, $value, $row, '/'.$id); |
| 146 | 141 | } |
| 147 | 142 | fputcsv($df, $row); |
| 148 | - } |
|
| 149 | - else if(is_object($row)) |
|
| 143 | + } else if(is_object($row)) |
|
| 150 | 144 | { |
| 151 | 145 | $keyName = $keys[0]; |
| 152 | 146 | $id = $row->$keyName; |
@@ -162,8 +156,7 @@ discard block |
||
| 162 | 156 | fputcsv($df, $values); |
| 163 | 157 | } |
| 164 | 158 | } |
| 165 | - } |
|
| 166 | - else |
|
| 159 | + } else |
|
| 167 | 160 | { |
| 168 | 161 | $array = get_object_vars($array); |
| 169 | 162 | fputcsv($df, array_keys($array)); |
@@ -262,8 +255,7 @@ discard block |
||
| 262 | 255 | break; |
| 263 | 256 | } |
| 264 | 257 | $this->app->response->setBody($text); |
| 265 | - } |
|
| 266 | - else if($this->app->response->getStatus() == 200) |
|
| 258 | + } else if($this->app->response->getStatus() == 200) |
|
| 267 | 259 | { |
| 268 | 260 | $this->app->response->headers->set('Content-Type', 'application/json;odata.metadata=none'); |
| 269 | 261 | } |
@@ -10,8 +10,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |