AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Replace quotes (https://forums.alliedmods.net/showthread.php?t=211697)

killergirl 03-25-2013 04:33

Replace quotes
 
I'm trying to insert safe data in my data base and I have written a function which replaces a few invalid symbols, I don't know why but I'm getting interesting strings which I can't copy+paste here because It can't be copied !

PHP Code:

public client_putinserver(id){
    static 
name[32]

    
get_user_name(idname31)
    
formatex(name31safe_string(name))

    
server_print(name)
}

public 
safe_string(string[]){
    new 
buffer[32]
    
    
copy(buffer31string)
    
replace_all(buffercharsmax(buffer), "^'""")
    
replace_all(buffercharsmax(buffer), "^"", "")
    replace_all(buffer, charsmax(buffer), "
\", "")
    replace_all(buffer, charsmax(buffer), "
/", "")
    
    return buffer



Podarok 03-25-2013 09:25

Re: Replace quotes
 
I dont really understand your problem. This works fine for me :
Code:
new name[32];     get_user_info(id, "name", name,31);     server_print("unsecured namex: %s",name);     //secure it     replace_all(name, 31, "\", "");     replace_all(name, 31, "'", "");     replace_all(name, 31, "`", "");     server_print("secured namex: %s",name);

^SmileY 03-25-2013 12:29

Re: Replace quotes
 
Se advanced bans code its have a good method to replace insecure chars from an string :)

>> http://forums.alliedmods.net/showthread.php?t=80858


All times are GMT -4. The time now is 16:17.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.