SunQuest
           FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 26th, 2004, 10:00 AM
acp acp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Location: Napoli - ITALY
Posts: 40 acp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 19 m 37 sec
Reputation Power: 7
Thumbs down Writing strings using FTP functions

Hello,
I’m trying to tranform an application that now is using filesystem functions, such as: fread,fwrite, fputs, move_uploaded_file, etc… in an application based on ftp functions, to make it more affordable file permissions management on the web server.Usually, filesystem function write files on file system as nobody user.I’m changing this by using ftp functions to write file as <owner user>.What I need is to find a corrispondence for fwrite or Fputs.In other words, I need an ftp function that take in input a string variable (as fwrite) and write it as a new file on the server.
Thanks for help
Claudia
__________________
Anna Claudia

Reply With Quote
  #2  
Old April 26th, 2004, 05:06 PM
banks's Avatar
banks banks is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Bristol, UK
Posts: 464 banks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 54 sec
Reputation Power: 6
look up the ftp functions on php.net.

you will probably have to write yourself a little function that writes to a temp text file normally and then uploads it to the server as 'owner' and then deletes the temp file. This is a very long winded way of doing things though. Arte you sure there is no way to change the file's ownership directly?

I have not tried it befor eso I don't know.

Hope this helps.
__________________

Reply With Quote
  #3  
Old April 26th, 2004, 05:08 PM
banks's Avatar
banks banks is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Bristol, UK
Posts: 464 banks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 54 sec
Reputation Power: 6
Just looked myself and found this in about 30 seconds:

chown() - "Attempts to change the owner of the file filename to user user (specified by name or number). Only the superuser may change the owner of a file."

Although that last bit makes it look like it might not work on all servers. I don't know what user php runs under on your server but I'm guessing it's not root so it sounds like this won't work.

Let us know how you get on.

Last edited by banks : April 26th, 2004 at 05:12 PM.

Reply With Quote
  #4  
Old April 26th, 2004, 05:48 PM
banks's Avatar
banks banks is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Bristol, UK
Posts: 464 banks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 54 sec
Reputation Power: 6
Does this help?

Quote:
The way to write files on server where it is not possible (e.g. Gorodok.net)

<?php

function killfile($ftp, $login, $pass, $filename){
$conn_id = ftp_connect($ftp);
$login_result = ftp_login($conn_id, $login, $pass);
if ((!$conn_id) || (!$login_result)) { return false; } else {
$del = ftp_delete($conn_id, $filename);
if (!del) { return false; } else {return true;}
}
ftp_close($conn_id);
}

killfile("gorodok.net", "login", "password", "/path/file.extension");
// Erasing file on server
$fs = fopen("ftp://login:password@gorodok.net/path/file.extension", "w");
// Opening file for writing
// You can't open file 4 writing without 'killfile' function because there must be no such file on server for fopen write mode via FTP/

// Here we write what we need

fclose($fs);



?>
-taken from the users notes from the filesytems function page on php.net: http://uk.php.net/manual/en/ref.filesystem.php

Reply With Quote
  #5  
Old April 27th, 2004, 04:46 AM
acp acp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Location: Napoli - ITALY
Posts: 40 acp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 19 m 37 sec
Reputation Power: 7
What I should need is an ftp function, instead of :


PHP Code:
 $news_fp fopen ($file_name,"w");
$string_value "abcdefghilmno";
fwrite ($news,$string_value);
fclose($news);
chmod($new_name,0777); 


Web Server runs as NOBODY, so the file $news will be written as NOBODY USer.
I force 777 to make it readable also from my FTP User.

Last edited by acp : April 28th, 2004 at 10:20 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > Writing strings using FTP functions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway