14.12.2014, 12:54
Quote:
This should do:
Код:
function ChangePassword( ) { new liRows = cache_get_row_count( ), liKey; new Cache:cache = cache_save(); for( new rowid = 0; rowid < liRows; rowid ++ ) { cache_set_active(cache); liKey = cache_get_row_int( rowid, 0 ); format( gsQuery, 1024, "UPDATE `Accounts` SET `Password` = '%s' WHERE `Key` = %d", SHA512_Account( liKey, gsString, "password" ), liKey ); mysql_pquery( 1, gsQuery ); // because SHA512_Account function has been executed, the result set is now empty and the following rows are returning only 0. I think that this result set is deleted when the one from mysql_query is created and activated. } cache_delete(cache); } |
pawn Код:
stock SHA512_Account( key, salt[ ], password[ ] )
{
new Cache:liCache = cache_save( ); // this
format( gs_lsString, 129, "SELECT sha2( '%d%s%s', 512 )", key, salt, mysql_escape_stringEx( password ) );
giCache = mysql_query( 1, gs_lsString );
cache_get_row( 0, 0, gs_lsString, 1 );
cache_delete( giCache );
cache_set_active( liCache ); // this
return gs_lsString;
}