Results 1 to 4 of 4
  1. #1
    Snuffleupagus's Avatar
    Join Date
    Dec 2014
    Gender
    female
    Posts
    54
    Reputation
    10
    Thanks
    76

    [TUTORIAL] PHP Script for Seraph's Dominion Email Verification

    For those of you that want to get the email verification system working on the Seraph's Dominion source you'll need to place the following little php script I whipped up on your website.

    Create a new text file and name it verify.php. Copy and paste this code into your new verify.php file and make sure to change the database credentials to your own before uploading it to your website.


     
    Code:
    <?php
    
    // Verification script by Snuffleupagus
    
    define('DB_HOST', 'LOCALHOST');
    define('DB_USER', 'USERNAME');
    define('DB_PASS', 'PASSWORD');
    define('DB_NAME', 'rotmg');
    
    function init_db() {
    	try {
    		$pdo = new PDO( 'mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASS );
    		return $pdo;
    	} catch ( PDOException $e ) {
    		error_log( "Failed to connect to database: " . $e->getMessage() );
    		die("No database connection.");
    	}
    }
    
    $pdo = init_db();
    
    if (@$_GET['email'] && @$_GET['key']) {
    	$q = $pdo->query("SELECT * FROM `emails` WHERE `email` = ".$pdo->quote($_GET['email'])." AND `accessKey` = ".$pdo->quote($_GET['key']) );
    	if (!$q) {
    		error_log( "Error fetching record from `emails` table: " . $e->getMessage() );
    		die("Database error.");
    	}
    
    	$row = $q->fetch();
    
    	if ($row) {
    		$q = $pdo->exec("UPDATE `accounts` SET verified = 1 WHERE `email` = ".$pdo->quote($row['email']));
    		if ($q == 1) {
    			echo "Account successfully verified.";
    		} else if ($q == 0) {
    			echo "Account already verified.";
    		}
    	} else {
    		echo "Account validation failed";
    	}
    }


    You'll also need to make some necessary adjustments in server/account/sendVerifyEmail.cs which is self explanatory.

    Enjoy!

     

    Snuffleupagus for the script.
    @Kithio for the source.
    @Club559 for the source.
    Last edited by Snuffleupagus; 02-28-2015 at 01:18 AM.

  2. The Following 11 Users Say Thank You to Snuffleupagus For This Useful Post:

    [MPGH]Ahl (02-28-2015),dilitot (03-01-2015),kao00723 (02-28-2015),Kithio (02-28-2015),maxmax19931 (02-28-2015),OwenHendry (02-28-2015),rangewolf15 (02-28-2015),sacredmike (02-28-2015),tjmax65 (02-28-2015),Travoos (02-28-2015),Zodkop (02-28-2015)

  3. #2
    Kithio's Avatar
    Join Date
    May 2014
    Gender
    male
    Posts
    641
    Reputation
    16
    Thanks
    803
    My Mood
    Innocent
    Quote Originally Posted by Snuffleupagus View Post
    For those of you that want to get the email verification system working on the Seraph's Dominion source you'll need to place the following little php script I whipped up on your website.

    Create a new text file and name it verify.php. Copy and paste this code into your new verify.php file and make sure to change the database credentials to your own before uploading it to your website.


     
    Code:
    <?php
    
    // Verification script by Snuffleupagus
    
    define('DB_HOST', 'LOCALHOST');
    define('DB_USER', 'USERNAME');
    define('DB_PASS', 'PASSWORD');
    define('DB_NAME', 'rotmg');
    
    function init_db() {
    	try {
    		$pdo = new PDO( 'mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASS );
    		return $pdo;
    	} catch ( PDOException $e ) {
    		error_log( "Failed to connect to database: " . $e->getMessage() );
    		die("No database connection.");
    	}
    }
    
    $pdo = init_db();
    
    if (@$_GET['email'] && @$_GET['key']) {
    	$q = $pdo->query("SELECT * FROM `emails` WHERE `email` = ".$pdo->quote($_GET['email'])." AND `accessKey` = ".$pdo->quote($_GET['key']) );
    	if (!$q) {
    		error_log( "Error fetching record from `emails` table: " . $e->getMessage() );
    		die("Database error.");
    	}
    
    	$row = $q->fetch();
    
    	if ($row) {
    		$q = $pdo->exec("UPDATE `accounts` SET verified = 1 WHERE `email` = ".$pdo->quote($row['email']));
    		if ($q == 1) {
    			echo "Account successfully verified.";
    		} else if ($q == 0) {
    			echo "Account already verified.";
    		}
    	} else {
    		echo "Account validation failed";
    	}
    }


    You'll also need to make some necessary adjustments in server/account/sendVerifyEmail.cs which is self explanatory.

    Enjoy!

     

    Snuffleupagus for the script.
    @Kithio for the source.
    @Club559 for the source.
    This could be useful down the road. I like the fact you use the newer PHP Standards for database connections instead of the old one that most poeple use

    PDO FTW
    I is pansexual furry and proud

    Server Information:
    Status: Confused

  4. #3
    sacredmike's Avatar
    Join Date
    Jul 2013
    Gender
    male
    Location
    Uranus ;)
    Posts
    685
    Reputation
    15
    Thanks
    3,255
    My Mood
    Devilish
    Thanks for this!
    i'm actually just a horny boy

  5. #4
    Ahl's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    /modcp
    Posts
    16,599
    Reputation
    3219
    Thanks
    5,383
    My Mood
    Angelic
    Good release. Will be helping many users.
    News Force Head Editor from 09/14/2018 - 03/02/2020
    Publicist from 11/23/2017 - 06/07/2019
    Global Moderator since 09/24/2017
    Minion+ from 04/16/2017 - 09/24/2017
    Market Place Minion from 04/16/2017 - 09/24/2017
    Minecraft Minion from 02/23/2017 - 09/24/2017
    Realm of the Mad God Minion from 11/06/2016 - 09/24/2017

    Middleman from 09/14/2016 - 09/24/2017
    News Force Editor from 08/23/2016 - 09/14/2018
    News Force (Section of the Week) from 03/21/2016 - 07/17/2017
    News Force (User News) from 10/18/2015 - 09/14/2018

    Donator since 03/16/2015
    Realm of the Mad God Editor from 05/20/2014 - 07/08/2014
    Member since 12/23/2012


    Rep Power: 82

Similar Threads

  1. Few scripts for rsbot
    By zupp10 in forum Runescape Hacks / Bots
    Replies: 3
    Last Post: 12-28-2009, 07:31 PM
  2. Basic Tutorials of HTML-For Noobs
    By PoP_KiLLaH in forum Web Languages
    Replies: 3
    Last Post: 11-29-2009, 01:51 AM
  3. Last request script for css
    By FingerMunch in forum Suggestions, Requests & General Help
    Replies: 0
    Last Post: 11-25-2009, 08:37 AM
  4. [Tutorial] Complete source for warrock hack!
    By Noxit in forum C++/C Programming
    Replies: 25
    Last Post: 09-27-2009, 02:59 PM
  5. Replies: 11
    Last Post: 08-06-2009, 02:28 PM