Here’s a fun little thing you can do for your next site goodie: display your users’ “fortunes” from the command-line interface, CLI, application Fortune. On Fedora, install: % sudo yum install fortune-mod from PHP (fortune.php) <pre> <? passthru(‘fortune’); ?> </pre> I pre-formatted the text because it comes out looking as it does in the CLI. …
Category Archives: Tutorials
Fixing Zen Cart’s Tax Miscalculation When Using a Coupon
I was recently alerted to an error in Zen Cart by a client where the tax was being miscalculated when using a coupon. Here’s the fix. Around line 240 in /store/includes/modules/order_total/ot_coupon.php Remove these lines: //$od_amount[$tax_desc] += (($products[$j][‘final_price’] * $products[$j][‘quantity’]) * $tax_rate)/100 * $ratio; //$od_amount[$tax_desc] += round(((($products[$j][‘final_price’] * $products[$j][‘quantity’]) * $tax_rate) + .5)/100 * $ratio, 2); …
Continue reading “Fixing Zen Cart’s Tax Miscalculation When Using a Coupon”
Clean file names using PHP preg_replace
It’s always a good idea to protect yourself from all sorts of possible malicious attempts by users (or even mistakes by misinformed users). Here we look at taking a string of text (a filename) containing characters that are generally speaking unsafe. Here’s a simple way to clean-up filenames (or other text input) using PHP – …
Cool Exposé trick in Mac OS X
When pressing F10 (or Ctrl-F10) to show a program’s open windows, you can press Cmd-Tab to cycle through all running apps, showing the icons across the screen as the normal Cmd-Tab does. You can also scroll through running apps in Exposé by pressing Cmd-` (back tick), but without the icons. Apparently this will also switch …
Smart template plugins with Smarty
Smarty is becoming more and more popular in the PHP community lately, especially as developers are moving away from mixing business and display logic in the same scripts and towards a cleaner MVC design pattern implementations. If you’ve followed my blog for any amount of time, you’ll know that I’m currently working on my own …
MySQLi PHP conversion tool
I just got the MySQL AB newsletter in my inbox this evening and there’s an interesting tool they introduce that will convert existing PHP scripts that use the standard (“old”) mysql extension to use the new mysqli. “i” stands for “improved” – the new extension is faster and can take advantage of the new MySQL …
SEO your URL
If you’re looking for some help on learning mod_rewrite, this post isn’t for you. sorry. Instead, I’m going to show you a neat little trick that will make sure you always have one the www in front of your domain name. Why is it important? Potentially for your stats package, definitely for search engine ranking …
Adding GD PHP support to Fedora Core 5 (FC5)
For some reason I thought GD was installed by default onto the DFL production servers… and that PHP was configured accordingly. I was wrong. But lo and behold I found a very simple upgrade path. % yum install gd-devel % yum install php-gd restart apache: % /sbin/service httpd restart You’re golden.
Fedora FC5 black screen install woes – FIX
Here’s a quick post for those having difficulties installing Fedora Core 5 (FC5) on systems with ATI cards. Our new 80 node cluster install at the DFL is just about finished. I get two Dell PowerEdge 1425s all to myself for web stuffs. First order of business: ditch RedHat Enterprise Linux. I need cutting-edge software. …
Continue reading “Fedora FC5 black screen install woes – FIX”
Export Evolution contacts data to Apple Mail
It was bound to happen – I finally got a Mac at work for most of the web/media authoring I do. It’s important for me to at least be able to send email (i.e. attachments) without having to go an extra step by copying things like PSD and movie files over to linux just so …
Continue reading “Export Evolution contacts data to Apple Mail”