PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Basically, there are a few things that don't work. Once you travel beyond the main directory, everything is recognized as just a file even if its a dir. This code is extremely slow when trying to move into somewhat populated directory's and im not sure how to make it at least fast enough to actually work. Finally, it fails to get the contents of a file to the textarea in edit mode.
One thing I might suggest is not changing your directory. You can just as easily update the path of the directory your trying to open, and it has less overhead.
Is the purpose of this script to be applicable to an arbitrary server or is it solely to access files on the server on which the script is running? If the situation is the latter, why not use file system calls?
Edit: never mind about the last paragraph.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Well, it is being accessed from a remote server, so i think it has to go through ftp. What do you mean by just updating the path to open? like instead of opening "." , open the full path? I have tried that and it does not work and better than the current. I just need to figure out how to get this all working properly.
pickle wrote:One thing I might suggest is not changing your directory. You can just as easily update the path of the directory your trying to open, and it has less overhead.
Is the purpose of this script to be applicable to an arbitrary server or is it solely to access files on the server on which the script is running? If the situation is the latter, why not use file system calls?
*Agrees ^^ I think you can better use a FTP script if you want to access remote scripts. For scripts on your own server, I'd use PHPs dir class or PHPs dir functions.
Say you login and your current directory is /home/me/. You then want to access /home/me/like/cookies.yum. Rather than calling ftp_chdir() and moving to /home/me/like/ and calling ftp_open('cookies.yum'), just update the string in your script to reflect the new address. So, just tack '/home/me/like/' in front of the filename 'cookies.yum'. That will save you one ftp transaction.
I'm sure this is meaningless to you, but congratulations on being my 1000th post
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
$conn = ftp_connect($server_ip);
$error = (!@ftp_login($conn,REMOTE_ACCOUNT_NAME,REMOTE_ACCOUNT_PASSWORD))
? "Could not connect to authentication server. Please contact ABC at x123"
: false;
$error = (!ftp_put($conn,'/etc/dir/users/'.$username.'/file.rules','/tmp/'.$username .'.tmp',FTP_ASCII))
? "Could not upload authentication rules. Please contact ABC at x123"
: false;
ftp_close($conn);
ftp_get() should be able to allow you to download the entire contents of a file into a local file. ftp_fget() can save the contents of an ftp'd file into an open file handler - could save you some time.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.