Programming + Design

Modifying the httpd.conf file on a WHM/CPanel server
Written by Brett Brewer   
Sunday, 06 April 2008

For those that do not know, the httpd.conf file is that special file on your Apache web server that controls all the fun stuff. It's where you enable modules, set default behaviors for web directories and create your "vhosts" which are the configuration containers that turn your specific web sites on and off. Depending on how your server is set up, you may need to take special things into consideration simply to make edits to this file because some types of servers build this file automagically and will destroy some types of changes. This is apparently true on WHM/CPanel servers. There are certain things you can and can't modify by hand in your Apache httpd.conf file on a WHM/Cpanel based server. The following info applies to Apache 1.3.41 and may not work for Apache2. Some options, such as enabling gzip output compression should be done from the WHM/CPanel apache updater, which will make the necessarry configuration file changes for you after you have recompiled apache with new modules or new PHP options. Sometimes you may need to manually modify the httpd.conf file to customize some things, but if you don't run a few extra commands after you are done, your config changes will be lost the next time apache is recompiled.

Last Updated ( Tuesday, 08 April 2008 )
Install APC on a WHM/CPanel based server
Written by Brett Brewer   
Sunday, 06 April 2008

If you've ever tried to install the Alternative PHP Cache (APC) on your Linux server, you've probably tried to use the PECL installer and discovered that you just get an error. When this happens you will need to manually compile the module from source and install it yourself. It's actually quite easy, but it's a pain if you don't know how. Here's how it was done on one of my WHM/CPanel based servers. Please note, you may first wish to try the PECL package installer built into WHM, but that has never worked right for me, so below is a list of commands you can enter to install it manually from a root commandline.

Last Updated ( Sunday, 06 April 2008 )
How to turn a wireless router into a switch.
Written by Brett Brewer   
Friday, 28 March 2008

