From 4d90ab2d436db7ee386ed8a80f319be1df7ee02a Mon Sep 17 00:00:00 2001 From: Floorb <132411956+Neetpone@users.noreply.github.com> Date: Fri, 16 Jul 2021 10:08:21 -0400 Subject: [PATCH] Remove most email stuff. --- admin/ajax_users.php | 2 - admin/configuration.php | 128 ---------------------------------------- admin/ssp.users.php | 1 - admin/users.php | 7 --- includes/functions.php | 6 -- login.php | 119 +++---------------------------------- profile.php | 1 - theme/bulma/header.php | 3 - theme/bulma/login.php | 43 -------------- theme/bulma/profile.php | 12 ---- verify.php | 70 ---------------------- 11 files changed, 9 insertions(+), 383 deletions(-) delete mode 100644 verify.php diff --git a/admin/ajax_users.php b/admin/ajax_users.php index c849d39..7468125 100644 --- a/admin/ajax_users.php +++ b/admin/ajax_users.php @@ -13,7 +13,6 @@ $primaryKey = 'id'; $columns = array( array('db' => 'id', 'dt' => 0), array('db' => 'username', 'dt' => 1), - array('db' => 'email_id', 'dt' => 2), array('db' => 'date', 'dt' => 3), array('db' => 'platform', 'dt' => 4), array('db' => 'id', 'dt' => 5), @@ -23,7 +22,6 @@ $columns = array( $columns2 = array( array('db' => 'id', 'dt' => 0), array('db' => 'username', 'dt' => 1), - array('db' => 'email_id', 'dt' => 2), array('db' => 'date', 'dt' => 3), array('db' => 'platform', 'dt' => 4), array('db' => 'ban', 'dt' => 5), diff --git a/admin/configuration.php b/admin/configuration.php index 81243e4..a71aad5 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -436,134 +436,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { - - - -
-
- -
-
- Registration Settings -
- - -
- -
-
- Mail Settings -
- - -
- -
- - -
- -
- - -
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
- -
- - - -
-
- -
-
- -
diff --git a/admin/ssp.users.php b/admin/ssp.users.php index 7a1ca3b..09a7f5e 100644 --- a/admin/ssp.users.php +++ b/admin/ssp.users.php @@ -315,7 +315,6 @@ class SSP { $result[$loop]['username'] = $arr['username']; $result[$loop]['platform'] = $arr['platform']; $result[$loop]['date'] = $arr['date']; - $result[$loop]['email_id'] = $arr['email_id']; $ver = $arr['verified']; $myid = $arr['id']; diff --git a/admin/users.php b/admin/users.php index 2b6db8e..fb88e55 100644 --- a/admin/users.php +++ b/admin/users.php @@ -168,7 +168,6 @@ if ($last_ip == $ip) { while ($row = mysqli_fetch_array($result)) { $user_oauth_uid = $row['oauth_uid']; $user_username = $row['username']; - $user_email_id = $row['email_id']; $user_full_name = $row['full_name']; $user_platform = Trim($row['platform']); $user_verified = $row['verified']; @@ -198,11 +197,6 @@ if ($last_ip == $ip) { - - Email ID - - - Platform @@ -250,7 +244,6 @@ if ($last_ip == $ip) { ID Username - Email ID Date Registered Platform Ban User diff --git a/includes/functions.php b/includes/functions.php index 9a43dd2..a1355d2 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -166,12 +166,6 @@ function monthpop($conn, $count) { return $query->fetchAll(); } - -function isValidEmail($email) { - return filter_var($email, FILTER_VALIDATE_EMAIL) - && preg_match('/@.+\./', $email); -} - function formatBytes($size, $precision = 2) { $base = log($size, 1024); $suffixes = array('B', 'KB', 'MB', 'GB', 'TB'); diff --git a/login.php b/login.php index 45f81c5..2458430 100644 --- a/login.php +++ b/login.php @@ -17,38 +17,6 @@ define('IN_PONEPASTE', 1); require_once('includes/common.php'); require_once('includes/functions.php'); -require_once('mail/mail.php'); - - -function sendVerificationEmail($email_address, $username, $full_name) { - global $lang; - global $email; - global $site_name; - - $mail_type = "1"; - - $protocol = paste_protocol(); - $verify_url = $protocol . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/verify.php?username=${username}&code=" . md5('4et4$55765' . $email_address . 'd94ereg'); - $subject = $lang['mail_acc_con']; // "$site_name Account Confirmation"; - $body = " - Hello ${full_name}, Please verify your account by clicking the link below.

- - $verify_url

- - After confirming your account you can log in using your username: $username and the password you used when signing up. - "; - - if ($mail_type == '1') { - default_mail($email, $site_name, $email_address, $subject, $body); - } else { - $email_info = getSiteInfo()['mail']; - smtp_mail( - $email_info['smtp_host'], $email_info['smtp_port'], - $email_info['auth'], $email_info['smtp_username'], $email_info['smtp_password'], $email_info['socket'], - $email, $site_name, $email_address, $subject, $body - ); - } -} // Current Date & User IP $date = date('jS F Y'); @@ -66,63 +34,6 @@ $p_title = $lang['login/register']; // "Login/Register"; updatePageViews($conn); -if (isset($_GET['resend'])) { - if (isset($_POST['email'])) { - $email = trim($_POST['email']); - $statement = $conn->prepare("SELECT username, verified FROM users WHERE email_id = ?"); - $statement->execute([$email]); - if ($row = $statement->fetch()) { - $username = $row['username']; - $verified = (bool) $row['verified']; - - if (!$verified) { - sendVerificationEmail($email, $username, $username); - $success = $lang['mail_suc']; // "Verification code successfully sent to your email."; - } else { - $error = $lang['email_ver']; //"Email already verified."; - } - } else { - $error = $lang['email_not']; // "Email not found."; - } - } -} - -if (isset($_GET['forgot'])) { - if (!empty($_POST['email'])) { - $query = $conn->prepare('SELECT id, username FROM users WHERE email_id = ?'); - $query->execute([trim($_POST['email'])]); - - if ($row = $query->fetch()) { - $username = $row['username']; - - $new_pass = uniqid(rand(), true); - $new_pass_hash = password_hash($new_pass, PASSWORD_DEFAULT); - - $conn->prepare('UPDATE users SET password = ? WHERE id = ?') - ->execute([$new_pass_hash, $row['id']]); - - $success = $lang['pass_change']; //"Password changed successfully and sent to your email address."; - $sent_mail = $email; - $subject = "$site_name Password Reset"; - $body = "
- Hello $username ,

- - Your password has been reset: $new_pass

- - You can now login and change your password.
- "; - if ($mail_type == '1') { - default_mail($admin_mail, $admin_name, $sent_mail, $subject, $body); - } else { - smtp_mail($smtp_host, $smtp_port, $smtp_auth, $smtp_user, $smtp_pass, $smtp_sec, $admin_mail, $admin_name, $sent_mail, $subject, $body); - } - - } else { - $error = $lang['email_not']; //"Email not found"; - } - } -} - if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Check if logged in if (isset($_SESSION['token'])) { @@ -173,41 +84,29 @@ if (isset($_POST['signup'])) { $password = password_hash($_POST['password'], PASSWORD_DEFAULT); $chara_max = 25; //characters for max input - if (empty($_POST['email']) || empty($_POST['password']) || empty($_POST['username'])) { + if (empty($_POST['password']) || empty($_POST['username'])) { $error = $lang['missingfields']; // "All fields must be filled out"; - } elseif (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { - $error = $lang['email_invalid']; // "Your email address seems to be invalid."; } elseif (strlen($username) > $chara_max) { $error = $lang['maxnamelimit']; // "Username already taken."; } elseif (!isValidUsername($username)) { $error = $lang['usrinvalid']; // "Username not valid. Usernames can't contain special characters."; } else { - $email = trim($_POST['email']); $query = $conn->prepare('SELECT 1 FROM users WHERE username = ?'); $query->execute([$username]); + if ($query->fetch()) { $error = $lang['userexists']; // "Username already taken."; } else { - $query = $conn->prepare("SELECT 1 FROM users WHERE email_id = ?"); - $query->execute([$email]); + $query = $conn->prepare( + "INSERT INTO users (oauth_uid, username, email_id, platform, password, verified, picture, date, ip, badge) VALUES ('0', ?, ?, 'Direct', ?, ?, 'NONE', ?, ?, '0')" + ); + $query->execute([$username, $email, $password, $verification_needed ? 0 : 1, $date, $ip]); - if ($query->fetch()) { - $error = $lang['emailexists']; // "Email already registered."; - } else { - $verification_needed = $verification !== 'disabled'; - - $query = $conn->prepare( - "INSERT INTO users (oauth_uid, username, email_id, platform, password, verified, picture, date, ip, badge) VALUES ('0', ?, ?, 'Direct', ?, ?, 'NONE', ?, ?, '0')" - ); - $query->execute([$username, $email, $password, $verification_needed ? 0 : 1, $date, $ip]); - - if ($verification_needed) { - sendVerificationEmail($email, $username, $username);; - } - - $success = $lang['registered']; // "Your account was successfully registered."; + if ($verification_needed) { + sendVerificationEmail($email, $username, $username);; } + $success = $lang['registered']; // "Your account was successfully registered."; } } } diff --git a/profile.php b/profile.php index ad4cd0c..2a8eee5 100644 --- a/profile.php +++ b/profile.php @@ -38,7 +38,6 @@ $query->execute([$user_username]); $row = $query->fetch(); $user_oauth_uid = $row['oauth_uid']; $user_id = $row['id']; -$user_email_id = $row['email_id']; $user_full_name = $row['full_name']; $user_platform = Trim($row['platform']); $user_verified = $row['verified']; diff --git a/theme/bulma/header.php b/theme/bulma/header.php index c6dba37..28fef30 100644 --- a/theme/bulma/header.php +++ b/theme/bulma/header.php @@ -293,9 +293,6 @@ $start = $time; - diff --git a/theme/bulma/login.php b/theme/bulma/login.php index 29db7c9..e368284 100644 --- a/theme/bulma/login.php +++ b/theme/bulma/login.php @@ -131,15 +131,6 @@ -
- -
- - - - -
-
@@ -248,39 +239,6 @@
- -
-
-
-

Resend verification email

-
- -
- - - - -
-
-
- -
-
-
-
-
- -
-
-
@@ -288,7 +246,6 @@ Login
Register
Forgot Password
- Resend verification email
diff --git a/theme/bulma/profile.php b/theme/bulma/profile.php index d76be67..e15e0c5 100644 --- a/theme/bulma/profile.php +++ b/theme/bulma/profile.php @@ -50,18 +50,6 @@
-
- -
- type="text" class="input" name="email" - placeholder=""> - - - -
-

diff --git a/verify.php b/verify.php deleted file mode 100644 index a10ddb0..0000000 --- a/verify.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License in GPL.txt for more details. - */ - -require_once('config.php'); - -// Database Connection -$con = mysqli_connect($dbhost, $dbuser, $dbpassword, $dbname); -if (mysqli_connect_errno()) { - die("Unable connect to database"); -} - -$username = htmlentities(trim($_GET['username'])); -$code = htmlentities(trim($_GET['code'])); - -$query = "SELECT email_id, verified FROM users WHERE username=?"; -if ($stmt = mysqli_prepare($con, $query)) { - - mysqli_stmt_bind_param($stmt, "s", $username); - mysqli_stmt_execute($stmt); - mysqli_stmt_store_result($stmt); - - if (mysqli_stmt_num_rows($stmt) > 0) { - - mysqli_stmt_bind_result($stmt, $db_email_id, $db_verified); - - while (mysqli_stmt_fetch($stmt)) { - if ($db_verified == '1') { - die("Account already verified."); - } - - $ver_code = Md5('4et4$55765' . $db_email_id . 'd94ereg'); - - if ($ver_code == $code) { - // Code okay - let's say the user is verified - $query = "UPDATE users SET verified='1' WHERE username=?"; - $stmt = mysqli_prepare($con, $query); - - mysqli_stmt_bind_param($stmt, "s", $username); - mysqli_stmt_execute($stmt); - - if (mysqli_stmt_errno($stmt)) { - $error = "Something went wrong."; - } else { - header("Location: login.php?login"); - exit(); - } - - } else { - die("Invalid verification code."); - } - } - } else { - die("Username not found."); - } - mysqli_stmt_close($stmt); -} else { - die('Things went terribly wrong.'); -}