0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-19 11:12:15 +02:00

try relaxing composer dependencies to allow php8.2 dev support, reformat so composer format passes

This commit is contained in:
David Goodwin 2024-04-22 21:02:01 +01:00
parent d3dfe6382b
commit f01274ec94
No known key found for this signature in database
31 changed files with 273 additions and 273 deletions

View File

@ -14,7 +14,7 @@ if (!defined('SM_PATH')) {
define('SM_PATH', '../');
}
$config_file = dirname(__FILE__ ) . '/config.php';
$config_file = dirname(__FILE__) . '/config.php';
$validate_file = dirname(__FILE__) . '/../include/validate.php';
if (!file_exists($config_file)) {

View File

@ -50,9 +50,9 @@ function deldir($dir)
{
$current_dir = opendir($dir);
while ($entryname = readdir($current_dir)) {
if (is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")) {
if (is_dir("$dir/$entryname") and ($entryname != "." and $entryname != "..")) {
deldir("{$dir}/{$entryname}");
} elseif ($entryname != "." and $entryname!="..") {
} elseif ($entryname != "." and $entryname != "..") {
unlink("{$dir}/{$entryname}");
}
}
@ -144,7 +144,7 @@ while ($row = mysqli_fetch_assoc($result)) {
//
// If there are results. unset the domain too.
//
if (count($dir[$strip[0]])==0 and mysqli_num_rows($result)>0) {
if (count($dir[$strip[0]]) == 0 and mysqli_num_rows($result) > 0) {
unset($dir[$strip[0]]);
}

View File

@ -22,7 +22,7 @@ require_once(dirname(__FILE__) . '/vendor/autoload.php');
$old = setlocale(LC_ALL, 'C');
if (preg_match('/_TR/i', $old)) {
error_log("WARNING: You may have a Turkish locale set; this breaks the loading of some libraries (Smarty) we depend upon.");
// don't revert back to $old?
// don't revert back to $old?
} else {
setlocale(LC_ALL, $old); // revert back.
}

View File

@ -32,11 +32,12 @@
"ext-mysqli": "*",
"ext-sqlite3": "*",
"ext-mbstring": "*",
"friendsofphp/php-cs-fixer": "^3.0",
"friendsofphp/php-cs-fixer": "^3.54.0",
"php-parallel-lint/php-parallel-lint": "^1.0",
"php": ">= 7.4",
"php-coveralls/php-coveralls": "*",
"phpunit/phpunit": "8.*",
"phpunit/phpunit": "8.*|9.*",
"psalm/phar":"^4.0",
"shardj/zf1-future" : "^1.12"
},

View File

@ -46,12 +46,12 @@ class AdminHandler extends PFAHandler
$reset_by_sms = 1;
}
$this->struct=array(
$this->struct = array(
# field name allow display in... type $PALANG label $PALANG description default / options / ...
# editing? form list
'username' => pacol($this->new, 1, 1, 'text', 'admin' , 'email_address' , '', array(),
array('linkto' => 'list.php?table=domain&username=%s') ),
'password' => pacol(1, 1, 0, 'pass', 'password' , '' ),
array('linkto' => 'list.php?table=domain&username=%s')),
'password' => pacol(1, 1, 0, 'pass', 'password' , ''),
'password2' => pacol(1, 1, 0, 'pass', 'password_again' , '' , '', array(),
/*not_in_db*/ 0,
/*dont_write_to_db*/ 1,
@ -84,13 +84,13 @@ class AdminHandler extends PFAHandler
" WHERE domain != 'ALL' GROUP BY username " .
' ) AS __domain on username = __domain_username'),
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1 ),
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1),
'phone' => pacol(1, $reset_by_sms, 0, 'text', 'pCreate_mailbox_phone', 'pCreate_mailbox_phone_desc', ''),
'email_other' => pacol(1, $passwordReset, 0, 'mail', 'pCreate_mailbox_email', 'pCreate_mailbox_email_desc', ''),
'token' => pacol(1, 0, 0, 'text', '' , '' ),
'token' => pacol(1, 0, 0, 'text', '' , ''),
'token_validity' => pacol(1, 0, 0, 'ts', '' , '', date("Y-m-d H:i:s",time())),
'created' => pacol(0, 0, 0, 'ts', 'created' , '' ),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , '' ),
'created' => pacol(0, 0, 0, 'ts', 'created' , ''),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , ''),
);
}

View File

