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.');
?>