mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 14:40:09 +01:00
Remove most email stuff.
This commit is contained in:
parent
0e5b5748a3
commit
4d90ab2d43
11 changed files with 9 additions and 383 deletions
|
@ -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),
|
||||
|
|
|
@ -436,134 +436,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Mail Settings -->
|
||||
|
||||
<div role="tabpanel" class="tab-pane" id="mail">
|
||||
<form class="form-horizontal" method="POST"
|
||||
action="<?php echo $_SERVER['PHP_SELF']; ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="panel-title">
|
||||
Registration Settings
|
||||
</div>
|
||||
<label class="col-sm-2 control-label form-label">Email Verification</label>
|
||||
<select class="selectpicker" name="verification">
|
||||
<?php
|
||||
if ($current_mail['verification']) {
|
||||
echo '<option selected value="enabled">Enabled</option>';
|
||||
echo '<option value="disabled">Disabled</option>';
|
||||
} else {
|
||||
echo '<option value="enabled">Enabled</option>';
|
||||
echo '<option selected value="disabled">Disabled</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="panel-title">
|
||||
Mail Settings
|
||||
</div>
|
||||
<label class="col-sm-2 control-label form-label">Mail Protocol</label>
|
||||
<select class="selectpicker" name="protocol">
|
||||
<?php
|
||||
if ($current_mail['protocol'] === '1') {
|
||||
echo '<option selected value="1">PHP Mail</option>';
|
||||
echo '<option value="2">SMTP</option>';
|
||||
} else {
|
||||
echo '<option value="1">PHP Mail</option>';
|
||||
echo '<option selected value="2">SMTP</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">SMTP Auth</label>
|
||||
<select class="selectpicker" name="auth">
|
||||
<?php
|
||||
if ($current_mail['auth']) {
|
||||
echo '<option selected value="true">True</option>
|
||||
<option value="false">False</option>';
|
||||
} else {
|
||||
echo '<option value="true">True</option>
|
||||
<option selected value="false">False</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">SMTP Protocol</label>
|
||||
<select class="selectpicker" name="socket">
|
||||
<?php
|
||||
if ($current_mail['socket'] === 'tls') {
|
||||
echo '
|
||||
<option selected value="tls">TLS</option>
|
||||
<option value="ssl">SSL</option>';
|
||||
} else {
|
||||
echo '
|
||||
<option value="tls">TLS</option>
|
||||
<option selected value="ssl">SSL</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">SMTP Host</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" placeholder="eg smtp.gmail.com"
|
||||
value="<?php echo htmlentities($current_mail['smtp_host'], ENT_QUOTES); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">SMTP Port</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="smtp_port"
|
||||
placeholder="eg 465 for SSL or 587 for TLS"
|
||||
value="<?php echo htmlentities($current_mail['smtp_port'], ENT_QUOTES); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">SMTP User</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="smtp_user"
|
||||
placeholder="eg user@gmail.com"
|
||||
value="<?php echo htmlentities($current_mail['smtp_username'], ENT_QUOTES); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">SMTP Password</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="password" class="form-control" id="smtp_pass"
|
||||
name="smtp_pass" placeholder="Email password"
|
||||
value="<?php echo htmlentities($current_mail['smtp_pass'], ENT_QUOTES); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button style="margin-bottom: 2%;" id="smtppasstoggle" type="button"
|
||||
class="btn btn-default"
|
||||
onclick="if (smtp_pass.type == 'text') {smtp_pass.type = 'password';} else {smtp_pass.type = 'text';}">
|
||||
Toggle password
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="smtp_code" value="smtp">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-default">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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'];
|
||||
|
|
|
@ -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) {
|
|||
<td> <?php echo $user_username; ?> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> Email ID</td>
|
||||
<td> <?php echo htmlentities($user_email_id); ?> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> Platform</td>
|
||||
<td> <?php echo $user_platform; ?> </td>
|
||||
|
@ -250,7 +244,6 @@ if ($last_ip == $ip) {
|
|||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Username</th>
|
||||
<th>Email ID</th>
|
||||
<th>Date Registered</th>
|
||||
<th>Platform</th>
|
||||
<th>Ban User</th>
|
||||
|
|
|
@ -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');
|
||||
|
|
119
login.php
119
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.<br /><br />
|
||||
|
||||
<a href='$verify_url' target='_self'>$verify_url</a> <br /> <br />
|
||||
|
||||
After confirming your account you can log in using your username: <b>$username</b> 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 = "<br />
|
||||
Hello $username , <br /><br />
|
||||
|
||||
Your password has been reset: $new_pass <br /> <br />
|
||||
|
||||
You can now login and change your password. <br />
|
||||
";
|
||||
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.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'];
|
||||
|
|
|
@ -293,9 +293,6 @@ $start = $time;
|
|||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<footer class="modal-card-foot">
|
||||
<a href="../login.php?resend">Resend verification email</a>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -131,15 +131,6 @@
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Email</label>
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input type="text" class="input" name="email" placeholder="Email" required>
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-envelope"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mb-4">
|
||||
<label class="label">Password</label>
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
|
@ -248,39 +239,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php // Resend verification email
|
||||
} elseif (isset($_GET['resend'])) {
|
||||
?>
|
||||
<form action="../login.php?resend" method="post">
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<h1 class="title is-4">Resend verification email</h1>
|
||||
<div class="field">
|
||||
<label class="label">Email</label>
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input type="text" class="input" name="email"
|
||||
placeholder="Enter your email address">
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-envelope"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input class="button" type="submit" value="Submit" name="resend"
|
||||
value="<?php echo md5($date . $ip); ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
</div>
|
||||
<div class="column">
|
||||
<?php
|
||||
if (isset($site_ads) && !isset($_SESSION['username'])) {
|
||||
echo $site_ads['ads_2'];
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php } else { ?>
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
|
@ -288,7 +246,6 @@
|
|||
<a href="login.php?login">Login</a><br/>
|
||||
<a href="login.php?registeraccount">Register</a> <br/>
|
||||
<a href="login.php?forgotpassw">Forgot Password</a><br/>
|
||||
<a href="login.php?resend">Resend verification email</a><br/>
|
||||
</div>
|
||||
<div class="column">
|
||||
</div>
|
||||
|
|
|
@ -50,18 +50,6 @@
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Email</label>
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input <?php if ($user_verified == "1") {
|
||||
echo 'disabled=""';
|
||||
} ?> type="text" class="input" name="email"
|
||||
placeholder="<?php echo htmlentities($user_email_id, ENT_QUOTES); ?>">
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-envelope"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<h1 class="title is-5"><?php echo $lang['chgpwd']; ?></h1>
|
||||
<div class="field">
|
||||
|
|
70
verify.php
70
verify.php
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Paste <https://github.com/jordansamuel/PASTE>
|
||||
*
|
||||
* 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.');
|
||||
}
|
Loading…
Add table
Reference in a new issue