SA-MP Forums Archive
[Tool/Web/Other] [PHP] Is this code safe to use? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: [Tool/Web/Other] [PHP] Is this code safe to use? (/showthread.php?tid=125024)



[PHP] Is this code safe to use? - SiJ - 01.02.2010

Hey,
I got this code:

Код:
/*[part of code removed]*/
$conn = ftp_connect("FTP") or die("Sorry!<br />....!");
	ftp_login($conn,"LOGIN","PASS");
	ftp_get($conn,"file.txt","/remotefile.txt",FTP_ASCII);
	$file = "file.txt";
	$handle = fopen($file, 'r');
	$data = fread($handle, filesize($file));
	ftp_close($conn);
	
	if(stristr($data, $keyword) != FALSE)
	{
		//Send a message
	}
	else {//Send a message}
	fclose($handle);
Do I have chmod file with this code?
Is the file is opened safely, and the connection is made safely?


Re: [PHP] Is this code safe to use? - SiJ - 02.02.2010

So...?


Re: [PHP] Is this code safe to use? - Creed - 02.02.2010

Ask my friend ;MaVe he's pro scriptz0r and he will help you via PN.

- Creed


Re: [PHP] Is this code safe to use? - SiJ - 02.02.2010

Quote:
Originally Posted by Creed
Ask my friend ;MaVe he's pro scriptz0r and he will help you via PN.

- Creed
Thanks


Re: [PHP] Is this code safe to use? - Streetplaya - 03.02.2010

Depends on what you mean by safe.
I don't even know what your code should be able to perform.


Re: [PHP] Is this code safe to use? - ettans - 03.02.2010

I belive that WAS the code to display banlist on a website. Connects to the server with FTP and echoes the content from .ban to the website.


Re: [PHP] Is this code safe to use? - SiJ - 03.02.2010

Quote:
Originally Posted by Ettans
I belive that WAS the code to display banlist on a website. Connects to the server with FTP and echoes the content from .ban to the website.
Well.. yeah..
And by 'safe' I mean if I write there a password, would anybody see it somehow? Or I need to chmod that file, or what?


Re: [PHP] Is this code safe to use? - Streetplaya - 03.02.2010

If it's your own dedicated server, and you are protecting your system, then it should be alright.
PHP source code will not be sent to the client when running


Re: [PHP] Is this code safe to use? - gotenks918 - 03.02.2010

If the file is on a live server as in people would be able to access the page then I would either create a folder called includes or w/e you want with a file which will contain the passwords you use to connect to FTP. So for example;

$username = "user123";
$password = "password123";

Be sure to include this file in you page. Then add a .htaccess to the includes folder. Any passwords used then wont be able to be reached and there will be no information in your main php file as you have referenced them by using variables.


Re: [PHP] Is this code safe to use? - Norn - 03.02.2010

Quote:
Originally Posted by gotenks918
If the file is on a live server as in people would be able to access the page then I would either create a folder called includes or w/e you want with a file which will contain the passwords you use to connect to FTP. So for example;

$username = "user123";
$password = "password123";

Be sure to include this file in you page. Then add a .htaccess to the includes folder. Any passwords used then wont be able to be reached and there will be no information in your main php file as you have referenced them by using variables.
It's serverside, they can't access it anyway it wouldn't matter.