SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Tools and Files

Reply
 
Thread Tools Display Modes
Old 03/12/2009, 01:48 AM   #1
iLinx
High-roller
 
Join Date: Jun 2009
Location: Toronto
Posts: 1,498
Reputation: 157
Default [PHP] SA-MP Website Banlist Parser

SA-MP Website Banlist Parser

The code is now cleaner, and simpler to a degree. Basically, this little script i have written for you all allows you to show your banlist on your website, and format it in any way you want.

For example, you could show the ip's of the 10 most recent bans.

Documentation

void Bans::__construct(string $fHost, string $fUser, string $fPass)
Parameters
$fHost - remote ftp host to connect to
$fUser - remote ftp username to connect to
$fPass - remote ftp password to connect to

string Bans::rawList(string $fVar)
Description
Reads banlist and returns it as a string with each ban on a new line
Parameters
$fVar - the file to read from

void Bans::cron(string $remote_file)
Description
Downloads banlist as 'samp.ban', good for cronjob
Parameters
$remote_file - the remote file to download (eg. 'samp03svr/samp.ban' or 'samp.ban')

string Bans:arseBan(string $format, bool $ASC=TRUE, int $LIMIT=0, bool $todayOnly=false)
Description
Formats the banlist and other select options in the way you wish
Parameters
$format - the specified format to use when formatting the banlist. format arguments:
#DATE - date of the ban
#DTIME - date and time of the ban, separated by a '-' in the middle
#TIME - time of the ban
#USER - display the username that was banned
#IP - display the ip that was banned
#BTYPE - type of ban issued (eg, range ban)
$ASC - toggle to display the ban list in ascending format, true will order it ascending
false will order the ban list descending
$LIMIT - limit of bans to print, 0 for unlimited
$todayOnly - display only todays bans, true will only show todays bans, false will show all


Download (Class + Example)
Heres a Live Example.

Setup
Extract the Bans.rar and upload it to your website or wherever you have a PHP parser installed and would like to display the bans.
Setup a cron job to run however often you like (i recommend every 20 or so minutes) and point it to your cron job script which calls the Bans::cron function, an example cron job script is included in the download (example_cron.php)

Examples
There are two example files included
example_index.php
example_cron.php

example_index.php is an example page which shows how the parser can be used to format your banlist
example_cron.php is an example cron job script, little editing is necessary.

Additionally, here are some more examples of Bans:arseBan function, as it's documented quite confusingly.

PHP Code:
<?php
$Bans 
= new Bans("localhost""root""pass");
echo 
"<ul>";
echo 
$Bans->parseBan("<li>#USER(#IP) banned at #TIME, #DATE</li>"false10);
echo 
"</ul>";
?>
PHP Code:
<?php
$Bans 
= new Bans("localhost""root""pass");
echo 
$Bans->parseBan("#USER was banned at #TIME on #DATE, #BTYPE"false).'<br/>';
?>
__________________
Servers in Arizona, Virginia, Quebec (Canada), United Kingdom, Netherlands. Over 12,000 served. Free cPanel web hosting is included with ALL servers. ********. *******.

Last edited by iLinx; 29/06/2012 at 06:38 PM.
iLinx is offline   Reply With Quote
Old 03/12/2009, 03:27 PM   #2
Christopher.
Big Clucker
 
