@@ -49,18 +49,27 @@ discard block |
||
| 49 | 49 | $get_before_set = $this->get(array($level,__CLASS__,$location)); |
| 50 | 50 | if (!is_null($get_before_set)) |
| 51 | 51 | { |
| 52 | - if ($verbose) echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n"; |
|
| 52 | + if ($verbose) |
|
| 53 | + { |
|
| 54 | + echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n"; |
|
| 55 | + } |
|
| 53 | 56 | ++$failed; |
| 54 | 57 | } |
| 55 | 58 | if (($set = $this->set(array($level,__CLASS__,$location), $data, 10)) !== true) |
| 56 | 59 | { |
| 57 | - if ($verbose) echo "$label: set returned ".array2string($set)." !== TRUE\n"; |
|
| 60 | + if ($verbose) |
|
| 61 | + { |
|
| 62 | + echo "$label: set returned ".array2string($set)." !== TRUE\n"; |
|
| 63 | + } |
|
| 58 | 64 | ++$failed; |
| 59 | 65 | } |
| 60 | 66 | $get_after_set = $this->get(array($level,__CLASS__,$location)); |
| 61 | 67 | if ($get_after_set !== $data) |
| 62 | 68 | { |
| 63 | - if ($verbose) echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n"; |
|
| 69 | + if ($verbose) |
|
| 70 | + { |
|
| 71 | + echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n"; |
|
| 72 | + } |
|
| 64 | 73 | ++$failed; |
| 65 | 74 | } |
| 66 | 75 | if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple')) |
@@ -68,25 +77,37 @@ discard block |
||
| 68 | 77 | $mget_after_set = $this->mget(array($level,__CLASS__,array($location))); |
| 69 | 78 | if ($mget_after_set[$location] !== $data) |
| 70 | 79 | { |
| 71 | - if ($verbose) echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n"; |
|
| 80 | + if ($verbose) |
|
| 81 | + { |
|
| 82 | + echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n"; |
|
| 83 | + } |
|
| 72 | 84 | ++$failed; |
| 73 | 85 | } |
| 74 | 86 | } |
| 75 | 87 | $add_after_set = $this->add(array($level,__CLASS__,$location), 'other-data'); |
| 76 | 88 | if ($add_after_set !== false) |
| 77 | 89 | { |
| 78 | - if ($verbose) echo "$label: add_after_set=".array2string($add_after_set)."\n"; |
|
| 90 | + if ($verbose) |
|
| 91 | + { |
|
| 92 | + echo "$label: add_after_set=".array2string($add_after_set)."\n"; |
|
| 93 | + } |
|
| 79 | 94 | ++$failed; |
| 80 | 95 | } |
| 81 | 96 | if (($delete = $this->delete(array($level,__CLASS__,$location))) !== true) |
| 82 | 97 | { |
| 83 | - if ($verbose) echo "$label: delete returned ".array2string($delete)." !== TRUE\n"; |
|
| 98 | + if ($verbose) |
|
| 99 | + { |
|
| 100 | + echo "$label: delete returned ".array2string($delete)." !== TRUE\n"; |
|
| 101 | + } |
|
| 84 | 102 | ++$failed; |
| 85 | 103 | } |
| 86 | 104 | $get_after_delete = $this->get(array($level,__CLASS__,$location)); |
| 87 | 105 | if (!is_null($get_after_delete)) |
| 88 | 106 | { |
| 89 | - if ($verbose) echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n"; |
|
| 107 | + if ($verbose) |
|
| 108 | + { |
|
| 109 | + echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n"; |
|
| 110 | + } |
|
| 90 | 111 | ++$failed; |
| 91 | 112 | } |
| 92 | 113 | // prepare for mget of everything |
@@ -96,18 +117,27 @@ discard block |
||
| 96 | 117 | $mget_after_delete = $this->mget(array($level,__CLASS__,array($location))); |
| 97 | 118 | if (isset($mget_after_delete[$location])) |
| 98 | 119 | { |
| 99 | - if ($verbose) echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n"; |
|
| 120 | + if ($verbose) |
|
| 121 | + { |
|
| 122 | + echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n"; |
|
| 123 | + } |
|
| 100 | 124 | ++$failed; |
| 101 | 125 | } |
| 102 | 126 | } |
| 103 | - elseif (!is_null($data)) // emulation can NOT distinquish between null and not set |
|
| 127 | + elseif (!is_null($data)) |
|
| 128 | + { |
|
| 129 | + // emulation can NOT distinquish between null and not set |
|
| 104 | 130 | { |
| 105 | 131 | $locations[$location] = $data; |
| 106 | 132 | } |
| 133 | + } |
|
| 107 | 134 | $add_after_delete = $this->add(array($level,__CLASS__,$location), $data, 10); |
| 108 | 135 | if ($add_after_delete !== true) |
| 109 | 136 | { |
| 110 | - if ($verbose) echo "$label: add_after_delete=".array2string($add_after_delete)."\n"; |
|
| 137 | + if ($verbose) |
|
| 138 | + { |
|
| 139 | + echo "$label: add_after_delete=".array2string($add_after_delete)."\n"; |
|
| 140 | + } |
|
| 111 | 141 | ++$failed; |
| 112 | 142 | } |
| 113 | 143 | else |
@@ -115,7 +145,10 @@ discard block |
||
| 115 | 145 | $get_after_add = $this->get(array($level,__CLASS__,$location)); |
| 116 | 146 | if ($get_after_add !== $data) |
| 117 | 147 | { |
| 118 | - if ($verbose) echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n"; |
|
| 148 | + if ($verbose) |
|
| 149 | + { |
|
| 150 | + echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n"; |
|
| 151 | + } |
|
| 119 | 152 | ++$failed; |
| 120 | 153 | } |
| 121 | 154 | } |
@@ -136,12 +169,18 @@ discard block |
||
| 136 | 169 | }*/ |
| 137 | 170 | if ($mget !== $locations) |
| 138 | 171 | { |
| 139 | - if ($verbose) echo "$label: mget=\n".array2string($mget)." !==\n".array2string($locations)."\n"; |
|
| 172 | + if ($verbose) |
|
| 173 | + { |
|
| 174 | + echo "$label: mget=\n".array2string($mget)." !==\n".array2string($locations)."\n"; |
|
| 175 | + } |
|
| 140 | 176 | ++$failed; |
| 141 | 177 | } |
| 142 | 178 | if ($mget_bogus !== $locations) |
| 143 | 179 | { |
| 144 | - if ($verbose) echo "$label: mget(".array2string($keys_bogus).")=\n".array2string($mget_bogus)." !==\n".array2string($locations)."\n"; |
|
| 180 | + if ($verbose) |
|
| 181 | + { |
|
| 182 | + echo "$label: mget(".array2string($keys_bogus).")=\n".array2string($mget_bogus)." !==\n".array2string($locations)."\n"; |
|
| 183 | + } |
|
| 145 | 184 | ++$failed; |
| 146 | 185 | } |
| 147 | 186 | } |
@@ -50,7 +50,10 @@ discard block |
||
| 50 | 50 | else |
| 51 | 51 | { |
| 52 | 52 | $this->base_path = Api\Cache::get_system_config('temp_dir', false); |
| 53 | - if (isset($this->base_path)) $this->base_path .= '/egw_cache'; |
|
| 53 | + if (isset($this->base_path)) |
|
| 54 | + { |
|
| 55 | + $this->base_path .= '/egw_cache'; |
|
| 56 | + } |
|
| 54 | 57 | } |
| 55 | 58 | if (!isset($this->base_path) || !file_exists($this->base_path) && !mkdir($this->base_path,0700,true)) |
| 56 | 59 | { |
@@ -86,7 +89,10 @@ discard block |
||
| 86 | 89 | { |
| 87 | 90 | flock($ret, LOCK_EX); |
| 88 | 91 | $ok = fwrite($ret, serialize($data)); |
| 89 | - if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); |
|
| 92 | + if ((int)$expiration > 0) |
|
| 93 | + { |
|
| 94 | + file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); |
|
| 95 | + } |
|
| 90 | 96 | flock($ret, LOCK_UN); |
| 91 | 97 | fclose($ret); |
| 92 | 98 | $ret = $ok !== false; |
@@ -106,7 +112,10 @@ discard block |
||
| 106 | 112 | { |
| 107 | 113 | if (($ret = @file_put_contents($fname=$this->filename($keys,true),serialize($data),LOCK_EX) > 0)) |
| 108 | 114 | { |
| 109 | - if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); |
|
| 115 | + if ((int)$expiration > 0) |
|
| 116 | + { |
|
| 117 | + file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); |
|
| 118 | + } |
|
| 110 | 119 | } |
| 111 | 120 | return $ret; |
| 112 | 121 | } |
@@ -182,17 +191,26 @@ discard block |
||
| 182 | 191 | } |
| 183 | 192 | foreach(scandir($path) as $file) |
| 184 | 193 | { |
| 185 | - if ($file == '.' || $file == '..') continue; |
|
| 194 | + if ($file == '.' || $file == '..') |
|
| 195 | + { |
|
| 196 | + continue; |
|
| 197 | + } |
|
| 186 | 198 | |
| 187 | 199 | $file = $path.'/'.$file; |
| 188 | 200 | |
| 189 | 201 | if (is_dir($file)) |
| 190 | 202 | { |
| 191 | - if (!self::rm_recursive($file)) return false; |
|
| 203 | + if (!self::rm_recursive($file)) |
|
| 204 | + { |
|
| 205 | + return false; |
|
| 206 | + } |
|
| 192 | 207 | } |
| 193 | 208 | else |
| 194 | 209 | { |
| 195 | - if (!unlink($file)) return false; |
|
| 210 | + if (!unlink($file)) |
|
| 211 | + { |
|
| 212 | + return false; |
|
| 213 | + } |
|
| 196 | 214 | } |
| 197 | 215 | } |
| 198 | 216 | return rmdir($path); |
@@ -18,4 +18,6 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * Exception thrown by Cache classes |
| 20 | 20 | */ |
| 21 | -class Exception extends Api\Exception {} |
|
| 21 | +class Exception extends Api\Exception |
|
| 22 | +{ |
|
| 23 | +} |
|
@@ -368,7 +368,10 @@ discard block |
||
| 368 | 368 | { |
| 369 | 369 | if ($translated) |
| 370 | 370 | { |
| 371 | - if (!self::$countries_translated) self::_translate_countries(); |
|
| 371 | + if (!self::$countries_translated) |
|
| 372 | + { |
|
| 373 | + self::_translate_countries(); |
|
| 374 | + } |
|
| 372 | 375 | |
| 373 | 376 | return self::$countries_translated[strtoupper($code)]; |
| 374 | 377 | } |
@@ -383,7 +386,11 @@ discard block |
||
| 383 | 386 | */ |
| 384 | 387 | public static function country_code($name) |
| 385 | 388 | { |
| 386 | - if (!$name) return ''; // nothing to do |
|
| 389 | + if (!$name) |
|
| 390 | + { |
|
| 391 | + return ''; |
|
| 392 | + } |
|
| 393 | + // nothing to do |
|
| 387 | 394 | |
| 388 | 395 | if (strlen($name) == 2 && isset(self::$country_array[$name])) |
| 389 | 396 | { |
@@ -394,7 +401,10 @@ discard block |
||
| 394 | 401 | { |
| 395 | 402 | return $code; |
| 396 | 403 | } |
| 397 | - if (!self::$countries_translated) self::_translate_countries(); |
|
| 404 | + if (!self::$countries_translated) |
|
| 405 | + { |
|
| 406 | + self::_translate_countries(); |
|
| 407 | + } |
|
| 398 | 408 | |
| 399 | 409 | if (($code = array_search(strtoupper($name),self::$countries_translated)) !== false || |
| 400 | 410 | ($code = array_search($name,self::$countries_translated)) !== false) |
@@ -429,7 +439,10 @@ discard block |
||
| 429 | 439 | { |
| 430 | 440 | if ($translated) |
| 431 | 441 | { |
| 432 | - if (!self::$countries_translated) self::_translate_countries(); |
|
| 442 | + if (!self::$countries_translated) |
|
| 443 | + { |
|
| 444 | + self::_translate_countries(); |
|
| 445 | + } |
|
| 433 | 446 | |
| 434 | 447 | return self::$countries_translated; |
| 435 | 448 | } |
@@ -443,7 +456,10 @@ discard block |
||
| 443 | 456 | */ |
| 444 | 457 | protected static function _translate_countries() |
| 445 | 458 | { |
| 446 | - if (self::$countries_translated) return; |
|
| 459 | + if (self::$countries_translated) |
|
| 460 | + { |
|
| 461 | + return; |
|
| 462 | + } |
|
| 447 | 463 | |
| 448 | 464 | self::$countries_translated = self::$country_array; |
| 449 | 465 | // try to translate them and sort alphabetic |
@@ -90,7 +90,10 @@ discard block |
||
| 90 | 90 | if (($id = $GLOBALS['egw']->accounts->name2id($username,'account_lid','u'))) |
| 91 | 91 | { |
| 92 | 92 | $ret = $GLOBALS['egw']->accounts->id2name($id,'account_status') == 'A'; |
| 93 | - if (!$ret) error_log(__METHOD__."('$username') account_status check returning ".array2string($ret)); |
|
| 93 | + if (!$ret) |
|
| 94 | + { |
|
| 95 | + error_log(__METHOD__."('$username') account_status check returning ".array2string($ret)); |
|
| 96 | + } |
|
| 94 | 97 | return $ret; |
| 95 | 98 | } |
| 96 | 99 | // store homedirectory for egw_session->read_repositories |
@@ -158,7 +161,10 @@ discard block |
||
| 158 | 161 | static function setLastPwdChange($account_id=0, $passwd=NULL, $lastpwdchange=NULL, $return_mod=false) |
| 159 | 162 | { |
| 160 | 163 | unset($passwd); // not used but required by function signature |
| 161 | - if (!($adldap = Api\Accounts\Ads::get_adldap())) return false; |
|
| 164 | + if (!($adldap = Api\Accounts\Ads::get_adldap())) |
|
| 165 | + { |
|
| 166 | + return false; |
|
| 167 | + } |
|
| 162 | 168 | |
| 163 | 169 | if ($lastpwdchange) |
| 164 | 170 | { |
@@ -166,7 +172,10 @@ discard block |
||
| 166 | 172 | $ldapServerInfo = Api\Ldap\ServerInfo::get($adldap->getLdapConnection(), $GLOBALS['egw_info']['server']['ads_host']); |
| 167 | 173 | if ($ldapServerInfo->serverType == Api\Ldap\ServerInfo::SAMBA4) |
| 168 | 174 | { |
| 169 | - if ($lastpwdchange == -1) $lastpwdchange = time(); |
|
| 175 | + if ($lastpwdchange == -1) |
|
| 176 | + { |
|
| 177 | + $lastpwdchange = time(); |
|
| 178 | + } |
|
| 170 | 179 | } |
| 171 | 180 | // while Windows only allows to set -1 for current time (or 0 to force user to change password) |
| 172 | 181 | else |
@@ -179,7 +188,10 @@ discard block |
||
| 179 | 188 | $lastpwdchange = Api\Accounts\Ads::convertUnixTimeToWindowsTime($lastpwdchange); |
| 180 | 189 | } |
| 181 | 190 | $mod = array('pwdlastset' => $lastpwdchange); |
| 182 | - if ($return_mod) return $mod; |
|
| 191 | + if ($return_mod) |
|
| 192 | + { |
|
| 193 | + return $mod; |
|
| 194 | + } |
|
| 183 | 195 | |
| 184 | 196 | $ret = false; |
| 185 | 197 | if ($account_id && ($username = Api\Accounts::id2name($account_id, 'account_lid')) && |
@@ -70,7 +70,10 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | catch(Horde_Imap_Client_Exception $e) { |
| 72 | 72 | // throw everything but authentication failed as exception |
| 73 | - if ($e->getCode() != Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED) throw $e; |
|
| 73 | + if ($e->getCode() != Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED) |
|
| 74 | + { |
|
| 75 | + throw $e; |
|
| 76 | + } |
|
| 74 | 77 | |
| 75 | 78 | $mailauth = false; |
| 76 | 79 | } |
@@ -84,23 +87,38 @@ discard block |
||
| 84 | 87 | { |
| 85 | 88 | case 'imap': |
| 86 | 89 | default: |
| 87 | - if (!isset($port)) $port = 143; |
|
| 90 | + if (!isset($port)) |
|
| 91 | + { |
|
| 92 | + $port = 143; |
|
| 93 | + } |
|
| 88 | 94 | $mailauth = imap_open('{'.$host.':'.$port.'/imap/novalidate-cert}INBOX', $username , $passwd); |
| 89 | 95 | break; |
| 90 | 96 | case 'imaps': |
| 91 | - if (!isset($port)) $port = 993; |
|
| 97 | + if (!isset($port)) |
|
| 98 | + { |
|
| 99 | + $port = 993; |
|
| 100 | + } |
|
| 92 | 101 | $mailauth = imap_open('{'.$host.'/imap/ssl/novalidate-cert:'.$port.'}INBOX', $username , $passwd); |
| 93 | 102 | break; |
| 94 | 103 | case 'pop3': |
| 95 | - if (!isset($port)) $port = 110; |
|
| 104 | + if (!isset($port)) |
|
| 105 | + { |
|
| 106 | + $port = 110; |
|
| 107 | + } |
|
| 96 | 108 | $mailauth = imap_open('{'.$host.'/pop3/novalidate-cert:'.$port.'}INBOX', $username , $passwd); |
| 97 | 109 | break; |
| 98 | 110 | case 'pop3s': |
| 99 | - if (!isset($port)) $port = 995; |
|
| 111 | + if (!isset($port)) |
|
| 112 | + { |
|
| 113 | + $port = 995; |
|
| 114 | + } |
|
| 100 | 115 | $mailauth = imap_open('{'.$host.'/pop3/ssl/novalidate-cert:'.$port.'}INBOX', $username , $passwd); |
| 101 | 116 | break; |
| 102 | 117 | } |
| 103 | - if ($mailauth) imap_close($mailauth); |
|
| 118 | + if ($mailauth) |
|
| 119 | + { |
|
| 120 | + imap_close($mailauth); |
|
| 121 | + } |
|
| 104 | 122 | } |
| 105 | 123 | return !!$mailauth; |
| 106 | 124 | } |
@@ -33,13 +33,16 @@ |
||
| 33 | 33 | { |
| 34 | 34 | /* if program goes here, authenticate is, normaly, already verified by CAS */ |
| 35 | 35 | if ($GLOBALS['egw_info']['server']['account_repository'] != 'ldap' && |
| 36 | - $GLOBALS['egw_info']['server']['account_repository'] != 'ldsq') /* For anonymous LDAP connection */ |
|
| 36 | + $GLOBALS['egw_info']['server']['account_repository'] != 'ldsq') |
|
| 37 | + { |
|
| 38 | + /* For anonymous LDAP connection */ |
|
| 37 | 39 | { |
| 38 | 40 | if (!($id = $GLOBALS['egw']->accounts->name2id($username,'account_lid','u')) && |
| 39 | 41 | $GLOBALS['egw_info']['server']['auto_create_acct']) |
| 40 | 42 | { |
| 41 | 43 | // create a global array with all availible info about that account |
| 42 | 44 | $GLOBALS['auto_create_acct'] = array(); |
| 45 | + } |
|
| 43 | 46 | foreach(array( |
| 44 | 47 | 'givenname' => 'firstname', |
| 45 | 48 | 'sn' => 'lastname', |
@@ -64,10 +64,16 @@ |
||
| 64 | 64 | if (!isset($stored_purpose) || $stored_purpose !== $_purpose) |
| 65 | 65 | { |
| 66 | 66 | error_log('CSRF detected from IP '.$_SERVER['REMOTE_ADDR'].' to '.$_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI']); |
| 67 | - if ($_POST) error_log(array2string($_POST)); |
|
| 67 | + if ($_POST) |
|
| 68 | + { |
|
| 69 | + error_log(array2string($_POST)); |
|
| 70 | + } |
|
| 68 | 71 | // we are not throwing an exception here, but die, to not allow catching it! |
| 69 | 72 | die("CSRF detected, request terminated!"); |
| 70 | 73 | } |
| 71 | - if ($_delete_token) Cache::unsetSession(__CLASS__, $_token); |
|
| 74 | + if ($_delete_token) |
|
| 75 | + { |
|
| 76 | + Cache::unsetSession(__CLASS__, $_token); |
|
| 77 | + } |
|
| 72 | 78 | } |
| 73 | 79 | } |
| 74 | 80 | \ No newline at end of file |
@@ -235,8 +235,14 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | /*static*/ public function mailbox_addr($account,$domain=null,$mail_login_type=null) |
| 237 | 237 | { |
| 238 | - if (is_null($domain)) $domain = $this->defaultDomain; |
|
| 239 | - if (is_null($mail_login_type)) $mail_login_type = $this->loginType; |
|
| 238 | + if (is_null($domain)) |
|
| 239 | + { |
|
| 240 | + $domain = $this->defaultDomain; |
|
| 241 | + } |
|
| 242 | + if (is_null($mail_login_type)) |
|
| 243 | + { |
|
| 244 | + $mail_login_type = $this->loginType; |
|
| 245 | + } |
|
| 240 | 246 | |
| 241 | 247 | switch($mail_login_type) |
| 242 | 248 | { |
@@ -245,7 +251,10 @@ discard block |
||
| 245 | 251 | break; |
| 246 | 252 | |
| 247 | 253 | case 'uidNumber': |
| 248 | - if (is_array($account)) $account = $account['account_id']; |
|
| 254 | + if (is_array($account)) |
|
| 255 | + { |
|
| 256 | + $account = $account['account_id']; |
|
| 257 | + } |
|
| 249 | 258 | $mbox = 'u'.$account.'@'.$domain; |
| 250 | 259 | break; |
| 251 | 260 | |