<a href="uptransfer.php"><b><?php echo T_("DONATE_UPLOAD_CREDITS"); ?></b></a><br /><?php
require_once("backend/functions.php");
dbconn();
loggedinonly();
$action = $_REQUEST["action"];
if ($action == "searchuser") {
$query = $_GET['query'];
$stmt = $GLOBALS["DBconnector"]->prepare("SELECT username FROM users WHERE username LIKE ?");
$searchTerm = $query . "%"; // match starting characters
$stmt->bind_param("s", $searchTerm);
$stmt->execute();
$result = $stmt->get_result();
$usernames = [];
while ($row = $result->fetch_assoc()) {
$usernames[] = $row['username'];
}
echo json_encode($usernames);
die();
}
if ($action == "taketransfer") {
$username = trim($_POST["username"]);
$credit = (int)$_POST["credit"];
$unit = trim($_POST["unit"]);
$anonym = isset($_POST["anonym"]) ? $_POST["anonym"] : '';
if (empty($username)) {
autolink("uptransfer.php", "No recipient was added...");
}
if ($credit < 1 || !$CURUSER) {
autolink("uptransfer.php", "Transfer is too small...");
}
// Define size units
define('KB', 1024);
define('MB', 1024 * KB);
define('GB', 1024 * MB);
define('TB', 1024 * GB);
// Convert credit to bytes
switch ($unit) {
case 'kb':
$credit *= KB;
break;
case 'mb':
$credit *= MB;
break;
case 'gb':
$credit *= GB;
break;
case 'tb':
$credit *= TB;
break;
default:
autolink("uptransfer.php", "Invalid unit specified...");
}
if ($CURUSER["uploaded"] < $credit) {
autolink("uptransfer.php", "You are trying to donate upload credits while you currently have insufficient credits...");
}
$stmt = $GLOBALS["DBconnector"]->prepare("SELECT id, uploaded, modcomment FROM users WHERE username = ?");
$stmt->bind_param("s", $username);
$stmt->execute();
$res = $stmt->get_result()->fetch_assoc();
if (!$res) {
autolink("uptransfer.php", T_("USER_NOT_FOUND"));
}
$receiver = $res["id"];
$sender = $CURUSER["id"];
$modcomment1 = $res["modcomment"];
$modcomment2 = $CURUSER["modcomment"];
// Prepare modcomments
$date = gmdate("Y-m-d");
$modcomment1 = "$date - Credit upload: $username obtained " . mksize($credit) . " from " . $CURUSER['username'] . ".\n" . $modcomment1;
$modcomment2 = "$date - Credit upload: " . $CURUSER['username'] . " donated " . mksize($credit) . " to $username.\n" . $modcomment2;
// Update receiver's uploaded credits and modcomment
$stmt = $GLOBALS["DBconnector"]->prepare("UPDATE users SET uploaded = uploaded + ?, modcomment = ? WHERE id = ?");
$stmt->bind_param("isi", $credit, $modcomment1, $receiver);
$stmt->execute();
// Update sender's uploaded credits and modcomment
$stmt = $GLOBALS["DBconnector"]->prepare("UPDATE users SET uploaded = uploaded - ?, modcomment = ? WHERE id = ?");
$stmt->bind_param("isi", $credit, $modcomment2, $sender);
$stmt->execute();
// Send notification
$subject = "You got an upload credit!";
if ($anonym != 'anonym') {
$msg = "Your account has been credited " . mksize($credit) . " compliments of " . $CURUSER['username'] . ".";
$stmt = $GLOBALS["DBconnector"]->prepare("INSERT INTO messages (sender, receiver, added, msg, poster, subject) VALUES (?, ?, NOW(), ?, 0, ?)");
$stmt->bind_param("iiss", $sender, $receiver, $msg, $subject);
} else {
$msg = "Your account has been credited " . mksize($credit) . " compliments of an anonymous user.";
$stmt = $GLOBALS["DBconnector"]->prepare("INSERT INTO messages (sender, receiver, added, msg, poster, subject) VALUES (0, ?, NOW(), ?, 0, ?)");
$stmt->bind_param("iss", $receiver, $msg, $subject);
}
$stmt->execute();
// Log the transfer
write_log("<font color=lime size=2>Credit Upload:</font><a href=account-details.php?id=$sender target=_blank>" . $CURUSER['username'] . "</a> donated " . mksize($credit) . " to <a href=account-details.php?id=$receiver target=_blank>$username</a>");
autolink("uptransfer.php", "You have given " . mksize($credit) . " in upload credit to " . $username);
die();
}
/* Start Page Output */
stdhead("Donate Uploads");
begin_frame(T_('Q&A'));
?>
<b><?php echo T_("WHY_SHOULD_DONATE"); ?></b><br />
<?php echo T_("CREDIT_UP_TEXT1"); ?>
<?php
end_frame();
begin_frame(T_('TRANSFER_UPLOAD'));
?>
<center>
<form name="transfer" method="post" action="uptransfer.php?action=taketransfer">
<table width="500" cellpadding="5">
<tr>
<td width="100"><b><?php echo T_("DONATE_TO"); ?>:</b></td>
<td>
<input type="text" id="username" name="username" size="20" onkeyup="searchUser(this.value)" autocomplete="off">
<input type="checkbox" name="anonym" value="anonym"> <?php echo T_("ANONYMOUS_TRANSFER"); ?>
<div id="suggestions" style="border: 1px solid #ccc; display: none; max-height: 100px; overflow-y: auto;"></div>
</td>
</tr>
<tr>
<td width="100"><b><?php echo T_("AMOUNT_CREDIT"); ?>:</b></td>
<td>
<input type="text" autocomplete="off" name="credit" size="20" value="1" pattern="\d*" title="Only numbers are allowed.">
<select name="unit">
<option value="kb">KB</option>
<option value="mb">MB</option>
<option value="gb">GB</option>
<option value="tb">TB</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<center><input name="submit" type="submit" value="Transfer!"></center>
</td>
</tr>
</table>
</form>
</center>
<?php
end_frame();
stdfoot();
?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
function searchUser(query) {
if (query.length > 0) { // Adjusted to start with the first character
$.ajax({
url: 'uptransfer.php?action=searchuser',
type: 'GET',
data: { query: query },
success: function(data) {
var suggestions = JSON.parse(data);
var suggestionsList = '';
if (suggestions.length > 0) {
suggestions.forEach(function(username) {
suggestionsList += '<div class="suggestion-item" onclick="selectUsername(\'' + username + '\')">' + username + '</div>';
});
} else {
suggestionsList = '<div class="suggestion-item">No suggestions found</div>';
}
$('#suggestions').html(suggestionsList).show();
}
});
} else {
$('#suggestions').hide();
}
}
function selectUsername(username) {
$('#username').val(username);
$('#suggestions').hide();
}
</script>
<style>
.suggestion-item {
padding: 10px;
cursor: pointer;
}
.suggestion-item:hover {
background-color: #f0f0f0;
}
</style> function therooms()
{
$data = '<select name="room" class="bb_icon" onchange="if(this.options[this.selectedIndex].value != -1){ window.location = this.options[this.selectedIndex].value; }">
<option value="shoutbox.php?room=0" ' . ($GLOBALS['room'] == 0 ? 'selected="selected"' : '') . '>Public</option>
<option value="shoutbox.php?room=1" ' . ($GLOBALS['room'] == 1 ? 'selected="selected"' : '') . '>VIP</option>';
if (get_user_class() >= 5) {
$data .= '<option value="shoutbox.php?room=2" ' . ($GLOBALS['room'] == 2 ? 'selected="selected"' : '') . '>Staff</option>';
}
$data .= '</select>';
return $data;
}function theroomsh()
{
$data = '<select name="room" class="bb_icon" onchange="if(this.options[this.selectedIndex].value != -1){ window.location = this.options[this.selectedIndex].value; }">
<option value="shoutbox.php?history=0&room=0" ' . ($GLOBALS['room'] == 0 ? 'selected="selected"' : '') . '>Public</option>
<option value="shoutbox.php?history=0&room=1" ' . ($GLOBALS['room'] == 1 ? 'selected="selected"' : '') . '>VIP</option>';
if (get_user_class() >= 5) {
$data .= '<option value="shoutbox.php?history=1&room=2" ' . ($GLOBALS['room'] == 2 ? 'selected="selected"' : '') . '>Staff</option>';
}
$data .= '</select>';
return $data;
} SQL_Query_exec("INSERT INTO commonpot (userid, points, added) VALUES($CURUSER[id], $_POST[seedbonus], '" . get_date_time() . "')"); Here is my file if it helps if (isset($_GET['del'])){
if (is_numeric($_GET['del'])){
$query = "SELECT * FROM ajshoutbox WHERE id=".$_GET['del'];
$result = SQL_Query_exec($query);
}else{
echo "invalid msg id STOP TRYING TO INJECT SQL";
exit;
}
$row = mysqli_fetch_row($result);
if ((get_user_class() >= 4) || ($CURUSER['username'] == $row[1]) ){
$query = "DELETE FROM ajshoutbox WHERE id=".$_GET['del'];
//write_log("<B>".SHOUTBOX_DEL." ".$CURUSER['username']."</b>");
SQL_Query_exec($query);
}
} if (isset($_GET['del'])) {
if (is_numeric($_GET['del'])) {
$delId = intval($_GET['del']); // Convert to integer for security
// Check if the message ID exists in the database
$query = "SELECT * FROM ajshoutbox WHERE id=$delId";
$result = SQL_Query_exec($query);
if (mysqli_num_rows($result) == 0) {
echo "Message with ID $delId not found.";
exit;
}
$row = mysqli_fetch_row($result);
// Perform further actions only if the user has sufficient privileges or owns the message
if (get_user_class() >= 4 || $CURUSER['username'] == $row[1]) {
// Check if the delete confirmation
if (isset($_POST['confirm_delete'])) {
$query = "DELETE FROM ajshoutbox WHERE id=$delId";
SQL_Query_exec($query);
echo "Message with ID $delId deleted successfully.";
} else {
// Display confirmation
echo "<form method='post' style='font-size: 16px; color: #333; text-align: center;'>
<p style='font-size: 18px; color: #f00;'>Are you sure you want to delete this message?</p>
<input type='submit' name='confirm_delete' value='Yes' style='font-size: 16px; color: #fff; background-color: #007bff; border: none; padding: 8px 16px; cursor: pointer;'>
<button type='button' onclick='window.history.back()' style='font-size: 16px; color: #fff; background-color: #6c757d; border: none; padding: 8px 16px; cursor: pointer;'>No</button>
</form>";
}
} else {
echo "You do not have permission to delete this message.";
}
} else {
echo "Invalid message ID. STOP TRYING TO INJECT SQL!";
exit;
}
} function delup(id) {
if (confirm("Are you sure you want to delete this message?")) {
var xhr = new XMLHttpRequest();
xhr.open("GET", "chatedit.php?del=" + id, true);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
alert("Message deleted successfully");
} else if (xhr.readyState === 4 && xhr.status !== 200) {
alert("Failed to delete message");
}
};
xhr.send();
}
} <?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\OAuth;
$GLOBALS["TTMail"] = new TTMail;
class TTMail {
var $type;
var $smtp_host;
var $smtp_port = 465; // Update to Gmail's SMTP port for TLS
var $smtp_ssl = false;
var $smtp_auth = true;
var $smtp_user;
var $smtp_pass;
var $oauth2_client_id; // Add OAuth2 client ID
var $oauth2_client_secret; // Add OAuth2 client secret
var $oauth2_refresh_token; // Add OAuth2 refresh token
function __construct() {
GLOBAL $site_config;
switch (strtolower($site_config["mail_type"])) {
case "phpmailer":
$this->type = "phpmailer";
$this->smtp_host = 'smtp.gmail.com';
$this->smtp_port = 465;
$this->smtp_auth = true;
$this->smtp_user = $site_config["mail_smtp_user"];
$this->smtp_pass = $site_config["mail_smtp_pass"];
// Add OAuth2 settings
$this->oauth2_client_id = $site_config["oauth2_client_id"];
$this->oauth2_client_secret = $site_config["oauth2_client_secret"];
$this->oauth2_refresh_token = $site_config["oauth2_refresh_token"];
// Enable TLS
$this->smtp_ssl = 'tls';
break;
case "pear":
$this->type = "pear";
$this->smtp_ssl = $site_config["mail_smtp_ssl"];
if ($this->smtp_ssl) {
$this->smtp_host = "ssl://" . $site_config["mail_smtp_host"];
} else {
$this->smtp_host = $site_config["mail_smtp_host"];
}
$this->smtp_port = $site_config["mail_smtp_port"];
$this->smtp_auth = $site_config["mail_smtp_auth"];
$this->smtp_user = $site_config["mail_smtp_user"];
$this->smtp_pass = $site_config["mail_smtp_pass"];
if (!@include_once("Mail.php")) {
trigger_error("Config is set to use PEAR Mail but it is not installed (or include_path is wrong).", E_USER_WARNING);
$this->type = "php";
}
break;
case "php":
default:
$this->type = "php";
}
}
function Send($to, $subject, $message, $additional_headers = "", $additional_parameters = "") {
GLOBAL $site_config;
if (preg_match("!^From:(.*)!m", $additional_headers, $matches)) {
$from = trim($matches[1]);
} else {
$from = "$site_config[SITEEMAIL]";
}
$additional_headers = preg_replace("!^From:(.*)!m", "", $additional_headers);
$additional_headers .= "\nFrom: $from\nReturn-Path: $from";
$additional_headers = trim($additional_headers);
$additional_headers = preg_replace("!\n+!", "\n", $additional_headers);
switch ($this->type) {
case "phpmailer":
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = $this->smtp_host;
$mail->Port = $this->smtp_port;
$mail->SMTPAuth = $this->smtp_auth;
$mail->Username = $this->smtp_user;
$mail->Password = $this->smtp_pass;
// Add OAuth2 settings
$mail->OAuth2ClientId = $this->oauth2_client_id;
$mail->OAuth2ClientSecret = $this->oauth2_client_secret;
$mail->OAuth2RefreshToken = $this->oauth2_refresh_token;
$mail->SMTPSecure = $this->smtp_ssl;
$mail->setFrom($from);
$mail->addAddress($to);
$mail->Subject = $subject;
$mail->Body = $message;
try {
$mail->send();
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
break;
case "pear":
$headers = array("From" => $from, "Return-Path" => $from, "To" => $to, "Subject" => $subject);
$params = array("host" => $this->smtp_host, "port" => $this->smtp_port, "auth" => $this->smtp_auth, "username" => $this->smtp_user, "password" => $this->smtp_pass);
$smtp = Mail::Factory("smtp", $params);
$mail = $smtp->send($to, $headers, $message);
break;
case "php":
default:
@mail($to, $subject, $message, $additional_headers, $additional_parameters);
break;
}
}
}
function sendmail($to, $subject, $message, $additional_headers = "", $additional_parameters = "") {
GLOBAL $TTMail;
$TTMail->Send($to, $subject, $message, $additional_headers, $additional_parameters);
}
?>// BELOW IS SETTINGS FOR OAUTH2 GMAIL. NEED OAUTH2 KEY (see code in mail.php)
// $site_config["mail_type"] = "phpmailer";
// $site_config["mail_smtp_host"] = "smtp.gmail.com"; // SMTP server hostname
// $site_config["mail_smtp_port"] = "465"; // SMTP server port
// $site_config["mail_smtp_ssl"] = true; // true to use SSL (ONLY USED WITH PEAR. Is not used with phpmailer)
// $site_config["mail_smtp_auth"] = true; // MUST BE true to use auth for SMTP (JUST LEAVE SET TO TRUE)
// $site_config["mail_smtp_user"] = "person@gmail.com"; // SMTP username
// $site_config["mail_smtp_pass"] = "Password"; // SMTP password
// $site_config["oauth2_client_id"] = "CLIENT ID HERE"; // OAUTH2 keys from google to use gmail shit
// $site_config["oauth2_client_secret"] = "SECRET KEY HERE";
// $site_config["oauth2_refresh_token"] = ""; //Im not sure how to get this yet. function delup(id) {
newWin=window.open('chatedit.php?del='+id,'delete','height=500,width=490,resizable=yes,scrollbars=yes');
if (window.focus) {newWin.focus()}
}function delup(id) {
if (confirm("Are you sure you want to delete this message?")) {
newWin = window.open('chatedit.php?del=' + id, 'delete', 'height=500,width=490,resizable=yes,scrollbars=yes');
if (window.focus) {
newWin.focus();
}
}
}