Raised This Month: $9 Target: $400
 2% 

[CS:GO] banned_user data tranfer to Mysql_bans


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
klikk
Junior Member
Join Date: Apr 2021
Old 10-15-2021 , 04:42   [CS:GO] banned_user data tranfer to Mysql_bans
Reply With Quote #1

I have PHP code that i looked for someone write on this forum but i can't figure it out how can i run it and can someone help me? This code can automaticlly transfer banned_user.cfg data to Mysql_bans database that it created of plugin itself. I need it because i got up to 500 clients data on it and it is stressful to tranfer by hand.

Plugin - https://forums.alliedmods.net/showthread.php?t=191283
And the PHP code author - https://forums.alliedmods.net/showpo...2&postcount=68

Code:
<?php
    
    $config    =    array(
        
        'db_prefix'    =>    'my',    //default prefix is my, so this shouldn't need to be changed.
        'host'        =>    'locahost',    //your database host, probably 127.0.0.1, or something
        'user'        =>    'myuseruser',    //your database username
        'pass'        =>    'mypassword',    //your database password
        'db'        =>    'mydatabase_name',    //and your database name
        
    );
    
    $db    =    mysqli_connect($config['host'], $config['user'], $config['pass'], $config['db']);
    if(!$db)die('There was an error connecting to the database.');
    
    $file = file('banned_user.cfg', FILE_SKIP_EMPTY_LINES);
    $query = array();
    
    foreach($file as $ban){
        $ban = explode(' ', substr($ban, 6));
        
        $query[] = 'INSERT INTO `'.$config['db_prefix'].'_bans`
            (steam_id, player_name, ban_length, ban_reason, banned_by, timestamp) VALUES
            (\''.mysqli_real_escape_string($db, $ban[1]).'\', \'Imported Ban\', '.((int)$ban[0]).', \'Imported Ban\', \'Console\', CURRENT_TIMESTAMP())';
            
    }
    
    $res = mysqli_multi_query($db, implode('; ', $query);
    if(!$res)die('One or more queries failed when importing the bans.');
    
?>

Last edited by klikk; 10-15-2021 at 04:48.
klikk is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-17-2021 , 11:41   Re: [CS:GO] banned_user data tranfer to Mysql_bans
Reply With Quote #2

What would happen, if you execute ban file ?

sm_rcon exec banned_user.cfg

*edit
About PHP, if you have home page which support PHP:
- create PHP file with that script, fill your mysql database parameters.
- copy banned_user.cfg in same folder.
-> ...go look that created PHP page from web ?
__________________
Do not Private Message @me

Last edited by Bacardi; 10-17-2021 at 11:45.
Bacardi is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:21.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode