@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } else { |
| 59 | 59 | $host = FCgetHostName(); |
| 60 | 60 | } |
| 61 | - $pattern = '#^https?://' . str_replace('.', '\.', $host) . '(:\d*)?/#'; |
|
| 61 | + $pattern = '#^https?://'.str_replace('.', '\.', $host).'(:\d*)?/#'; |
|
| 62 | 62 | if (!preg_match($pattern, $_SERVER['HTTP_REFERER'])) { |
| 63 | 63 | exit; |
| 64 | 64 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Percent-encode special characters in the URL |
| 76 | -$search = array( '%', '#', ' '); |
|
| 76 | +$search = array('%', '#', ' '); |
|
| 77 | 77 | $replace = array('%25', '%23', '%20'); |
| 78 | 78 | $url = str_replace($search, $replace, $_GET['url']); |
| 79 | 79 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | |
| 42 | 42 | // Force download |
| 43 | 43 | header('Content-Type: application/octet-stream'); |
| 44 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 44 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 45 | 45 | |
| 46 | 46 | if (isset($_POST['dataurl'])) { |
| 47 | 47 | // Decode the base64-encoded data |
@@ -12,45 +12,45 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | function __construct($params) |
| 14 | 14 | { |
| 15 | - if(isset($params['filter'])) |
|
| 15 | + if (isset($params['filter'])) |
|
| 16 | 16 | { |
| 17 | 17 | $this->filter = new \Data\Filter($params['filter']); |
| 18 | 18 | } |
| 19 | - else if(isset($params['$filter'])) |
|
| 19 | + else if (isset($params['$filter'])) |
|
| 20 | 20 | { |
| 21 | 21 | $this->filter = new \Data\Filter($params['$filter']); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - if(isset($params['$expand'])) |
|
| 24 | + if (isset($params['$expand'])) |
|
| 25 | 25 | { |
| 26 | - $this->expand = explode(',',$params['$expand']); |
|
| 26 | + $this->expand = explode(',', $params['$expand']); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if(isset($params['select'])) |
|
| 29 | + if (isset($params['select'])) |
|
| 30 | 30 | { |
| 31 | - $this->select = explode(',',$params['select']); |
|
| 31 | + $this->select = explode(',', $params['select']); |
|
| 32 | 32 | } |
| 33 | - else if(isset($params['$select'])) |
|
| 33 | + else if (isset($params['$select'])) |
|
| 34 | 34 | { |
| 35 | - $this->select = explode(',',$params['$select']); |
|
| 35 | + $this->select = explode(',', $params['$select']); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if(isset($params['$orderby'])) |
|
| 38 | + if (isset($params['$orderby'])) |
|
| 39 | 39 | { |
| 40 | 40 | $this->orderby = array(); |
| 41 | - $orderby = explode(',',$params['$orderby']); |
|
| 41 | + $orderby = explode(',', $params['$orderby']); |
|
| 42 | 42 | $count = count($orderby); |
| 43 | - for($i = 0; $i < $count; $i++) |
|
| 43 | + for ($i = 0; $i < $count; $i++) |
|
| 44 | 44 | { |
| 45 | - $exp = explode(' ',$orderby[$i]); |
|
| 46 | - if(count($exp) === 1) |
|
| 45 | + $exp = explode(' ', $orderby[$i]); |
|
| 46 | + if (count($exp) === 1) |
|
| 47 | 47 | { |
| 48 | 48 | //Default to assending |
| 49 | 49 | $this->orderby[$exp[0]] = 1; |
| 50 | 50 | } |
| 51 | 51 | else |
| 52 | 52 | { |
| 53 | - switch($exp[1]) |
|
| 53 | + switch ($exp[1]) |
|
| 54 | 54 | { |
| 55 | 55 | case 'asc': |
| 56 | 56 | $this->orderby[$exp[0]] = 1; |
@@ -65,22 +65,22 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if(isset($params['$top'])) |
|
| 68 | + if (isset($params['$top'])) |
|
| 69 | 69 | { |
| 70 | 70 | $this->top = $params['$top']; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if(isset($params['$skip'])) |
|
| 73 | + if (isset($params['$skip'])) |
|
| 74 | 74 | { |
| 75 | 75 | $this->skip = $params['$skip']; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if(isset($params['$count']) && $params['$count'] === 'true') |
|
| 78 | + if (isset($params['$count']) && $params['$count'] === 'true') |
|
| 79 | 79 | { |
| 80 | 80 | $this->count = true; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if(isset($params['$seach'])) |
|
| 83 | + if (isset($params['$seach'])) |
|
| 84 | 84 | { |
| 85 | 85 | throw new Exception('Search not yet implemented'); |
| 86 | 86 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | public function getUserFromToken($token) |
| 32 | 32 | { |
| 33 | - if($token === false) |
|
| 33 | + if ($token === false) |
|
| 34 | 34 | { |
| 35 | 35 | $token = \FlipSession::getVar('OAuthToken'); |
| 36 | 36 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } else { |
| 59 | 59 | $host = FCgetHostName(); |
| 60 | 60 | } |
| 61 | - $pattern = '#^https?://' . str_replace('.', '\.', $host) . '(:\d*)?/#'; |
|
| 61 | + $pattern = '#^https?://'.str_replace('.', '\.', $host).'(:\d*)?/#'; |
|
| 62 | 62 | if (!preg_match($pattern, $_SERVER['HTTP_REFERER'])) { |
| 63 | 63 | exit; |
| 64 | 64 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Percent-encode special characters in the URL |
| 76 | -$search = array( '%', '#', ' '); |
|
| 76 | +$search = array('%', '#', ' '); |
|
| 77 | 77 | $replace = array('%25', '%23', '%20'); |
| 78 | 78 | $url = str_replace($search, $replace, $_GET['url']); |
| 79 | 79 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | |
| 42 | 42 | // Force download |
| 43 | 43 | header('Content-Type: application/octet-stream'); |
| 44 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 44 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 45 | 45 | |
| 46 | 46 | if (isset($_POST['dataurl'])) { |
| 47 | 47 | // Decode the base64-encoded data |
@@ -6,13 +6,13 @@ discard block |
||
| 6 | 6 | public $user; |
| 7 | 7 | public $is_admin = false; |
| 8 | 8 | |
| 9 | - function __construct($title, $adminGroup='LDAPAdmins') |
|
| 9 | + function __construct($title, $adminGroup = 'LDAPAdmins') |
|
| 10 | 10 | { |
| 11 | 11 | $this->user = FlipSession::getUser(); |
| 12 | 12 | $this->is_admin = $this->userIsAdmin($adminGroup); |
| 13 | 13 | parent::__construct($title); |
| 14 | 14 | $adminCSS = '/css/common/admin.min.css'; |
| 15 | - if($this->minified !== 'min') |
|
| 15 | + if ($this->minified !== 'min') |
|
| 16 | 16 | { |
| 17 | 17 | $adminCSS = '/css/common/admin.css'; |
| 18 | 18 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | protected function userIsAdmin($adminGroup) |
| 24 | 24 | { |
| 25 | - if($this->user === false || $this->user === null) |
|
| 25 | + if ($this->user === false || $this->user === null) |
|
| 26 | 26 | { |
| 27 | 27 | return false; |
| 28 | 28 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | function addAllLinks() |
| 33 | 33 | { |
| 34 | - if($this->user === false || $this->user === null) |
|
| 34 | + if ($this->user === false || $this->user === null) |
|
| 35 | 35 | { |
| 36 | 36 | $this->addLink('<i class="fa fa-sign-in"></i> Login', $this->loginUrl); |
| 37 | 37 | } |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | $ret = '<li>'; |
| 48 | 48 | $href = $this->getHrefForDropdown($link); |
| 49 | 49 | $ret .= $this->createLink($name.' <i class="fa fa-arrow-right"></i>', $href); |
| 50 | - $ret.='<ul>'; |
|
| 50 | + $ret .= '<ul>'; |
|
| 51 | 51 | $subNames = array_keys($link); |
| 52 | - foreach($subNames as $subName) |
|
| 52 | + foreach ($subNames as $subName) |
|
| 53 | 53 | { |
| 54 | - $ret.=$this->getLinkByName($subName, $link); |
|
| 54 | + $ret .= $this->getLinkByName($subName, $link); |
|
| 55 | 55 | } |
| 56 | - $ret.='</ul></li>'; |
|
| 56 | + $ret .= '</ul></li>'; |
|
| 57 | 57 | return $ret; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $sites = $this->getSiteLinksForHeader(); |
| 63 | 63 | $sideNav = $this->getLinksMenus(); |
| 64 | 64 | $log = '<a href="https://profiles.burningflipside.com/logout.php"><i class="fa fa-sign-out"></i></a>'; |
| 65 | - if($this->user === false || $this->user === null) |
|
| 65 | + if ($this->user === false || $this->user === null) |
|
| 66 | 66 | { |
| 67 | 67 | $log = '<a href="https://profiles.burningflipside.com/login.php?return='.$this->currentUrl().'"><i class="fa fa-sign-in"></i></a>'; |
| 68 | 68 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | const CARD_YELLOW = 'panel-yellow'; |
| 109 | 109 | const CARD_RED = 'panel-red'; |
| 110 | 110 | |
| 111 | - function add_card($iconName, $bigText, $littleText, $link='#', $color = self::CARD_BLUE, $textColor=false) |
|
| 111 | + function add_card($iconName, $bigText, $littleText, $link = '#', $color = self::CARD_BLUE, $textColor = false) |
|
| 112 | 112 | { |
| 113 | 113 | $card = '<div class="col-lg-3 col-md-6"> |
| 114 | 114 | <div class="panel '.$color.'"> |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | $this->body .= $card; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - function printPage($header=true) |
|
| 138 | + function printPage($header = true) |
|
| 139 | 139 | { |
| 140 | - if($this->user === false || $this->user === null) |
|
| 140 | + if ($this->user === false || $this->user === null) |
|
| 141 | 141 | { |
| 142 | 142 | $this->body = ' |
| 143 | 143 | <div class="row"> |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | </div> |
| 147 | 147 | </div>'; |
| 148 | 148 | } |
| 149 | - else if($this->is_admin === false) |
|
| 149 | + else if ($this->is_admin === false) |
|
| 150 | 150 | { |
| 151 | 151 | $this->body = ' |
| 152 | 152 | <div class="row"> |
@@ -8,15 +8,15 @@ discard block |
||
| 8 | 8 | private $ldapObj; |
| 9 | 9 | private $server; |
| 10 | 10 | |
| 11 | - function __construct($data=false) |
|
| 11 | + function __construct($data = false) |
|
| 12 | 12 | { |
| 13 | 13 | $this->server = \LDAP\LDAPServer::getInstance(); |
| 14 | - if($data !== false && !isset($data['dn']) && !isset($data['extended'])) |
|
| 14 | + if ($data !== false && !isset($data['dn']) && !isset($data['extended'])) |
|
| 15 | 15 | { |
| 16 | 16 | //Generic user object |
| 17 | 17 | $filter = new \Data\Filter('mail eq '.$data['mail']); |
| 18 | 18 | $users = $this->server->read($this->server->user_base, $filter); |
| 19 | - if($users === false || !isset($users[0])) |
|
| 19 | + if ($users === false || !isset($users[0])) |
|
| 20 | 20 | { |
| 21 | 21 | throw new \Exception('No such LDAP User!'); |
| 22 | 22 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | else |
| 26 | 26 | { |
| 27 | - if(isset($data['extended'])) |
|
| 27 | + if (isset($data['extended'])) |
|
| 28 | 28 | { |
| 29 | 29 | $this->ldapObj = $data['extended']; |
| 30 | 30 | } |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | private function check_child_group($array) |
| 39 | 39 | { |
| 40 | 40 | $res = false; |
| 41 | - for($i = 0; $i < $array['count']; $i++) |
|
| 41 | + for ($i = 0; $i < $array['count']; $i++) |
|
| 42 | 42 | { |
| 43 | - if(strpos($array[$i], $this->server->group_base) !== false) |
|
| 43 | + if (strpos($array[$i], $this->server->group_base) !== false) |
|
| 44 | 44 | { |
| 45 | 45 | $dn = explode(',', $array[$i]); |
| 46 | 46 | $res = $this->isInGroupNamed(substr($dn[0], 3)); |
| 47 | - if($res) return $res; |
|
| 47 | + if ($res) return $res; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | return $res; |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $filter = new \Data\Filter('cn eq '.$name); |
| 56 | 56 | $group = $this->server->read($this->server->group_base, $filter); |
| 57 | - if(!empty($group)) |
|
| 57 | + if (!empty($group)) |
|
| 58 | 58 | { |
| 59 | 59 | $group = $group[0]; |
| 60 | 60 | $dn = $this->ldapObj->dn; |
| 61 | 61 | $uid = $this->ldapObj->uid[0]; |
| 62 | - if(isset($group['member'])) |
|
| 62 | + if (isset($group['member'])) |
|
| 63 | 63 | { |
| 64 | - if(in_array($dn, $group['member'])) |
|
| 64 | + if (in_array($dn, $group['member'])) |
|
| 65 | 65 | { |
| 66 | 66 | return true; |
| 67 | 67 | } |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | return $this->check_child_group($group['member']); |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | - else if(isset($group['uniquemember'])) |
|
| 73 | + else if (isset($group['uniquemember'])) |
|
| 74 | 74 | { |
| 75 | - if(in_array($dn, $group['uniquemember'])) |
|
| 75 | + if (in_array($dn, $group['uniquemember'])) |
|
| 76 | 76 | { |
| 77 | 77 | return true; |
| 78 | 78 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | return $this->check_child_group($group['uniquemember']); |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | - else if(isset($group['memberUid']) && in_array($uid, $group['memberUid'])) |
|
| 84 | + else if (isset($group['memberUid']) && in_array($uid, $group['memberUid'])) |
|
| 85 | 85 | { |
| 86 | 86 | return true; |
| 87 | 87 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | function getOrganization() |
| 123 | 123 | { |
| 124 | 124 | $org = $this->getFieldSingleValue('o'); |
| 125 | - if($org === false) |
|
| 125 | + if ($org === false) |
|
| 126 | 126 | { |
| 127 | 127 | return 'Volunteer'; |
| 128 | 128 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | function getTitles() |
| 133 | 133 | { |
| 134 | 134 | $titles = $this->getField('title'); |
| 135 | - if(isset($titles['count'])) |
|
| 135 | + if (isset($titles['count'])) |
|
| 136 | 136 | { |
| 137 | 137 | unset($titles['count']); |
| 138 | 138 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | function getOrganizationUnits() |
| 178 | 178 | { |
| 179 | 179 | $units = $this->getField('ou'); |
| 180 | - if(isset($units['count'])) |
|
| 180 | + if (isset($units['count'])) |
|
| 181 | 181 | { |
| 182 | 182 | unset($units['count']); |
| 183 | 183 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | function getLoginProviders() |
| 188 | 188 | { |
| 189 | 189 | $hosts = $this->getField('host'); |
| 190 | - if(isset($hosts['count'])) |
|
| 190 | + if (isset($hosts['count'])) |
|
| 191 | 191 | { |
| 192 | 192 | unset($hosts['count']); |
| 193 | 193 | } |
@@ -198,12 +198,12 @@ discard block |
||
| 198 | 198 | { |
| 199 | 199 | $res = array(); |
| 200 | 200 | $groups = $this->server->read($this->server->group_base); |
| 201 | - if(!empty($groups)) |
|
| 201 | + if (!empty($groups)) |
|
| 202 | 202 | { |
| 203 | 203 | $count = count($groups); |
| 204 | - for($i = 0; $i < $count; $i++) |
|
| 204 | + for ($i = 0; $i < $count; $i++) |
|
| 205 | 205 | { |
| 206 | - if($this->isInGroupNamed($groups[$i]['cn'][0])) |
|
| 206 | + if ($this->isInGroupNamed($groups[$i]['cn'][0])) |
|
| 207 | 207 | { |
| 208 | 208 | array_push($res, new LDAPGroup($groups[$i])); |
| 209 | 209 | } |
@@ -223,23 +223,23 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | private function generateLDAPPass($pass) |
| 225 | 225 | { |
| 226 | - mt_srand((double)microtime()*1000000); |
|
| 226 | + mt_srand((double)microtime() * 1000000); |
|
| 227 | 227 | $salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand()); |
| 228 | - $hash = base64_encode(pack('H*',sha1($pass.$salt)).$salt); |
|
| 228 | + $hash = base64_encode(pack('H*', sha1($pass.$salt)).$salt); |
|
| 229 | 229 | return '{SSHA}'.$hash; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | function setPass($password) |
| 233 | 233 | { |
| 234 | - if(!is_object($this->ldapObj)) |
|
| 234 | + if (!is_object($this->ldapObj)) |
|
| 235 | 235 | { |
| 236 | - return $this->setFieldLocal('userPassword', $this->generateLDAPPass($password)); |
|
| 236 | + return $this->setFieldLocal('userPassword', $this->generateLDAPPass($password)); |
|
| 237 | 237 | } |
| 238 | 238 | else |
| 239 | 239 | { |
| 240 | 240 | $obj = array('dn'=>$this->ldapObj->dn); |
| 241 | 241 | $obj['userPassword'] = $this->generateLDAPPass($password); |
| 242 | - if(isset($this->ldapObj->uniqueidentifier)) |
|
| 242 | + if (isset($this->ldapObj->uniqueidentifier)) |
|
| 243 | 243 | { |
| 244 | 244 | $obj['uniqueIdentifier'] = null; |
| 245 | 245 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | function validate_password($password) |
| 255 | 255 | { |
| 256 | - if($this->server->bind($this->ldapObj->dn, $password)) |
|
| 256 | + if ($this->server->bind($this->ldapObj->dn, $password)) |
|
| 257 | 257 | { |
| 258 | 258 | return true; |
| 259 | 259 | } |
@@ -262,37 +262,37 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | function validate_reset_hash($hash) |
| 264 | 264 | { |
| 265 | - if(isset($this->ldapObj->uniqueidentifier) && strcmp($this->ldapObj->uniqueidentifier[0], $hash) === 0) |
|
| 265 | + if (isset($this->ldapObj->uniqueidentifier) && strcmp($this->ldapObj->uniqueidentifier[0], $hash) === 0) |
|
| 266 | 266 | { |
| 267 | 267 | return true; |
| 268 | 268 | } |
| 269 | 269 | return false; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - static function from_name($name, $data=false) |
|
| 272 | + static function from_name($name, $data = false) |
|
| 273 | 273 | { |
| 274 | - if($data === false) |
|
| 274 | + if ($data === false) |
|
| 275 | 275 | { |
| 276 | 276 | throw new \Exception('data must be set for LDAPUser'); |
| 277 | 277 | } |
| 278 | 278 | $filter = new \Data\Filter("uid eq $name"); |
| 279 | 279 | $user = $data->read($data->user_base, $filter); |
| 280 | - if($user === false || !isset($user[0])) |
|
| 280 | + if ($user === false || !isset($user[0])) |
|
| 281 | 281 | { |
| 282 | 282 | return false; |
| 283 | 283 | } |
| 284 | 284 | return new static($user[0]); |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - static function from_dn($dn, $data=false) |
|
| 287 | + static function from_dn($dn, $data = false) |
|
| 288 | 288 | { |
| 289 | - if($data === false) |
|
| 289 | + if ($data === false) |
|
| 290 | 290 | { |
| 291 | 291 | throw new \Exception('data must be set for LDAPUser'); |
| 292 | 292 | } |
| 293 | 293 | $filter = new \Data\Filter("dn eq $dn"); |
| 294 | 294 | $user = $data->read($data->user_base, $filter); |
| 295 | - if($user === false || !isset($user[0])) |
|
| 295 | + if ($user === false || !isset($user[0])) |
|
| 296 | 296 | { |
| 297 | 297 | return false; |
| 298 | 298 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | function setUid($uid) |
| 323 | 323 | { |
| 324 | - if(!is_object($this->ldapObj)) |
|
| 324 | + if (!is_object($this->ldapObj)) |
|
| 325 | 325 | { |
| 326 | 326 | return $this->setFieldLocal('uid', $uid); |
| 327 | 327 | } |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | function setTitles($titles) |
| 371 | 371 | { |
| 372 | - if(!is_array($titles)) |
|
| 372 | + if (!is_array($titles)) |
|
| 373 | 373 | { |
| 374 | 374 | $titles = array($titles); |
| 375 | 375 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | |
| 379 | 379 | function setOrganizationUnits($ous) |
| 380 | 380 | { |
| 381 | - if(!is_array($ous)) |
|
| 381 | + if (!is_array($ous)) |
|
| 382 | 382 | { |
| 383 | 383 | $ous = array($ous); |
| 384 | 384 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | function flushUser() |
| 389 | 389 | { |
| 390 | - if(is_object($this->ldapObj)) |
|
| 390 | + if (is_object($this->ldapObj)) |
|
| 391 | 391 | { |
| 392 | 392 | //In this mode we are always up to date |
| 393 | 393 | return true; |
@@ -395,11 +395,11 @@ discard block |
||
| 395 | 395 | $obj = $this->ldapObj; |
| 396 | 396 | $obj['objectClass'] = array('top', 'inetOrgPerson', 'extensibleObject'); |
| 397 | 397 | $obj['dn'] = 'uid='.$this->ldapObj['uid'].','.$this->server->user_base; |
| 398 | - if(!isset($obj['sn'])) |
|
| 398 | + if (!isset($obj['sn'])) |
|
| 399 | 399 | { |
| 400 | 400 | $obj['sn'] = $obj['uid']; |
| 401 | 401 | } |
| 402 | - if(!isset($obj['cn'])) |
|
| 402 | + if (!isset($obj['cn'])) |
|
| 403 | 403 | { |
| 404 | 404 | $obj['cn'] = $obj['uid']; |
| 405 | 405 | } |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $ldapObj = $this->server->read($ldap->user_base, new \Data\Filter('uid eq '.$this->getUid())); |
| 417 | 417 | $ldapObj = $ldapObj[0]; |
| 418 | 418 | $hash = false; |
| 419 | - if(isset($ldapObj->userpassword)) |
|
| 419 | + if (isset($ldapObj->userpassword)) |
|
| 420 | 420 | { |
| 421 | 421 | $hash = hash('sha512', $ldapObj->dn.';'.$ldapObj->userpassword[0].';'.$ldapObj->mail[0]); |
| 422 | 422 | } |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | } |
| 427 | 427 | $obj = array('dn'=>$this->ldapObj->dn); |
| 428 | 428 | $obj['uniqueIdentifier'] = $hash; |
| 429 | - if($this->server->update($obj) === false) |
|
| 429 | + if ($this->server->update($obj) === false) |
|
| 430 | 430 | { |
| 431 | 431 | throw new \Exception('Unable to create hash in LDAP object!'); |
| 432 | 432 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 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 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $res = array(); |
| 24 | 24 | $ids = FlipsideCAPTCHA::get_valid_captcha_ids(); |
| 25 | 25 | $count = count($ids); |
| 26 | - for($i = 0; $i < $count; $i++) |
|
| 26 | + for ($i = 0; $i < $count; $i++) |
|
| 27 | 27 | { |
| 28 | 28 | $captcha = new FlipsideCAPTCHA(); |
| 29 | 29 | $captcha->random_id = $ids[$i]; |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $dataset = DataSetFactory::getDataSetByName('profiles'); |
| 38 | 38 | $datatable = $dataset['captcha']; |
| 39 | - return $datatable->create(array('question'=>$question,'hint'=>$hint,'answer'=>$answer)); |
|
| 39 | + return $datatable->create(array('question'=>$question, 'hint'=>$hint, 'answer'=>$answer)); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function __construct() |
| 43 | 43 | { |
| 44 | 44 | $this->validIDs = FlipsideCAPTCHA::get_valid_captcha_ids(); |
| 45 | - $this->random_id = mt_rand(0, count($this->validIDs)-1); |
|
| 45 | + $this->random_id = mt_rand(0, count($this->validIDs) - 1); |
|
| 46 | 46 | $this->random_id = $this->validIDs[$this->random_id]; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $dataset = DataSetFactory::getDataSetByName('profiles'); |
| 52 | 52 | $datatable = $dataset['captcha']; |
| 53 | 53 | $data = $datatable->read(new \Data\Filter('id eq '.$this->random_id), array('question')); |
| 54 | - if($data === false) |
|
| 54 | + if ($data === false) |
|
| 55 | 55 | { |
| 56 | 56 | return false; |
| 57 | 57 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $dataset = DataSetFactory::getDataSetByName('profiles'); |
| 64 | 64 | $datatable = $dataset['captcha']; |
| 65 | 65 | $data = $datatable->read(new \Data\Filter('id eq '.$this->random_id), array('hint')); |
| 66 | - if($data === false) |
|
| 66 | + if ($data === false) |
|
| 67 | 67 | { |
| 68 | 68 | return false; |
| 69 | 69 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $dataset = DataSetFactory::getDataSetByName('profiles'); |
| 76 | 76 | $datatable = $dataset['captcha']; |
| 77 | 77 | $data = $datatable->read(new \Data\Filter('id eq '.$this->random_id), array('answer')); |
| 78 | - if($data === false) |
|
| 78 | + if ($data === false) |
|
| 79 | 79 | { |
| 80 | 80 | return false; |
| 81 | 81 | } |
@@ -84,29 +84,29 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | public function is_answer_right($answer) |
| 86 | 86 | { |
| 87 | - return strcasecmp($this->get_answer(),$answer) == 0; |
|
| 87 | + return strcasecmp($this->get_answer(), $answer) == 0; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function draw_captcha($explination=true, $return=false, $ownForm=false) |
|
| 90 | + public function draw_captcha($explination = true, $return = false, $ownForm = false) |
|
| 91 | 91 | { |
| 92 | 92 | $string = ''; |
| 93 | 93 | |
| 94 | - if($ownForm) |
|
| 94 | + if ($ownForm) |
|
| 95 | 95 | { |
| 96 | - $string.= '<form id="flipcaptcha" name="flipcaptcha">'; |
|
| 96 | + $string .= '<form id="flipcaptcha" name="flipcaptcha">'; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $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>'; |
| 100 | - if($ownForm) |
|
| 100 | + if ($ownForm) |
|
| 101 | 101 | { |
| 102 | - $string.='</form>'; |
|
| 102 | + $string .= '</form>'; |
|
| 103 | 103 | } |
| 104 | - if($explination) |
|
| 104 | + if ($explination) |
|
| 105 | 105 | { |
| 106 | 106 | $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>'; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if(!$return) |
|
| 109 | + if (!$return) |
|
| 110 | 110 | { |
| 111 | 111 | echo $string; |
| 112 | 112 | } |