Jump to content

Senator

Members
  • Posts

    8
  • Joined

  • Last visited

Senator's Achievements

Rookie

Rookie (2/14)

  • First Post
  • Conversation Starter
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  1. Well, i did open a ticket and the permissions were changed from '99' back to user permissions. However, I dont think that is my issue here. At least, only part of my issue here. I think ive isolated it to be the FTP retreival. Let me explain furthur..mabye some PHP guru's can see an issue with what Im doing. Im trying to FTP a log file from a remote server to the local webserver via PHP. In order to do this I need to have a file on the webserver to download it to. Now, in code, if the file doesnt exist locally I use the fopen() function in PHP to create the file so it has somewhere to write to. Ive noticed when I do this that the ownership of the file I have created is set to '99' (nobody) because thats just the way it is when u create via PHP script. Everything to this point is fine and dandy. The FTP grabs the file remotley and it is downloaded to the webserver no problem...here is the results i get... So, the file (even with permissions of 99) holds the FTP data i gathered from the remote file. My parser can read from it and no issues. The new file on my webserver is called '2.log' and it has the appropriate file size with. The problem becomes when I try to resume the FTP from the previous position. Here is the function that I use to FTP the file and do all the work. Ive tried doing this multiple ways with multiple approaches and they all fail on file resume. I dont think its a file permissions error at this point because even when i manually FTP up a '2.log' file with non-nobody permissions and try to resume, I still get an error on ftp_get(). >function ftpConnect($ip, $user, $pass, $path, $file, $dest) { //check validity $i = 0; if(file_exists($dest)) { //check for the current file $local_file_size = filesize($dest); if($local_file_size) rw("\n$dest exists @ size: $local_file_size"); } else { //try creating the file... rw("\nTrying to create new local log file".$dest); if ($fileconn = @fopen($dest, 'w')) { chmod($dest, 0666); fputs($fileconn, ""); fclose($fileconn); } else trigger_error("Unable to create a local file", E_USER_ERROR); //clear cache clearstatcache(); //now check the file again if(file_exists($dest)) { //now lets get the file size! rw("\n$dest was created sucessfully"); $local_file_size = filesize($dest); //we know its there dont care if its 0 } else trigger_error("Unable to create a local file", E_USER_ERROR); } //clear cache clearstatcache(); //disable script timeout set_time_limit(0); // set up basic connection $conn_id = ftp_connect($ip); // login with username and password $login_result = ftp_login($conn_id, $user, $pass); // check connection if ((!$conn_id) || (!$login_result)) trigger_error("FTP Connection has failed on $ip for user $user", E_USER_ERROR); else trigger_error("Connected to $ip, for user $user", E_USER_NOTICE); // Get remote filesize if(ftp_chdir($conn_id, $path)) { //size of file $remote_file_size = ftp_size($conn_id, $file); //check validity if($remote_file_size) rw("\n$path$file exists @ size: $remote_file_size"); //check the remotesize if ( $remote_file_size == -1 || $remote_file_size < $local_file_size ) { rw("\nRemote filesize of $remote_file_size < $local_file_size, log file reset!"); // Reset logfilesize $local_file_size = 0; } //clear cache clearstatcache(); rw("\nDest: $dest File: $file LocalSize: $local_file_size"); // try to download $server_file and save to $local_file if(is_readable($dest)) { //can we read the file? if(ftp_get($conn_id, $dest, $path.$file, FTP_BINARY, $local_file_size)) rw("\nDownload Complete"); else rw("\nError loading file"); } else trigger_error("Unable to read from local file", E_USER_ERROR); } else trigger_error("Error changing to directory $path", E_USER_ERROR); // close the FTP stream and doc stream ftp_close($conn_id); //reenable script time out set_time_limit(30); The most annoying part about this is that the file will be deleted once it fails. So, I have to redownload a huge log file in the event it fails. Me no likey. Suggestions?
  2. Is this PHP? //disable script timeout set_time_limit(0);
  3. Hello, I have a very newbish question that I cant put my finger on and hoping to find some guidance here. I have a script that gets a log file from an offsite ftp download. The script is setup to resume the download each time it is run so it doesnt have to redownload the complete file over and over. However, Im getting an error the 2nd time i run the script. Basically, the ftp_get php function fails to run. Now, when I login via FTP and try to change permissons on the file (regarless if it was 644 or 777), I get a 'bad file descriptor' message from the ftp and it wont change any of the permissions. Do I have to submitt a ticket to the helpdesk or something to change permissions on this directory? Im at aloss.
  4. Ok, I didnt know that,but assumed. Thanks for confirming.
  5. You will have to excuse me again, im a bit brain dead with all this searching im doing. I originally meant "CHOWN" not "CHMOD"...cause I know i can CHMOD. I just saw this post in security... http://www.totalchoicehosting.com/forums/i...=24913&hl=CHOWN and know what to do now...thanks.
  6. Excuse my ignorance on the matter. I have a CRON job that is set to run every day that establishes an FTP connection to a remote server and downloads a log file. This file grows on a daily basis, and I want the option of just resuming the download everyday instead of downloading the whole thing over, and over, and over again. I can run this script manually each day and it establishes the FTP connection no problem and works its magic without failure. However, if the CRON job takes a stab at it...i get a permissions failure. The problem that I think I have isolated seems to be a possible ownership issue. When I run the PHP script fron CRON it states that it cannot write the file becasue it does not have the proper access. Now, the folder that the file exists in was CHMOD'ed by myself and like I said before, it seems to work fine. My question would be getting to the end result of having my folder (which only has 1 file in it) the proper ownership/access so that this web script that Im running can have write access to make the necessary updates to the file everyday without downloading the whole file again. I dont have any knowledge of the CHOWN command or if that should even be my solution. Ive been searching around the great ol' www and cant put my thumb on my resolution (if there is one). Im left wondering if I need to contact someone at tch support to have my directory/folder have the proper permissions?? Any suggestions?
  7. Thanks, That is what I assumed...but I wanted to make sure.
  8. Hello, Just curious on the specs/price difference on the Silver plan. It is quite possible that I am overlooking something on the disk space. The link here for hosting plans --> http://www.totalchoicehosting.com/web-hosting-plans.html shows that silver has 850mb of disk storage. The link here in the forums ---> http://www.totalchoicehosting.com/forums/i...?showtopic=4038 shows 500mb of disk storage. Am I mixing up something as what constitutes as "storage", or is there a simple mixup in one of the advertisements?
×
×
  • Create New...