dont access db result arrays directly without checking whether it's false due to an error (php7.4 related)
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -583,8 +583,12 @@ abstract class ApiCommand extends ApiParameter
|
|||||||
"group" => $group,
|
"group" => $group,
|
||||||
"var" => $varname
|
"var" => $varname
|
||||||
), true, true);
|
), true, true);
|
||||||
|
$content = $default;
|
||||||
|
if ($result) {
|
||||||
|
$content = $result['value'] ?? $default;
|
||||||
|
}
|
||||||
// @fixme html_entity_decode
|
// @fixme html_entity_decode
|
||||||
$content = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result['value'] != '') ? $result['value'] : $default), $replace_arr));
|
$content = html_entity_decode(\Froxlor\PhpHelper::replaceVariables($content, $replace_arr));
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
|||||||
'login' => $loginname
|
'login' => $loginname
|
||||||
), true, true);
|
), true, true);
|
||||||
|
|
||||||
if (strtolower($loginname_check['loginname']) == strtolower($loginname) || strtolower($loginname_check_admin['loginname']) == strtolower($loginname)) {
|
if (($loginname_check && strtolower($loginname_check['loginname']) == strtolower($loginname)) || ($loginname_check_admin && strtolower($loginname_check_admin['loginname']) == strtolower($loginname))) {
|
||||||
\Froxlor\UI\Response::standard_error('loginnameexists', $loginname, true);
|
\Froxlor\UI\Response::standard_error('loginnameexists', $loginname, true);
|
||||||
} elseif (preg_match('/^' . preg_quote(Settings::Get('customer.accountprefix'), '/') . '([0-9]+)/', $loginname)) {
|
} elseif (preg_match('/^' . preg_quote(Settings::Get('customer.accountprefix'), '/') . '([0-9]+)/', $loginname)) {
|
||||||
// Accounts which match systemaccounts are not allowed, filtering them
|
// Accounts which match systemaccounts are not allowed, filtering them
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
|
|||||||
), true, true);
|
), true, true);
|
||||||
|
|
||||||
$mysql_maxlen = \Froxlor\Database\Database::getSqlUsernameLength() - strlen(Settings::Get('customer.mysqlprefix'));
|
$mysql_maxlen = \Froxlor\Database\Database::getSqlUsernameLength() - strlen(Settings::Get('customer.mysqlprefix'));
|
||||||
if (strtolower($loginname_check['loginname']) == strtolower($loginname) || strtolower($loginname_check_admin['loginname']) == strtolower($loginname)) {
|
if (($loginname_check && strtolower($loginname_check['loginname']) == strtolower($loginname)) || ($loginname_check_admin && strtolower($loginname_check_admin['loginname']) == strtolower($loginname))) {
|
||||||
\Froxlor\UI\Response::standard_error('loginnameexists', $loginname, true);
|
\Froxlor\UI\Response::standard_error('loginnameexists', $loginname, true);
|
||||||
} elseif (! \Froxlor\Validate\Validate::validateUsername($loginname, Settings::Get('panel.unix_names'), $mysql_maxlen)) {
|
} elseif (! \Froxlor\Validate\Validate::validateUsername($loginname, Settings::Get('panel.unix_names'), $mysql_maxlen)) {
|
||||||
if (strlen($loginname) > $mysql_maxlen) {
|
if (strlen($loginname) > $mysql_maxlen) {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
|||||||
), true, true);
|
), true, true);
|
||||||
|
|
||||||
// duplicate check
|
// duplicate check
|
||||||
if ($path_dupe_check['path'] == $path) {
|
if ($path_dupe_check && $path_dupe_check['path'] == $path) {
|
||||||
\Froxlor\UI\Response::standard_error('errordocpathdupe', $userpath, true);
|
\Froxlor\UI\Response::standard_error('errordocpathdupe', $userpath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,8 +309,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
|||||||
$query_fields = array();
|
$query_fields = array();
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
SELECT * FROM `" . TABLE_PANEL_HTACCESS . "`
|
SELECT * FROM `" . TABLE_PANEL_HTACCESS . "`
|
||||||
WHERE `customerid` IN (" . implode(', ', $customer_ids) . ")" . $this->getSearchWhere($query_fields, true) . $this->getOrderBy() . $this->getLimit()
|
WHERE `customerid` IN (" . implode(', ', $customer_ids) . ")" . $this->getSearchWhere($query_fields, true) . $this->getOrderBy() . $this->getLimit());
|
||||||
);
|
|
||||||
Database::pexecute($result_stmt, $query_fields, true, true);
|
Database::pexecute($result_stmt, $query_fields, true, true);
|
||||||
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
$result[] = $row;
|
$result[] = $row;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
|
|||||||
$password_enc = \Froxlor\System\Crypt::makeCryptPassword($password, true);
|
$password_enc = \Froxlor\System\Crypt::makeCryptPassword($password, true);
|
||||||
|
|
||||||
// duplicate check
|
// duplicate check
|
||||||
if ($username_path_check['username'] == $username && $username_path_check['path'] == $path) {
|
if ($username_path_check && $username_path_check['username'] == $username && $username_path_check['path'] == $path) {
|
||||||
\Froxlor\UI\Response::standard_error('userpathcombinationdupe', '', true);
|
\Froxlor\UI\Response::standard_error('userpathcombinationdupe', '', true);
|
||||||
} elseif ($password == $username) {
|
} elseif ($password == $username) {
|
||||||
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
|
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
|
||||||
|
|||||||
@@ -674,9 +674,9 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
|
|||||||
), '', true);
|
), '', true);
|
||||||
} elseif ($customerid == 0) {
|
} elseif ($customerid == 0) {
|
||||||
\Froxlor\UI\Response::standard_error('adduserfirst', '', true);
|
\Froxlor\UI\Response::standard_error('adduserfirst', '', true);
|
||||||
} elseif (strtolower($domain_check['domain']) == strtolower($domain)) {
|
} elseif ($domain_check && strtolower($domain_check['domain']) == strtolower($domain)) {
|
||||||
\Froxlor\UI\Response::standard_error('domainalreadyexists', $idna_convert->decode($domain), true);
|
\Froxlor\UI\Response::standard_error('domainalreadyexists', $idna_convert->decode($domain), true);
|
||||||
} elseif ($aliasdomain_check['id'] != $aliasdomain) {
|
} elseif ($aliasdomain_check && $aliasdomain_check['id'] != $aliasdomain) {
|
||||||
\Froxlor\UI\Response::standard_error('domainisaliasorothercustomer', '', true);
|
\Froxlor\UI\Response::standard_error('domainisaliasorothercustomer', '', true);
|
||||||
} else {
|
} else {
|
||||||
$wwwserveralias = ($serveraliasoption == '1') ? '1' : '0';
|
$wwwserveralias = ($serveraliasoption == '1') ? '1' : '0';
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
|||||||
'port' => $port
|
'port' => $port
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($result_checkfordouble['id'] != '') {
|
if ($result_checkfordouble && $result_checkfordouble['id'] != '') {
|
||||||
\Froxlor\UI\Response::standard_error('myipnotdouble', '', true);
|
\Froxlor\UI\Response::standard_error('myipnotdouble', '', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,9 +462,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
|||||||
$docroot = '';
|
$docroot = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result['ip'] != $ip && $result['ip'] == Settings::Get('system.ipaddress') && $result_sameipotherport['id'] == '') {
|
if ($result['ip'] != $ip && $result['ip'] == Settings::Get('system.ipaddress') && ($result_sameipotherport && $result_sameipotherport['id'] == '')) {
|
||||||
\Froxlor\UI\Response::standard_error('cantchangesystemip', '', true);
|
\Froxlor\UI\Response::standard_error('cantchangesystemip', '', true);
|
||||||
} elseif ($result_checkfordouble['id'] != '' && $result_checkfordouble['id'] != $id) {
|
} elseif ($result_checkfordouble && $result_checkfordouble['id'] != '' && $result_checkfordouble['id'] != $id) {
|
||||||
\Froxlor\UI\Response::standard_error('myipnotdouble', '', true);
|
\Froxlor\UI\Response::standard_error('myipnotdouble', '', true);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -560,7 +560,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
|||||||
'ip' => $result['ip']
|
'ip' => $result['ip']
|
||||||
));
|
));
|
||||||
|
|
||||||
if (($result['ip'] != Settings::Get('system.ipaddress')) || ($result['ip'] == Settings::Get('system.ipaddress') && $result_sameipotherport['id'] != '')) {
|
if (($result['ip'] != Settings::Get('system.ipaddress')) || ($result['ip'] == Settings::Get('system.ipaddress') && ($result_sameipotherport && $result_sameipotherport['id'] != ''))) {
|
||||||
|
|
||||||
$del_stmt = Database::prepare("
|
$del_stmt = Database::prepare("
|
||||||
DELETE FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
DELETE FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
|||||||
), true, true);
|
), true, true);
|
||||||
$mbdata = $mbdata_stmt->fetch(\PDO::FETCH_ASSOC);
|
$mbdata = $mbdata_stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
Database::needRoot(false);
|
Database::needRoot(false);
|
||||||
$result['size'] = $mbdata['MB'];
|
$result['size'] = $mbdata['MB'] ?? 0;
|
||||||
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get database '" . $result['databasename'] . "'");
|
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get database '" . $result['databasename'] . "'");
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
@@ -411,7 +411,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
|||||||
"table_schema" => $row['databasename']
|
"table_schema" => $row['databasename']
|
||||||
), true, true);
|
), true, true);
|
||||||
$mbdata = $mbdata_stmt->fetch(\PDO::FETCH_ASSOC);
|
$mbdata = $mbdata_stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
$row['size'] = $mbdata['MB'];
|
$row['size'] = $mbdata['MB'] ?? 0;
|
||||||
$result[] = $row;
|
$result[] = $row;
|
||||||
}
|
}
|
||||||
Database::needRoot(false);
|
Database::needRoot(false);
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
|
|||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
SELECT c.*, fd.description as fpmdesc
|
SELECT c.*, fd.description as fpmdesc
|
||||||
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
|
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
|
||||||
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fd ON fd.id = c.fpmsettingid" . $this->getSearchWhere($query_fields) . $this->getOrderBy() . $this->getLimit()
|
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fd ON fd.id = c.fpmsettingid" . $this->getSearchWhere($query_fields) . $this->getOrderBy() . $this->getLimit());
|
||||||
);
|
|
||||||
Database::pexecute($result_stmt, $query_fields, true, true);
|
Database::pexecute($result_stmt, $query_fields, true, true);
|
||||||
$phpconfigs = array();
|
$phpconfigs = array();
|
||||||
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
|
|||||||
} elseif ($subdomain == 'www' && $domain_check['wwwserveralias'] == '1') {
|
} elseif ($subdomain == 'www' && $domain_check['wwwserveralias'] == '1') {
|
||||||
// you cannot add 'www' as subdomain when the maindomain generates a www-alias
|
// you cannot add 'www' as subdomain when the maindomain generates a www-alias
|
||||||
\Froxlor\UI\Response::standard_error('wwwnotallowed', '', true);
|
\Froxlor\UI\Response::standard_error('wwwnotallowed', '', true);
|
||||||
} elseif (strtolower($completedomain_check['domain']) == strtolower($completedomain)) {
|
} elseif ($completedomain_check && strtolower($completedomain_check['domain']) == strtolower($completedomain)) {
|
||||||
// the domain does already exist as main-domain
|
// the domain does already exist as main-domain
|
||||||
\Froxlor\UI\Response::standard_error('domainexistalready', $completedomain, true);
|
\Froxlor\UI\Response::standard_error('domainexistalready', $completedomain, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,4 @@ class FroxlorVhostSettings
|
|||||||
$result = Database::pexecute_first($sel_stmt);
|
$result = Database::pexecute_first($sel_stmt);
|
||||||
return $result['vcentries'] > 0 ? true : false;
|
return $result['vcentries'] > 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user