HOWTO: Change home directory for a virtual FTP user on a server running pure-ftpd

I run CPanel on my web server and I recently needed to add an FTP account for one of the domains I am hosting. This is easy enough using the FTP Accounts option from the domain's CPanel page. However, I needed to set the home directory for the FTP account to be outside the root web directory (/home/username/public_html). This is not possible from the CPanel interface, most likely because it's a security risk. I checked my server and it shows that I'm running pure-ftpd, so I have no idea why I needed to use the proftpd directory. Heres how I did it:


[email protected]:~# cd /etc/proftpd
[email protected]:~# ls
./ savememo username2 username3
../ username4 username5 username6
[email protected]:~# vi savememo


savememo:RiIR2pPqeBWSM:32023:32024::/home/savememo:/bin/ftpsh
ftp:Ad3Dg04yDsk2dF:14:50:FTP User:/home/savememo/public_ftp:/sbin/nologin
savememo_logs:RiIR2pPqeBWSM:32023:32024:savememo:/usr/local/apache/domlogs:/bin/ftpsh

As you can see, /etc/proftpd contains a file for each of the accounts on your server. Edit the file for the domain in question, in this case savememo.com, and locate the line for the FTP account for which you wish to change the home directory. If I wanted to change the savememo FTP account's home directory to /home/savememo/myfiles, the new file would look like this:


savememo:RiIR2pPqeBWSM:32023:32024::/home/savememo/myfiles:/bin/ftpsh

After editing the file using your favorite console editor, in my case it's vi, save the file and then restart your pure-ftpd service (I'm not sure if this is required).

[email protected]:~# /etc/init.d/pure-ftpd restart
Stopping pure-config.pl:
Stopping pure-authd:
Starting pure-config.pl: [ OK ]
Starting pure-authd:

And that should do it. Now if you go into the FTP Accounts section of the CPanel for the domain you're working with, you should see the new home directory for that FTP user.

HTML_QuickForm – Setting the advcheckbox Checked Value

I must have spent an hour looking for a solution to this problem. Hopefully this post will save someone from the agony I went through. This problem is specific to PEAR HTML_QuickForm, so anyone who doesn't know what that is can enjoy the pretty colors. 🙂

With the standard 'checkbox' element you can simply append the word 'checked' as the last attribute in the addElement method, like this:

$form->addElement('checkbox','remember','Remember me?',
                         '(Check this to remember your login info.)', 'checked');

However, with advcheckbox, which is required if you want to define the checkbox values, setting the checked value from the addElement method is not possible. So how do you do it? First a quick review of the options available with advcheckbox:

  addElement('advcheckbox',
             string element-name,   // name of advcheckbox
             string element-label,  // label output before advcheckbox
             string text,           // label output after advcheckbox
             mixed attributes,      // string or array of attributes
             mixed values);

OK, now here is what I had to do to solve the problem:

$formCheckbox = $form->createElement('advcheckbox',mycheckbox,'',
                                               $row['name'],null,$row['permission_id']);
if(in_array($row['permission_id'], $groups2perms))
	$formCheckbox->setChecked(true); // <-- this is where the magic happens!
else
	$formCheckbox->setChecked(false); // <-- here too!

$form->addElement($formCheckbox);

Thats it! As you can see, you need to use the setChecked() method. However, before you can use it you have to assign the object to a variable ($formCheckbox = $form->createElement(..,..)) and then call the setChecked() method on that variable ($formCheckbox->setChecked(true)). Keep in mind that you can call any number of available methods on the variable before using the addElement() method.

Eclipse

After spending so much time customizing my vim and GVIM programming environment, I finally decided to give in and use the Eclipse IDE for managing my programming projects. The overwhelmingly large scale of the Aerva project I'm working on made me realize that I need a better way of keeping track of all the files, classes, functions, and templates. I also purchased a MyEclipse subscription ($30 a year). MyEclipse is a plugin for Eclipse that features a visual HTML editor (WYSIWYG), similar to Macromedia's Dreamweaver.

Previously, I had been using VMWare on my laptop to run Windows XP on top of Linux (Ubuntu). I then used Dreamweaver to create HTML pages and copied the HTML over to whatever PHP script I was working on in GVIM. It was a messy; constantly switching from one window to another. Now I have a WYSIWYG HTML editor (through MyEclipse), PHP syntax highlighting and other PHP tools (through PHPEclipse) all integrated in a single programming environment (Eclipse).

If I have one thing to say about Eclipse, it's that they need to make the installation process easier. When you visit the Eclipse homepage, it's difficult to figure out what the hell is going on. Everything is a link to something else that only describes vague features. But I guess that's what you can expect to happen when you create a platform that's designed solely for developers who want to create plugins that add functionality to the platform. Eclipse is like the skeleton for a creature and using plugins you create the animal you want.

Bugs are in my Stomach!

Some useful things I learned the past few days:

Want to disable the annoying Linux console bell that beeps when you type the wrong command?

setterm -blength 0

Want to disable the graphical login on Ubuntu/Kubuntu?