@ -25,13 +25,13 @@ class AdminpasswordHandler extends PFAHandler
{
# TODO: shorter PALANG labels ;-)
$this->struct=array(
$this->struct = array(
# field name allow display in... type $PALANG label $PALANG description default / options / ...
# editing? form list
'username' => pacol(0, 1, 1, 'text', 'admin' , '' ),
'username' => pacol(0, 1, 1, 'text', 'admin' , ''),
'oldpass' => pacol(1, 1, 0, 'pass', 'pPassword_password_current' , '', '', array(),
/*not_in_db*/ 1 ),
'password' => pacol(1, 1, 0, 'pass', 'pPassword_password' , '' ),
/*not_in_db*/ 1),
'password' => pacol(1, 1, 0, 'pass', 'pPassword_password' , ''),
'password2' => pacol(1, 1, 0, 'pass', 'pPassword_password2' , '' , '', array(),
/*not_in_db*/ 0,
/*dont_write_to_db*/ 1,

View File

@ -28,36 +28,36 @@ class AliasHandler extends PFAHandler
# field name allow display in... type $PALANG label $PALANG description default / ...
# editing? form list
'status' => pacol(0, 0, 0, 'html', '' , '' , '', array(),
array('not_in_db' => 1) ),
'address' => pacol($this->new, 1, 1, 'mail', 'alias' , 'pCreate_alias_catchall_text' ),
array('not_in_db' => 1)),
'address' => pacol($this->new, 1, 1, 'mail', 'alias' , 'pCreate_alias_catchall_text'),
'localpart' => pacol($this->new, 0, 0, 'text', 'alias' , 'pCreate_alias_catchall_text' , '',
/*options*/ array(),
/*not_in_db*/ 1 ),
/*not_in_db*/ 1),
'domain' => pacol($this->new, 0, 1, 'enum', '' , '' , '',
/*options*/ $this->allowed_domains ),
'goto' => pacol(1, 1, 1, 'txtl', 'to' , 'pEdit_alias_help' , array() ),
/*options*/ $this->allowed_domains),
'goto' => pacol(1, 1, 1, 'txtl', 'to' , 'pEdit_alias_help' , array()),
'is_mailbox' => pacol(0, 0, 1, 'int', '' , '' , 0 ,
# technically 'is_mailbox' is bool, but the automatic bool conversion breaks the query. Flagging it as int avoids this problem.
# Maybe having a vbool type (without the automatic conversion) would be cleaner - we'll see if we need it.
/*options*/ array(),
/*not_in_db*/ 0,
/*dont_write_to_db*/ 1,
/*select*/ 'coalesce(__is_mailbox,0) as is_mailbox' ),
/*select*/ 'coalesce(__is_mailbox,0) as is_mailbox'),
/*extrafrom set via set_is_mailbox_extrafrom() */
'__mailbox_username' => pacol( 0, 0, 1, 'vtxt', '' , '' , 0), # filled via is_mailbox
'__mailbox_username' => pacol(0, 0, 1, 'vtxt', '' , '' , 0), # filled via is_mailbox
'goto_mailbox' => pacol($mbgoto, $mbgoto,$mbgoto,'bool', 'pEdit_alias_forward_and_store' , '' , 0,
/*options*/ array(),
/*not_in_db*/ 1 ), # read_from_db_postprocess() sets the value
/*not_in_db*/ 1), # read_from_db_postprocess() sets the value
'on_vacation' => pacol(1, 0, 1, 'bool', 'pUsersMenu_vacation' , '' , 0 ,
/*options*/ array(),
/*not_in_db*/ 1 ), # read_from_db_postprocess() sets the value - TODO: read active flag from vacation table instead?
'created' => pacol(0, 0, 0, 'ts', 'created' , '' ),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , '' ),
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1 ),
/*not_in_db*/ 1), # read_from_db_postprocess() sets the value - TODO: read active flag from vacation table instead?
'created' => pacol(0, 0, 0, 'ts', 'created' , ''),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , ''),
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1),
'_can_edit' => pacol(0, 0, 1, 'vnum', '' , '' , 0 , array(),
array('select' => '1 as _can_edit') ),
array('select' => '1 as _can_edit')),
'_can_delete' => pacol(0, 0, 1, 'vnum', '' , '' , 0 , array(),
array('select' => '1 as _can_delete') ), # read_from_db_postprocess() updates the value
array('select' => '1 as _can_delete')), # read_from_db_postprocess() updates the value
# aliases listed in $CONF[default_aliases] are read-only for domain admins if $CONF[special_alias_control] is NO.
);
@ -71,7 +71,7 @@ class AliasHandler extends PFAHandler
* When using this function to optimize the is_mailbox extrafrom, don't forget to reset it to the default value
* (all domains for this admin) afterwards.
*/
private function set_is_mailbox_extrafrom($condition=array(), $searchmode=array())
private function set_is_mailbox_extrafrom($condition = array(), $searchmode = array())
{
$extrafrom = 'LEFT JOIN ( ' .
' SELECT 1 as __is_mailbox, username as __mailbox_username ' .
@ -168,7 +168,7 @@ class AliasHandler extends PFAHandler
$this->struct['goto_mailbox']['display_in_list'] = 0;
}
if (!$this->new && $this->result['is_mailbox'] && $this->admin_username != ''&& !authentication_has_role('global-admin')) {
if (!$this->new && $this->result['is_mailbox'] && $this->admin_username != '' && !authentication_has_role('global-admin')) {
# domain admins are not allowed to change mailbox alias $CONF['alias_control_admin'] = NO
# TODO: apply the same restriction to superadmins?
if (!Config::bool('alias_control_admin')) {
@ -372,7 +372,7 @@ class AliasHandler extends PFAHandler
return array($condition, $searchmode);
}
public function getList($condition, $searchmode = array(), $limit=-1, $offset=-1): bool
public function getList($condition, $searchmode = array(), $limit = -1, $offset = -1): bool
{
list($condition, $searchmode) = $this->condition_ignore_mailboxes($condition, $searchmode);
$this->set_is_mailbox_extrafrom($condition, $searchmode);

View File

@ -14,17 +14,17 @@ class AliasdomainHandler extends PFAHandler
protected function initStruct()
{
$this->struct=array(
$this->struct = array(
# field name allow display in... type $PALANG label $PALANG description default / options / ...
# editing? form list
'alias_domain' => pacol($this->new, 1, 1, 'enum', 'pCreate_alias_domain_alias' , 'pCreate_alias_domain_alias_text' , '',
/*options, filled below*/ array(),
/* multiopt */ array('linkto' => 'list-virtual.php?domain=%s') ),
/* multiopt */ array('linkto' => 'list-virtual.php?domain=%s')),
'target_domain' => pacol(1, 1, 1, 'enum', 'pCreate_alias_domain_target' , 'pCreate_alias_domain_target_text', '',
/*options*/ array() /* filled below */ ),
'created' => pacol(0, 0, 0, 'ts', 'created' , '' ),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , '' ),
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1 ),
/*options*/ array() /* filled below */),
'created' => pacol(0, 0, 0, 'ts', 'created' , ''),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , ''),
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1),
);

View File

