Page 1 of 1

PHP, FTP & Windows Server

Posted: Wed Jul 06, 2005 9:37 pm
by Mr Tech
Just a quick question about PHP, FTP & a Windows Server... I don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable when created, it will stay writeable even when moved?
Is that how it would work?
Woudl the same apply for creating folders?

Thanks for your input

Ben be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable when created, it will stay writeable even when moved?
Is that how it would work?
Woudl the same apply for creating folders?

Thanks for your temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo &amrver... I don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script... 

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = &quote;Enter your html here...&quote;;
$fp=fopen(&quote;temp/filesname.php&quote;,w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {ve a script that creates writeable files that can be edited via an online PHP script... 

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = &quote;Enter your html here...&quote;;
$fp=fopen(&quote;temp/filesname.php&quote;,w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable whenServer... I don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable when created, it will stay writeable even when moved?
Is that how it would work?
Woudl the same apply for creating folders?

Thanks for your input

Benince I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
Thmmands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable when created, it will stay writeable even when moved?
Is that how it would work?
Woudl the same apply for creating folders?

Thanks for your input

Benut.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable ws say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }[/phpion about PHP, FTP & a Windows Server... I don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script... 

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = &quote;Enter your html here...&quote;;
$fp=fopen(&quote;temp/filesname.php&quote;,w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_fiP & a Windows Server... I don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script... 

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = &quote;Enter your html here...&quote;;
$fp=fopen(&quote;temp/filesname.php&quote;,w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.
e the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
Thline PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/f have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script... 

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable when created, it will stay writeable even when moved?
Is that how it would work?
Woudl the same apply for creating folders?

Thanks for your input

Ben directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo &quote;FTP us this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script... 

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = &quote;Enter your html here...&quote;;
$fp=fopen(&quote;temp/filesname.php&quote;,w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It shouion about PHP, FTP & a Windows Server... I don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
p;amp; a Windows Server... I don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload sta an online PHP script... 

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = &quote;Enter your html here...&quote;;
$fp=fopen(&quote;temp/filesname.php&quote;,w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo &quote;FTP upload has a Windows Server... I don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script... 

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!&ampp security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable when created, it will stay writeable even when moved?
Is that how it would work?
Woudl the same apply for creating folders?

Thanks for your input

BenI don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

Ite input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable when created, it will stay writeable even when moved?
Is that how it would work?
Woudl the same apply for creating folders?

Thanks for your input

Benion about PHP, FTP & a Windows Server... I don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable when created, it will stay writeable even when moved?
Is that how it would work?
Woudl the same apply for creatin tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
Tis on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It shouneed some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script...

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_ion about PHP, FTP & a Windows Server... I don't have a Windows Server to tets this on so I need some input.

Let's say I have a script that creates writeable files that can be edited via an online PHP script... 

I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?

Since I can't create files using the FTP commands, the only way around this is creating a folder in the root directory (e.g: /the/root/directory/temp) and make that one folder writeable.

Then I use the PHP script to create a file in the temp folder:

Code: Select all

$content = "Enter your html here...";
$fp=fopen("temp/filesname.php",w);
fputs($fp,$content);
fclose($fp);
So that should work fine correct?

Ok, then to move it to the root directory I would have to use FTP commands...

Code: Select all

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
 
// check upload status
if (!$upload) {
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }
This code worked on a Linux server.

It should work fine on Windows?
And since the .php file was writeable when created, it will stay writeable even when moved?
Is that how it would work?
Woudl the same apply for creating folders?

Thanks for your input

Ben

Posted: Thu Jul 07, 2005 6:17 am
by Chris Corbyn
Or you could just change the name that PHP runs under (can you do that on windows?)

Re: PHP, FTP & Windows Server

Posted: Thu Jul 07, 2005 8:24 am
by hairyjim
Mr Tech wrote: I can't make the root directory (e.g: /the/root/directory/) writeable without opening up security issues which is what I don't want, but I still want to create writeable files and folders in the root directory using PHP... So the only way around this is using the PHP FTP commands right?
Are you familiar with Windows security and ACL's?

Ok. You do not need to make the 'root' folder writeable. But lets say you have this folder structure:
c:\inetpub\wwwroot\writeable
c:\inetpub\wwwroot\unwriteable

If you make wwwroot readable only for Internet Guest Account then the root folder become unwritable.

Now if you go to the 'writeable' folder and view its properties for security it will probably by default have the 'inherit from parent' property set. If you untick this, then choose to copy the permissions from parent you can the modify the permission on this folder so the Internet Guest Account can write to the folder.

So you would have the following effective permissios.

wwwroot is unwriteable by the Int Guest Account.
The writeable folder is writeable by the Int Guest Account.
Unwriteable folder will not be writeable because it will inherit its permissions from the wwwroot folder.

Further to this I beleive (not 100% sure) that any files uploaded by FTP will inherit any parent property security settings. So if you had a FTP enabled folder inside the 'unwriteable' folder a user could not modify any files within either by http or ftp because the file level permissions deny 'write' access.

Posted: Thu Jul 07, 2005 6:47 pm
by Mr Tech
Thanks hairyjim,

I don't think I am familiar with Windows security and ACL's... I might but just not know what they are called... I've almost getting my head around this...

So you are referring to the Internet Guest Account as the owner of the website who will create the new PHP files or the website visitor?

So if I read correctly you are saying the PHP files will inherit the permissions of the folder it is placed in? So if it's in the writeable folder it will be writabl;e but if I FTP it to the wwwroot folder it will no longer be writable?

Thanks again!

Posted: Fri Jul 08, 2005 3:29 am
by hairyjim
The internet guest account is the 'security group' assigned to all visitors to your website by default on windows.

So yes if you place a file inside a writeable folder the files within should inherit those permissions - well that is the theory. Anything can unexpectedly happen on windows!

The important thing to remember that every folder when created will inherit the permissions from the folder it is inside of, the same is true for files. To make individual folders or files different from the folder they reside you must turn off the option 'inherit from parent'.

This is found by right click on folder/file, go to properties, then security tab. You will see a list of groups that have permissions on the resource. The advanced button at the bottom of the window takes you to the 'inherit from' bit.

Windows security can be complicated. It might be worth reading one or two tutorials on it.

Posted: Sun Jul 10, 2005 10:29 pm
by Mr Tech
Ok thanks. So Lets say I did turn off the 'inherit from parent' option, I would still have to use FTP to move it? I wont be able to create a file in the root directory?

So if I did do that, if I FTP'd a writeable file into the root directory and 'inherit from parent' is turned off it should stay writeable. I think I've got it all :wink: