Simple Registration Page for TrinityCore 3.3.5a | SRP6 Support | Reshare

Azzlaer

Trial Member
2
2024
0
View attachment 1877
Extra Information:
The site is responsive, but bootstrap is not used.
The website has a chat that refresh automatically so you wont need to refresh the page to see new incoming messages, it will appear automatically.

Install Guide:
1. make sure you have a webserver, if you don't then download xampp from apachefriends.org and install to C:\ drive
2. go to C:\xampp\htdocs and delete everything inside this folder
3. Extract my website to htdocs folder
4. Open the website folder and find the config folder and open it.
5. Edit your database connection in file dbconf1.php and dbconf2.php
6. Go back to the root of the website folder and find folder "sql" open this folder and import the SQL File to your database. This will create a new database for the website. But do not worry, It will not delete database so you still keep auth, characters and world and whatever other database you may have.
7. go back to the root of xampp folder and find file xampp-control.exe and start it.
8. Click "Config" button next to apache and choose "php.ini", now look for ";extension=gmp" and remove the ";" before "extension" so it should be "extension=gmp" and this save php.ini and open xampp control panel again if you closed it
9. Click "Start" next to Apache and type 127.0.0.1 in address bar and hit enter and you should see the website.

Optional changes:
If you want the chat to stay open when refresh if you toggle chat on and stay close on refresh when you toggle chat off then you can replace the content inside the js file with this code https://pastebin.com/ryrg1ah3 I have used localStorage feature to get this to work
this will also require that you add this css code to style.min.css file in css folder
Code:
.chat-box.enabled {
  display:block;
}

NOTE! : You will have to modify 2 config files, because the registration script is made for some who uses OOP with PDO.

Credits:
Treeston
Tok124


Download




Logre configurar la pagina web para que cada usuario que se registre es anuncie a traves de discord por un webhook que se ha registrado un nuevo usuario y adjuntando unincamente USUARIO y CORREO.
Solo deben modificar y que quede asi su register.php
Solo deben cambiar el link de su WEBHOOK de discord y listo
Eespero que les haya gustado y un saludo a la comunidad de WOW


Code:
<?php

require_once('../config/dbconf2.php');

$db = new db();

if($_POST['cpassword'] != $_POST['password']) {
  exit("<div class='alert alert-danger'><strong>Failed !</strong> Passwords Missmatch !</div>");
}

// Get POST data and validate.
if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $username = validateInput($_POST['username']);
  $email = validateInput($_POST['email']);
  $password = validateInput($_POST['password']);
}

if (!isset($username) || !is_string($username))
  throw new InvalidArgumentException("Username is invalid or empty.");

if (!isset($password) || !is_string($password))
  throw new InvalidArgumentException("Password is invalid or empty.");

if (!isset($email))
  throw new InvalidArgumentException("Email is empty.");

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  echo "<div class='alert alert-danger'><strong>Failed !</strong> Invalid Email !</div>";
  return;
}

try {

  // First, we need to check if the account name already exists.
  $accountCheckQuery = "SELECT * FROM account WHERE username = ?";
  $accountCheckParams = array($username);

  $results = $db->queryMultiRow($accountCheckQuery, $accountCheckParams);

  if ($db->getRowCount($results) > 0) {

    // Account already exists, inform user and stop transaction.
    echo "<div class='alert alert-danger'><strong>Failed !</strong> Account already exist !</div>";

    // Close connection to the database.
    $db->close();

    return;
  }

  // If no account exists, create a new one.

  // Get the SHA1 encrypted password.
  list($salt, $verifier) = $db->getRegistrationData($username, $password);

  $accountCreateQuery = "INSERT INTO account(username, salt, verifier, email) VALUES(?, ?, ?, ?)";
  $accountCreateParams = array($username, $salt, $verifier, $email);

  // Execute the query.
  $db->insertQuery($accountCreateQuery, $accountCreateParams);

  // Close connection to the database.
  $db->close();

  // Return successful to AJAX call.
  echo "<div class='alert alert-success'><strong>Success !</strong> Account has been created !</div>";

  // Aquí comienza el código del webhook para Discord
  $webhookURL = "https://discord.com/api/webhooks/1217675238033068052/4OjF8Is8E8dIdhoyD-JHBAuaD33PVyCbykwUb1FOGTtv2mlAABwAXkbBHygiK7SWOQ9i";

  $message = "✅ Usuario registrado: $username - $email";

  $data = array(
    "content" => $message
  );

  $options = array(
    "http" => array(
      "header" => "Content-Type: application/json",
      "method" => "POST",
      "content" => json_encode($data)
    )
  );

  $context = stream_context_create($options);
  $result = file_get_contents($webhookURL, false, $context);

  if ($result === FALSE) {
    // Handle error
    error_log("Failed to send message to Discord webhook.");
  } else {
    // Message sent successfully
    error_log("Message sent to Discord webhook successfully.");
  }
  // Fin del código del webhook para Discord

}
catch(PDOException $e) {
  echo "<div class='alert alert-danger'><strong>Failed !</strong> An unknown PDO Error has occured !</div>";
  error_log("PDO Database error occurred: " . $e->getMessage());
}
catch (Exception $e) {
  echo "<div class='alert alert-danger'><strong>Failed !</strong> An unknown PDO Error has occured !</div>";
  error_log("Unknown error occurred: " . $e->getMessage());
}

// Validates POST input data.
function validateInput($param) {
  $param = trim($param);
  $param = stripslashes($param);
  $param = htmlspecialchars($param);

  return $param;
}
?>
 
Top