If you're like me, you've probably upgraded multiple generations of routers over the years and have old routers lying around that could be used as switches. I happen to have two old Linksys routers collecting dust in my closet. Recently I built my girlfriend a new PC and I did not have an extra network connection near her PC, so as a temporary measure, (I'm waiting for a new $29 gigabit switch to arrive from NewEgg), I decided to turn a spare router into a switch. So here's how I did it on a Linksys WRT54G version II using the latest official Firmware from Linksys.

Last Updated ( Sunday, 06 April 2008 )
Hacking the "Top Message" box in X-Cart
Written by Brett Brewer   
Tuesday, 25 March 2008

Sometimes in developing various mods or hacks for x-cart, you may want to display a message to the user on the next page load after taking some action. To do this, x-cart supplies the $top_message session variable which is automatically registered on every page load and made available in your scripts. The $top_message variable is an array with a few flags you can set to control how the message displays.

$top_message['content'] .= "My warning";

$top_message['type'] = "W"; 

You can set the flag to "I" for info, "E" for errors, and "W" for warnings. The top message box will be styled accordingly. 

Also, if your script doesn't already assign the top message to a smarty template variable, you'll want to assign it before displaying your template:


Sometimes you may notice that your messages don't show up no matter what you try. Usually this is due to a page redirect happening in the background which clears the $top_message before you can display it. To get around this, put the following snippet in your script to keep the $top_message from being cleared on the next page load:

$adaptives['is_first_start'] = 'Y' ;    

Usually that will do the trick.  

Last Updated ( Tuesday, 25 March 2008 )
How to recursively copy directories in Linux
Written by Brett Brewer   
Monday, 24 March 2008

I had a problem using the Linux "cp" command to recursively copy directories today. Normally you can use the following command to recursively copy directories and overwrite any existing files in the target directory:

cp -Rfd /source/dir  /destination

 however, this will not work on many RedHat based systems because the "cp" command is aliased by default to "cp -i" which forces interactive mode to confirm overwrites of all files. If you don't know this it can be very infuriating. You could simply re-alias the cp command, but it's probably better to create a new alias so you don't alter the expected default system behavior of the cp command in case your system is touched by admins who don't expect the cp command to be re-aliased to allow non-ineractive file overwrites. Instead, you can creatie your own alias to the main cp binary to bypass the aliasing of the cp command entirely and run your own command line switches. Usually cp is located at "/bin/cp" but to find yours you can usually type "which cp" at the command line and it will tell you the full path to the cp binary. Once you know the path, just create a new alias such as:

 alias cprecursive='/bin/cp -Rfd' 

If you want to make this a permanent alias, you might want to add it to the /root/.bashrc  or the corresponding file in your /home/userdir. 

Also, please note, that when copying one directory to another, you specify the source directory normally, but for the target you only specify the directory that should CONTAIN the directory you are copying. So for example if you wanted to copy the images directory from a test site to a live site (and assuming you've already created the above alias) you might do something like this:

cd /home/userdir/public_html

cprecursive mytestsite/images mylivesite

this would copy the "images" directory from the "mytestsite" directory into the "mylivesite" directory, creating the mylivesite/images directory if necessarry and recursively creating/overwriting any files/directories contained within. 

Last Updated ( Tuesday, 25 March 2008 )
Windows XP Clock stuck on AM or PM?
Written by Brett Brewer   
Friday, 21 March 2008

I had a strange thing happen to my desktop system running WindowsXP Pro recently, where the clock would only read AM and would never let me change it to PM. After many days of searching for a solution and running every utility I could find to fix my system's internal time server. Finally I tried doing a search of my entire registry for the string "AM" and woldn't you know it, the first thing I found was a the following key that fixed the problem....

[HKEY_CURRENT_USER\Control Panel\International]

Under that key you will find two subkeys named


The values should be set to "AM" and "PM" respectively. I changed key s2359 to "PM" and everything seem to be working properly now.

Last Updated ( Monday, 24 March 2008 )
Getting IE8 to behave like IE7 without user intervention
Written by Brett Brewer   
Thursday, 20 March 2008

The Microsoft IE8 Beta was released recently and with it, a slew of new layout problems with sites that formerly worked on IE7. The interface looks similar enough to IE7 that I forgot I upgraded my laptop to IE8 Beta a couple of weeks ago. As a result I spent 4 hours debugging a navbar layout problem before I remembered I had upgraded to IE8 when I noticed the "Emulate IE7" button at the top of the window. I turned on IE7 emulation and suddenly everything started working properly again in IE. Fortunately Microsoft had the foresight to make this feature truly useful by letting content authors turn this feature on an off transparently using a meta tag in the page header. To get IE8 to render like IE7 simply add the following to the <head> section of your page: 

<meta http-equiv="X-UA-Compatible" content="IE=7" />

Voila! No new IE bugs to deal with today! I can hardly believe Microsoft did something this nice for web developers after all the years of obvious indifference. I've heard some ranting in the CSS community about this new meta tag being added just to satisfy IE, but honestly, who cares at this point. CSS is so stupid and broken it can't get any worse and if they want to give me a meta-tag to make dealing with this horrible technology easier then I'm 100% for it. In fact, I can think of about 10 other meta tags I'd like to add. I'd like one that would let me override both the standards-compliance and all browser hacks with one single browser hack that would make boxes properly resize themselves vertically to fit their contents. Or how about a simple way to get a bar to sit at the bottom or top of the screen without overlapping anything when the screen is resized. There's so many holes in the CSS specs and browser implementations of those specs that we are all lucky we can get even the simplest of layouts to look good on multiple browsers. Things have definitely gotten worse instead of better for web developers over the past few years. Microsoft is the primary cause of all of this, though the folks at Opera and Mozilla have done their fair share of crappy CSS rendering too. Hopefully with Microsoft's new policy of making IE8 work in standards-compliant mode by default will start a new trend, but I'm not optimistic. Let's not forget, we've been waiting for a way to easily make a 3-column layout with CSS for well over 7 years now without a single elegant solution from the CSS standards bodies or browser makers. Layout tricks that remain trivial to do with tables are STILL nearly impossible with CSS2. If you don't know what those things are, then you are lucky you haven't been using CSS for very long. This post is about a paragraph longer than it was supposed to be, but every time I get started talking about CSS it just turns into a rant. Sorry folks. Enjoy your new "standards-compliant" IE8 and the new meta tag...they are by far the best things to happen to a Microsoft browser in a loooooong time. 

Last Updated ( Thursday, 20 March 2008 )
PHP Stream Wrappers Rock!
Written by Brett Brewer   
Sunday, 16 March 2008
Today I'd like to give a big shout out to PHP's stream wrapper functions . I was listening to the PHP_Abstract podcast recently and they interviewed Manuel Lemos, the guy who started , and he was talking about "Stream Abstraction" in PHP.  Stream wrappers basically let you treat any kind of stream as a regular file that you can read and write to using the standard file handling functions such as fopen. During the interview Lemos mentioned some cool stream wrapper classes they had at and mentioned several cool stream wrappers including a Microsoft Excel stream wrapper class written by an overachieving Aussie named Ignatius Teo. Basically it lets you take associative arrays in PHP and save them directly to Excel spreadsheet files with keys as column cool is that!? Scarecely 24 hours later I had a request from a client to export some x-cart data to an Excel spreadsheet and thanks to this stream wrapper class it was a breeze (I might even say FUN) instead of an annoyance. So thanks PHP , PHP_Abstract , , and Ignatius Teo, for making my job as a web developer that much easier today!
Last Updated ( Sunday, 16 March 2008 )
<< Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>

Results 49 - 56 of 85


Who's Online

© 2017
Joomla! is Free Software released under the GNU/GPL License.