echo "false" | sudo tee /etc/X11/default-display-manager

Here's an excellent article on getting PHP4 and PHP5 running side by side while using Apache 1.33. I'm recoding the work I've been doing for Aerva using Object-Oriented programming and templates. So to utilize PHP5's OOP features, I needed to have it running on my laptop.

Last night, while taking a crap, I suddenly became extremely dizzy and almost fainted. I literally almost fell off the toilet! I've never almost fainted like that before, ever. When I stood up, I couldn't even walk. Since then I've had a really bad stomach ache, almost threw up twice, and wasn't able to eat very much today. Maybe it's food poisoning (DJT, Vietnam?) or some stomach bug. I was reconsidering completing my Friday workout, but I decided I'd start the workout and stop if I started feeling worse. I actually felt better after I started the workout and I was able to complete it in it's entirety.

The temperature for today, as well as the next two days, is supposed to be in the upper 90's. I'm headed to the beach tomorrow morning, then I'll probably spend the afternoon doing programming work for Aerva. The project I'm working on has a deadline of this Wednesday, and I've got plenty to finish before then.

I had 4 appointments to show the Bowers ST 3 bedroom apartment today. None of them showed up. Anyone looking for a 3bdrm apartment? New stove, new bathroom floor, some new paint, 3rd floor, first month + security deposit, no utilities included, $800 a month.

My truck's transmission really felt as if it was about to crack open while driving to work on Wednesday, so I took the train in on Thursday. I parked my truck at my Lowell office and rode my bike to the train station. I think it was quicker to ride the bike to the train station than it was to drive there; three minutes tops, and I save myself $5 parking. I did some quick calculations and figured out I can save $30 a month taking the train into work three days a week (assuming I don't have to pay for parking and instead ride my bike to the train station, otherwise it's $30 more expensive to take the train in). But the $30 isn't the great part. I actually save my truck from 1000 miles every month! That should extend it's life for awhile (it has 143k miles right now). Taking the train adds an extra 3 hours a week of commuting, but that's 3 hours I can read or use my laptop, so its all good.

I decided not to buy another cell phone. However, by accident I was looking at T-Mobile's website and I glanced at their Blackberry plans. If I switch to T-Mobile's service, I can get the same number of minutes with the unlimited Blackberry Internet service for $40 less than what I'm paying now! And if it costs me $170 to cancel my 2 year contract with Nextel, I still would save $340 by switching to T-Mobile right now ($40 x 12 months = $480 saved, $480 - $170 = $340). Add that $40 to the $30 a month I'm saving by taking the train, and I've just saved myself $840 a year! This finding-ways-to-save stuff is becoming fun!

Urgh, I still feel the stomach bug inside me and my body still feels weird. I've had chills all day today, even though its been 85+ degrees and I still feel a little dizzy when I stand up. I'm sure if I threw up, I'd feel better, but I'm too stubborn to throw up. To give you an idea of how stubborn, I've only thrown up twice in the past 15 years.

Maybe lying in the sun at the beach tomorrow will help.

Must
Remember
To
Wear
Sunblock...

My Text Editor of Choice

First a little history:

I first started programming using the MS-DOS Edit program while programming QBasic (I know, I should have learned C first, and I regret it!). Edit was the first text editor I ever used.

When I started writing HTML web pages, I used Microsoft's Notepad. It wasn't until many years later that WYSIWYG editors came out and made creating HTML pages as simple as writing a letter in Microsoft Word. I learned to use Macromedia's Dreamweaver when I started to manage hundreds of separate HTML files (Microsoft's FrontPage is crap!). A WYSIWYG editor is a godsend if you have lots of tables to work with. However, I've learned to use CSS styling in place of tables, so that doesn't even apply to me. Continue reading

Coding a style changer for WordPress 2.0

I'm sure there are plugin's that take care of this function, however I decided to hardcode this right into my WordPress theme. Why? Because I don't plan to use any other themes. All style changes I make will be done through changing the CSS style sheet. I coded this so that I could work on a new style sheet offline, and when I'm finished, upload the file to my styles directory. It will then automatically show up in the drop down box on the Style Changer page.

So here is what I did. First I created a new WordPress page and called it Style Changer. On this page I put the following PHP code: Continue reading

MyFMO.com Status Update

I have decided to have phpBB, an open-source messaging board, handle the user authentication and registration process for MyFMO. I've already coded my own registration process, and it works flawlessly, but I realized I would eventually want to have a forum on MyFMO for users to discuss fitness related topics. It would be a lot easier to use phpBB's authentication system on my PHP pages, instead of trying to integrate my authentication system with phpBB's.

I added a little progress meter to MyFMO.com to use while it's under construction.

I also added the Before I Die page to the About section of this site.

Modifying the WordPress (more…) link

I found the more feature of WordPress to be very useful, however I wanted to change the link that was displayed. The default is "(more...)", and I wanted it to say something more useful, such as "Continued...". After doing some Googling and finding nothing, I dug through all the PHP files included with WordPress. Finally I found the following in template-functions-post.php, located in the /wp-includes/ directory: Continue reading