@ -68,7 +68,7 @@ class CliView extends Shell
} else {
$value = $result[$field];
$func="_formatted_".$field;
$func = "_formatted_".$field;
if (method_exists($handler, $func)) {
$value = $handler->{$func}($result); # call _formatted_$fieldname()
}

View File

@ -16,15 +16,15 @@ class DkimHandler extends PFAHandler
protected function initStruct()
{
$this->struct=array(
$this->struct = array(
# field name allow display in... type $PALANG label $PALANG description default / options / ...
# editing? form list
'id' => pacol(0, 0, 1, 'num' , 'pFetchmail_field_id' , '' , '', array(), array('dont_write_to_db' => 1) ),
'description' => pacol(1, 1, 1, 'text', 'description' , '' ),
'id' => pacol(0, 0, 1, 'num' , 'pFetchmail_field_id' , '' , '', array(), array('dont_write_to_db' => 1)),
'description' => pacol(1, 1, 1, 'text', 'description' , ''),
'selector' => pacol(1, 1, 1, 'text', 'pDkim_field_selector', 'pDkim_field_selector_desc'),
'domain_name' => pacol(1, 1, 1, 'enum', 'domain' , 'pDkim_field_domain_desc' , '', $this->allowed_domains),
'private_key' => pacol(1, 1, 0, 'txta', 'pDkim_field_pkey' , 'pDkim_field_pkey_desc' ),
'public_key' => pacol(1, 1, 0, 'txta', 'pDkim_field_pub' , 'pDkim_field_pub_desc' ),
'private_key' => pacol(1, 1, 0, 'txta', 'pDkim_field_pkey' , 'pDkim_field_pkey_desc'),
'public_key' => pacol(1, 1, 0, 'txta', 'pDkim_field_pub' , 'pDkim_field_pub_desc'),
);
}

View File

@ -31,10 +31,10 @@ class DkimsigningHandler extends PFAHandler
array_keys($mail_handler->result())
);
$this->struct=array(
$this->struct = array(
# field name allow display in... type $PALANG label $PALANG description default / options / ...
# editing? form list
'id' => pacol(0, 0, 1, 'num' , 'pFetchmail_field_id' , '' , '', array(), array('dont_write_to_db' => 1) ),
'id' => pacol(0, 0, 1, 'num' , 'pFetchmail_field_id' , '' , '', array(), array('dont_write_to_db' => 1)),
'dkim_id' => pacol(1, 1, 1, 'enum' , 'pDkim_field_dkim_id' , 'pDkim_field_dkim_id_desc' , '', array_keys($dkim_handler->result)),
'author' => pacol(1, 1, 1, 'enum' , 'pDkim_field_author' , 'pDkim_field_author_desc' , '', $authors),
);

View File

@ -55,15 +55,15 @@ class DomainHandler extends PFAHandler
$domain_quota_default = -1;
}
$this->struct=array(
$this->struct = array(
# field name allow display in... type $PALANG label $PALANG description default / options / ...
# editing? form list
'domain' => pacol($this->new, 1, 1, 'text', 'domain' , '' , '', array(),
array('linkto' => 'list-virtual.php?domain=%s') ),
'description' => pacol($super, $super, $super, 'text', 'description' , '' ),
array('linkto' => 'list-virtual.php?domain=%s')),
'description' => pacol($super, $super, $super, 'text', 'description' , ''),
# Aliases
'aliases' => pacol($super, $super, 0, 'num' , 'aliases' , 'pAdminEdit_domain_aliases_text' , Config::read('aliases') ),
'aliases' => pacol($super, $super, 0, 'num' , 'aliases' , 'pAdminEdit_domain_aliases_text' , Config::read('aliases')),
'alias_count' => pacol(0, 0, 1, 'vnum', '' , '' , '', array(),
/*not_in_db*/ 0,
/*dont_write_to_db*/ 1,
@ -71,12 +71,12 @@ class DomainHandler extends PFAHandler
/*extrafrom*/ 'left join ( select count(*) as __alias_count, domain as __alias_domain from ' . table_by_key('alias') .
' group by domain) as __alias on domain = __alias_domain'),
'aliases_quot' => pacol(0, 0, 1, 'quot', 'aliases' , '' , 0, array(),
array('select' => db_quota_text( '__alias_count - coalesce(__mailbox_count,0)', 'aliases', 'aliases_quot')) ),
'_aliases_quot_percent' => pacol( 0, 0, 1, 'vnum', '' ,'' , 0, array(),
array('select' => db_quota_percent('__alias_count - coalesce(__mailbox_count,0)', 'aliases', '_aliases_quot_percent')) ),
array('select' => db_quota_text('__alias_count - coalesce(__mailbox_count,0)', 'aliases', 'aliases_quot'))),
'_aliases_quot_percent' => pacol(0, 0, 1, 'vnum', '' ,'' , 0, array(),
array('select' => db_quota_percent('__alias_count - coalesce(__mailbox_count,0)', 'aliases', '_aliases_quot_percent'))),
# Mailboxes
'mailboxes' => pacol($super, $super, 0, 'num' , 'mailboxes' , 'pAdminEdit_domain_aliases_text' , Config::read('mailboxes') ),
'mailboxes' => pacol($super, $super, 0, 'num' , 'mailboxes' , 'pAdminEdit_domain_aliases_text' , Config::read('mailboxes')),
'mailbox_count' => pacol(0, 0, 1, 'vnum', '' , '' , '', array(),
/*not_in_db*/ 0,
/*dont_write_to_db*/ 1,
@ -84,39 +84,39 @@ class DomainHandler extends PFAHandler
/*extrafrom*/ 'left join ( select count(*) as __mailbox_count, sum(quota) as __total_quota, domain as __mailbox_domain from ' . table_by_key('mailbox') .
' group by domain) as __mailbox on domain = __mailbox_domain'),
'mailboxes_quot' => pacol(0, 0, 1, 'quot', 'mailboxes' , '' , 0, array(),
array('select' => db_quota_text( '__mailbox_count', 'mailboxes', 'mailboxes_quot')) ),
'_mailboxes_quot_percent' => pacol( 0, 0, 1, 'vnum', '' , '' , 0, array(),
array('select' => db_quota_percent('__mailbox_count', 'mailboxes', '_mailboxes_quot_percent')) ),
array('select' => db_quota_text('__mailbox_count', 'mailboxes', 'mailboxes_quot'))),
'_mailboxes_quot_percent' => pacol(0, 0, 1, 'vnum', '' , '' , 0, array(),
array('select' => db_quota_percent('__mailbox_count', 'mailboxes', '_mailboxes_quot_percent'))),
'maxquota' => pacol($editquota,$editquota,$quota, 'num', 'pOverview_get_quota' , 'pAdminEdit_domain_maxquota_text' , Config::read('maxquota') ),
'maxquota' => pacol($editquota,$editquota,$quota, 'num', 'pOverview_get_quota' , 'pAdminEdit_domain_maxquota_text' , Config::read('maxquota')),
# Domain quota
'quota' => pacol($edit_dom_q,$edit_dom_q, 0, 'num', 'pAdminEdit_domain_quota' , 'pAdminEdit_domain_maxquota_text' , $domain_quota_default ),
'quota' => pacol($edit_dom_q,$edit_dom_q, 0, 'num', 'pAdminEdit_domain_quota' , 'pAdminEdit_domain_maxquota_text' , $domain_quota_default),
'total_quota' => pacol(0, 0, 1, 'vnum', '' , '' , '', array(),
array('select' => "$query_used_domainquota AS total_quota") /*extrafrom*//* already in mailbox_count */ ),
'total_quot' => pacol( 0, 0, $dom_q, 'quot', 'pAdminEdit_domain_quota' , '' , 0, array(),
array('select' => db_quota_text( $query_used_domainquota, 'quota', 'total_quot')) ),
'_total_quot_percent'=> pacol( 0, 0, $dom_q, 'vnum', '' , '' , 0, array(),
array('select' => db_quota_percent($query_used_domainquota, 'quota', '_total_quot_percent')) ),
array('select' => "$query_used_domainquota AS total_quota") /*extrafrom*//* already in mailbox_count */),
'total_quot' => pacol(0, 0, $dom_q, 'quot', 'pAdminEdit_domain_quota' , '' , 0, array(),
array('select' => db_quota_text($query_used_domainquota, 'quota', 'total_quot'))),
'_total_quot_percent' => pacol(0, 0, $dom_q, 'vnum', '' , '' , 0, array(),
array('select' => db_quota_percent($query_used_domainquota, 'quota', '_total_quot_percent'))),
'transport' => pacol($transp, $transp,$transp,'enum', 'transport' , 'pAdminEdit_domain_transport_text' , Config::read('transport_default') ,
/*options*/ Config::read_array('transport_options') ),
/*options*/ Config::read_array('transport_options')),
'backupmx' => pacol($super, $super, 1, 'bool', 'pAdminEdit_domain_backupmx' , '' , 0),
'active' => pacol($super, $super, 1, 'bool', 'active' , '' , 1 ),
'default_aliases' => pacol($this->new, $this->new, 0, 'bool', 'pAdminCreate_domain_defaultaliases', '' , 1,array(), /*not in db*/ 1 ),
'created' => pacol(0, 0, 0, 'ts', 'created' , '' ),
'modified' => pacol(0, 0, $super, 'ts', 'last_modified' , '' ),
'active' => pacol($super, $super, 1, 'bool', 'active' , '' , 1),
'default_aliases' => pacol($this->new, $this->new, 0, 'bool', 'pAdminCreate_domain_defaultaliases', '' , 1,array(), /*not in db*/ 1),
'created' => pacol(0, 0, 0, 'ts', 'created' , ''),
'modified' => pacol(0, 0, $super, 'ts', 'last_modified' , ''),
'password_expiry' => pacol($super, $pwexp, $pwexp, 'num', 'password_expiration' , 'password_expiration_desc' , 365),
'_can_edit' => pacol(0, 0, 1, 'int', '' , '' , 0 ,
/*options*/ array(),
/*not_in_db*/ 0,
/*dont_write_to_db*/ 1,
/*select*/ $this->is_superadmin . ' as _can_edit' ),
/*select*/ $this->is_superadmin . ' as _can_edit'),
'_can_delete' => pacol(0, 0, 1, 'int', '' , '' , 0 ,
/*options*/ array(),
/*not_in_db*/ 0,
/*dont_write_to_db*/ 1,
/*select*/ $this->is_superadmin . ' as _can_delete' ),
/*select*/ $this->is_superadmin . ' as _can_delete'),
);
}
@ -171,7 +171,7 @@ class DomainHandler extends PFAHandler
protected function postSave(): bool
{
if ($this->new && $this->values['default_aliases']) {
foreach (Config::read_array('default_aliases') as $address=>$goto) {
foreach (Config::read_array('default_aliases') as $address => $goto) {
$address = $address . "@" . $this->id;
# if $goto doesn't contain @, let the alias point to the same domain
if (!strstr($goto, '@')) {
@ -286,7 +286,7 @@ class DomainHandler extends PFAHandler
*/
protected function domain_postcreation()
{
$script=Config::read_string('domain_postcreation_script');
$script = Config::read_string('domain_postcreation_script');
if (empty($script)) {
return true;
@ -297,13 +297,13 @@ class DomainHandler extends PFAHandler
return false;
}
$cmdarg1=escapeshellarg($this->id);
$command= "$script $cmdarg1";
$retval=0;
$output=array();
$firstline='';
$firstline=exec($command, $output, $retval);
if (0!=$retval) {
$cmdarg1 = escapeshellarg($this->id);
$command = "$script $cmdarg1";
$retval = 0;
$output = array();
$firstline = '';
$firstline = exec($command, $output, $retval);
if (0 != $retval) {
error_log("Running $command yielded return value=$retval, first line of output=$firstline");
$this->errormsg[] = 'Problems running domain postcreation script!';
return false;
@ -319,7 +319,7 @@ class DomainHandler extends PFAHandler
*/
protected function domain_postedit()
{
$script=Config::read_string('domain_postedit_script');
$script = Config::read_string('domain_postedit_script');
if (empty($script)) {
return true;
@ -330,13 +330,13 @@ class DomainHandler extends PFAHandler
return false;
}
$cmdarg1=escapeshellarg($this->id);
$command= "$script $cmdarg1";
$retval=0;
$output=array();
$firstline='';
$firstline=exec($command, $output, $retval);
if (0!=$retval) {
$cmdarg1 = escapeshellarg($this->id);
$command = "$script $cmdarg1";
$retval = 0;
$output = array();
$firstline = '';
$firstline = exec($command, $output, $retval);
if (0 != $retval) {
error_log("Running $command yielded return value=$retval, first line of output=$firstline");
$this->errormsg[] = 'Problems running domain postedit script!';
return false;
@ -352,7 +352,7 @@ class DomainHandler extends PFAHandler
*/
protected function domain_postdeletion()
{
$script=Config::read_string('domain_postdeletion_script');
$script = Config::read_string('domain_postdeletion_script');
if (empty($script)) {
return true;
@ -363,13 +363,13 @@ class DomainHandler extends PFAHandler
return false;
}
$cmdarg1=escapeshellarg($this->id);
$command= "$script $cmdarg1";
$retval=0;
$output=array();
$firstline='';
$firstline=exec($command, $output, $retval);
if (0!=$retval) {
$cmdarg1 = escapeshellarg($this->id);
$command = "$script $cmdarg1";
$retval = 0;
$output = array();
$firstline = '';
$firstline = exec($command, $output, $retval);
if (0 != $retval) {
error_log("Running $command yielded return value=$retval, first line of output=$firstline");
$this->errormsg[] = 'Problems running domain postdeletion script!';
return false;

View File

@ -20,34 +20,34 @@ class FetchmailHandler extends PFAHandler
$extra = Config::intbool('fetchmail_extra_options');
$this->struct=array(
$this->struct = array(
# field name allow display in... type $PALANG label $PALANG description default / options / ...
# editing? form list
'id' => pacol(0, 0, 1, 'num' , '' , '' , '', array(),
array('dont_write_to_db' => 1) ),
'domain' => pacol(0, 0, 1, 'text', '' , '' ),
'mailbox' => pacol(1, 1, 1, 'enum', 'pFetchmail_field_mailbox' , 'pFetchmail_desc_mailbox' ), # mailbox list
'src_server' => pacol(1, 1, 1, 'text', 'pFetchmail_field_src_server' , 'pFetchmail_desc_src_server' ),
'src_port' => pacol(1, 1, 1, 'num', 'pFetchmail_field_src_port' , 'pFetchmail_desc_src_port' , 0 ),
array('dont_write_to_db' => 1)),
'domain' => pacol(0, 0, 1, 'text', '' , ''),
'mailbox' => pacol(1, 1, 1, 'enum', 'pFetchmail_field_mailbox' , 'pFetchmail_desc_mailbox'), # mailbox list
'src_server' => pacol(1, 1, 1, 'text', 'pFetchmail_field_src_server' , 'pFetchmail_desc_src_server'),
'src_port' => pacol(1, 1, 1, 'num', 'pFetchmail_field_src_port' , 'pFetchmail_desc_src_port' , 0),
'src_auth' => pacol(1, 1, 1, 'enum', 'pFetchmail_field_src_auth' , 'pFetchmail_desc_src_auth' , '', $src_auth_options),
'src_user' => pacol(1, 1, 1, 'text', 'pFetchmail_field_src_user' , 'pFetchmail_desc_src_user' ),
'src_password' => pacol(1, 1, 0, 'b64p', 'pFetchmail_field_src_password' , 'pFetchmail_desc_src_password' ),
'src_folder' => pacol(1, 1, 1, 'text', 'pFetchmail_field_src_folder' , 'pFetchmail_desc_src_folder' ),
'poll_time' => pacol(1, 1, 1, 'num' , 'pFetchmail_field_poll_time' , 'pFetchmail_desc_poll_time' , 10 ),
'fetchall' => pacol(1, 1, 1, 'bool', 'pFetchmail_field_fetchall' , 'pFetchmail_desc_fetchall' ),
'keep' => pacol(1, 1, 1, 'bool', 'pFetchmail_field_keep' , 'pFetchmail_desc_keep' ),
'src_user' => pacol(1, 1, 1, 'text', 'pFetchmail_field_src_user' , 'pFetchmail_desc_src_user'),
'src_password' => pacol(1, 1, 0, 'b64p', 'pFetchmail_field_src_password' , 'pFetchmail_desc_src_password'),
'src_folder' => pacol(1, 1, 1, 'text', 'pFetchmail_field_src_folder' , 'pFetchmail_desc_src_folder'),
'poll_time' => pacol(1, 1, 1, 'num' , 'pFetchmail_field_poll_time' , 'pFetchmail_desc_poll_time' , 10),
'fetchall' => pacol(1, 1, 1, 'bool', 'pFetchmail_field_fetchall' , 'pFetchmail_desc_fetchall'),
'keep' => pacol(1, 1, 1, 'bool', 'pFetchmail_field_keep' , 'pFetchmail_desc_keep'),
'protocol' => pacol(1, 1, 1, 'enum', 'pFetchmail_field_protocol' , 'pFetchmail_desc_protocol' , '', $src_protocol_options),
'usessl' => pacol(1, 1, 1, 'bool', 'pFetchmail_field_usessl' , 'pFetchmail_desc_usessl' ),
'sslcertck' => pacol(1, 1, 1, 'bool', 'pFetchmail_field_sslcertck' , '' ),
'sslcertpath' => pacol($extra, $extra, $extra, 'text', 'pFetchmail_field_sslcertpath' , '' ),
'sslfingerprint' => pacol($extra, $extra, $extra, 'text', 'pFetchmail_field_sslfingerprint','' ),
'extra_options' => pacol($extra, $extra, $extra, 'text', 'pFetchmail_field_extra_options', 'pFetchmail_desc_extra_options' ),
'mda' => pacol($extra, $extra, $extra, 'text', 'pFetchmail_field_mda' , 'pFetchmail_desc_mda' ),
'date' => pacol(0, 0, 1, 'text', 'pFetchmail_field_date' , 'pFetchmail_desc_date' , '2000-01-01' ),
'returned_text' => pacol(0, 0, 1, 'text', 'pFetchmail_field_returned_text', 'pFetchmail_desc_returned_text' ),
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1 ),
'created' => pacol(0, 0, 0, 'ts', 'created' , '' ),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , '' ),
'usessl' => pacol(1, 1, 1, 'bool', 'pFetchmail_field_usessl' , 'pFetchmail_desc_usessl'),
'sslcertck' => pacol(1, 1, 1, 'bool', 'pFetchmail_field_sslcertck' , ''),
'sslcertpath' => pacol($extra, $extra, $extra, 'text', 'pFetchmail_field_sslcertpath' , ''),
'sslfingerprint' => pacol($extra, $extra, $extra, 'text', 'pFetchmail_field_sslfingerprint',''),
'extra_options' => pacol($extra, $extra, $extra, 'text', 'pFetchmail_field_extra_options', 'pFetchmail_desc_extra_options'),
'mda' => pacol($extra, $extra, $extra, 'text', 'pFetchmail_field_mda' , 'pFetchmail_desc_mda'),
'date' => pacol(0, 0, 1, 'text', 'pFetchmail_field_date' , 'pFetchmail_desc_date' , '2000-01-01'),
'returned_text' => pacol(0, 0, 1, 'text', 'pFetchmail_field_returned_text', 'pFetchmail_desc_returned_text'),
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1),
'created' => pacol(0, 0, 0, 'ts', 'created' , ''),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , ''),
);
# get list of mailboxes (for currently logged in user)

View File

@ -15,8 +15,8 @@ class MailboxHandler extends PFAHandler
# init $this->struct, $this->db_table and $this->id_field
protected function initStruct()
{
$passwordReset = (int) ( Config::bool('forgotten_user_password_reset') && !Config::read('mailbox_postpassword_script') );
$smtpActiveFlag = (int) ( Config::bool('smtp_active_flag') );
$passwordReset = (int)(Config::bool('forgotten_user_password_reset') && !Config::read('mailbox_postpassword_script'));
$smtpActiveFlag = (int)(Config::bool('smtp_active_flag'));
$reset_by_sms = 0;
if ($passwordReset && Config::read_string('sms_send_function')) {
$reset_by_sms = 1;
@ -30,38 +30,38 @@ class MailboxHandler extends PFAHandler
# field name allow display in... type $PALANG label $PALANG description default / options / ...
# editing? form list
'username' => pacol($this->new, 1, 1, 'mail', 'pEdit_mailbox_username' , '' , '' ),
'local_part' => pacol($this->new, 0, 0, 'text', 'pEdit_mailbox_username' , '' , '',
'username' => pacol($this->new, 1, 1, 'mail', 'pEdit_mailbox_username', '', ''),
'local_part' => pacol($this->new, 0, 0, 'text', 'pEdit_mailbox_username', '', '',
/*options*/ array('legal_chars' => Config::read('username_legal_chars'), 'legal_char_warning' => Config::lang('pLegal_char_warning'))
),
'domain' => pacol($this->new, 0, 1, 'enum', '' , '' , '',
/*options*/ $this->allowed_domains ),
'domain' => pacol($this->new, 0, 1, 'enum', '', '', '',
/*options*/ $this->allowed_domains),
# TODO: maildir: display in list is needed to include maildir in SQL result (for post_edit hook)
# TODO: (not a perfect solution, but works for now - maybe we need a separate "include in SELECT query" field?)
'maildir' => pacol($this->new, 0, 1, 'text', '' , '' , '' ),
'password' => pacol($editPw, $editPw,0, 'pass', 'password' , 'pCreate_mailbox_password_text' , '' ),
'password2' => pacol($editPw, $editPw,0, 'pass', 'password_again' , '' , '',
'maildir' => pacol($this->new, 0, 1, 'text', '', '', ''),
'password' => pacol($editPw, $editPw, 0, 'pass', 'password', 'pCreate_mailbox_password_text', ''),
'password2' => pacol($editPw, $editPw, 0, 'pass', 'password_again', '', '',
/*options*/ array(),
/*not_in_db*/ 0,
/*dont_write_to_db*/ 1,
/*select*/ 'password as password2'
),
'name' => pacol(1, 1, 1, 'text', 'name' , 'pCreate_mailbox_name_text' , '' ),
'quota' => pacol(1, 1, 1, 'int' , 'pEdit_mailbox_quota' , 'pEdit_mailbox_quota_text' , '' ), # in MB
'name' => pacol(1, 1, 1, 'text', 'name', 'pCreate_mailbox_name_text', ''),
'quota' => pacol(1, 1, 1, 'int', 'pEdit_mailbox_quota', 'pEdit_mailbox_quota_text', ''), # in MB
# read_from_db_postprocess() also sets 'quotabytes' for use in init()
# TODO: read used quota from quota/quota2 table
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1 ),
'smtp_active' => pacol($smtpActiveFlag, $smtpActiveFlag,0, 'int', 'smtp_active' , '' , 1 ),
'welcome_mail' => pacol($this->new, $this->new, 0, 'bool', 'pCreate_mailbox_mail' , '' , 1,
'active' => pacol(1, 1, 1, 'bool', 'active', '', 1),
'smtp_active' => pacol($smtpActiveFlag, $smtpActiveFlag, 0, 'int', 'smtp_active', '', 1),
'welcome_mail' => pacol($this->new, $this->new, 0, 'bool', 'pCreate_mailbox_mail', '', 1,
/*options*/ array(),
/*not_in_db*/ 1 ),
'phone' => pacol(1, $reset_by_sms, 0, 'text', 'pCreate_mailbox_phone' , 'pCreate_mailbox_phone_desc' , ''),
'email_other' => pacol(1, $passwordReset, 0, 'mail', 'pCreate_mailbox_email' , 'pCreate_mailbox_email_desc' , ''),
'token' => pacol(1, 0, 0, 'text', '' , '' ),
'token_validity' => pacol(1, 0, 0, 'ts', '' , '', date("Y-m-d H:i:s",time())),
'created' => pacol(0, 0, 1, 'ts', 'created' , '' ),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , '' ),
'password_expiry' => pacol(0, 0, 1, 'ts', 'password_expiration' , '' ),
/*not_in_db*/ 1),
'phone' => pacol(1, $reset_by_sms, 0, 'text', 'pCreate_mailbox_phone', 'pCreate_mailbox_phone_desc', ''),
'email_other' => pacol(1, $passwordReset, 0, 'mail', 'pCreate_mailbox_email', 'pCreate_mailbox_email_desc', ''),
'token' => pacol(1, 0, 0, 'text', '', ''),
'token_validity' => pacol(1, 0, 0, 'ts', '', '', date("Y-m-d H:i:s", time())),
'created' => pacol(0, 0, 1, 'ts', 'created', ''),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified', ''),
'password_expiry' => pacol(0, 0, 1, 'ts', 'password_expiration', ''),
# TODO: add virtual 'notified' column and allow to display who received a vacation response?
);
@ -227,7 +227,7 @@ class MailboxHandler extends PFAHandler
foreach ($db_result as $key => $row) {
if (isset($row['quota']) && is_numeric($row['quota']) && $row['quota'] > -1) { # quota could be disabled in $struct
$db_result[$key]['quotabytes'] = $row['quota'];
$db_result[$key]['quota'] = divide_quota( (int) $row['quota']); # convert quota to MB
$db_result[$key]['quota'] = divide_quota((int)$row['quota']); # convert quota to MB
} else {
$db_result[$key]['quotabytes'] = -1;
$db_result[$key]['quota'] = -1;
@ -364,7 +364,7 @@ class MailboxHandler extends PFAHandler
public function delete()
{
if (! $this->view()) {
if (!$this->view()) {
$this->errormsg[] = Config::Lang('pFetchmail_invalid_mailbox'); # TODO: can users hit this message at all? init() should already fail...
return false;
}
@ -392,7 +392,6 @@ class MailboxHandler extends PFAHandler
}
protected function _prefill_domain($field, $val)
{
if (in_array($val, $this->struct[$field]['options'])) {
@ -469,7 +468,6 @@ class MailboxHandler extends PFAHandler
# public function _formatted_quota ($item) { return $item['used_quota'] . ' / ' . $item['quota'] ; }
/**
* calculate maildir path for the mailbox
*/
@ -527,7 +525,7 @@ class MailboxHandler extends PFAHandler
return true; # enforcing quotas is disabled - just allow it
}
$quota = (int) $quota;
$quota = (int)$quota;
list(/*NULL*/, $domain) = explode('@', $this->id);
$limit = get_domain_properties($domain);
@ -628,26 +626,26 @@ class MailboxHandler extends PFAHandler
$quota = $this->values['quota'];
if (empty($this->id) || empty($domain) || empty($this->values['maildir'])) {
trigger_error('In '.__FUNCTION__.': empty username, domain and/or maildir parameter', E_USER_ERROR);
trigger_error('In ' . __FUNCTION__ . ': empty username, domain and/or maildir parameter', E_USER_ERROR);
return false;
}
$cmdarg1=escapeshellarg($this->id);
$cmdarg2=escapeshellarg($domain);
$cmdarg1 = escapeshellarg($this->id);
$cmdarg2 = escapeshellarg($domain);
$status = true;
if (!empty($cmd)) {
$cmdarg3=escapeshellarg($this->values['maildir']);
$cmdarg3 = escapeshellarg($this->values['maildir']);
if ($quota <= 0) {
$quota = 0;
} # TODO: check if this is correct behaviour
$cmdarg4 = escapeshellarg("" . $quota);
$command= "$cmd $cmdarg1 $cmdarg2 $cmdarg3 $cmdarg4";
$retval=0;
$output=array();
$firstline='';
$firstline=exec($command, $output, $retval);
if (0!=$retval) {
$command = "$cmd $cmdarg1 $cmdarg2 $cmdarg3 $cmdarg4";
$retval = 0;
$output = array();
$firstline = '';
$firstline = exec($command, $output, $retval);
if (0 != $retval) {
error_log("Running $command yielded return value=$retval, first line of output=$firstline");
$this->errormsg[] .= $warnmsg;
$status = false;
@ -672,14 +670,14 @@ class MailboxHandler extends PFAHandler
} else {
// Write passwords through pipe to command stdin -- provide old password, then new password.
fwrite($pipes[0], "\0", 1);
fwrite($pipes[0], $this->values['password'] . "\0", 1+strlen($this->values['password']));
fwrite($pipes[0], $this->values['password'] . "\0", 1 + strlen($this->values['password']));
$output = stream_get_contents($pipes[1]);
fclose($pipes[0]);
fclose($pipes[1]);
$retval = proc_close($proc);
if (0!=$retval) {
if (0 != $retval) {
error_log("Running $command yielded return value=$retval, output was: " . json_encode($output));
$this->errormsg[] .= $warnmsg_pw;
$status = false;
@ -711,14 +709,14 @@ class MailboxHandler extends PFAHandler
return false;
}
$cmdarg1=escapeshellarg($this->id);
$cmdarg2=escapeshellarg($domain);
$cmdarg1 = escapeshellarg($this->id);
$cmdarg2 = escapeshellarg($domain);
$command = "$cmd $cmdarg1 $cmdarg2";
$retval=0;
$output=array();
$firstline='';
$firstline=exec($command, $output, $retval);
if (0!=$retval) {
$retval = 0;
$output = array();
$firstline = '';
$firstline = exec($command, $output, $retval);
if (0 != $retval) {
error_log("Running $command yielded return value=$retval, first line of output=$firstline");
$this->errormsg[] = 'Problems running mailbox postdeletion script!';
return false;

View File

@ -413,7 +413,7 @@ abstract class PFAHandler
*/
public function prefill($field, $val)
{
$func="_prefill_".$field;
$func = "_prefill_".$field;
if (method_exists($this, $func)) {
$this->{$func}($field, $val); # call _missing_$fieldname()
} else {
@ -442,7 +442,7 @@ abstract class PFAHandler
# Warning: $this->RAWvalues contains unchecked input data - use it carefully!
if ($this->new) {
foreach ($this->struct as $key=>$row) {
foreach ($this->struct as $key => $row) {
if ($row['editable'] && !isset($values[$key])) {
/**
* when creating a new item:
@ -452,7 +452,7 @@ abstract class PFAHandler
* - otherwise use the default value from $this->struct
* (if you don't want this, create an empty _missing_$fieldname() function)
*/
$func="_missing_".$key;
$func = "_missing_".$key;
if (method_exists($this, $func)) {
$this->{$func}($key); # call _missing_$fieldname()
} else {
@ -467,7 +467,7 @@ abstract class PFAHandler
# base validation
$this->values = array();
$this->values_valid = false;
foreach ($this->struct as $key=>$row) {
foreach ($this->struct as $key => $row) {
if ($row['editable'] == 0) { # not editable
if ($this->new == 1) {
# on $new, always set non-editable field to default value on $new (even if input data contains another value)
@ -485,7 +485,7 @@ abstract class PFAHandler
$valid = true; # trust input unless validator objects
# validate based on field type ($this->_inp_$type)
$func="_inp_".$row['type'];
$func = "_inp_".$row['type'];
if (method_exists($this, $func)) {
if (!$this->{$func}($key, $values[$key])) {
$valid = false;
@ -495,7 +495,7 @@ abstract class PFAHandler
}
# validate based on field name (_validate_$fieldname)
$func="_validate_".$key;
$func = "_validate_".$key;
if (method_exists($this, $func)) {
if (!$this->{$func}($key, $values[$key])) {
$valid = false;
@ -690,7 +690,7 @@ abstract class PFAHandler
# get list of fields to display
$extrafrom = "";
foreach ($this->struct as $key=>$row) {
foreach ($this->struct as $key => $row) {
if (($row['display_in_list'] != 0 || $row['display_in_form'] != 0) && $row['not_in_db'] == 0) {
if ($row['select'] != '') {
$key = $row['select'];
@ -771,7 +771,7 @@ abstract class PFAHandler
* @param int $offset - number of first row to return
* @return array - rows (as associative array, with the ID as key)
*/
protected function read_from_db($condition, $searchmode = array(), $limit=-1, $offset=-1): array
protected function read_from_db($condition, $searchmode = array(), $limit = -1, $offset = -1): array
{
$queryparts = $this->build_select_query($condition, $searchmode);
@ -814,7 +814,7 @@ abstract class PFAHandler
* The data is stored in $this->result (as associative array of column => value)
* error messages (if any) are stored in $this->errormsg
*/
public function view($errors=true)
public function view($errors = true)
{
$result = $this->read_from_db(array($this->id_field => $this->id));
if (count($result) == 1) {
@ -839,7 +839,7 @@ abstract class PFAHandler
* @return bool - always true, no need to check ;-) (if $result is not an array, getList die()s)
* The data is stored in $this->result (as array of rows, each row is an associative array of column => value)
*/
public function getList($condition, $searchmode = array(), $limit=-1, $offset=-1): bool
public function getList($condition, $searchmode = array(), $limit = -1, $offset = -1): bool
{
if (is_array($condition)) {
$real_condition = array();

View File

@ -105,12 +105,12 @@ class Shell
*/
public function __construct(&$dispatch)
{
$vars = array('params', 'args', 'shell', 'shellCommand'=> 'command');
$vars = array('params', 'args', 'shell', 'shellCommand' => 'command');
foreach ($vars as $key => $var) {
if (is_string($key)) {
$this->{$var} =& $dispatch->{$key};
$this->{$var} = & $dispatch->{$key};
} else {
$this->{$var} =& $dispatch->{$var};
$this->{$var} = & $dispatch->{$var};
}
}
@ -120,7 +120,7 @@ class Shell
$this->name = str_replace(array('shell', 'Shell', 'task', 'Task'), '', $this->className);
}
$this->Dispatch =& $dispatch;
$this->Dispatch = & $dispatch;
}
/**

View File

@ -29,23 +29,23 @@ class VacationHandler extends PFAHandler
*/
protected function initStruct()
{
$this->struct=array(
$this->struct = array(
# field name allow display in... type $PALANG label $PALANG description default / options / ...
# editing? form list
'email' => pacol($this->new, 1, 1, 'text', 'pLogin_username' , '' , '' ),
'domain' => pacol(1, 0, 0, 'text', '' , '' , '' ),
'subject' => pacol(1, 1, 0, 'text', 'pUsersVacation_subject' , '' , '' ),
'body' => pacol(1, 1, 0, 'text', 'pUsersVacation_body' , '' , '' ),
'activefrom' => pacol(1, 1, 1, 'text', 'pUsersVacation_activefrom' , '' , '' ),
'activeuntil' => pacol(1, 1, 1, 'text', 'pUsersVacation_activeuntil' , '' , '' ),
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1 ),
'created' => pacol(0, 0, 1, 'ts', 'created' , '' ),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , '' ),
'email' => pacol($this->new, 1, 1, 'text', 'pLogin_username' , '' , ''),
'domain' => pacol(1, 0, 0, 'text', '' , '' , ''),
'subject' => pacol(1, 1, 0, 'text', 'pUsersVacation_subject' , '' , ''),
'body' => pacol(1, 1, 0, 'text', 'pUsersVacation_body' , '' , ''),
'activefrom' => pacol(1, 1, 1, 'text', 'pUsersVacation_activefrom' , '' , ''),
'activeuntil' => pacol(1, 1, 1, 'text', 'pUsersVacation_activeuntil' , '' , ''),
'active' => pacol(1, 1, 1, 'bool', 'active' , '' , 1),
'created' => pacol(0, 0, 1, 'ts', 'created' , ''),
'modified' => pacol(0, 0, 1, 'ts', 'last_modified' , ''),
# TODO: add virtual 'notified' column and allow to display who received a vacation response?
);
if ( ! db_pgsql() ) {
$this->struct['cache'] = pacol(0, 0, 0, 'text', '' , '' , '' ); # leftover from 2.2
if (! db_pgsql()) {
$this->struct['cache'] = pacol(0, 0, 0, 'text', '' , '' , ''); # leftover from 2.2
}
}

View File

@ -71,7 +71,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$recipients = array_unique($recipients);
if (count($recipients)>0) {
if (count($recipients) > 0) {
mb_internal_encoding("UTF-8");
$b_name = mb_encode_mimeheader($_POST['name'], 'UTF-8', 'Q');
$b_subject = mb_encode_mimeheader($_POST['subject'], 'UTF-8', 'Q');

View File

@ -268,13 +268,13 @@ foreach ($result as $row) {
if (db_pgsql()) {
$row['modified'] = date('Y-m-d H:i', strtotime($row['modified']));
$row['created'] = date('Y-m-d H:i', strtotime($row['created']));
$row['active']=('t'==$row['active']) ? 1 : 0;
$row['active'] = ('t' == $row['active']) ? 1 : 0;
if (Config::bool('vacation_control_admin')) {
if ($row['v_active'] == null) {
$row['v_active'] = 'f';
}
$row['v_active']=('t'==$row['v_active']) ? 1 : 0;
$row['v_active'] = ('t' == $row['v_active']) ? 1 : 0;
}
}
$tMailbox[] = $row;
@ -345,8 +345,8 @@ for ($i = 0; $i < sizeof($tMailbox); $i++) {
$divide_quota['quota'][$i] = divide_quota($tMailbox[$i]['quota']);
}
if (isset($tMailbox[$i]['quota']) && isset($tMailbox[$i]['current'])) {
$divide_quota['percent'][$i] = min(100, round(($divide_quota ['current'][$i]/max(1, $divide_quota ['quota'][$i]))*100));
$divide_quota['quota_width'][$i] = ($divide_quota['percent'][$i] / 100 ) * 120; // because 100px wasn't wide enough?
$divide_quota['percent'][$i] = min(100, round(($divide_quota ['current'][$i] / max(1, $divide_quota ['quota'][$i])) * 100));
$divide_quota['quota_width'][$i] = ($divide_quota['percent'][$i] / 100) * 120; // because 100px wasn't wide enough?
}
}

View File

@ -60,7 +60,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
$fPassword = safepost('fPassword');
if ($lang != check_language(false)) { # only set cookie if language selection was changed
setcookie('lang', $lang, time() + 60*60*24*30); # language cookie, lifetime 30 days
setcookie('lang', $lang, time() + 60 * 60 * 24 * 30); # language cookie, lifetime 30 days
# (language preference cookie is processed even if username and/or password are invalid)
}

View File

@ -188,11 +188,11 @@ if ($authenticated) {
EOF;
}
if ($old_setup_password) {
if ($old_setup_password) {
echo '<p class="text-danger"><strong>Your setup_password is in an obsolete format. As of PostfixAdmin 3.3 it needs regenerating.</strong>';
}
}
if (!$authenticated || !$configSetupDone) { ?>
if (!$authenticated || !$configSetupDone) { ?>
<h2>Generate setup_password</h2>
@ -271,7 +271,7 @@ EOF;
<?php
} // end if(!$authenticated)?>
} // end if(!$authenticated)?>
</div>
</div>
@ -280,7 +280,7 @@ EOF;
<h2 class="h2">Hosting Environment Check</h2>
<?php
$check = do_software_environment_check();
$check = do_software_environment_check();
if ($authenticated) {
if (!empty($check['info'])) {
@ -559,9 +559,9 @@ function do_software_environment_check()
$info = [];
//
//
// Check for availability functions
//
//
$f_phpversion = function_exists("phpversion");
$f_apache_get_version = function_exists("apache_get_version");

View File

@ -193,7 +193,7 @@ function _do_upgrade($current_version)
$current_version = 1823;
}
for ($i = $current_version +1; $i <= $target_version; $i++) {
for ($i = $current_version + 1; $i <= $target_version; $i++) {
$function = "upgrade_$i";
$function_mysql_pgsql = $function . "_mysql_pgsql";
$function_mysql = $function . "_mysql";

View File

@ -108,7 +108,7 @@ if ($_SERVER['REQUEST_METHOD'] === "POST") {
// throttle password reset requests to prevent brute force attack
$elapsed_time = microtime(true) - $start_time;
if ($elapsed_time < 2 * pow(10, 6)) {
usleep( (int) ( 2 * pow(10, 6) - $elapsed_time ) );
usleep((int) (2 * pow(10, 6) - $elapsed_time));
}
flash_info(Config::Lang('pPassword_recovery_processed'));

View File

@ -100,7 +100,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
if ( $totppf->usesTOTP($username)) {
if ($totppf->usesTOTP($username)) {
$smarty->assign('show_form', 'hidden');
} else {
$smarty->assign('show_form', 'visible');

View File

@ -52,14 +52,14 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
if ((is_array($list_domains) and sizeof($list_domains) > 0)) {
foreach ($list_domains as $domain) {
if ($domain == $fDomain_aux) {
$fDomain=$domain;
$flag_fDomain=1;
$fDomain = $domain;
$flag_fDomain = 1;
break;
}
}
}
if ($flag_fDomain == 0 ) {
if ($flag_fDomain == 0) {
die('Unknown domain');
}
@ -68,13 +68,13 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
die('Unknown page number');
}
} else {
$page_number=1;
$page_number = 1;
if ((is_array($list_domains) and sizeof($list_domains) > 0)) {
$fDomain = $list_domains[0];
}
}
} elseif ($_SERVER['REQUEST_METHOD'] == "POST") {
$page_number=1;
$page_number = 1;
if (isset($_POST['fDomain'])) {
$fDomain = escape_string($_POST['fDomain']);
}
@ -108,26 +108,26 @@ if ($error != 1) {
$number_of_logs=0;
$number_of_pages=0;
$number_of_logs = 0;
$number_of_pages = 0;
//get number of total logs
$query = "SELECT count(*) as number_of_logs FROM $table_log $where_sql";
$result = db_query_all($query, $params);
foreach ($result as $r ) {
$number_of_logs=$r['number_of_logs'];
foreach ($result as $r) {
$number_of_logs = $r['number_of_logs'];
}
$number_of_pages = ceil($number_of_logs/$page_size);
$number_of_pages = ceil($number_of_logs / $page_size);
if ($page_number > $number_of_pages) {
die('Unknown page number');
}
if ($page_number == 1 ) {
$offset=0;
if ($page_number == 1) {
$offset = 0;
} else {
$offset=($page_number-1)*$page_size;
$offset = ($page_number - 1) * $page_size;
}
$query = "SELECT timestamp,username,domain,action,data FROM $table_log $where_sql ORDER BY timestamp DESC LIMIT $page_size OFFSET $offset";
@ -153,7 +153,7 @@ foreach ($tLog as $k => $v) {
}
}
//get url
$url=explode("?",(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]")[0];
$url = explode("?",(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]")[0];
$smarty->assign('domain_list', $list_domains);
$smarty->assign('domain_selected', $fDomain);

View File

@ -1,8 +1,9 @@
#!/bin/env php
<?php
// Get positional arguments
$USERNAME=$argv[1];
$DOMAIN=$argv[2];
$USERNAME = $argv[1];
$DOMAIN = $argv[2];
// Get TOTP shared secret from stdin
$SHARED_SECRET = trim(fgets(STDIN));

View File

@ -40,7 +40,7 @@ class PostfixAdmin
*
* @var string
*/
public $version ='0.3';
public $version = '0.3';
/**
* Standard input stream.
@ -330,12 +330,12 @@ class PostfixAdmin
for ($i = 0; $i < $count; $i++) {
if ($params[$i] != '' && $params[$i][0] === '-' && $params[$i] != '-1') {
$key = substr($params[$i], 1);
if (isset($params[$i+1])) {
if (isset($params[$i + 1])) {
# TODO: ideally we should know if a parameter can / must have a value instead of whitelisting known valid values starting with '-' (probably only bool doesn't need a value)
if ($params[$i+1][0] === '-' && $params[$i+1] != '-1') {
if ($params[$i + 1][0] === '-' && $params[$i + 1] != '-1') {
$this->params[$key] = true;
} else {
$this->params[$key] = $params[$i+1];
$this->params[$key] = $params[$i + 1];
$i++;
}
}

View File

@ -1,10 +1,10 @@
<?php
define('SHA1_RESULTLEN', (160/8));
define('SHA1_RESULTLEN', (160 / 8));
define('SHA256_RESULTLEN', (256 / 8));
define('CRAM_MD5_CONTEXTLEN', 32);
define('MD5_RESULTLEN', (128/8));
define('MD4_RESULTLEN', (128/8));
define('MD5_RESULTLEN', (128 / 8));
define('MD4_RESULTLEN', (128 / 8));
define('LM_HASH_SIZE', 16);
define('NTLMSSP_HASH_SIZE', 16);

View File

@ -4,7 +4,7 @@ class ListAdminsTest extends \PHPUnit\Framework\TestCase
{
public function testBasic()
{
$list= list_admins();
$list = list_admins();
// may be empty, depending on db.

View File

@ -12,7 +12,7 @@ class RemoveFromArrayTest extends \PHPUnit\Framework\TestCase
list($found, $new) = remove_from_array($list, 'a');
$this->assertEquals(1, $found);
$this->assertEquals(array(1 => 'b',2 => 'c',3=>'d'), $new);
$this->assertEquals(array(1 => 'b',2 => 'c',3 => 'd'), $new);
list($found, $new) = remove_from_array($list, 'x');
$this->assertEquals(0, $found);