[PHP] SA-MP Website Banlist Parser -
iLinx - 03.12.2009
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 код:
<?php
$Bans = new Bans("localhost", "root", "pass");
echo "<ul>";
echo $Bans->parseBan("<li>#USER(#IP) banned at #TIME, #DATE</li>", false, 10);
echo "</ul>";
?>
PHP код:
<?php
$Bans = new Bans("localhost", "root", "pass");
echo $Bans->parseBan("#USER was banned at #TIME on #DATE, #BTYPE", false).'<br/>';
?>
Re: [PHP] Format your banlist [make it look however you want] (banlist parser cl -
Christopher. - 03.12.2009
Awesome script, Handy for if you want a neat professional outlook on your ban list, Highly recommended PHP script!.
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
Luka P. - 03.12.2009
Nice, but I'll never learn it
I'm starting with HTML and CSS, then I'll go to PHP and maybe try this.
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
Joske_Vermeulen - 03.12.2009
I can't seem to connect, does it matter if it's SFTP instead FTP
I'm 100% sure the login details are correct
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
KKashimia - 03.12.2009
luv ur deescreepti0n mah C;
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
iLinx - 03.12.2009
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); )
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
kukars22 - 07.12.2009
this is all what I get:
Код:
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
Re: [PHP] Format your banlist [make it look however you want] (banlist parser cl -
iLinx - 07.12.2009
it means that samp.ban or whatever your calling your banfile isnt getting downloaded to your webserver properly
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
kukars22 - 07.12.2009
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.
Re: [PHP] Format your banlist [make it look however you want] (banlist parser cl -
iLinx - 07.12.2009
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"); )
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
kukars22 - 07.12.2009
So I have to replace
Код:
$file = fopen($this->fLocation, 'r');
$data = fread($file, filesize($this->fLocation));
fclose($file);
with something else?
Im not good @ php.. sorry for being annoying.
Re: [PHP] Format your banlist [make it look however you want] (banlist parser cl -
iLinx - 07.12.2009
no, dont replace anything in ban.class.php
download the example file and open up index.php, look at how the code works there.
the ban.class.php file in simple terms is a set of instructions for php to follow when setting up the ban list, you dont need to change anything in it, its there for you to use externally (in a webpage, like index.php)
add my msn and i can help you over that
Re: [PHP] Format your banlist [make it look however you want] (banlist parser cl -
lolumadd - 08.12.2009
This guy is an amazing web designer; exactly why I am paying him $50 for a website
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
Bayler - 18.01.2010
This Pretty much cuts off and ( Reason ) for ban....
example:
which SHOULD read:
Quote:
[Tom_Gates]Exploiting Vehicles
|
What would you recommend to reconstruct the array to include till the end of line ?
Re: [PHP] Format your banlist [make it look however you want] (banlist parser cl -
iLinx - 18.01.2010
i suppose you could limit the explode and just cut it off at the final ], then use the rest of it as a reason string, i didnt have a ban test file with a reason so i didnt put it in,
the class overall is poorly written imo, was made at 2am, i'll be re-writing it soon =P
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
Bayler - 18.01.2010
dont know about 'Poor'
Im a big Fan of Nuke ( one of the Former Devs ) ...
And this class function is generating a page with 78 Bans at 0.00032 seconds
Its even Faster after the initial page load because of the Cache system im using
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
kevinwalter - 18.01.2010
Good but,,
can you also make a local version?
without ftp
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
thiaZ_ - 18.01.2010
haha you pown, thanks:
http://web1.samp4you.net/banlist/index.php
Re: [PHP] Format your banlist [make it look however you want] (banlist parser class) -
WardenCS - 19.01.2010
Looks nice!
too bad im nub at PHP
Re: [PHP] Format your banlist [make it look however you want] (banlist parser cl -
RenisiL - 19.01.2010
It's great, thank you so much