Welcome to RaGEZONE - MMORPG Development Forums (sponsored by tfn.gr) Mark forums read | View Forum Leaders
RaGEZONE - MMORPG Development Forums (sponsored by tfn.gr)

Knight Releases Discuss, [Share][PHP][KO Panel] Restat Script (SNOXDKO) at Knight Online forum; I've used the same description/introduction as in the Nation Transfer topic since incase others didn't read both topics etc. Due ...




Reply
Thread Tools
[Share][PHP][KO Panel] Restat Script (SNOXDKO)
 
 
Average Member

Rank: Omicron


Reply With Quote
 
Join Date: Dec 2006
Posts: 64
06-18-2008, 11:47 AM
 
I've used the same description/introduction as in the Nation Transfer topic since incase others didn't read both topics etc.

Due to the panel being totally re-written, I've decided to release some of the older scripts from the SnoxdKO Panel. By common request I've began with Nation Transfer and Character Restat(Which will be posted momentarily).
All I ask is that the credits in the title are left intact, or the releases will stop.

There's a few things for example Killing connected users which can't be released as they communicate with another application which currently is private.
Also, you'll need to remove the logging unless you're gonna reproduce the table (I'll post the SQL for it here, later).

Both scripts are 100% as were used on SnoxdKO (I haven't modified any of it, including the comments)

Anyway, enjoy:

PHP Code:
<?php 
// Restat - Not really commented it much atm - I'll finish commenting later.
require('./anti_inject.php');
require(
'./kill_user.php');

parth1tr();
parth1('100%'2'center');
echo 
'Character Restat - Beta - by BlaDe @ Snoxd.net';
parth2();
parth2tr();
//ini_set('error_reporting', '1');
//ini_set('display_errors', '1');

if (isset($_SESSION['sesuser'])) {
    if (
$_GET['Confirmed'] == 1) {
        
$user trim($_POST['Character']);
        
$stat trim($_POST['stat']);
        
$user test($user);
        
$stat test($stat);
        
$connect odbc_connect($dbname$dbuser$dbpass);

        
$query "SELECT COUNT(*) FROM RESTAT_LOG WHERE DATEDIFF(hh,[Date],GETDATE()) < 24 AND AccountID = '" $_SESSION['sesuser'] . "'";
        
$results odbc_exec($connect$query);
        while (
odbc_fetch_row($results)) {
            
$logcheck odbc_result($results1);
        } 
        if (
$logcheck 0) {
            
part1('100%'11'center');
            echo 
'</br>You may only use this feature once every 24hours.';
            echo 
'</br></br><a href="./index.php">Back</a></br>';
            
part2();
            die();
        } 
        
$getuser "SELECT strCharID FROM CURRENTUSER where strAccountID = '" $_SESSION['sesuser'] . "'";
        
$getusere odbc_exec($connect$getuser);
        
$characterID odbc_result($getusere1);

        if (
strlen(trim($characterID)) > 0) {
            
$killed 1;
            
KillUserAndWait(trim($characterID), $connect);
        } 
        if (
strlen($user) == 0) {
            
part1('100%'11'center');
            echo 
'</br>You\'r Character was invalid!';
            echo 
'</br></br><a href="./index.php">Back</a></br>';
            
part2();
            die();
        } 

        if (
strlen($stat) == 0) {
            
part1('100%'11'center');
            echo 
'</br>You havn\'t selected a basic stat point!';
            echo 
'</br></br><a href="./index.php">Back</a></br>';
            
part2();
            die();
        } 
        
// Anti SQL Inject shit - I'm not sure if it's even possible to manipulate the values of a combo
        // However - I'd personally rather not risk it.
        // Get the current stats n race ;o
        
$query "SELECT Strong, Cha, Dex, Intel, Sta, Points, Race, Gold, strItem FROM USERDATA WHERE strUserID ='" $user "'";
        
$results odbc_exec($connect$query);
        while (
odbc_fetch_row($results)) {
            
$str odbc_result($results1);
            
$mp odbc_result($results2);
            
$dex odbc_result($results3);
            
$int odbc_result($results4);
            
$hp odbc_result($results5);
            
$rem odbc_result($results6);
            
$race odbc_result($results7);
            
$cash odbc_result($results8);
            
$items odbc_result($results9);
        } 
        if (
$cash 500000000) {
            
part1('100%'11'center');
            echo 
'</br>You havn\'t got enough money!';
            echo 
'</br>You must have 500 Million GP in your inventory.';
            echo 
'</br></br><a href="./index.php">Back</a></br>';
            
part2();
            die();
        } 
     
//    lame slow method by Goat® (K)
     //   for ($itempos = 0; $itempos < 104; $itempos++) { if ($items[$itempos] != 0) { $notnull = 1; } } 
     
        
if (!preg_match('/^\x00{103}/',$items)) {
             
part1('100%'11'center');
            echo 
'</br>You\'r Character isn\'t naked!';
            echo 
'</br></br><a href="./index.php">Back</a></br>';
            
part2();
            die();
        } 
        
// Calculate the new stats based on race
        // Also sum up the old stats to obtain a total value
        
$total $str $mp $dex $int $hp $rem;
        if ((
$race == 1) || ($race == 2) || ($race == 11)) {
            
$stats = array(6565605050);
        } elseif ((
$race == 3) || ($race == 13)) {
            
$stats = array(5050707050);
        } elseif (
$race == 4) {
            
$stats = array(5060607050);
        } elseif (
$race == 12) {
            
$stats = array(6060705050);
        } 
        
$newstr $stats[0];
        
$newmp $stats[4];
        
$newdex $stats[2];
        
$newint $stats[3];
        
$newhp $stats[1];
        
$newcash $cash 500000000;
        
$total $total $newstr $newmp $newdex $newint $newhp
        
// Add the basic stat points..
        
if ($total 255) {
            
$toallocate $total 255;
            if (
$stat == "str") {
                
$newstr $newstr $toallocate;
            } elseif (
$stat == "dex") {
                
$newdex $newdex $toallocate;
            } elseif (
$stat == "int") {
                
$newint $newint $toallocate;
            } elseif (
$stat == "mp") {
                
$newmp $newmp $toallocate;
            } elseif (
$stat == "hp") {
                
$newhp $newhp $toallocate;
            } 
        } 
        
// Update SQL
        
if ($total 255) { $total $total $toallocate; }
        if ((
$newint 0) && ($newdex 0) && ($newstr 0) && ($newmp 0) && ($newhp 0) && ($total 0)) {
            
$query "INSERT INTO RESTAT_LOG([Date], AccountID, CharID, Strong, Cha, Dex, Intel, Sta, Points, OldGold, NewGold) VALUES (GETDATE(), '" $_SESSION['sesuser'] . "', '$user', $newstr, $newmp, $newdex, $newint, $newhp, $total, $cash, $newcash)";
            
$results odbc_exec($connect$query);
            
$query "UPDATE USERDATA SET Strong = $newstr, Cha = $newmp, Dex = $newdex, Intel = $newint, Sta = $newhp, Points = $total, Gold = $newcash WHERE strUserId = '$user'";
            
$results odbc_exec($connect$query);
            
part1('100 % '11'center');
            echo 
'Success!</br>';
            echo 
'</br>New Strength:' $newstr '</br>New Magic Power:' $newmp '</br>New Dexterity:' $newdex '</br>New Intelligence:' $newint '</br>New Health:' $newhp '</br>Unused:' $total '</br></br>New Cash:' $newcash;
            if (
$killed == 1) {
                echo 
'</br></br> This character was disconnected during the restat process.';
            } 
            
part2();
        } else {
            
// Error code #000002 - I just made up numbers so we know what occured.
            
die("Error Code: #000002");
        } 
    } else {
        
$connect odbc_connect($dbname$dbuser$dbpass);
        
$query "SELECT strCharID1, strCharID2, strCharID3 FROM Account_Char WHERE strAccountID ='" $_SESSION['sesuser'] . "' ";
        
$results odbc_exec($connect$query);
        while (
odbc_fetch_row($results)) {
            
$char1 odbc_result($results1);
            
$char2 odbc_result($results2);
            
$char3 odbc_result($results3);
        } 
        if ((empty(
$char1)) && (empty($char2)) && (empty($char3))) {
            
part2();
            
part1('100%'11'center');
            echo 
'</br>You don\'t have a character to restat';
            echo 
'</br></br><a href="./index.php">Back</a></br>';
            
part2();
        } else {
            
part1tr();
            
part1('25%'11'center');
            echo 
'Please select a character to restat:</br>';
            echo 
'You will also have to re-select your basic stat point!</br></br></br>';
            echo 
'<center></br>
            <FORM method=post name=restat action=index.php?act=Restat&Confirmed=1 style="margin:0px; padding:0px">
            <select name="Character">'
;
            foreach (array(
$char1$char2$char3) as $char) {
                if (
$char != "") {
                    
$chars 0;
                    
$query "SELECT Level FROM USERDATA WHERE strUserID = '" $char "'";
                    
$results odbc_exec($connect$query);
                    while (
odbc_fetch_row($results)) {
                        
$lvl odbc_result($results1);
                    } 
                    if (
$lvl == '') {
                        
// Error code #000001 - Also made up .. 6 digits looks more professional (H)
                        
die('error code: #000001');
                    } 
                    if (
$lvl >= 70) {
                        
$chars++;
                        echo 
'<OPTION>' $char '</option>';
                    } 
                } 
            } 
            echo 
'</select></br></br>
        
            <input type="radio" name="stat" value="str"> Strength
            <input type="radio" name="stat" value="dex"> Dexterity
            <input type="radio" name="stat" value="mp"> Magic Power
            <input type="radio" name="stat" value="int"> Intelligence
            <input type="radio" name="stat" value="hp"> Health
            </center></br></br>'
;

            if (
$chars == 0) {
                
part2tr();
                
part1tr();
                
part1('100 % '11'center');
                echo 
'You don\'t have a character above level 70!';
                
part2();
                
part2tr();
                die();
            } else {
                echo
'<li>You may only use this feature <b>once</b> every 24 hours</li>
        <li>You must be <b>logged out</b> of the selected character to proceed</li>
        <li>You must be naked on the selected character</li>
        <li>You must have 500 Million coins in the Inventory of the Character you wish to be Transfered
        </br></br>
            <input class="input" type="submit" value="Confirm">
            </form>'
;
                
part2();
                
part2tr();
            } 
        } 
    } 
} else {
    
part1('100%'11'center');
    echo 
'You must login first!';
    
part2();


?>
Feel free to post if you have any issues, questions or requests.

Thanks,

BlaDe.
 
 
permalink
 

RaGEZONE is proudly sponsored by
 
Retired OurKO Hoster

Rank: (E)Subscriber


Reply With Quote
 
Join Date: Aug 2007
Location: In My Room
Posts: 210
06-18-2008, 12:57 PM
 
TY for this also.
 
 
permalink
 

 
Average Member

Rank: Omicron


Reply With Quote
 
Join Date: Dec 2006
Posts: 64
06-18-2008, 04:39 PM
 
CREATE TABLE [dbo].[RESTAT_LOG] (
[Date] [datetime] NOT NULL ,
[AccountID] [char] (21) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[CharID] [char] (21) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Strong] [tinyint] NOT NULL ,
[Cha] [tinyint] NOT NULL ,
[Dex] [tinyint] NOT NULL ,
[Intel] [tinyint] NOT NULL ,
[Sta] [tinyint] NOT NULL ,
[Points] [tinyint] NOT NULL ,
[OldGold] [int] NOT NULL ,
[NewGold] [int] NOT NULL
) ON [PRIMARY]
GO

The table used.
 
 
permalink
 


 
Retired OurKO Hoster

Rank: (E)Subscriber


Reply With Quote
 
Join Date: Aug 2007
Location: In My Room
Posts: 210
07-13-2008, 06:49 PM
 
I having problems with this script..

Its saying to my users, they dont have characters above level 70, But infact they do..

Thanks for any help..
 
 
permalink
 

 
Retired OurKO Hoster

Rank: (E)Subscriber


Reply With Quote
 
Join Date: Aug 2007
Location: In My Room
Posts: 210
07-13-2008, 08:38 PM
 
Fixed 100%

Code:
<?php 
// Restat - Not really commented it much atm - I'll finish commenting later.
require('./anti_inject.php');

parth1tr();
parth1('100%', 2, 'center');
echo 'Character Restat';
parth2();
parth2tr();
//ini_set('error_reporting', '1');
//ini_set('display_errors', '1');

if (isset($_SESSION['sesuser'])) {
    if ($_GET['Confirmed'] == 1) {
        $user = trim($_POST['Character']);
        $stat = trim($_POST['stat']);
        $user = test($user);
        $stat = test($stat);
        $connect = odbc_connect($dbname, $dbuser, $dbpass);

        $query = "SELECT COUNT(*) FROM RESTAT_LOG WHERE DATEDIFF(hh,[Date],GETDATE()) < 24 AND AccountID = '" . $_SESSION['sesuser'] . "'";
        $results = odbc_exec($connect, $query);
        while (odbc_fetch_row($results)) {
            $logcheck = odbc_result($results, 1);
        } 
        if ($logcheck > 0) {
            part1('100%', 1, 1, 'center');
            echo '</br>You may only use this feature once every 24hours.';
            echo '</br></br><a href="./index.php">Back</a></br>';
            part2();
            die();
        } 
        $getuser = "SELECT strCharID FROM CURRENTUSER where strAccountID = '" . $_SESSION['sesuser'] . "'";
        $getusere = odbc_exec($connect, $getuser);
        $characterID = odbc_result($getusere, 1);

        if (strlen(trim($characterID)) > 0) {
            $killed = 1;
            KillUserAndWait(trim($characterID), $connect);
        } 
        if (strlen($user) == 0) {
            part1('100%', 1, 1, 'center');
            echo '</br>You\'r Character was invalid!';
            echo '</br></br><a href="./index.php">Back</a></br>';
            part2();
            die();
        } 

        if (strlen($stat) == 0) {
            part1('100%', 1, 1, 'center');
            echo '</br>You havn\'t selected a basic stat point!';
            echo '</br></br><a href="./index.php">Back</a></br>';
            part2();
            die();
        } 
        // Anti SQL Inject shit - I'm not sure if it's even possible to manipulate the values of a combo
        // However - I'd personally rather not risk it.
        // Get the current stats n race ;o
        $query = "SELECT Strong, Cha, Dex, Intel, Sta, Points, Race, Gold, strItem FROM USERDATA WHERE strUserID ='" . $user . "'";
        $results = odbc_exec($connect, $query);
        while (odbc_fetch_row($results)) {
            $str = odbc_result($results, 1);
            $mp = odbc_result($results, 2);
            $dex = odbc_result($results, 3);
            $int = odbc_result($results, 4);
            $hp = odbc_result($results, 5);
            $rem = odbc_result($results, 6);
            $race = odbc_result($results, 7);
            $cash = odbc_result($results, 8);
            $items = odbc_result($results, 9);
        } 
        if ($cash < 500000000) {
            part1('100%', 1, 1, 'center');
            echo '</br>You havn\'t got enough money!';
            echo '</br>You must have 500 Million GP in your inventory.';
            echo '</br></br><a href="./index.php">Back</a></br>';
            part2();
            die();
        } 
     //    lame slow method by Goat® (K)
     //   for ($itempos = 0; $itempos < 104; $itempos++) { if ($items[$itempos] != 0) { $notnull = 1; } } 
     
        if (!preg_match('/^\x00{103}/',$items)) {
             part1('100%', 1, 1, 'center');
            echo '</br>You\'r Character isn\'t naked!';
            echo '</br></br><a href="./index.php">Back</a></br>';
            part2();
            die();
        } 
        // Calculate the new stats based on race
        // Also sum up the old stats to obtain a total value
        $total = $str + $mp + $dex + $int + $hp + $rem;
        if (($race == 1) || ($race == 2) || ($race == 11)) {
            $stats = array(65, 65, 60, 50, 50);
        } elseif (($race == 3) || ($race == 13)) {
            $stats = array(50, 50, 70, 70, 50);
        } elseif ($race == 4) {
            $stats = array(50, 60, 60, 70, 50);
        } elseif ($race == 12) {
            $stats = array(60, 60, 70, 50, 50);
        } 
        $newstr = $stats[0];
        $newmp = $stats[4];
        $newdex = $stats[2];
        $newint = $stats[3];
        $newhp = $stats[1];
        $newcash = $cash - 500000000;
        $total = $total - $newstr - $newmp - $newdex - $newint - $newhp; 
        // Add the basic stat points..
        if ($total > 255) {
            $toallocate = $total - 255;
            if ($stat == "str") {
                $newstr = $newstr + $toallocate;
            } elseif ($stat == "dex") {
                $newdex = $newdex + $toallocate;
            } elseif ($stat == "int") {
                $newint = $newint + $toallocate;
            } elseif ($stat == "mp") {
                $newmp = $newmp + $toallocate;
            } elseif ($stat == "hp") {
                $newhp = $newhp + $toallocate;
            } 
        } 
        // Update SQL
        if ($total > 255) { $total = $total - $toallocate; }
        if (($newint > 0) && ($newdex > 0) && ($newstr > 0) && ($newmp > 0) && ($newhp > 0) && ($total > 0)) {
            $query = "INSERT INTO RESTAT_LOG([Date], AccountID, CharID, Strong, Cha, Dex, Intel, Sta, Points, OldGold, NewGold) VALUES (GETDATE(), '" . $_SESSION['sesuser'] . "', '$user', $newstr, $newmp, $newdex, $newint, $newhp, $total, $cash, $newcash)";
            $results = odbc_exec($connect, $query);
            $query = "UPDATE USERDATA SET Strong = $newstr, Cha = $newmp, Dex = $newdex, Intel = $newint, Sta = $newhp, Points = $total, Gold = $newcash WHERE strUserId = '$user'";
            $results = odbc_exec($connect, $query);
            part1('100 % ', 1, 1, 'center');
            echo 'Success!</br>';
            echo '</br>New Strength:' . $newstr . '</br>New Magic Power:' . $newmp . '</br>New Dexterity:' . $newdex . '</br>New Intelligence:' . $newint . '</br>New Health:' . $newhp . '</br>Unused:' . $total . '</br></br>New Cash:' . $newcash;
            if ($killed == 1) {
                echo '</br></br> This character was disconnected during the restat process.';
            } 
            part2();
        } else {
            // Error code #000002 - I just made up numbers so we know what occured.
            die("Error Code: #000002");
        } 
    } else {
        $connect = odbc_connect($dbname, $dbuser, $dbpass);
        $query = "SELECT strCharID1, strCharID2, strCharID3 FROM Account_Char WHERE strAccountID ='" . $_SESSION['sesuser'] . "' ";
        $results = odbc_exec($connect, $query);
        while (odbc_fetch_row($results)) {
            $char1 = odbc_result($results, 1);
            $char2 = odbc_result($results, 2);
            $char3 = odbc_result($results, 3);
        } 
        if ((empty($char1)) && (empty($char2)) && (empty($char3))) {
            part2();
            part1('100%', 1, 1, 'center');
            echo '</br>You don\'t have a character to restat';
            echo '</br></br><a href="./index.php">Back</a></br>';
            part2();
        } else {
            part1tr();
            part1('25%', 1, 1, 'center');
            echo 'Please select a character to restat:</br>';
            echo 'You will also have to re-select your basic stat point!</br></br></br>';
            echo '<center></br>
            <FORM method=post name=restat action=index.php?act=Restat&Confirmed=1 style="margin:0px; padding:0px">
            <select name="Character">';
            foreach (array($char1, $char2, $char3) as $char) {
                if ($char != "") {
                    $chars = 3;
                    $query = "SELECT Level FROM USERDATA WHERE strUserID = '" . $char . "'";
                    $results = odbc_exec($connect, $query);
                    while (odbc_fetch_row($results)) {
                        $lvl = odbc_result($results, 1);
                    } 
                    if ($lvl == '') {
                        // Error code #000001 - Also made up .. 6 digits looks more professional (H)
                        die('error code: #000001');
                    } 
                    if ($lvl >= 70) {
                        $chars++;
                        echo '<OPTION>' . $char . '</option>';
                    } 
                } 
            } 
            echo '</select></br></br>
        
            <input type="radio" name="stat" value="str"> Strength
            <br />
            <input type="radio" name="stat" value="dex"> Dexterity
            <br />
            <input type="radio" name="stat" value="mp"> Magic Power
            <br />
            <input type="radio" name="stat" value="int"> Intelligence
            <br />
            <input type="radio" name="stat" value="hp"> Health
            </center></br></br>';

            if ($chars == 0) {
                part2tr();
                part1tr();
                part1('100 % ', 1, 1, 'center');
                echo 'You don\'t have a character above level 70!';
                part2();
                part2tr();
                die();
            } else {
                echo'<li>You may only use this feature <b>once</b> every 24 hours</li>
        <li>You must be <b>logged out</b> of the selected character to proceed</li>
        <li>You must be naked on the selected character</li>
        <li>You must have 500 Million coins in the Inventory of the Character you wish to Restat
        </br></br>
            <input class="input" type="submit" value="Confirm">
            </form>';
                part2();
                part2tr();
            } 
        } 
    } 
} else {
    part1('100%', 1, 1, 'center');
    echo 'You must login first!';
    part2();
} 

?>
Credits to BlaDe for the script and credits to me for the edits..

Last edited by lollipop07; 07-13-2008 at 10:52 PM.
 
 
permalink
 

 
Newbie

Rank: Omicron


Reply With Quote
 
Join Date: Sep 2007
Posts: 23
07-17-2008, 03:14 AM
 
The bug with this is you can restat with your armor or weapon on... The one I made does an inventory check and makes you put everything in the warehouse. Now my only bug is the items that you can't put in the warehouse. I could do a further check on the item numbers to allow in your inventory to restat. I didnt look over you code too well but make sure uses can't lower a starting stat value to use the points in another. like making your int 10.
 
 
permalink
 

 
SecretSquirrel

Rank: Member


Reply With Quote
 
Join Date: Jun 2006
Location: Perfect World - Yaoshous the Awakening
Posts: 1,475
07-22-2008, 09:18 PM
 
hmm getting action not found Error
Action not found, Please click here
[Only Registered and Activated Users Can See Links. Click Here To Register...]

Last edited by Advocate; 07-23-2008 at 03:07 AM.
 
 
permalink
 

 
Retired OurKO Hoster

Rank: (E)Subscriber


Reply With Quote
 
Join Date: Aug 2007
Location: In My Room
Posts: 210
07-22-2008, 10:37 PM
 
Moderator should remove advocates link, as its advertising his KO server.

This is just a redirect to his KO panel..
 
 
permalink
 

 
SecretSquirrel

Rank: Member


Reply With Quote
 
Join Date: Jun 2006
Location: Perfect World - Yaoshous the Awakening
Posts: 1,475
07-23-2008, 03:06 AM
 
wasnt meaning to do that was showing what happen after you restat what came up zzzz like i care if my server is showed rather not keeps hackers and dupers out .
there i edited my post happy now instead of bitching about my link how do we solve my problem.
 
 
permalink
 

 
Retired OurKO Hoster

Rank: (E)Subscriber


Reply With Quote
 
Join Date: Aug 2007
Location: In My Room
Posts: 210
07-23-2008, 11:40 AM
 
Quote: Originally Posted by Advocate View Post
wasnt meaning to do that was showing what happen after you restat what came up zzzz like i care if my server is showed rather not keeps hackers and dupers out .
there i edited my post happy now instead of bitching about my link how do we solve my problem.

Yup, same rule applys for everyone else I jusy simpily made an observation no need to be nasty about it, was I?

For your problem.


You need to put the Restat.php script in your Functions folder.

You need to edit user.php

PHP Code:
} elseif ($_GET['actu'] == "Restat") {
            
$security 1;
            include(
"./Restat.php");
        } 

You need to Edit skins/default/Main.php (2 Places)

1st
PHP Code:
<div>• <a href="index.php?act=user&actu=Restat">Restat</a></div
2nd
PHP Code:
<div>• <a href="index.php?act=user&actu=Restat">Restat</a></div
However alough this script works, there is some bugs.

Not all users can use this script successfully.

Some mages, some priests try to use it and it has no effect..

And BTW it does have a check if you are wearing armours so Ignore 'cherry' said.
 
 
permalink
 

 
SecretSquirrel

Rank: Member


Reply With Quote
 
Join Date: Jun 2006
Location: Perfect World - Yaoshous the Awakening
Posts: 1,475
07-23-2008, 11:05 PM
 
Quote: Originally Posted by lollipop07 View Post
Yup, same rule applys for everyone else I jusy simpily made an observation no need to be nasty about it, was I?

For your problem.


You need to put the Restat.php script in your Functions folder.

You need to edit user.php

PHP Code:
} elseif ($_GET