[Tool/Web/Other] [PHP] GetBan (display the banlist on your website)
#1

Note: If you are getting errors regarding to the ftp_ functions etc, etc, thats becuase your host hasnt enabled them on their version of php. You can either ask them to do it for you, if you have access to the php you can add it in yourself or you can switch hosts.

This script is just an example to show how you could retrieve your samp.ban file from your server using an FTP connection to your web host and then display it.

Код:
<?php
	
	$ftp_host = "serverhostname ex: could be a ip address"; //put the ip / hostname to your ftp here
	$ftp_user = "ftp login"; //put your login here
	$ftp_pass = "ftp password"; //put your password here
	$banfile = "samp.ban";
	
	$con = ftp_connect($ftp_host) or die("Couldnt connect to your ftp (check your settings!");
	ftp_login($con, $ftp_user, $ftp_pass);
	ftp_get($con, "ban.txt", $banfile, FTP_ASCII);
	ftp_close($con);
	
	$file = fopen("ban.txt", "r");
	$bans = fread($file, filesize("ban.txt"));
	fclose($file);
	
	echo nl2br($bans);

?>
CRON : if you want to run this script in a cron just run this as a crontab every say 5 minutes
Код:
<?php $ftp_host = "serverhostname ex: could be a ip address"; //put the ip / hostname to your ftp here
	$ftp_user = "ftp login"; //put your login here
	$ftp_pass = "ftp password"; //put your password here
	$banfile = "samp.ban";
	
	$con = ftp_connect($ftp_host) or die("Couldnt connect to your ftp (check your settings!");
	ftp_login($con, $ftp_user, $ftp_pass);
	ftp_get($con, "ban.txt", $banfile, FTP_ASCII);
	ftp_close($con); ?>
and run this for retrieving the actual ban list
Код:
<?php $file = fopen("ban.txt", "r");
	$bans = fread($file, filesize("ban.txt"));
	fclose($file);
	
	echo nl2br($bans); ?>
Reply
#2

Thanks!, Excellent script, Adds a nice touch to any server's website!.
Reply
#3

whats ftp ??
Reply
#4

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by MiDNiGhT.
whats ftp ??
File Transfer Protocol
and to explain it more simple, it let u connect to a other pc to transfer file's
Reply
#5

Good Job!
Reply
#6

Useful, nice work.
Reply
#7

how could i get it to get bans from another file becouse im useing Madmin and the file is located here , /scriptfiles/mAdmin/logs/Bans.txt

nvm my i my website wont let me edit the templates or anything
Reply
#8

man i got all the FTP stuff right but i get this error.
Код:
Fatal error: Call to undefined function ftp_connect()
im kinda new to PHP so could you tell me what i did wrong?
thanks,

Boozman
Reply
#9

Quote:
Originally Posted by Boozmang
man i got all the FTP stuff right but i get this error.
Код:
Fatal error: Call to undefined function ftp_connect()
im kinda new to PHP so could you tell me what i did wrong?
thanks,

Boozman
Your doing something wrong were your defining the Hostname and Username/Password:

Код:
	$ftp_host = "serverhostname ex: could be a ip address"; //put the ip / hostname to your ftp here
	$ftp_user = "ftp login"; //put your login here
	$ftp_pass = "ftp password"; //put your password here
	$banfile = "samp.ban";
That bit.
Reply
#10

well i took the exact info that was in the .php file and put it into filezilla to test it and it worked.
Reply
#11

Quote:
Originally Posted by Boozmang
well i took the exact info that was in the .php file and put it into filezilla to test it and it worked.
Worked 100%? Or you still are having that error?
Reply
#12

nah it dont work yet. im trying to work on it but no luck
Reply
#13

Quote:
Originally Posted by Boozmang
nah it dont work yet. im trying to work on it but no luck
What happen to you? Can i put this in any place i want, or this need to be on the server FTP?
Reply
#14

Quote:
Originally Posted by RoamPT
Quote:
Originally Posted by Boozmang
nah it dont work yet. im trying to work on it but no luck
What happen to you? Can i put this in any place i want, or this need to be on the server FTP?
this script can be placed anywhere you want the banlist to be viewed (example on your website)
it will download the banlist and display it.
Reply
#15

Easy to make and is pretty CPU intensive in all honesty. MySQL is the way forward.
Reply
#16

This is incredibly simple, and useful! i plan to use this nice little snippet for my servers website's Ban List section! anyway Great job
Reply
#17

----
Reply
#18

Nice I will use this
Reply
#19

Nice
Reply
#20

Quote:
Originally Posted by CalgonX
Easy to make and is pretty CPU intensive in all honesty. MySQL is the way forward.
its only CPU intensive if your cpu is from 1940
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)