• Gmod ban database (Lua/Html)
    6 replies, posted
I have been trying to make it when we ban on our server through ULX it writes to a database on our website ravencrew.com and can be accessible though login in as an admin, and I cannot figure out how to do it. If you have an suggestions/would like to help please comment below/add me on steam: -=R|C=- Gmanc2!
You need to understand that if you come here asking for help, you should have a budget. People don't do things for free, time is money afterall. PS; Get a different default forum theme that doesn't make the eyes bleed on contact.
ULX gbans - [url]http://forums.ulyssesmod.net/index.php/topic,5878.0.html[/url] MySQLOO - [url]http://facepunch.com/showthread.php?t=1220537[/url]
Writing the bans to the database is a good start. Well done. You are going to need some script on the server to read the database and then output the result as HTML. The ones which are more likely to be compatible with your web hosting are Python and PHP. Before you go ahead and start hacking together some system, you should look at what already exists. A google search for "ulx bans website" came up with this. [url]http://forums.ulyssesmod.net/index.php?topic=5347.0[/url]
Write the bans to the MySQL database then create a quick PHP script to connect to the MySQL database, run a 'SELECT * FROM bans' query and then just loop through the results array and write them to the table. e.g [QUOTE] <?php //SQL code goes here //Write to database ?> <table> <tr> <th>Username</th> <th>Steam ID</th> <th>Date</th> </tr> <?php foreach($bans as $ban) { ?> <tr> <td><?php echo($ban['name']); ?></td> <td><?php echo($ban['steamid']); ?></td> <td><?php echo($ban['date']); ?></td> </tr> <?php } ?> </table> [/QUOTE] Then put the php script in a protected directory using cPanel. Probably a nicer way of doing this but it'd work.
[QUOTE=benbb;41709735]Write the bans to the MySQL database then create a quick PHP script to connect to the MySQL database, run a 'SELECT * FROM bans' query and then just loop through the results array and write them to the table. e.g Then put the php script in a protected directory using cPanel. Probably a nicer way of doing this but it'd work.[/QUOTE] [b]Please make sure to HTML escape the username using [url=http://us.php.net/manual/en/function.htmlspecialchars.php]htmlspecialchars($username, ENT_QUOTES)[/url] first.[/b] Else, somebody could do pretty bad things to your website by changing their Steam name to valid HTML snippets. Even if nobody would exploit this, the site would break eventually anyhow - as soon as someone has a "<" in their name, things probably would get ugly really quick.
[QUOTE=Alternative Account;41727977][b]Please make sure to HTML escape the username using [url=http://us.php.net/manual/en/function.htmlspecialchars.php]htmlspecialchars($username, ENT_QUOTES)[/url] first.[/b] Else, somebody could do pretty bad things to your website by changing their Steam name to valid HTML snippets. Even if nobody would exploit this, the site would break eventually anyhow - as soon as someone has a "<" in their name, things probably would get ugly really quick.[/QUOTE] Here is a little example that took me like a minute to make (it's pretty rough, and hasn't been tested, but should work): [CODE] <?php $mysqli = new mysqli($db_hostname, $db_user, $db_pass, $db_name); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } //desc limit can be changed obviously if ($stmt = $mysqli -> prepare("SELECT name,reason,length FROM `bans` DESC LIMIT 10")) { foreach($bans as $ban) { $stmt -> execute(); $stmt -> bind_result($ban_plyn,$ban_reason,$ban_length); $stmt -> fetch(); $ban_plyname = htmlspecialchars($ban_plyn, ENT_QUOTES); } } $stmt -> close(); $mysqli -> close(); ?> [/CODE] You can then echo the resulting data with foreach. I don't know if that works, but it should.
Sorry, you need to Log In to post a reply to this thread.