03.12.2009, 01:48
(
Последний раз редактировалось iLinx; 29.06.2012 в 18:38.
)
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.
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/>';
?>