diff --git a/classes/db_mysql.class.php b/classes/db_mysql.class.php index 3d00e7e27..2b78c18ef 100644 --- a/classes/db_mysql.class.php +++ b/classes/db_mysql.class.php @@ -119,10 +119,6 @@ throw new Exception('Mysqli Extension not loaded.'); } -function enum_boolean($bool) { - return $bool == true ? '1' : '0'; -} - //Handles escaping function db_string($String, $DisableWildcards = false) { global $DB; @@ -135,19 +131,6 @@ function db_string($String, $DisableWildcards = false) { return $String; } -function db_array($Array, $DontEscape = [], $Quote = false) { - foreach ($Array as $Key => $Val) { - if (!in_array($Key, $DontEscape)) { - if ($Quote) { - $Array[$Key] = '\''.db_string(trim($Val)).'\''; - } else { - $Array[$Key] = db_string(trim($Val)); - } - } - } - return $Array; -} - class DB_MYSQL_Exception extends Exception {} //TODO: revisit access levels once Drone is replaced by ZeRobot diff --git a/phpcs.xml b/phpcs.xml index 1f384ddc7..93dd18a90 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -63,7 +63,6 @@ - diff --git a/sections/tools/managers/referral_alter.php b/sections/tools/managers/referral_alter.php index 4b933045d..209dacfe4 100644 --- a/sections/tools/managers/referral_alter.php +++ b/sections/tools/managers/referral_alter.php @@ -5,15 +5,14 @@ error(403); } -$P = db_array($_POST); -$ReferralManager = new \Gazelle\Manager\Referral; +$ReferralManager = new Gazelle\Manager\Referral; if ($_POST['submit'] == 'Delete') { - if (!is_number($_POST['id']) || $_POST['id'] == '') { + $id = (int)$_POST['id']; + if (!$id) { error(0); } - - $ReferralManager->deleteAccount($_POST['id']); + $ReferralManager->deleteAccount($id); } else { $Val->SetFields('site', '1', 'string', 'The site must be set, and has a max length of 30 characters', ['maxlength' => 30]); $Val->SetFields('url', '1', 'string', 'The URL must be set, and has a max length of 30 characters', ['maxlength' => 30]); @@ -22,29 +21,22 @@ $Val->SetFields('active', '1', 'checkbox', ''); $Err = $Val->ValidateForm($_POST); - if (substr($P['url'], -1) !== '/') { - $P['url'] .= '/'; + if (substr($_POST['url'], -1) !== '/') { + $_POST['url'] .= '/'; } - if ($_POST['submit'] == 'Create') { - $ReferralManager->createAccount($P['site'], $P['url'], $P['user'], $P['password'], - $P['active'] == 'on' ? 1 : 0, $P['type'], $P['cookie']); - } elseif ($_POST['submit'] == 'Edit') { - if (!is_number($_POST['id']) || $_POST['id'] == '') { - error(0); - } - - $account = $ReferralManager->getAccount($P['id']); - if ($account == null) { + if ($_POST['submit'] === 'Create') { + $ReferralManager->createAccount($_POST['site'], $_POST['url'], $_POST['user'], $_POST['password'], + $_POST['active'] == 'on' ? 1 : 0, $_POST['type'], $_POST['cookie']); + } elseif ($_POST['submit'] === 'Edit') { + $id = (int)$_POST['id']; + if (!$id || !$ReferralManager->getAccount($id)) { error(0); } - $P['cookie'] = str_replace('\\"', '"', $P['cookie']); - $P['password'] = str_replace('\\"', '"', $P['password']); - $ReferralManager->updateAccount($P['id'], $P['site'], $P['url'], $P['user'], - $P['password'], $P['active'] == 'on' ? 1 : 0, $P['type'], $P['cookie']); + $ReferralManager->updateAccount($_POST['id'], $_POST['site'], $_POST['url'], $_POST['user'], + $_POST['password'], $_POST['active'] == 'on' ? 1 : 0, $_POST['type'], $_POST['cookie']); } } header('Location: tools.php?action=referral_accounts'); -?>