more minor fixes and code-cleaning
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -411,7 +411,7 @@ if ($action == 'forgotpwd') {
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$loginname = Validate::validate($_POST['loginname'], 'loginname');
|
||||
$email = Validate::validateEmail($_POST['loginemail'], 'email');
|
||||
$email = Validate::validateEmail($_POST['loginemail']);
|
||||
$result_stmt = Database::prepare("SELECT `adminid`, `customerid`, `customernumber`, `firstname`, `name`, `company`, `email`, `loginname`, `def_language`, `deactivated` FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
||||
WHERE `loginname`= :loginname
|
||||
AND `email`= :email");
|
||||
|
||||
@@ -98,7 +98,7 @@ if (Froxlor::isDatabaseVersion('201809280')) {
|
||||
if (Froxlor::isDatabaseVersion('201811180')) {
|
||||
|
||||
Update::showUpdateStep("Adding new settings for 2FA");
|
||||
Settings::AddNew('2fa.enabled', '1', true);
|
||||
Settings::AddNew('2fa.enabled', '1');
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
Update::showUpdateStep("Adding new fields to admin-table for 2FA");
|
||||
@@ -127,7 +127,7 @@ if (Froxlor::isDatabaseVersion('201812010')) {
|
||||
|
||||
Update::showUpdateStep("Adding new is_configured-flag");
|
||||
// updated systems are already configured (most likely :P)
|
||||
Settings::AddNew('panel.is_configured', '1', true);
|
||||
Settings::AddNew('panel.is_configured', '1');
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
Froxlor::updateToDbVersion('201812100');
|
||||
@@ -287,8 +287,8 @@ if (Froxlor::isFroxlorVersion('0.10.0-rc1')) {
|
||||
if (Froxlor::isDatabaseVersion('201904250')) {
|
||||
|
||||
Update::showUpdateStep("Adding new settings for CAA");
|
||||
Settings::AddNew('caa.caa_entry', '', true);
|
||||
Settings::AddNew('system.dns_createcaaentry', 1, true);
|
||||
Settings::AddNew('caa.caa_entry', '');
|
||||
Settings::AddNew('system.dns_createcaaentry', 1);
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
Froxlor::updateToDbVersion('201907270');
|
||||
@@ -928,7 +928,7 @@ if (Froxlor::isFroxlorVersion('0.10.27')) {
|
||||
|
||||
if (Froxlor::isDatabaseVersion('202108180')) {
|
||||
Update::showUpdateStep("Adding czech language file", true);
|
||||
Database::query("INSERT INTO `" . TABLE_PANEL_LANGUAGE . "` SET `language` = 'Česká republika', `iso` = 'cs', `file` = 'lng/czech.lng.php'");
|
||||
Database::query("INSERT INTO `panel_languages` SET `language` = 'Česká republika', `iso` = 'cs', `file` = 'lng/czech.lng.php'");
|
||||
Update::lastStepStatus(0);
|
||||
Froxlor::updateToDbVersion('202109040');
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||
|
||||
// le format
|
||||
if (isset($sql['root_user']) && isset($sql['root_password']) && (!isset($sql_root) || !is_array($sql_root))) {
|
||||
if (isset($sql['root_user']) && isset($sql['root_password']) &&!is_array($sql_root)) {
|
||||
$sql_root = array(
|
||||
0 => array(
|
||||
'caption' => 'Default',
|
||||
@@ -154,7 +154,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
'password' => $privileged_password,
|
||||
'ssl' => [
|
||||
'caFile' => $mysql_ca ?? "",
|
||||
'verifyServerCertificate' => $mysql_verifycert ?? false
|
||||
'verifyServerCertificate' => $mysql_verifycert
|
||||
]
|
||||
];
|
||||
|
||||
@@ -195,6 +195,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
throw new Exception('Cannot delete first/default mysql-server', 406);
|
||||
}
|
||||
|
||||
$sql_root = [];
|
||||
// get all data from lib/userdata
|
||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||
|
||||
@@ -358,6 +359,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
$dbserver = (int) $this->getParam('dbserver', $dn_optional, -1);
|
||||
$dbserver = $id >= 0 ? $id : $dbserver;
|
||||
|
||||
$sql_root = [];
|
||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||
|
||||
if (!isset($sql_root[$dbserver])) {
|
||||
|
||||
@@ -94,7 +94,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
||||
Database::needSqlData();
|
||||
$sql_root = Database::getSqlData();
|
||||
Database::needRoot(false);
|
||||
if (!isset($sql_root) || !is_array($sql_root)) {
|
||||
if (!is_array($sql_root)) {
|
||||
throw new Exception("Database server with index #" . $dbserver . " is unknown", 404);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class ConfigDisplay
|
||||
}
|
||||
}
|
||||
|
||||
Database::needSqlData(true);
|
||||
Database::needSqlData();
|
||||
$sql = Database::getSqlData();
|
||||
|
||||
self::$replace_arr = [
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Froxlor\Cron\System;
|
||||
|
||||
use Froxlor\Cron\FroxlorCron;
|
||||
use Froxlor\Cron\Http\ConfigIO;
|
||||
use Froxlor\Cron\Http\HttpConfigBase;
|
||||
use Froxlor\Cron\TaskId;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Dns\PowerDNS;
|
||||
@@ -158,7 +159,7 @@ class TasksCron extends FroxlorCron
|
||||
// get webserver object
|
||||
$webserver = new $websrv();
|
||||
|
||||
if (isset($webserver)) {
|
||||
if ($webserver instanceof HttpConfigBase) {
|
||||
$webserver->init();
|
||||
// clean up old configs
|
||||
$configio->cleanUp();
|
||||
|
||||
@@ -45,6 +45,7 @@ use PDOStatement;
|
||||
* object
|
||||
* @method static string lastInsertId ($name = null) Returns the ID of the last inserted row or sequence value
|
||||
* @method static string quote ($string, $parameter_type = null) Quotes a string for use in a query.
|
||||
* @method static mixed getAttribute(int $attribute) Retrieve a database connection attribute
|
||||
*/
|
||||
class Database
|
||||
{
|
||||
@@ -134,7 +135,7 @@ class Database
|
||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||
|
||||
// le format
|
||||
if (isset($sql['root_user']) && isset($sql['root_password']) && (!isset($sql_root) || !is_array($sql_root))) {
|
||||
if (isset($sql['root_user']) && isset($sql['root_password']) && !is_array($sql_root)) {
|
||||
$sql_root = [
|
||||
0 => [
|
||||
'caption' => 'Default',
|
||||
@@ -294,13 +295,13 @@ class Database
|
||||
*/
|
||||
private static function genUniqueToken(int $length = 16)
|
||||
{
|
||||
if (!isset($length) || intval($length) <= 8) {
|
||||
if (intval($length) <= 8) {
|
||||
$length = 16;
|
||||
}
|
||||
if (function_exists('random_bytes')) {
|
||||
return bin2hex(random_bytes($length));
|
||||
}
|
||||
if (function_exists('mcrypt_create_iv')) {
|
||||
if (function_exists('mcrypt_create_iv') && defined('MCRYPT_DEV_URANDOM')) {
|
||||
return bin2hex(mcrypt_create_iv($length, MCRYPT_DEV_URANDOM));
|
||||
}
|
||||
if (function_exists('openssl_random_pseudo_bytes')) {
|
||||
|
||||
@@ -313,9 +313,9 @@ class FileDir
|
||||
*
|
||||
* @return string the corrected filename
|
||||
*/
|
||||
public static function makeCorrectFile($filename)
|
||||
public static function makeCorrectFile(string $filename)
|
||||
{
|
||||
if (!isset($filename) || trim($filename) == '') {
|
||||
if (trim($filename) == '') {
|
||||
$error = 'Given filename for function ' . __FUNCTION__ . ' is empty.' . "\n";
|
||||
$error .= 'This is very dangerous and should not happen.' . "\n";
|
||||
$error .= 'Please inform the Froxlor team about this issue so they can fix it.';
|
||||
|
||||
@@ -234,13 +234,13 @@ final class Froxlor
|
||||
*/
|
||||
public static function genSessionId(int $length = 16)
|
||||
{
|
||||
if (!isset($length) || intval($length) <= 8) {
|
||||
if (intval($length) <= 8) {
|
||||
$length = 16;
|
||||
}
|
||||
if (function_exists('random_bytes')) {
|
||||
return bin2hex(random_bytes($length));
|
||||
}
|
||||
if (function_exists('mcrypt_create_iv')) {
|
||||
if (function_exists('mcrypt_create_iv') && defined('MCRYPT_DEV_URANDOM')) {
|
||||
return bin2hex(mcrypt_create_iv($length, MCRYPT_DEV_URANDOM));
|
||||
}
|
||||
if (function_exists('openssl_random_pseudo_bytes')) {
|
||||
|
||||
@@ -332,7 +332,7 @@ class Install
|
||||
throw new Exception(lng('error.emailiswrong', [$email]));
|
||||
} elseif (empty($password) || $password != $password_confirm) {
|
||||
throw new Exception(lng('error.newpasswordconfirmerror'));
|
||||
} elseif (!empty($password) && $password == $loginname) {
|
||||
} elseif ($password == $loginname) {
|
||||
throw new Exception(lng('error.passwordshouldnotbeusername'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,10 +70,10 @@ class Update
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function lastStepStatus(int $status = -1, string $message = '', string $additional_info = '')
|
||||
public static function lastStepStatus(int $status = -1, string $message = 'OK', string $additional_info = '')
|
||||
{
|
||||
self::$update_tasks[self::$task_counter]['result_txt'] = $message ?? 'OK';
|
||||
self::$update_tasks[self::$task_counter]['result_desc'] = $additional_info ?? '';
|
||||
self::$update_tasks[self::$task_counter]['result_txt'] = $message;
|
||||
self::$update_tasks[self::$task_counter]['result_desc'] = $additional_info;
|
||||
|
||||
switch ($status) {
|
||||
case 0:
|
||||
|
||||
@@ -458,7 +458,7 @@ class PhpHelper
|
||||
'ssl_default_vhostconf_domain',
|
||||
'filecontent'
|
||||
];
|
||||
if (isset($global) && !empty($global)) {
|
||||
if (!empty($global)) {
|
||||
$tmp = $global;
|
||||
foreach ($tmp as $index => $value) {
|
||||
if (!in_array($index, $ignored_fields)) {
|
||||
@@ -516,7 +516,7 @@ class PhpHelper
|
||||
$str .= self::tabPrefix(($depth-1), "[\n");
|
||||
}
|
||||
foreach ($array as $key => $value) {
|
||||
if (isset($key) && !is_array($value)) {
|
||||
if (!is_array($value)) {
|
||||
if (is_bool($value)) {
|
||||
$str .= self::tabPrefix($depth, sprintf("'%s' => %s,\n", $key, $value ? 'true' : 'false'));
|
||||
} elseif (is_int($value)) {
|
||||
|
||||
@@ -34,11 +34,11 @@ class Mailer extends PHPMailer
|
||||
/**
|
||||
* class constructor
|
||||
*
|
||||
* @param string $exceptions
|
||||
* @param bool $exceptions
|
||||
* whether to throw exceptions or not
|
||||
*
|
||||
*/
|
||||
public function __construct($exceptions = false)
|
||||
public function __construct(bool $exceptions = false)
|
||||
{
|
||||
parent::__construct($exceptions);
|
||||
$this->CharSet = "UTF-8";
|
||||
|
||||
@@ -52,7 +52,7 @@ class Listing
|
||||
'is_search' => $collection->getPagination() instanceof Pagination && $collection->getPagination()->isSearchResult(),
|
||||
'self_overview' => $tabellisting['self_overview'] ?? [],
|
||||
'available_columns' => self::getAvailableColumnsForListing($tabellisting),
|
||||
'listing_search_additional_param' => $listing_search_additional_param ?? [],
|
||||
'listing_search_additional_param' => $listing_search_additional_param,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ class UI
|
||||
}
|
||||
}
|
||||
if (!file_exists(Froxlor::getInstallDir() . '/templates/' . $theme)) {
|
||||
PhpHelper::phpErrHandler(E_USER_WARNING, "Theme '" . $theme . "' could not be found.", __FILE__, __LINE__, null);
|
||||
PhpHelper::phpErrHandler(E_USER_WARNING, "Theme '" . $theme . "' could not be found.", __FILE__, __LINE__);
|
||||
$theme = self::$default_theme;
|
||||
}
|
||||
return $theme;
|
||||
|
||||
@@ -223,7 +223,7 @@ if (!CurrentUser::hasSession() && AREA != 'login') {
|
||||
}
|
||||
|
||||
$userinfo = CurrentUser::getData();
|
||||
UI::twig()->addGlobal('userinfo', ($userinfo ?? []));
|
||||
UI::twig()->addGlobal('userinfo', $userinfo);
|
||||
UI::setCurrentUser($userinfo);
|
||||
// Initialize logger
|
||||
if (CurrentUser::hasSession()) {
|
||||
|
||||
Reference in New Issue
Block a user