serial calculation
#1

<p>You maybe noticed, in t_inven or t_stash you see a strange number example: "LR9JCa08R", this is the serial,

 

you can decode this into:

itemguid: 523
creation date: 19.09.2011
creation time: 12:36
server: 1
channel 1

but how is it calculated ? it's usefull to know this for a webmall, here a sample php code:

 

how to use: 2 any number

function calcSerial($item_guid){

$arrSerial = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$year = (int)date("Y");
$month = (int)date("m");
$day = (int)date("d");
$hour = (int)date("G");
$minute = (int)date("i");
$second = (int)date("s");
$server = (int)1;
$channel = (int)1;
$serial = array(20);

// calculate Server + Channel
$temp1 = (20 * $server + $channel) % 62;
if ($temp1 < 0 ) $temp1 = 0;
$serial[0] = $arrSerial[$temp1 % 62];

// calculate time
$serial[1] = $arrSerial[$year % 62];
$serial[2] = $arrSerial[$month % 62];
$serial[3] = $arrSerial[$day % 62];
$serial[4] = $arrSerial[$hour % 62];
$serial[5] = $arrSerial[$minute % 62];
$serial[6] = $arrSerial[$second % 62];

// avoid negative guid
If ($item_guid < 0) $item_guid = -$item_guid;

// calculate item guid
$temp2 = $item_guid % 238328;
$temp3 = (int)($temp2 / 62);
$temp4 = (int)($temp3 / 62);

$serial[7] = $arrSerial[$temp4 % 62];
$serial[8] = $arrSerial[$temp3 % 62];
$serial[9] = $arrSerial[$temp2 % 62];

//return
return $serial[0].$serial[1].$serial[2].$serial[3].$serial[4].$serial[5].$serial[7].$serial[8].$serial[9];
}



Messages In This Thread
[No subject] - by Falo - 10-02-2011, 11:44 PM
[No subject] - by Wizatek - 10-02-2011, 11:59 PM
[No subject] - by Falo - 10-03-2011, 12:46 AM
[No subject] - by maxig - 10-04-2011, 09:55 AM
[No subject] - by rioking - 10-11-2011, 11:58 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)