Join Date: Nov 2009
Posts: 111
Reputation: 1
Default Re: [PHP] Format your banlist [make it look however you want] (banlist parser cl

Awesome script, Handy for if you want a neat professional outlook on your ban list, Highly recommended PHP script!.
Christopher. is offline   Reply With Quote
Old 03/12/2009, 03:29 PM   #3
Luka P.
High-roller
 
Join Date: Feb 2009
Posts: 1,428
Reputation: 13
Default Re: [PHP] Format your banlist [make it look however you want] (banlist parser class)

Nice, but I'll never learn it
I'm starting with HTML and CSS, then I'll go to PHP and maybe try this.
Luka P. is offline   Reply With Quote
Old 03/12/2009, 03:45 PM   #4
Joske_Vermeulen
Big Clucker
 
Joske_Vermeulen's Avatar
 
Join Date: Mar 2007
Posts: 110
Reputation: 9
Default Re: [PHP] Format your banlist [make it look however you want] (banlist parser class)

I can't seem to connect, does it matter if it's SFTP instead FTP

I'm 100% sure the login details are correct
Joske_Vermeulen is offline   Reply With Quote
Old 03/12/2009, 04:59 PM   #5
KKashimia
Little Clucker
 
Join Date: Sep 2009
Posts: 40
Reputation: 0
Default Re: [PHP] Format your banlist [make it look however you want] (banlist parser class)

luv ur deescreepti0n mah C;
KKashimia is offline   Reply With Quote
Old 03/12/2009, 08:00 PM   #6
iLinx
High-roller
 
Join Date: Jun 2009
Location: Toronto
Posts: 1,498
Reputation: 157
Default Re: [PHP] Format your banlist [make it look however you want] (banlist parser class)

Quote:
Originally Posted by =Contador=
I can't seem to connect, does it matter if it's SFTP instead FTP

I'm 100% sure the login details are correct
I havent tested this but i just modified the class and changed the ftp to a ssl connection.
Download
If your using a port other than 21 for sftp, then in your cfg make sure you specify which port (ie cfg("samp.ban", "localhost", "root", "toor", YOUR PORT); )
__________________
Servers in Arizona, Virginia, Quebec (Canada), United Kingdom, Netherlands. Over 12,000 served. Free cPanel web hosting is included with ALL servers. ********. *******.
iLinx is offline   Reply With Quote
Old 07/12/2009, 10:44 PM   #7
kukars22
Big Clucker
 
Join Date: Apr 2008
Posts: 152
Reputation: 0
Default Re: [PHP] Format your banlist [make it look however you want] (banlist parser class)

this is all what I get:

Code:
Warning: fopen(samp.ban) [function.fopen]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\bans\ban.class.php on line 127

Warning: filesize() [function.filesize]: stat failed for samp.ban in C:\Program Files\xampp\htdocs\bans\ban.class.php on line 128

Warning: fread(): supplied argument is not a valid stream resource in C:\Program Files\xampp\htdocs\bans\ban.class.php on line 128

Warning: fclose(): supplied argument is not a valid stream resource in C:\Program Files\xampp\htdocs\bans\ban.class.php on line 129

Warning: join() [function.join]: Bad arguments. in C:\Program Files\xampp\htdocs\bans\ban.class.php on line 183
kukars22 is offline   Reply With Quote
Old 07/12/2009, 10:54 PM   #8
iLinx
High-roller
 
Join Date: Jun 2009
Location: Toronto
Posts: 1,498
Reputation: 157
Default Re: [PHP] Format your banlist [make it look however you want] (banlist parser cl

it means that samp.ban or whatever your calling your banfile isnt getting downloaded to your webserver properly
__________________
Servers in Arizona, Virginia, Quebec (Canada), United Kingdom, Netherlands. Over 12,000 served. Free cPanel web hosting is included with ALL servers. ********. *******.
iLinx is offline   Reply With Quote
Old 07/12/2009, 11:02 PM   #9
kukars22
Big Clucker
 
Join Date: Apr 2008
Posts: 152
Reputation: 0
Default Re: [PHP] Format your banlist [make it look however you want] (banlist parser class)

And how to download it propely if you have called samp.ban like: "r"
$file = fopen($this->fLocation, 'r');

even after changing r to samp.ban, it shows the same errors.
kukars22 is offline   Reply With Quote
Old 07/12/2009, 11:07 PM   #10
iLinx
High-roller
 
Join Date: Jun 2009
Location: Toronto
Posts: 1,498
Reputation: 157
Default Re: [PHP] Format your banlist [make it look however you want] (banlist parser cl

thats the class method, your not supposed to modify that.
the class is simply an object that you use, look at the example index.php file
you use the cfg method to configure which file you want to use ( $ban->cfg("samp.ban"); )
__________________
Servers in Arizona, Virginia, Quebec (Canada), United Kingdom, Netherlands. Over 12,000 served. Free cPanel web hosting is included with ALL servers. ********. *******.
iLinx is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tool/Web/Other] [PHP] GetBan (display the banlist on your website) iLinx Tools and Files 91 14/08/2014 06:57 PM
PAWN code parser Torekk Everything and Nothing 1 10/10/2010 09:39 PM
Website Geekzor Everything and Nothing 6 07/07/2009 12:29 AM
Can you help me with my website ? JaYmE Everything and Nothing 4 25/02/2009 09:12 PM


All times are GMT. The time now is 09:55 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.