FTP writing is working

I officially have FTP file writing working and have built a configuration screen for it. The file writing config screen, which will be the first thing that you see in the initial configuration, lets you choose whether to use FTP for file writing and lets you enter your username, password, host, absolute path to your FTP root, and a path prefix (e.g. ~) if applicable. The script will attempt to detect the host and path automatically, although you can probably change the host to 'localhost' in many cases.

So far, the only complication I need to work out is how newlines work. See, the BBCode routine replaces single line breaks with an HTML break tag, while it uses double line breaks to indicate the start of a new HTML paragraph. However, for some reason, it isn't working correctly. I think the problem is related to FTP trying to automatically do the DOS/UNIX newline translation, but I haven't had much time to look at it yet. (For those who don't know, UNIX systems use one character to represent a line break whereas DOS and Windows use two characters.)

I've uploaded the new code to my web server and am posting with it right now. I've also added some more BBCode-style markup tags and fixed several bugs. That means that, with any luck, LnBlog 0.1.1 will be available for download soon.

Work continues....

I'm making progress on the next release of LnBlog. I've implemented file upload support and am working on an (optional) interface to write files via FTP. In fact, I've finished the backend class and it seems to work, so now I need to integrate it with the rest of the code. The idea is to work around that annoying issue where the files in your weblog are not owned by your account, but rather the Apache account. Instead of letting the web server write the files using native filesystem funcitons, we can use PHP's FTP interface functions, to authenticates to the FTP server using your credentials and writes the files by using FTP commands.

I'm also planning to add some interface elements to the next release. For example, I need to add per-blog login creation, as well as both editing and deleting for comments and entries (right now entries have editing and comments have deleting). I was also thinking of adding an abstract field, i.e. a summary, for entries and articles to support that "teaser links to full article" thing that a lot of sites have. And as long as I'm at it, I was thinking RSS feeds for comments might be nice, as well as a GUI for changing the site map and adding articles to the side bar.

First release - LnBlog 0.1.0

As promised, I've uploaded the first release of LnBlog. You can download it here.

It's still a little rough around the edges, what with this being the first release and all. For one thing, you still have to manually edit the HTML template to change the menubar (where it says "Site map" under the banner) and there isn't yet any mechanism for adding articles to the sidebar. I was going to have all articles shown there automatically, but I'm not entirely sure if that's a good idea. Of course, these won't become real issues until I have some users. ;)

I spent some time tonight fixing a permissions problem. Through a stunning lack of foresight, I failed to account for the fact that the PHP mkdir() function uses the system umask when setting the permissions on new directories. For those who aren't well versed in the ways of UNIX, mkdir() is the function that creates new directories (also known as "folders" in the Windows world) and the umask is a value that essentially determines the default permissions for new files and directories.

On most systems, as on my web host, the standard umask is set to give the file's owner read and write permissions, but only write to anyone else. Well, this turns out to be a problem because LnBlog doesn't yet have a file upload function (that's coming in the next release), so I have to manually upload files via FTP. The catch is that when when LnBlog runs and creates the directories I need to put files in, it doesn't run as the same user account that I use for FTP - it runs as "apache," the web server account. Thus, I couldn't write files to the directories it created.

Fortunately, this was an easy fix. Just change the umask in the directory creation routine and hack together a quick script to change the permissions on the directories I've already created. However, as I was reading over the online PHP manual, I cam across a novel solution to the problem. Somebody suggested using the PHP FTP functions to create new directories. This would allow a script to use FTP-based mkdir() calls and so create directories under my FTP user account. Of course, it would require a little more user setup to make it work, but it sounds like it would be a neat feature to have. It would certainly be better than having a bunch of my data in world-writable directories that I don't own. I think I'll look into that a little further.