PHP code example of duelistrag3 / php-wowemu-auth

1. Go to this page and download the library: Download duelistrag3/php-wowemu-auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

duelistrag3 / php-wowemu-auth example snippets

 bash
composer 
 php
 Duelistrag3\Wowemu\SRP\UserClient;
 php
$client = new UserClient($username);
$salt = $client->generateSalt();
$verifier = $client->generateVerifier($password);
 php
 Duelistrag3\Wowemu\SRP\UserClient;
 php
$client = new UserClient($username, $saltFromDatabase);
$verifier = strtoupper($client->generateVerifier($password));
 php


/* login.php */

UserClient;

/* Connect to your CMaNGOS database. */
$db = new mysqli($dbHost, $dbUser, $dbPassword, $dbName);

/* Function to get values from MySQL. */
function getMySQLResult($query) {
    global $db;
    return $db->query($query)->fetch_object();
}

/* If the form has been submitted. */
if (isset($_POST['login'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    /* Get the salt and verifier from realmd.account for the user. */
    $query = "SELECT s,v FROM account WHERE username='$username'";
    $result = getMySQLResult($query);
    $saltFromDatabase = $result->s;
    $verifierFromDatabase = strtoupper($result->v);
    
    /* Setup your client and verifier values. */
    $client = new UserClient($username, $saltFromDatabase);
    $verifier = strtoupper($client->generateVerifier($password));

    /* Compare $verifierFromDatabase and $verifier. */
    if ($verifierFromDatabase === $verifier) {
        /* Do your login stuff here, like setting cookies/sessions... */
    }
    else {
        /* Do whatever you wanna do when the login has failed, send a failure message, redirect them to another page, etc... */
    }