Jump to content

File Editting System


shadowayex

Recommended Posts

I'm working on creating a file editting system so I can edit my files on my server from anywhere. I've got most of it figured out, but I've hit a slight block.I want the files and folders that can be accessed to be displayed on screen, much like if you connect to a server without an index page, it just lists out the files and folders that can be navigated through.Of course, I'll be adding options to add, edit, and delete the files, rather than just go to them, but is there a function or set of functions I can use to create the basic layout I mentioned above?

Link to comment
Share on other sites

glob() looks like it will work, but I have another problem.Is there any way to give mytself permission to edit files through my system? I'm writing the file access system in PHP evidently, but when I try to edit the files permission is denied. Is there some kind of code I can put in the file access code that will open the files under the root account so I can edit them through my system?

Link to comment
Share on other sites

You could change the permissions. Theoretically you could use exec() to edit the file as a local user, also.

Link to comment
Share on other sites

You could change the permissions. Theoretically you could use exec() to edit the file as a local user, also.
Changing the permissions would work, but ould also be a bit tedious, so I'll try exec() first. I'll return here with the results and probably more questions :).Edit: I went with changing permissions in the end, and I can now access the files. I'm currently attempting to build a full dynamic system that can be applied to any server without too much modification whatsoever. I'll probably run into more questions as time goes on. Thanks for now though.
Link to comment
Share on other sites

The glob("*") function worked decently well. It pulled the names for the Folders and the files, except there's one problem that is really in the way. When it gets to pulling out the file names, it pulls out two copies, one with a regular name and one with the name and a ~ after it. For example:[3] => filename.php [4] => filename.php~I want my code to be fully dynamic and able to be applied to any filesystem without changes, so building a code that will just skip every other file after it reads the folders won't be very effective. Instead, I would like an answer to why the function is doing this so I can fix that instead. Any ideas?

Link to comment
Share on other sites

That's because there is actually a file named filename.php~ on your filesystem. Delete it! :)It's an artifact generated because you didn't close the file properly (I think). Did you try using exec() to edit the file?

Link to comment
Share on other sites

On a Linux system, the files with the ~ (tilde) are backup copies left over from editing the files.
Oh, well, that makes a lot of sense because I'm using a Debian 4.04a so yeah. Any way to stop/prevent this? And what about removing the current back up files?
Link to comment
Share on other sites

You could just check the glob() entries to make sure that they don't have the tilde in them...Not using FileZilla by any chance?

Link to comment
Share on other sites

You could just check the glob() entries to make sure that they don't have the tilde in them...Not using FileZilla by any chance?
Nope, just a regular old LAMP server. Like I said, I just edit the files through fopen(), fread(), fwrite(), and fclose(). They are all in the www folder and all that good stuff.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...