[Web] Clean PHP code by removing unused variables (#3646)
* [WEB] $lang is not used in this context * [Web] $stmt variable is not usedmaster
parent
1cb5780e9c
commit
6bff958ab4
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
function fail2ban($_action, $_data = null) {
|
function fail2ban($_action, $_data = null) {
|
||||||
global $redis;
|
global $redis;
|
||||||
global $lang;
|
|
||||||
$_data_log = $_data;
|
$_data_log = $_data;
|
||||||
switch ($_action) {
|
switch ($_action) {
|
||||||
case 'get':
|
case 'get':
|
||||||
|
|
|
@ -729,7 +729,6 @@ function edit_user_account($_data) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
function user_get_alias_details($username) {
|
function user_get_alias_details($username) {
|
||||||
global $lang;
|
|
||||||
global $pdo;
|
global $pdo;
|
||||||
$data['direct_aliases'] = false;
|
$data['direct_aliases'] = false;
|
||||||
$data['shared_aliases'] = false;
|
$data['shared_aliases'] = false;
|
||||||
|
@ -811,7 +810,6 @@ function is_valid_domain_name($domain_name) {
|
||||||
&& preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name));
|
&& preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name));
|
||||||
}
|
}
|
||||||
function set_tfa($_data) {
|
function set_tfa($_data) {
|
||||||
global $lang;
|
|
||||||
global $pdo;
|
global $pdo;
|
||||||
global $yubi;
|
global $yubi;
|
||||||
global $u2f;
|
global $u2f;
|
||||||
|
@ -1097,7 +1095,6 @@ function get_tfa($username = null) {
|
||||||
}
|
}
|
||||||
function verify_tfa_login($username, $token) {
|
function verify_tfa_login($username, $token) {
|
||||||
global $pdo;
|
global $pdo;
|
||||||
global $lang;
|
|
||||||
global $yubi;
|
global $yubi;
|
||||||
global $u2f;
|
global $u2f;
|
||||||
global $tfa;
|
global $tfa;
|
||||||
|
@ -1231,7 +1228,6 @@ function verify_tfa_login($username, $token) {
|
||||||
}
|
}
|
||||||
function admin_api($access, $action, $data = null) {
|
function admin_api($access, $action, $data = null) {
|
||||||
global $pdo;
|
global $pdo;
|
||||||
global $lang;
|
|
||||||
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
||||||
$_SESSION['return'][] = array(
|
$_SESSION['return'][] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
|
@ -1419,7 +1415,6 @@ function license($action, $data = null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function rspamd_ui($action, $data = null) {
|
function rspamd_ui($action, $data = null) {
|
||||||
global $lang;
|
|
||||||
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
||||||
$_SESSION['return'][] = array(
|
$_SESSION['return'][] = array(
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
|
@ -1505,7 +1500,6 @@ function get_logs($application, $lines = false) {
|
||||||
$to = intval($to);
|
$to = intval($to);
|
||||||
if ($from < 1 || $to < $from) { return false; }
|
if ($from < 1 || $to < $from) { return false; }
|
||||||
}
|
}
|
||||||
global $lang;
|
|
||||||
global $redis;
|
global $redis;
|
||||||
global $pdo;
|
global $pdo;
|
||||||
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
||||||
|
|
|
@ -45,7 +45,6 @@ function mailq($_action, $_data = null) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
global $lang;
|
|
||||||
if ($_action == 'get') {
|
if ($_action == 'get') {
|
||||||
$mailq_lines = docker('post', 'postfix-mailcow', 'exec', array('cmd' => 'mailq', 'task' => 'list'));
|
$mailq_lines = docker('post', 'postfix-mailcow', 'exec', array('cmd' => 'mailq', 'task' => 'list'));
|
||||||
$lines = 0;
|
$lines = 0;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
function presets($_action, $_kind) {
|
function presets($_action, $_kind) {
|
||||||
global $lang;
|
|
||||||
switch ($_action) {
|
switch ($_action) {
|
||||||
case 'get':
|
case 'get':
|
||||||
if ($_SESSION['mailcow_cc_role'] != "admin" && $_SESSION['mailcow_cc_role'] != "domainadmin") {
|
if ($_SESSION['mailcow_cc_role'] != "admin" && $_SESSION['mailcow_cc_role'] != "domainadmin") {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
function pushover($_action, $_data = null) {
|
function pushover($_action, $_data = null) {
|
||||||
global $pdo;
|
global $pdo;
|
||||||
global $lang;
|
|
||||||
switch ($_action) {
|
switch ($_action) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
if (!isset($_SESSION['acl']['pushover']) || $_SESSION['acl']['pushover'] != "1" ) {
|
if (!isset($_SESSION['acl']['pushover']) || $_SESSION['acl']['pushover'] != "1" ) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
function quota_notification($_action, $_data = null) {
|
function quota_notification($_action, $_data = null) {
|
||||||
global $redis;
|
global $redis;
|
||||||
global $lang;
|
|
||||||
$_data_log = $_data;
|
$_data_log = $_data;
|
||||||
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
if ($_SESSION['mailcow_cc_role'] != "admin") {
|
||||||
$_SESSION['return'][] = array(
|
$_SESSION['return'][] = array(
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
function ratelimit($_action, $_scope, $_data = null) {
|
function ratelimit($_action, $_scope, $_data = null) {
|
||||||
global $redis;
|
global $redis;
|
||||||
global $lang;
|
|
||||||
$_data_log = $_data;
|
$_data_log = $_data;
|
||||||
switch ($_action) {
|
switch ($_action) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
|
|
|
@ -1105,7 +1105,6 @@ function init_db_schema() {
|
||||||
elseif (strtolower($key_type) == 'fkey') {
|
elseif (strtolower($key_type) == 'fkey') {
|
||||||
foreach ($key_content as $key_name => $key_values) {
|
foreach ($key_content as $key_name => $key_values) {
|
||||||
@list($table_ref, $field_ref) = explode('.', $key_values['ref']);
|
@list($table_ref, $field_ref) = explode('.', $key_values['ref']);
|
||||||
$fields = "`" . implode("`, `", $key_values) . "`";
|
|
||||||
$sql .= "FOREIGN KEY `" . $key_name . "` (" . $key_values['col'] . ") REFERENCES `" . $table_ref . "` (`" . $field_ref . "`)
|
$sql .= "FOREIGN KEY `" . $key_name . "` (" . $key_values['col'] . ") REFERENCES `" . $table_ref . "` (`" . $field_ref . "`)
|
||||||
ON DELETE " . $key_values['delete'] . " ON UPDATE " . $key_values['update'] . ",";
|
ON DELETE " . $key_values['delete'] . " ON UPDATE " . $key_values['update'] . ",";
|
||||||
}
|
}
|
||||||
|
@ -1130,31 +1129,31 @@ function init_db_schema() {
|
||||||
$stmt = $pdo->query("SELECT NULL FROM `admin`");
|
$stmt = $pdo->query("SELECT NULL FROM `admin`");
|
||||||
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||||
if ($num_results == 0) {
|
if ($num_results == 0) {
|
||||||
$stmt = $pdo->query("INSERT INTO `admin` (`username`, `password`, `superadmin`, `created`, `modified`, `active`)
|
$pdo->query("INSERT INTO `admin` (`username`, `password`, `superadmin`, `created`, `modified`, `active`)
|
||||||
VALUES ('admin', '{SSHA256}K8eVJ6YsZbQCfuJvSUbaQRLr0HPLz5rC9IAp0PAFl0tmNDBkMDc0NDAyOTAxN2Rk', 1, NOW(), NOW(), 1)");
|
VALUES ('admin', '{SSHA256}K8eVJ6YsZbQCfuJvSUbaQRLr0HPLz5rC9IAp0PAFl0tmNDBkMDc0NDAyOTAxN2Rk', 1, NOW(), NOW(), 1)");
|
||||||
$stmt = $pdo->query("INSERT INTO `domain_admins` (`username`, `domain`, `created`, `active`)
|
$pdo->query("INSERT INTO `domain_admins` (`username`, `domain`, `created`, `active`)
|
||||||
SELECT `username`, 'ALL', NOW(), 1 FROM `admin`
|
SELECT `username`, 'ALL', NOW(), 1 FROM `admin`
|
||||||
WHERE superadmin='1' AND `username` NOT IN (SELECT `username` FROM `domain_admins`);");
|
WHERE superadmin='1' AND `username` NOT IN (SELECT `username` FROM `domain_admins`);");
|
||||||
$stmt = $pdo->query("DELETE FROM `admin` WHERE `username` NOT IN (SELECT `username` FROM `domain_admins`);");
|
$pdo->query("DELETE FROM `admin` WHERE `username` NOT IN (SELECT `username` FROM `domain_admins`);");
|
||||||
}
|
}
|
||||||
// Insert new DB schema version
|
// Insert new DB schema version
|
||||||
$stmt = $pdo->query("REPLACE INTO `versions` (`application`, `version`) VALUES ('db_schema', '" . $db_version . "');");
|
$pdo->query("REPLACE INTO `versions` (`application`, `version`) VALUES ('db_schema', '" . $db_version . "');");
|
||||||
|
|
||||||
// Fix dangling domain admins
|
// Fix dangling domain admins
|
||||||
$stmt = $pdo->query("DELETE FROM `admin` WHERE `superadmin` = 0 AND `username` NOT IN (SELECT `username`FROM `domain_admins`);");
|
$pdo->query("DELETE FROM `admin` WHERE `superadmin` = 0 AND `username` NOT IN (SELECT `username`FROM `domain_admins`);");
|
||||||
$stmt = $pdo->query("DELETE FROM `da_acl` WHERE `username` NOT IN (SELECT `username`FROM `domain_admins`);");
|
$pdo->query("DELETE FROM `da_acl` WHERE `username` NOT IN (SELECT `username`FROM `domain_admins`);");
|
||||||
|
|
||||||
// Migrate attributes
|
// Migrate attributes
|
||||||
// pushover
|
// pushover
|
||||||
$stmt = $pdo->query("UPDATE `pushover` SET `attributes` = '{}' WHERE `attributes` = '' OR `attributes` IS NULL;");
|
$pdo->query("UPDATE `pushover` SET `attributes` = '{}' WHERE `attributes` = '' OR `attributes` IS NULL;");
|
||||||
$stmt = $pdo->query("UPDATE `pushover` SET `attributes` = JSON_SET(`attributes`, '$.evaluate_x_prio', \"0\") WHERE JSON_EXTRACT(`attributes`, '$.evaluate_x_prio') IS NULL;");
|
$pdo->query("UPDATE `pushover` SET `attributes` = JSON_SET(`attributes`, '$.evaluate_x_prio', \"0\") WHERE JSON_EXTRACT(`attributes`, '$.evaluate_x_prio') IS NULL;");
|
||||||
$stmt = $pdo->query("UPDATE `pushover` SET `attributes` = JSON_SET(`attributes`, '$.only_x_prio', \"0\") WHERE JSON_EXTRACT(`attributes`, '$.only_x_prio') IS NULL;");
|
$pdo->query("UPDATE `pushover` SET `attributes` = JSON_SET(`attributes`, '$.only_x_prio', \"0\") WHERE JSON_EXTRACT(`attributes`, '$.only_x_prio') IS NULL;");
|
||||||
// mailbox
|
// mailbox
|
||||||
$stmt = $pdo->query("UPDATE `mailbox` SET `attributes` = '{}' WHERE `attributes` = '' OR `attributes` IS NULL;");
|
$pdo->query("UPDATE `mailbox` SET `attributes` = '{}' WHERE `attributes` = '' OR `attributes` IS NULL;");
|
||||||
$stmt = $pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.force_pw_update', \"0\") WHERE JSON_EXTRACT(`attributes`, '$.force_pw_update') IS NULL;");
|
$pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.force_pw_update', \"0\") WHERE JSON_EXTRACT(`attributes`, '$.force_pw_update') IS NULL;");
|
||||||
$stmt = $pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.sogo_access', \"1\") WHERE JSON_EXTRACT(`attributes`, '$.sogo_access') IS NULL;");
|
$pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.sogo_access', \"1\") WHERE JSON_EXTRACT(`attributes`, '$.sogo_access') IS NULL;");
|
||||||
$stmt = $pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.mailbox_format', \"maildir:\") WHERE JSON_EXTRACT(`attributes`, '$.mailbox_format') IS NULL;");
|
$pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.mailbox_format', \"maildir:\") WHERE JSON_EXTRACT(`attributes`, '$.mailbox_format') IS NULL;");
|
||||||
$stmt = $pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.quarantine_notification', \"never\") WHERE JSON_EXTRACT(`attributes`, '$.quarantine_notification') IS NULL;");
|
$pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.quarantine_notification', \"never\") WHERE JSON_EXTRACT(`attributes`, '$.quarantine_notification') IS NULL;");
|
||||||
foreach($tls_options as $tls_user => $tls_options) {
|
foreach($tls_options as $tls_user => $tls_options) {
|
||||||
$stmt = $pdo->prepare("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.tls_enforce_in', :tls_enforce_in),
|
$stmt = $pdo->prepare("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.tls_enforce_in', :tls_enforce_in),
|
||||||
`attributes` = JSON_SET(`attributes`, '$.tls_enforce_out', :tls_enforce_out)
|
`attributes` = JSON_SET(`attributes`, '$.tls_enforce_out', :tls_enforce_out)
|
||||||
|
@ -1162,13 +1161,13 @@ function init_db_schema() {
|
||||||
$stmt->execute(array(':tls_enforce_in' => $tls_options['tls_enforce_in'], ':tls_enforce_out' => $tls_options['tls_enforce_out'], ':username' => $tls_user));
|
$stmt->execute(array(':tls_enforce_in' => $tls_options['tls_enforce_in'], ':tls_enforce_out' => $tls_options['tls_enforce_out'], ':username' => $tls_user));
|
||||||
}
|
}
|
||||||
// Set tls_enforce_* if still missing (due to deleted attrs for example)
|
// Set tls_enforce_* if still missing (due to deleted attrs for example)
|
||||||
$stmt = $pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.tls_enforce_out', \"1\") WHERE JSON_EXTRACT(`attributes`, '$.tls_enforce_out') IS NULL;");
|
$pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.tls_enforce_out', \"1\") WHERE JSON_EXTRACT(`attributes`, '$.tls_enforce_out') IS NULL;");
|
||||||
$stmt = $pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.tls_enforce_in', \"1\") WHERE JSON_EXTRACT(`attributes`, '$.tls_enforce_in') IS NULL;");
|
$pdo->query("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.tls_enforce_in', \"1\") WHERE JSON_EXTRACT(`attributes`, '$.tls_enforce_in') IS NULL;");
|
||||||
// Fix ACL
|
// Fix ACL
|
||||||
$stmt = $pdo->query("INSERT INTO `user_acl` (`username`) SELECT `username` FROM `mailbox` WHERE `kind` = '' AND NOT EXISTS (SELECT `username` FROM `user_acl`);");
|
$pdo->query("INSERT INTO `user_acl` (`username`) SELECT `username` FROM `mailbox` WHERE `kind` = '' AND NOT EXISTS (SELECT `username` FROM `user_acl`);");
|
||||||
$stmt = $pdo->query("INSERT INTO `da_acl` (`username`) SELECT DISTINCT `username` FROM `domain_admins` WHERE `username` != 'admin' AND NOT EXISTS (SELECT `username` FROM `da_acl`);");
|
$pdo->query("INSERT INTO `da_acl` (`username`) SELECT DISTINCT `username` FROM `domain_admins` WHERE `username` != 'admin' AND NOT EXISTS (SELECT `username` FROM `da_acl`);");
|
||||||
// Fix domain_admins
|
// Fix domain_admins
|
||||||
$stmt = $pdo->query("DELETE FROM `domain_admins` WHERE `domain` = 'ALL';");
|
$pdo->query("DELETE FROM `domain_admins` WHERE `domain` = 'ALL';");
|
||||||
|
|
||||||
if (php_sapi_name() == "cli") {
|
if (php_sapi_name() == "cli") {
|
||||||
echo "DB initialization completed" . PHP_EOL;
|
echo "DB initialization completed" . PHP_EOL;
|
||||||
|
|
Loading…
Reference in New Issue