psalm fixes/workarounds; require PHP 5.6+

pull/316/head
David Goodwin 5 years ago
parent 1df7f15d40
commit 87824ef970

@ -27,7 +27,7 @@ Integrates with :
- Users have the ability to login, change their password or vacation (out of office) status.
- Integration with Squirrelmail / Roundcube (via plugins)
- Optional XMLRPC based API
- Supports PHP5.4+
- Supports PHP5.6+
## Useful Links

@ -8,7 +8,6 @@
*
* Further details on the project are available at http://postfixadmin.sf.net
*
* @version $Id$
* @license GNU GPL v2 or later.
*
* File: common.php

@ -34,8 +34,7 @@
"autoload": {
"files": [
"config.inc.php",
"functions.inc.php",
"lib/smarty/libs/bootstrap.php"
"functions.inc.php"
]
}
}

@ -8,7 +8,6 @@
*
* Further details on the project are available at http://postfixadmin.sf.net
*
* @version $Id$
* @license GNU GPL v2 or later.
*
* File: config.inc.php

@ -8,7 +8,6 @@
*
* Further details on the project are available at http://postfixadmin.sf.net
*
* @version $Id$
* @license GNU GPL v2 or later.
*
* File: functions.inc.php
@ -665,11 +664,6 @@ function list_domains_for_admin($username) {
return array_column($result, 'domain');
}
if (!function_exists('array_column')) {
require_once(dirname(__FILE__) . '/lib/array_column.php');
}
/**
* List all available domains.
*
@ -1916,15 +1910,10 @@ function db_in_clause($field, array $values) {
* Note: the $searchmode operator will only be used if a $condition for that field is set.
* This also means you'll need to set a (dummy) condition for NULL and NOTNULL.
*/
function db_where_clause($condition, $struct, $additional_raw_where = '', $searchmode = array()) {
if (!is_array($condition)) {
throw new Exception('db_where_cond: parameter $cond is not an array!');
} elseif (!is_array($searchmode)) {
throw new Exception('db_where_cond: parameter $searchmode is not an array!');
} elseif (count($condition) == 0 && trim($additional_raw_where) == '') {
function db_where_clause(array $condition, array $struct, $additional_raw_where = '', array $searchmode = array()) {
if (count($condition) == 0 && trim($additional_raw_where) == '') {
throw new Exception("db_where_cond: parameter is an empty array!");
} elseif (!is_array($struct)) {
throw new Exception('db_where_cond: parameter $struct is not an array!');
}
$allowed_operators = array('<', '>', '>=', '<=', '=', '!=', '<>', 'CONT', 'LIKE', 'NULL', 'NOTNULL');

@ -1,8 +0,0 @@
<?php
function array_column(array $array, $column) {
$retval = array();
foreach ($array as $row) {
$retval[] = $row[$column];
}
return $retval;
}

@ -1,14 +1,17 @@
<?php
/**
* This file should only be loaded if you're :
* a. running PHP < 7.0, and
* b. have the php_crypt password hash configured, and
* c. have not loaded paragonie's random_compat library.
*
*/
if(function_exists('random_int')) {
return;
}
function random_int() { // someone might not be using php_crypt or ask for password generation, in which case random_int() won't be called
die(__FILE__ . " Postfixadmin security: Please install https://github.com/paragonie/random_compat OR enable the 'Phar' extension.");
}

@ -263,7 +263,7 @@ class DomainHandler extends PFAHandler {
* @return boolean
*/
protected function domain_postcreation() {
$script=Config::read('domain_postcreation_script');
$script=Config::read_string('domain_postcreation_script');
if (empty($script)) {
return true;
@ -295,7 +295,7 @@ class DomainHandler extends PFAHandler {
* @return boolean
*/
protected function domain_postdeletion() {
$script=Config::read('domain_postdeletion_script');
$script=Config::read_string('domain_postdeletion_script');
if (empty($script)) {
return true;

@ -561,10 +561,10 @@ class MailboxHandler extends PFAHandler {
*/
protected function mailbox_post_script() {
if ($this->new) {
$cmd = Config::read('mailbox_postcreation_script');
$cmd = Config::read_string('mailbox_postcreation_script');
$warnmsg = Config::Lang('mailbox_postcreate_failed');
} else {
$cmd = Config::read('mailbox_postedit_script');
$cmd = Config::read_string('mailbox_postedit_script');
$warnmsg = Config::Lang('mailbox_postedit_failed');
}
@ -608,7 +608,7 @@ class MailboxHandler extends PFAHandler {
* also adds a detailed error message to $this->errormsg[]
*/
protected function mailbox_postdeletion() {
$cmd = Config::read('mailbox_postdeletion_script');
$cmd = Config::read_string('mailbox_postdeletion_script');
if (empty($cmd)) {
return true;
@ -735,8 +735,8 @@ class MailboxHandler extends PFAHandler {
/**
* @return boolean true on success; false on failure
* @param string $new_password
* @param string $old_password
* @param string $new_passwords
* @param bool $match = true
*
* All passwords need to be plain text; they'll be hashed appropriately

@ -33,12 +33,12 @@ abstract class PFAHandler {
* @var string (default) name of the database table
* (can be overridden by $CONF[database_prefix] and $CONF[database_tables][*] via table_by_key())
*/
protected $db_table;
protected $db_table = '';
/**
* @var string field containing the ID
*/
protected $id_field;
protected $id_field = '';
/**
* @var string field containing the label
@ -52,7 +52,7 @@ abstract class PFAHandler {
* defaults to $id_field if not set
* @var string
*/
protected $order_by;
protected $order_by = '';
/**
* @var string
@ -215,6 +215,9 @@ abstract class PFAHandler {
$this->initStruct();
/**
* @psalm-suppress InvalidArrayOffset
*/
if (!isset($this->struct['_can_edit'])) {
$this->struct['_can_edit'] = pacol(0, 0, 1, 'vnum', '' , '' , '', array(),
/*not_in_db*/ 0,
@ -223,6 +226,9 @@ abstract class PFAHandler {
);
}
/**
* @psalm-suppress InvalidArrayOffset
*/
if (!isset($this->struct['_can_delete'])) {
$this->struct['_can_delete'] = pacol(0, 0, 1, 'vnum', '' , '' , '', array(),
/*not_in_db*/ 0,
@ -231,7 +237,10 @@ abstract class PFAHandler {
);
}
$struct_hook = Config::read($this->db_table . '_struct_hook');
if(empty($this->db_table)) {
throw new Exception("db_table not defined");
}
$struct_hook = Config::read_string($this->db_table . '_struct_hook');
if (!empty($struct_hook) && is_string($struct_hook) && $struct_hook != 'NO' && function_exists($struct_hook)) {
$this->struct = $struct_hook($this->struct);
}
@ -810,15 +819,7 @@ abstract class PFAHandler {
$real_condition = $condition;
}
$result = $this->read_from_db($real_condition, $searchmode, $limit, $offset);
if (!is_array($result)) {
error_log('getList: read_from_db didn\'t return an array. table: ' . $this->db_table . ' - condition: $condition - limit: $limit - offset: $offset');
error_log('getList: This is most probably caused by read_from_db_postprocess()');
die('Unexpected error while reading from database! (Please check the error log for details, and open a bugreport)');
}
$this->result = $result;
$this->result = $this->read_from_db($real_condition, $searchmode, $limit, $offset);
return true;
}

@ -12,6 +12,7 @@
<directory name="tests" />
<directory name="templates_c" />
<directory name="lib/smarty" />
<file name="lib/block_random_int.php" />
<directory name="ADDITIONS/" />
</ignoreFiles>
</projectFiles>

@ -7,7 +7,7 @@ if (!defined('POSTFIXADMIN')) {
require_once('common.php');
}
if (!isset($CONF) || !is_array($CONF)) {
if (empty($CONF)) {
die("config.inc.php seems invalid");
}

Loading…
Cancel
Save