@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param string $arguments =null array with command line argruments |
| 32 | 32 | * @param boolean $verbose =false if true, echos out some status information during the run |
| 33 | 33 | */ |
| 34 | - function __construct($domain,$config_user=null,$config_passwd=null,$arguments=null,$verbose=false) |
|
| 34 | + function __construct($domain, $config_user = null, $config_passwd = null, $arguments = null, $verbose = false) |
|
| 35 | 35 | { |
| 36 | 36 | if (!is_array($domain)) |
| 37 | 37 | { |
@@ -55,16 +55,16 @@ discard block |
||
| 55 | 55 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
| 56 | 56 | * @throws Exception('header.inc.php not found!'); |
| 57 | 57 | */ |
| 58 | - protected function exec($check_only=false) |
|
| 58 | + protected function exec($check_only = false) |
|
| 59 | 59 | { |
| 60 | 60 | if ($check_only && $this->remote_id) |
| 61 | 61 | { |
| 62 | - return true; // can only check locally |
|
| 62 | + return true; // can only check locally |
|
| 63 | 63 | } |
| 64 | 64 | // instanciate setup object and check authorisation |
| 65 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
| 65 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
| 66 | 66 | |
| 67 | - $this->check_installed($this->domain,15,$this->verbose); |
|
| 67 | + $this->check_installed($this->domain, 15, $this->verbose); |
|
| 68 | 68 | |
| 69 | 69 | // fixing authtypes in self::$options |
| 70 | 70 | self::auth_types(true); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // store the config |
| 83 | - foreach($values as $name => $value) |
|
| 83 | + foreach ($values as $name => $value) |
|
| 84 | 84 | { |
| 85 | 85 | if (substr($name, 0, 4) == 'acc_') continue; |
| 86 | 86 | |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | list($app, $name) = explode('/', $name); |
| 91 | 91 | } |
| 92 | - self::$egw_setup->db->insert(self::$egw_setup->config_table,array( |
|
| 92 | + self::$egw_setup->db->insert(self::$egw_setup->config_table, array( |
|
| 93 | 93 | 'config_value' => $value, |
| 94 | - ),array( |
|
| 94 | + ), array( |
|
| 95 | 95 | 'config_app' => $app, |
| 96 | 96 | 'config_name' => $name, |
| 97 | - ),__LINE__,__FILE__); |
|
| 97 | + ), __LINE__, __FILE__); |
|
| 98 | 98 | } |
| 99 | 99 | if (count($values)) |
| 100 | 100 | { |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | * @param boolean $echoit =false if true the config is additionally echo'ed out |
| 119 | 119 | * @return array with name => value pairs |
| 120 | 120 | */ |
| 121 | - static function get_config($echoit=false) |
|
| 121 | + static function get_config($echoit = false) |
|
| 122 | 122 | { |
| 123 | - self::$egw_setup->db->select(self::$egw_setup->config_table,'config_name,config_value',array( |
|
| 123 | + self::$egw_setup->db->select(self::$egw_setup->config_table, 'config_name,config_value', array( |
|
| 124 | 124 | 'config_app' => 'phpgwapi', |
| 125 | 125 | "(config_name LIKE '%\\_dir' OR (config_name LIKE 'mail%' AND config_name != 'mail_footer') OR config_name LIKE 'smtp\\_%' OR config_name LIKE 'ldap%' OR config_name IN ('webserver_url','system_charset','auth_type','account_repository'))", |
| 126 | - ),__LINE__,__FILE__); |
|
| 126 | + ), __LINE__, __FILE__); |
|
| 127 | 127 | |
| 128 | 128 | $config = array(); |
| 129 | 129 | while (($row = self::$egw_setup->db->row(true))) |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | if ($echoit) |
| 134 | 134 | { |
| 135 | 135 | echo lang('Current configuration:')."\n"; |
| 136 | - foreach($config as $name => $value) |
|
| 136 | + foreach ($config as $name => $value) |
|
| 137 | 137 | { |
| 138 | - echo str_pad($name.':',22).$value."\n"; |
|
| 138 | + echo str_pad($name.':', 22).$value."\n"; |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | return $config; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @var array |
| 148 | 148 | */ |
| 149 | 149 | static $options = array( |
| 150 | - '--config' => array(), // name=value,... |
|
| 150 | + '--config' => array(), // name=value,... |
|
| 151 | 151 | '--files-dir' => 'files_dir', |
| 152 | 152 | '--vfs-root-user' => 'vfs_root_user', |
| 153 | 153 | '--backup-dir' => 'backup_dir', |
@@ -158,14 +158,14 @@ discard block |
||
| 158 | 158 | 'acc_imap_host', |
| 159 | 159 | 'acc_imap_port', |
| 160 | 160 | 'acc_domain', |
| 161 | - array('name' => 'acc_imap_logintype','allowed' => array( |
|
| 161 | + array('name' => 'acc_imap_logintype', 'allowed' => array( |
|
| 162 | 162 | 'username (standard)' => 'standard', |
| 163 | 163 | 'username@domain (virtual mail manager)' => 'vmailmgr', |
| 164 | 164 | 'Username/Password defined by admin' => 'admin', |
| 165 | 165 | 'userId@domain eg. u123@domain' => 'uidNumber', |
| 166 | 166 | 'email (Standard Maildomain should be set)' => 'email', |
| 167 | 167 | )), |
| 168 | - array('name' => 'acc_imap_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')), |
|
| 168 | + array('name' => 'acc_imap_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')), |
|
| 169 | 169 | ), |
| 170 | 170 | '--imap' => array( |
| 171 | 171 | 'acc_imap_admin_username', |
@@ -173,28 +173,28 @@ discard block |
||
| 173 | 173 | 'acc_imap_type', |
| 174 | 174 | ), |
| 175 | 175 | '--folder' => array( |
| 176 | - 'acc_folder_sent','acc_folder_trash','acc_folder_draft','acc_folder_template','acc_folder_junk','acc_folder_archive','acc_folder_ham' |
|
| 176 | + 'acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk', 'acc_folder_archive', 'acc_folder_ham' |
|
| 177 | 177 | ), |
| 178 | 178 | '--sieve' => array( |
| 179 | 179 | array('name' => 'acc_sieve_host'), |
| 180 | 180 | 'acc_sieve_port', |
| 181 | 181 | 'acc_sieve_enabled', |
| 182 | - array('name' => 'acc_sieve_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')), |
|
| 182 | + array('name' => 'acc_sieve_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')), |
|
| 183 | 183 | ), |
| 184 | 184 | '--smtp' => array( |
| 185 | - array('name' => 'editforwardingaddress','allowed' => array('yes',null)), |
|
| 185 | + array('name' => 'editforwardingaddress', 'allowed' => array('yes', null)), |
|
| 186 | 186 | 'acc_smtp_type', |
| 187 | 187 | ), |
| 188 | 188 | '--smtpserver' => array( //smtp server,[smtp port],[smtp user],[smtp password],[auth session user/pw],[no|starttls|ssl|tls],[user editable],[further identities] |
| 189 | - 'acc_smtp_host','acc_smtp_port','acc_smtp_username','acc_smtp_passwd','acc_smtp_auth_session', |
|
| 190 | - array('name' => 'acc_smtp_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')), |
|
| 191 | - 'acc_user_editable','acc_further_identities', |
|
| 189 | + 'acc_smtp_host', 'acc_smtp_port', 'acc_smtp_username', 'acc_smtp_passwd', 'acc_smtp_auth_session', |
|
| 190 | + array('name' => 'acc_smtp_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')), |
|
| 191 | + 'acc_user_editable', 'acc_further_identities', |
|
| 192 | 192 | ), |
| 193 | 193 | '--account-auth' => array( |
| 194 | - array('name' => 'account_repository','allowed' => array('sql','ldap','ads'),'default'=>'sql'), |
|
| 195 | - array('name' => 'auth_type','allowed' => array('sql','ldap','mail','ads','http','sqlssl','nis','pam'),'default'=>'sql'), |
|
| 196 | - array('name' => 'sql_encryption','allowed' => array('blowfish_crypt','sha512_crypt','sha256_crypt','md5_crypt','crypt','ssha','smd5','md5'),'default'=>'blowfish_crypt'), |
|
| 197 | - 'check_save_password','allow_cookie_auth'), |
|
| 194 | + array('name' => 'account_repository', 'allowed' => array('sql', 'ldap', 'ads'), 'default'=>'sql'), |
|
| 195 | + array('name' => 'auth_type', 'allowed' => array('sql', 'ldap', 'mail', 'ads', 'http', 'sqlssl', 'nis', 'pam'), 'default'=>'sql'), |
|
| 196 | + array('name' => 'sql_encryption', 'allowed' => array('blowfish_crypt', 'sha512_crypt', 'sha256_crypt', 'md5_crypt', 'crypt', 'ssha', 'smd5', 'md5'), 'default'=>'blowfish_crypt'), |
|
| 197 | + 'check_save_password', 'allow_cookie_auth'), |
|
| 198 | 198 | '--ldap-host' => 'ldap_host', |
| 199 | 199 | '--ldap-root-dn' => 'ldap_root_dn', |
| 200 | 200 | '--ldap-root-pw' => 'ldap_root_pw', |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | '--install-id' => 'install_id', |
| 207 | 207 | '--ads-host' => 'ads_host', |
| 208 | 208 | '--ads-domain' => 'ads_domain', |
| 209 | - '--ads-admin-user' => 'ads_domain_admin', // eg. Administrator |
|
| 209 | + '--ads-admin-user' => 'ads_domain_admin', // eg. Administrator |
|
| 210 | 210 | '--ads-admin-pw' => 'ads_admin_pw', |
| 211 | 211 | '--ads-connection' => array( |
| 212 | 212 | array('name' => 'ads_connection', 'allowed' => array('ssl', 'tls')) |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | $save_mail_account = false; |
| 254 | 254 | $values = array(); |
| 255 | - foreach(self::$options as $arg => $option) |
|
| 255 | + foreach (self::$options as $arg => $option) |
|
| 256 | 256 | { |
| 257 | - foreach(is_array($option) ? $option : array($option) as $n => $data) |
|
| 257 | + foreach (is_array($option) ? $option : array($option) as $n => $data) |
|
| 258 | 258 | { |
| 259 | 259 | $name = is_array($data) ? $data['name'] : $data; |
| 260 | 260 | $oldname = array_key_exists($name, $this->old2new); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | if (isset($this->$name)) |
| 268 | 268 | { |
| 269 | - $save_mail_account = $this->_parse_value($arg,$n,$option,$this->$name,$values) || $save_mail_account; |
|
| 269 | + $save_mail_account = $this->_parse_value($arg, $n, $option, $this->$name, $values) || $save_mail_account; |
|
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | } |
@@ -284,27 +284,27 @@ discard block |
||
| 284 | 284 | $values = array(); |
| 285 | 285 | $save_mail_account = false; |
| 286 | 286 | $args = $this->arguments; |
| 287 | - while(($arg = array_shift($args))) |
|
| 287 | + while (($arg = array_shift($args))) |
|
| 288 | 288 | { |
| 289 | 289 | if (!isset(self::$options[$arg])) |
| 290 | 290 | { |
| 291 | - throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$arg),90); |
|
| 291 | + throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!", $arg), 90); |
|
| 292 | 292 | } |
| 293 | - $options = is_array(self::$options[$arg]) ? explode(',',array_shift($args)) : array(array_shift($args)); |
|
| 293 | + $options = is_array(self::$options[$arg]) ? explode(',', array_shift($args)) : array(array_shift($args)); |
|
| 294 | 294 | |
| 295 | 295 | if ($arg == '--config' || $arg == '--setup_cmd_config') |
| 296 | 296 | { |
| 297 | - foreach($options as $option) |
|
| 297 | + foreach ($options as $option) |
|
| 298 | 298 | { |
| 299 | - list($name,$value) = explode('=',$option,2); |
|
| 299 | + list($name, $value) = explode('=', $option, 2); |
|
| 300 | 300 | $values[$name] = $value; |
| 301 | 301 | } |
| 302 | 302 | continue; |
| 303 | 303 | } |
| 304 | 304 | $options[] = ''; $options[] = ''; |
| 305 | - foreach($options as $n => $value) |
|
| 305 | + foreach ($options as $n => $value) |
|
| 306 | 306 | { |
| 307 | - $save_mail_account = $this->_parse_value($arg,$n,self::$options[$arg],$value,$values) || $save_mail_account; |
|
| 307 | + $save_mail_account = $this->_parse_value($arg, $n, self::$options[$arg], $value, $values) || $save_mail_account; |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | return $save_mail_account; |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * @param array &$values where the values get set |
| 321 | 321 | * @return boolean true if mail-accounts needs to be saved, false if not |
| 322 | 322 | */ |
| 323 | - private function _parse_value($arg,$n,$data,$value,array &$values) |
|
| 323 | + private function _parse_value($arg, $n, $data, $value, array &$values) |
|
| 324 | 324 | { |
| 325 | 325 | if ($value === '' && is_array($data) && !isset($data[$n]['default'])) return false; |
| 326 | 326 | |
@@ -330,15 +330,15 @@ discard block |
||
| 330 | 330 | { |
| 331 | 331 | if (!$value && isset($name['default'])) $value = $name['default']; |
| 332 | 332 | |
| 333 | - if (isset($name['allowed']) && !in_array($value,$name['allowed'])) |
|
| 333 | + if (isset($name['allowed']) && !in_array($value, $name['allowed'])) |
|
| 334 | 334 | { |
| 335 | - throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!",$value,1+$n,$arg)." ($name[name])",91); |
|
| 335 | + throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!", $value, 1 + $n, $arg)." ($name[name])", 91); |
|
| 336 | 336 | } |
| 337 | 337 | $name = $name['name']; |
| 338 | 338 | } |
| 339 | 339 | $values[$name] = $value; |
| 340 | 340 | |
| 341 | - return in_array($arg,array('--mailserver','--smtpserver','--imap','--smtp','--sieve','--folder')); |
|
| 341 | + return in_array($arg, array('--mailserver', '--smtpserver', '--imap', '--smtp', '--sieve', '--folder')); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** |
@@ -349,9 +349,9 @@ discard block |
||
| 349 | 349 | function _save_mail_account(array $data) |
| 350 | 350 | { |
| 351 | 351 | // convert ssl textual values to nummerical ones used in Api\Mail\Account |
| 352 | - foreach(array('acc_imap_ssl', 'acc_sieve_ssl', 'acc_smtp_ssl') as $name) |
|
| 352 | + foreach (array('acc_imap_ssl', 'acc_sieve_ssl', 'acc_smtp_ssl') as $name) |
|
| 353 | 353 | { |
| 354 | - switch(strtolower($data[$name])) |
|
| 354 | + switch (strtolower($data[$name])) |
|
| 355 | 355 | { |
| 356 | 356 | case 'no': $data[$name] = Api\Mail\Account::SSL_NONE; break; |
| 357 | 357 | case 'starttls': $data[$name] = Api\Mail\Account::SSL_STARTTLS; break; |
@@ -360,12 +360,12 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | // convert 'yes', 'no' to boolean |
| 363 | - foreach(array('acc_sieve_enabled','acc_user_editable','acc_further_identities','acc_smtp_auth_session') as $name) |
|
| 363 | + foreach (array('acc_sieve_enabled', 'acc_user_editable', 'acc_further_identities', 'acc_smtp_auth_session') as $name) |
|
| 364 | 364 | { |
| 365 | 365 | $data[$name] = $data[$name] && strtolower($data[$name]) != 'no'; |
| 366 | 366 | } |
| 367 | 367 | // do NOT write empty usernames |
| 368 | - foreach(array('acc_imap_username', 'acc_smtp_username') as $name) |
|
| 368 | + foreach (array('acc_imap_username', 'acc_smtp_username') as $name) |
|
| 369 | 369 | { |
| 370 | 370 | if (empty($data[$name])) |
| 371 | 371 | { |
@@ -375,16 +375,16 @@ discard block |
||
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | $data['acc_name'] = 'Created by setup'; |
| 378 | - $data['account_id'] = 0; // 0 = valid for all users |
|
| 378 | + $data['account_id'] = 0; // 0 = valid for all users |
|
| 379 | 379 | |
| 380 | 380 | Api\Mail\Account::write($data); |
| 381 | 381 | |
| 382 | 382 | if ($this->verbose) |
| 383 | 383 | { |
| 384 | 384 | echo "\n".lang('EMailAdmin mail account saved:')."\n"; |
| 385 | - foreach($data as $name => $value) |
|
| 385 | + foreach ($data as $name => $value) |
|
| 386 | 386 | { |
| 387 | - echo str_pad($name.':',22).$value."\n"; |
|
| 387 | + echo str_pad($name.':', 22).$value."\n"; |
|
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | } |
@@ -397,11 +397,11 @@ discard block |
||
| 397 | 397 | static function options() |
| 398 | 398 | { |
| 399 | 399 | $options = array(); |
| 400 | - foreach(self::$options as $option) |
|
| 400 | + foreach (self::$options as $option) |
|
| 401 | 401 | { |
| 402 | 402 | if (is_array($option)) |
| 403 | 403 | { |
| 404 | - foreach($option as $data) |
|
| 404 | + foreach ($option as $data) |
|
| 405 | 405 | { |
| 406 | 406 | if (is_array($data) && isset($data['allowed'])) |
| 407 | 407 | { |
@@ -414,11 +414,11 @@ discard block |
||
| 414 | 414 | $options[$data['name']] = self::account_repositories(); |
| 415 | 415 | continue 2; |
| 416 | 416 | } |
| 417 | - foreach($data['allowed'] as $label => $value) |
|
| 417 | + foreach ($data['allowed'] as $label => $value) |
|
| 418 | 418 | { |
| 419 | 419 | if (is_int($label)) |
| 420 | 420 | { |
| 421 | - $label = (string) $value === '' ? 'No' : strtoupper($value); |
|
| 421 | + $label = (string)$value === '' ? 'No' : strtoupper($value); |
|
| 422 | 422 | } |
| 423 | 423 | $options[$data['name']][$value] = lang($label); |
| 424 | 424 | } |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | if (!$scan_done++) |
| 452 | 452 | { |
| 453 | 453 | // now add auth backends found in filesystem |
| 454 | - foreach(scandir(EGW_INCLUDE_ROOT.'/api/src/Auth') as $file) |
|
| 454 | + foreach (scandir(EGW_INCLUDE_ROOT.'/api/src/Auth') as $file) |
|
| 455 | 455 | { |
| 456 | 456 | $matches = null; |
| 457 | 457 | if (preg_match('/^([a-z0-9]+)\.php$/i', $file, $matches) && |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | $auth_types[strtolower($matches[1])] = $matches[1]; |
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | - foreach(self::$options['--account-auth'] as &$param) |
|
| 463 | + foreach (self::$options['--account-auth'] as &$param) |
|
| 464 | 464 | { |
| 465 | 465 | if ($param['name'] == 'auth_type') |
| 466 | 466 | { |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @param string $current =null current value, to allways return it |
| 479 | 479 | * @return array |
| 480 | 480 | */ |
| 481 | - static function account_repositories($current=null) |
|
| 481 | + static function account_repositories($current = null) |
|
| 482 | 482 | { |
| 483 | 483 | static $account_repositories = array( |
| 484 | 484 | 'sql' => 'SQL', |
@@ -489,13 +489,13 @@ discard block |
||
| 489 | 489 | if (!$scan_done++) |
| 490 | 490 | { |
| 491 | 491 | // now add auth backends found in filesystem |
| 492 | - foreach(scandir(EGW_INCLUDE_ROOT.'/api/src/Accounts') as $file) |
|
| 492 | + foreach (scandir(EGW_INCLUDE_ROOT.'/api/src/Accounts') as $file) |
|
| 493 | 493 | { |
| 494 | 494 | $matches = null; |
| 495 | 495 | if (preg_match('/^([a-z0-9]+)\.php$/', $file, $matches) && |
| 496 | 496 | !isset($account_repositories[strtolower($matches[1])]) && |
| 497 | - class_exists($class='EGroupware\\Api\\Accounts\\'.$matches[1]) && |
|
| 498 | - (strtolower($matches[1]) == $current || !is_callable($callable=$class.'::available') || call_user_func($callable))) |
|
| 497 | + class_exists($class = 'EGroupware\\Api\\Accounts\\'.$matches[1]) && |
|
| 498 | + (strtolower($matches[1]) == $current || !is_callable($callable = $class.'::available') || call_user_func($callable))) |
|
| 499 | 499 | { |
| 500 | 500 | $account_repositories[strtolower($matches[1])] = $matches[1]; |
| 501 | 501 | } |
@@ -513,11 +513,11 @@ discard block |
||
| 513 | 513 | { |
| 514 | 514 | $defaults = array(); |
| 515 | 515 | // fetch the default from the cli options |
| 516 | - foreach(self::$options as $option) |
|
| 516 | + foreach (self::$options as $option) |
|
| 517 | 517 | { |
| 518 | 518 | if (is_array($option)) |
| 519 | 519 | { |
| 520 | - foreach($option as $data) |
|
| 520 | + foreach ($option as $data) |
|
| 521 | 521 | { |
| 522 | 522 | if (is_array($data) && isset($data['default'])) |
| 523 | 523 | { |
@@ -545,20 +545,20 @@ discard block |
||
| 545 | 545 | */ |
| 546 | 546 | private function _merge_defaults() |
| 547 | 547 | { |
| 548 | - foreach(self::defaults() as $name => $default) |
|
| 548 | + foreach (self::defaults() as $name => $default) |
|
| 549 | 549 | { |
| 550 | 550 | if (!$this->$name) |
| 551 | 551 | { |
| 552 | 552 | //echo "<p>setting $name='{$this->$name}' to it's default='$default'</p>\n"; |
| 553 | 553 | $this->set_defaults[$name] = $this->$name = $default; |
| 554 | 554 | } |
| 555 | - if (strpos($this->$name,'$') !== false) |
|
| 555 | + if (strpos($this->$name, '$') !== false) |
|
| 556 | 556 | { |
| 557 | 557 | $this->set_defaults[$name] = $this->$name = str_replace(array( |
| 558 | 558 | '$domain', |
| 559 | - ),array( |
|
| 559 | + ), array( |
|
| 560 | 560 | $this->domain, |
| 561 | - ),$this->$name); |
|
| 561 | + ), $this->$name); |
|
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | } |
@@ -9,10 +9,13 @@ discard block |
||
| 9 | 9 | * @version $Id$ |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling post_install as web-page |
|
| 12 | +if (php_sapi_name() !== 'cli') |
|
| 13 | +{ |
|
| 14 | + // security precaution: forbit calling post_install as web-page |
|
| 13 | 15 | { |
| 14 | 16 | die('<h1>post_install.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 15 | 17 | } |
| 18 | +} |
|
| 16 | 19 | $verbose = false; |
| 17 | 20 | $config = array( |
| 18 | 21 | 'php' => PHP_BINARY, |
@@ -100,7 +103,10 @@ discard block |
||
| 100 | 103 | { |
| 101 | 104 | case 'suse': |
| 102 | 105 | // openSUSE 12.1+ no longer uses php5 |
| 103 | - if (file_exists('/usr/bin/php5')) $config['php'] = '/usr/bin/php5'; |
|
| 106 | + if (file_exists('/usr/bin/php5')) |
|
| 107 | + { |
|
| 108 | + $config['php'] = '/usr/bin/php5'; |
|
| 109 | + } |
|
| 104 | 110 | $config['start_db'] = '/sbin/service mysql'; |
| 105 | 111 | $config['autostart_db'] = '/sbin/chkconfig --level 345 mysql on'; |
| 106 | 112 | $config['start_webserver'] = '/sbin/service apache2'; |
@@ -145,9 +151,12 @@ discard block |
||
| 145 | 151 | // fall through |
| 146 | 152 | case 'rh': |
| 147 | 153 | // some MySQL packages (mysql.com, MariaDB, ...) use "mysql" as service name instead of RH default "mysqld" |
| 148 | - if (file_exists('/usr/bin/systemctl')) // RHEL 7 |
|
| 154 | + if (file_exists('/usr/bin/systemctl')) |
|
| 155 | + { |
|
| 156 | + // RHEL 7 |
|
| 149 | 157 | { |
| 150 | 158 | $config['start_db'] = '/usr/bin/systemctl %s mariadb'; |
| 159 | + } |
|
| 151 | 160 | $config['autostart_db'] = build_cmd('start_db', 'enable'); |
| 152 | 161 | $config['start_webserver'] = '/usr/bin/systemctl %s httpd'; |
| 153 | 162 | $config['autostart_webserver'] = build_cmd('start_webserver', 'enable'); |
@@ -176,11 +185,14 @@ discard block |
||
| 176 | 185 | while($config_set) |
| 177 | 186 | { |
| 178 | 187 | $val = array_shift($config_set); |
| 179 | - if (($quote = $val[0]) == "'" || $quote == '"') // arguments might be quoted with ' or " |
|
| 188 | + if (($quote = $val[0]) == "'" || $quote == '"') |
|
| 189 | + { |
|
| 190 | + // arguments might be quoted with ' or " |
|
| 180 | 191 | { |
| 181 | 192 | while (substr($val,-1) != $quote) |
| 182 | 193 | { |
| 183 | 194 | if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!'); |
| 195 | + } |
|
| 184 | 196 | $val .= ' '.array_shift($config_set); |
| 185 | 197 | } |
| 186 | 198 | $val = substr($val,1,-1); |
@@ -245,8 +257,11 @@ discard block |
||
| 245 | 257 | // basic config checks |
| 246 | 258 | foreach(array('php','source_dir','data_dir','setup-cli') as $name) |
| 247 | 259 | { |
| 248 | - if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!'); |
|
| 249 | -} |
|
| 260 | + if (!file_exists($config[$name])) |
|
| 261 | + { |
|
| 262 | + bail_out(1,$config[$name].' not found!'); |
|
| 263 | + } |
|
| 264 | + } |
|
| 250 | 265 | |
| 251 | 266 | // fix important php.ini and conf.d/*.ini settings |
| 252 | 267 | check_fix_php_apc_ini(); |
@@ -255,7 +270,9 @@ discard block |
||
| 255 | 270 | $setup_cli = $config['php'].' -d memory_limit=-1 '.$config['setup-cli']; |
| 256 | 271 | |
| 257 | 272 | // if we have a header, include it |
| 258 | -if (file_exists($config['header']) && filesize($config['header']) >= 200) // default header redirecting to setup is 147 bytes |
|
| 273 | +if (file_exists($config['header']) && filesize($config['header']) >= 200) |
|
| 274 | +{ |
|
| 275 | + // default header redirecting to setup is 147 bytes |
|
| 259 | 276 | { |
| 260 | 277 | $GLOBALS['egw_info'] = array( |
| 261 | 278 | 'flags' => array( |
@@ -263,6 +280,7 @@ discard block |
||
| 263 | 280 | 'currentapp' => 'login', // stop PHP Notice: Undefined index "currentapp" in pre 16.1 header |
| 264 | 281 | ) |
| 265 | 282 | ); |
| 283 | +} |
|
| 266 | 284 | include $config['header']; |
| 267 | 285 | |
| 268 | 286 | // get user from header and replace password, as we dont know it |
@@ -286,7 +304,10 @@ discard block |
||
| 286 | 304 | if ($ret) |
| 287 | 305 | { |
| 288 | 306 | system(build_cmd('start_db', 'start')); |
| 289 | - if (!empty($config['autostart_db'])) system($config['autostart_db']); |
|
| 307 | + if (!empty($config['autostart_db'])) |
|
| 308 | + { |
|
| 309 | + system($config['autostart_db']); |
|
| 310 | + } |
|
| 290 | 311 | } |
| 291 | 312 | } |
| 292 | 313 | // create database |
@@ -302,7 +323,10 @@ discard block |
||
| 302 | 323 | @list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3); |
| 303 | 324 | $extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']); |
| 304 | 325 | $extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type'])); |
| 305 | - if (empty($rest)) unset($config['account-auth']); |
|
| 326 | + if (empty($rest)) |
|
| 327 | + { |
|
| 328 | + unset($config['account-auth']); |
|
| 329 | + } |
|
| 306 | 330 | if ($config['account_repository'] == 'ldap' || $config['auth_type'] == 'ldap') |
| 307 | 331 | { |
| 308 | 332 | // set account_min_id to 1100 if not specified to NOT clash with system accounts |
@@ -362,7 +386,10 @@ discard block |
||
| 362 | 386 | $setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']); |
| 363 | 387 | foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name) |
| 364 | 388 | { |
| 365 | - if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]); |
|
| 389 | + if (!empty($config[$name])) |
|
| 390 | + { |
|
| 391 | + $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]); |
|
| 392 | + } |
|
| 366 | 393 | } |
| 367 | 394 | run_cmd($setup_mailserver); |
| 368 | 395 | |
@@ -378,7 +405,10 @@ discard block |
||
| 378 | 405 | if ($ret) |
| 379 | 406 | { |
| 380 | 407 | system(build_cmd('start_webserver', 'start')); |
| 381 | - if (!empty($config['autostart_webserver'])) system($config['autostart_webserver']); |
|
| 408 | + if (!empty($config['autostart_webserver'])) |
|
| 409 | + { |
|
| 410 | + system($config['autostart_webserver']); |
|
| 411 | + } |
|
| 382 | 412 | } |
| 383 | 413 | else |
| 384 | 414 | { |
@@ -424,10 +454,16 @@ discard block |
||
| 424 | 454 | $header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']); |
| 425 | 455 | run_cmd($header_update); |
| 426 | 456 | $ret = run_cmd($setup_update,$output,15); |
| 427 | - if ($ret != 15) break; |
|
| 457 | + if ($ret != 15) |
|
| 458 | + { |
|
| 459 | + break; |
|
| 460 | + } |
|
| 428 | 461 | // fall through |
| 429 | 462 | case 15: // missing configuration (eg. mailserver) |
| 430 | - if (!$verbose) echo implode("\n",(array)$output)."\n"; |
|
| 463 | + if (!$verbose) |
|
| 464 | + { |
|
| 465 | + echo implode("\n",(array)$output)."\n"; |
|
| 466 | + } |
|
| 431 | 467 | break; |
| 432 | 468 | |
| 433 | 469 | case 0: |
@@ -457,9 +493,15 @@ discard block |
||
| 457 | 493 | { |
| 458 | 494 | global $config; |
| 459 | 495 | |
| 460 | - if (isset($config[$cmd])) $cmd = $config[$cmd]; |
|
| 496 | + if (isset($config[$cmd])) |
|
| 497 | + { |
|
| 498 | + $cmd = $config[$cmd]; |
|
| 499 | + } |
|
| 461 | 500 | |
| 462 | - if (strpos($cmd, '%s')) return str_replace('%s', $arg, $cmd); |
|
| 501 | + if (strpos($cmd, '%s')) |
|
| 502 | + { |
|
| 503 | + return str_replace('%s', $arg, $cmd); |
|
| 504 | + } |
|
| 463 | 505 | |
| 464 | 506 | return $cmd.' '.$arg; |
| 465 | 507 | } |
@@ -528,7 +570,10 @@ discard block |
||
| 528 | 570 | */ |
| 529 | 571 | function bail_out($ret=1,$output=null) |
| 530 | 572 | { |
| 531 | - if ($output) echo implode("\n",(array)$output); |
|
| 573 | + if ($output) |
|
| 574 | + { |
|
| 575 | + echo implode("\n",(array)$output); |
|
| 576 | + } |
|
| 532 | 577 | echo "\n\nInstallation failed --> exiting!\n\n"; |
| 533 | 578 | exit($ret); |
| 534 | 579 | } |
@@ -574,7 +619,11 @@ discard block |
||
| 574 | 619 | echo "options and their defaults:\n"; |
| 575 | 620 | foreach($config as $name => $default) |
| 576 | 621 | { |
| 577 | - if (in_array($name, array('postfix','cyrus'))) continue; // do NOT report deprecated options |
|
| 622 | + if (in_array($name, array('postfix','cyrus'))) |
|
| 623 | + { |
|
| 624 | + continue; |
|
| 625 | + } |
|
| 626 | + // do NOT report deprecated options |
|
| 578 | 627 | if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16) |
| 579 | 628 | { |
| 580 | 629 | $default = '<16 char random string>'; |
@@ -667,7 +716,10 @@ discard block |
||
| 667 | 716 | // only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' && |
| 668 | 717 | ($domains=_ucr_get('mail/hosteddomains'))) |
| 669 | 718 | { |
| 670 | - if (!is_array($domains)) $domains = explode("\n", $domains); |
|
| 719 | + if (!is_array($domains)) |
|
| 720 | + { |
|
| 721 | + $domains = explode("\n", $domains); |
|
| 722 | + } |
|
| 671 | 723 | $domain = array_shift($domains); |
| 672 | 724 | // set "use auth with session credentials",tls,"not user editable","further identities" |
| 673 | 725 | $config['smtpserver'] = "$mailserver,465,,,yes,tls,no,yes"; |
@@ -686,13 +738,19 @@ discard block |
||
| 686 | 738 | $config['imap'] = ',,Imap\\Dovecot'; |
| 687 | 739 | } |
| 688 | 740 | // default with sieve port to 4190, as config is only available on host mailserver app is installed |
| 689 | - if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) $sieve_port = 4190; |
|
| 741 | + if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) |
|
| 742 | + { |
|
| 743 | + $sieve_port = 4190; |
|
| 744 | + } |
|
| 690 | 745 | } |
| 691 | 746 | else |
| 692 | 747 | { |
| 693 | 748 | $config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Cyrus'; |
| 694 | 749 | // default with sieve port to 4190, as config is only available on host mailserver app is installed |
| 695 | - if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) $sieve_port = 4190; |
|
| 750 | + if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) |
|
| 751 | + { |
|
| 752 | + $sieve_port = 4190; |
|
| 753 | + } |
|
| 696 | 754 | } |
| 697 | 755 | // set folders so mail creates them on first login, UCS does not automatic |
| 698 | 756 | $config['folder'] = 'INBOX/Sent,INBOX/Trash,INBOX/Drafts,INBOX/Templates,Spam,,Ham'; |
@@ -757,7 +815,10 @@ discard block |
||
| 757 | 815 | $shm_size = ini_get('apc.shm_size'); |
| 758 | 816 | $shm_segments = ini_get('apc.shm_segments'); |
| 759 | 817 | // ancent APC (3.1.3) in Debian 6/Squezze has size in MB without a unit |
| 760 | - if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576)) $shm_size .= 'M'; |
|
| 818 | + if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576)) |
|
| 819 | + { |
|
| 820 | + $shm_size .= 'M'; |
|
| 821 | + } |
|
| 761 | 822 | |
| 762 | 823 | $size = _size_with_unit($shm_size) * $shm_segments; |
| 763 | 824 | //echo "shm_size=$shm_size, shm_segments=$shm_segments --> $size, numeric_size=$numeric_size\n"; |
@@ -773,7 +834,10 @@ discard block |
||
| 773 | 834 | file_exists($path = $matches[1]) && ($apc_ini = file_get_contents($path))) |
| 774 | 835 | { |
| 775 | 836 | $new_shm_size = 128 / $shm_segments; |
| 776 | - if (!$numeric_size) $new_shm_size .= 'M'; |
|
| 837 | + if (!$numeric_size) |
|
| 838 | + { |
|
| 839 | + $new_shm_size .= 'M'; |
|
| 840 | + } |
|
| 777 | 841 | if (preg_match('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', $apc_ini)) |
| 778 | 842 | { |
| 779 | 843 | file_put_contents($path, preg_replace('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', 'apc.shm_size='.$new_shm_size, $apc_ini)); |