- Joined
- Sep 20, 2012
- Messages
- 420
- Reaction score
- 47
I Use This In The TEST Server Only!
This one took me a while because of the way the system is now done, there is an easy explanation i have worked on this part all night, and now is the time to do a step by step guide on how to set it up; 5.3.1 didn't have the sqlsrv plugins you require, this has to be done correctly. In this guide i'm using Windows Server 2008 R2 Web edition. (although i don't use the web facilities much anymore!).
Step 1:
Step 2: Make sure you have the SQL plugins you can easily obtain them from Microsoft (they're unoffical mind but they do work)
Step 3: This is where it gets more tricky because there isn't just 1 php.ini file that needs modifying (i kept slipping up here because of the way the system is done you have to make sure both of them has the extension put in!)
Step 4: Start Wamp Server (yes its ok to start now!)
--> Side note: If you have issues please don't hesitate to ask, i will try and explain to the fullest of my abilities.
------------------------------------------
Wamp Completed Php Begin
------------------------------------------
We have now lost the old method of executing a query i.e.
However....the new system if done correctly looks like
I still don't like the way the system is done but remember to close the connection to MSSQL which is the new system again.
I didn't add the last part to my server which i'll do now, this doesn't have screenshots if done correctly, you should already have the working system.
I will however release the code for the Login.php (this is important for 5.5+)
The reason for this as a release also is because i feel 5.3.1 is a little basic but this new system i'm even new to, and i had help from Lugapha
oh This one uses nAuthID in the SQL 4 = banned, 2 = Email not verified, 1 = Under Maintenance, this one doesn't have the Account Under Admin Control (that would be normally 9)
This one took me a while because of the way the system is now done, there is an easy explanation i have worked on this part all night, and now is the time to do a step by step guide on how to set it up; 5.3.1 didn't have the sqlsrv plugins you require, this has to be done correctly. In this guide i'm using Windows Server 2008 R2 Web edition. (although i don't use the web facilities much anymore!).
Step 1:
You must be registered to see links
- This version is 5.5.12 (32bit) - MUST be 32 bit for this to workStep 2: Make sure you have the SQL plugins you can easily obtain them from Microsoft (they're unoffical mind but they do work)
You must be registered to see links
Step 3: This is where it gets more tricky because there isn't just 1 php.ini file that needs modifying (i kept slipping up here because of the way the system is done you have to make sure both of them has the extension put in!)
Step 4: Start Wamp Server (yes its ok to start now!)
--> Side note: If you have issues please don't hesitate to ask, i will try and explain to the fullest of my abilities.
------------------------------------------
Wamp Completed Php Begin
------------------------------------------
We have now lost the old method of executing a query i.e.
Code:
mssql_query("SELECT * FROM tAccounts where sUsername = '$user'")
However....the new system if done correctly looks like
Code:
$sql="SELECT nEMID, sUserPass, nAuthID from tAccounts WHERE sUsername = '$user'";
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$result=sqlsrv_query($conn2, $sql, $params, $options);
$num=sqlsrv_num_rows($result);
I still don't like the way the system is done but remember to close the connection to MSSQL which is the new system again.
Code:
sqlsrv_close($conn);
I didn't add the last part to my server which i'll do now, this doesn't have screenshots if done correctly, you should already have the working system.
I will however release the code for the Login.php (this is important for 5.5+)
Code:
<?php
$user = sql_clean($_GET['Username']);
$passhash = sql_clean($_GET['Password']);
$server = 'localhost\SQLEXPRESS';
//connect to account ===========================================================
$connectionInfo2 = array( 'Database'=>'Account', 'UID'=>'sa', 'PWD'=>'MSSQL Password');
$conn2 = sqlsrv_connect($server, $connectionInfo2);
if (!$conn2) {
print_r ('Something went wrong while connecting to MSSQL ac <br />');
die( print_r( sqlsrv_errors(), true));
}
$sql="SELECT nEMID, sUserPass, nAuthID from tAccounts WHERE sUsername = '$user'";
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$result=sqlsrv_query($conn2, $sql, $params, $options);
$num=sqlsrv_num_rows($result);
if( $num == false ) {
die('Wrong Username.');
}
$stmt = sqlsrv_query( $conn2, $sql);
while($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC))
{
$nEMID = $row['nEMID']."";
$sPass = $row['sUserPass']."";
$nAuthID = $row['nAuthID']."";
$Passhash2 = MD5($sPass);
if( $nAuthID == 4 )
{
die('Account Banned.');
}
elseif ($nAuthID == 1)
{
die('Under Maintenance.');
}
elseif ($nAuthID == 2)
{
die('Email Not Verified.');
}
elseif ($nAuthID == 3){
$Token = RandomToken(35);
$sql2="SELECT nEMID, sUserPass, nAuthID from tAccounts WHERE sUsername = '$user' AND sUserPass= '$passhash'";
$result2=sqlsrv_query($conn2, $sql2, $params, $options);
// Due to the MD5 Format Must be Converted To MD5 First!
if( $passhash != $Passhash2){
die('Wrong Password.');
}
elseif( $passhash == $Passhash2)
$setToken = null;
$Query3="SELECT * FROM tTokens WHERE nEMID='$nEMID'";
$Query4="Delete FROM tTokens WHERE nEMID='$nEMID'";
$Query5="INSERT INTO tTokens (nEMID, sToken) VALUES('".$nEMID."', '".$Token."')";
$result3=sqlsrv_query($conn2, $Query3, $params, $options);
$tok=sqlsrv_num_rows($result);
if( $tok >= 1 ) {
$SQL1=sqlsrv_query($conn2, $Query4, $params, $options);
$setToken =sqlsrv_query($conn2, $Query5, $params, $options);
}
else
$setToken =sqlsrv_query($conn2, $Query5, $params, $options);
if ($setToken)
die('OK#'.$Token);
else
die('SetToken Error');
}
sqlsrv_close($conn2);
}
function sql_clean($str)
{
$search = array("\\", "\0", "\n", "\r", "\x1a", "'", '"', '(', ')');
$replace = array("", "", "", "", "", "", "", "", "");
return str_replace($search, $replace, $str);
}
function RandomToken( $length )
{
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$str = "";
$size = strlen( $chars );
for( $i = 0; $i < $length; $i++ ) {
$str .= $chars[ rand( 0, $size - 1 ) ];
}
return $str;
}
?>
The reason for this as a release also is because i feel 5.3.1 is a little basic but this new system i'm even new to, and i had help from Lugapha
oh This one uses nAuthID in the SQL 4 = banned, 2 = Email not verified, 1 = Under Maintenance, this one doesn't have the Account Under Admin Control (that would be normally 9)
Last edited: