* Added the md5() script command. (follow up to r13719)

- Changed kafra storage password to be stored as md5 hash in #kafra_code$.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@13728 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
brianluau 2009-05-04 08:22:53 +00:00
parent 1b588722ad
commit 53998c9f3d
10 changed files with 60 additions and 11 deletions

View File

@ -3,6 +3,8 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2009/05/04
* Added the md5() script command. [brianluau]
2009/05/03
* Updated item_db.sql and mob_db.sql from recent changes to both. Thanks to Peter once again! [Jguy]
* Do not log damage if it's done by mob itself (bugreport:2933) [Inkfish]

View File

@ -5917,6 +5917,17 @@ set @i, distance(100,200,101,202);
---------------------------------------
*md5("<string>")
Returns the md5 checksum of a number or string.
Example:
mes md5(12345);
mes md5("12345"); // Will both display 827ccb0eea8a706c4c34a16891f84e7b
mes md5("qwerty"); // Will display d8578edf8458ce06fbc5bb76a58c5ca4
---------------------------------------
*query_sql "your MySQL query", <array variable> {,<array variable>, ...};
*query_logsql "your MySQL query", <array variable> {,<array variable>, ...};

View File

@ -1,6 +1,7 @@
Date Added
======
2009/05/04
- The md5 checksum of the kafra code is now stored in #kafra_code$ [brianluau]
- Added a missing zeny check in the Jawaii Bartender. (bugreport:2897) [brianluau]
- Added a missing 'close' in the Mage quest Bookshelf. (bugreport:2873)
2009/05/03

View File

@ -71,6 +71,7 @@
// - Special warpname menu option name bug fixed
//-2.1 Updated names to fall within retrictions. [L0ne_W0lf]
//-2.2 #kafra_code is now stored as is. [brianluau]
//-2.2b The md5() of their kafra code is now stored in #kafra_code$ [brianluau]
//=================================================================
//========================Function=&=Script========================
@ -597,11 +598,11 @@ L_Storage:
end;
F_CheckKafCode:
if(#kafra_code==0) return;
if(#kafra_code$=="") return;
mes "Enter your storage password:";
set @code_,0;
input @code_;
if(@code_ != #kafra_code) {
if(md5(@code_) != #kafra_code$) {
dispbottom "Wrong storage password.";
close;
}

View File

@ -58,6 +58,7 @@
//= 6.1 Added menu for Turbo Track Kafra Staff. [L0ne_W0lf]
//= 6.2 Updated/Fixed warp cords. [Kisuka]
//= 6.3 #kafra_code is now stored as is. [brianluau]
//= 6.3b The md5() of their kafra code is now stored in #kafra_code$ [brianluau]
//============================================================
@ -557,11 +558,11 @@ function script F_KafEnd {
// Check Storage Password Function ====================
function script F_CheckKafCode {
if(#kafra_code==0) return;
if(#kafra_code$=="") return;
mes "Enter your storage password:";
set @code_,0;
input @code_;
if(@code_ != #kafra_code) {
if(md5(@code_) != #kafra_code$) {
dispbottom "Wrong storage password.";
close2;
cutin "",255;
@ -576,7 +577,7 @@ function script F_CheckKafCode {
// getarg(0) = NPC Name, getarg(1) = Company Name
function script F_SetKafCode {
mes getarg(0);
if(#kafra_code) {
if(#kafra_code$) {
mes "Your storage is protected with a password. What would you do now?";
next;
menu "Change old password -> 5000z",-,
@ -593,7 +594,7 @@ function script F_SetKafCode {
mes getarg(0);
mes "At first, please enter your ^0000FFold password^000000.";
set @code,callfunc("F_EntKafCode");
if(@code==0 || @code != #kafra_code) {
if(@code==0 || md5(@code) != #kafra_code$) {
mes "Wrong password. You can't set a new password.";
emotion e_hmm;
goto M_END;
@ -615,7 +616,7 @@ M_SET:
set Zeny,Zeny-5000;
//set RESRVPTS, RESRVPTS + (5000/50); //hardcoded password doesn't add pts
set #kafra_code,@code;
set #kafra_code$,md5(@code);
mes "You've protected your storage with a secret password.";
mes "Thank you for using "+getarg(1)+".";
emotion e_thx;
@ -635,8 +636,8 @@ M_CLEAR:
if(Zeny < 1000) goto L_ZENY;
set Zeny,Zeny-1000;
//set RESRVPTS, RESRVPTS + (1000/50); //hardcoded password doesn't add pts
if(@code == #kafra_code) {
set #kafra_code,0;
if(md5(@code) == #kafra_code$) {
set #kafra_code$,"";
mes "You've successfully cleared your storage password.";
mes "Thank you for using "+getarg(1)+".";
emotion e_thx;

View File

@ -0,0 +1 @@
UPDATE `global_reg_value` SET `str`='#kafra_code$',`value`=MD5(`value`) WHERE `str` = '#kafra_code';

View File

@ -3,12 +3,12 @@ COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_a
../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \
../common/obj_all/nullpo.o ../common/obj_all/malloc.o ../common/obj_all/showmsg.o \
../common/obj_all/utils.o ../common/obj_all/strlib.o ../common/obj_all/grfio.o \
../common/obj_all/mapindex.o ../common/obj_all/ers.o
../common/obj_all/mapindex.o ../common/obj_all/ers.o ../common/obj_all/md5calc.o
COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h \
../common/db.h ../common/plugins.h ../common/lock.h \
../common/nullpo.h ../common/malloc.h ../common/showmsg.h \
../common/utils.h ../common/strlib.h ../common/grfio.h \
../common/mapindex.h ../common/ers.h
../common/mapindex.h ../common/ers.h ../common/md5calc.h
COMMON_SQL_OBJ = ../common/obj_sql/sql.o
COMMON_SQL_H = ../common/sql.h

View File

@ -9,6 +9,7 @@
#include "../common/cbasetypes.h"
#include "../common/malloc.h"
#include "../common/md5calc.h"
#include "../common/lock.h"
#include "../common/nullpo.h"
#include "../common/showmsg.h"
@ -11900,6 +11901,7 @@ BUILDIN_FUNC(pow)
script_pushint(st,(int)i);
return 0;
}
BUILDIN_FUNC(distance)
{
int x0, y0, x1, y1;
@ -11914,6 +11916,19 @@ BUILDIN_FUNC(distance)
}
// <--- [zBuffer] List of mathematics commands
BUILDIN_FUNC(md5)
{
const char *tmpstr;
char *md5str;
tmpstr = script_getstr(st,2);
md5str = (char *)aMallocA((32+1)*sizeof(char));
MD5_String(tmpstr, md5str);
script_pushstr(st, md5str);
return 0;
}
// [zBuffer] List of dynamic var commands --->
BUILDIN_FUNC(setd)
@ -13900,6 +13915,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(pow,"ii"),
BUILDIN_DEF(distance,"iiii"),
// <--- [zBuffer] List of mathematics commands
BUILDIN_DEF(md5,"s"),
// [zBuffer] List of dynamic var commands --->
BUILDIN_DEF(getd,"*"),
BUILDIN_DEF(setd,"*"),

View File

@ -254,6 +254,14 @@
RelativePath="..\src\common\malloc.h"
>
</File>
<File
RelativePath="..\src\common\md5calc.c"
>
</File>
<File
RelativePath="..\src\common\md5calc.h"
>
</File>
<File
RelativePath="..\src\common\mapindex.c"
>

View File

@ -501,6 +501,14 @@
RelativePath="..\src\common\malloc.h"
>
</File>
<File
RelativePath="..\src\common\md5calc.c"
>
</File>
<File
RelativePath="..\src\common\md5calc.h"
>
</File>
<File
RelativePath="..\src\common\mapindex.c"
>