CartMetrix - Do you know yours?

6/22/2007

CodeIgniter and BambooInvoice

I recently started toying around with CodeIgniter on a new project where I need a simple user login and administration system. I was initially attracted to the first two features listed:

  1. You want a framework with a small footprint.
  2. You need exceptional performance.

This is the first framework I have ever stayed with after a day because it didn’t feel constricting.

CodeIgniter is an open source Web Application Framework that helps you write kick-ass PHP programs.

While looking at the products made with CodeIgniter I found this cool invoicing application:
BambooInvoice: Simple, Open Source, Online Invoicing

Works very similarly to Blinksale buy you own it and can fully customize it. If I only had time to customize it… I think for now Blinksale will work for me.

Popularity: 14%

4/9/2007

Wordpress Hack to Debug Themes on a Live Site

How can a Wordpress them be debugged privately without showing the wizard behind the curtain to everyone else? This simple hack will use the specified theme only for one remote IP... yours. This can be used when creating a new theme by configuring Wordpress to present the original theme and specifying your new theme in development in place of THEME_NAME below. Also replace YOUR_IP_ADDR with your local IP address. THEME_NAME must be an existing theme directory in wp-content/themes/.

To debug an existing theme, copy your theme directory to a new directory under /themes/ (maybe THEME_NAME-dev). Leave Wordpress configured to serve the original theme at THEME_NAME and configure the hack to serve THEME_NAME-dev to your IP address.

Edit wordpress/wp-includes/theme.php as below:

Before

function get_template() {
   return apply_filters('template', get_option('template'));
}

After

function get_template() {
if($_SERVER['REMOTE_ADDR'] == 'YOUR_IP_ADDR')   {
   return 'THEME_NAME';
}
   return apply_filters('template', get_option('template'));
}

Depending on how the template links to it's stylesheet, the get_stylesheet() function (in the same file) may need a similar hack:

Before

function get_stylesheet() {
   return apply_filters('stylesheet', get_option('stylesheet'));
}

After

function get_stylesheet() {
if($_SERVER['REMOTE_ADDR'] == 'YOUR_IP_ADDR')   {
   return 'THEME_NAME';
}
   return apply_filters('stylesheet', get_option('stylesheet'));
}

This will not work with a private IP address like 192.168.x.x or 10.10.x.x. The IP must be the external address of your router or firewall. To find your external IP address use this link:
http://emailurl.com/myip

Also remember that if you change local IP addresses, you need to update the IP address configured in the snippet above. Most DSL/cable connections use a dynamic IP address that changes every few hours or daily.

Once the theme is good to go, merge the changes into the live template and comment out the code to disable the hack.

Popularity: 24%

3/10/2007

ZenCart Inventory Report - Updated

Thanks to Ron for posting a bug back on the Zencart forums about my Zencart Inventory Report

Fixed… download… enjoy.

Popularity: 21%

2/23/2007

PHP Error - Parse error: syntax error, unexpected $end in

Parse error: syntax error, unexpected $end in ... on line ...

Don't you love it when the line number indicated for an error message is the last line in the file which obviously has no error? I spent twenty minutes on this one last night.

Check for unmatched braces, brackets, parentheses or PHP tags. Nope.

Try echoing line numbers to see where execution stops. In this case no output was generated even with an echo on line #1.

Create a new file and pasted the code as Unix ASCII. Still no change.

Check PHP settings. short_open_tag is disabled by default.

[root@atlas ~]# php -i | grep short_open_tag
105:short_open_tag => On => On

Create .htaccess file:

php_flag short_open_tag on

Page loads with no errors.

Do a search for short open PHP tags in the source and replace with default tags.

Find

<?

Replace

<?php

Turn short_open_tag back off in .htacess:

php_flag short_open_tag off

Page still loads with no errors.

Popularity: 36%

1/30/2007

Use PHP Substr() and Strpos() to Split a String

To split a variable $act like:

$act = 'coupon:edit';
$act = 'coupon:delete';
$method = substr($act, strpos($act, ':')+1);

Popularity: 19%

1/9/2007

PHP Register_Globals and Register_Long_Arrays

After upgrading several servers to PHP5 a few older versions of popular applications started giving odd errors. Register_globals has been configured off by default for security reasons since early PHP4. Applications that rely on register_globals all had .htaccess files enabling it for the subdirectory only. The errors we were seeing were similar though, data didn’t appear to be passing through a form post.

With a little research inside the PHP5 php.ini file, I found a related parameter, register_long_arrays. This parameter turns on legacy support for the long PHP parameters $HTTP_POST_VARS, $HTTP_GET_VARS, etc. which have since been supplanted by $_POST, $_GET, etc.

Dropped the following into the .htaccess file and all is well:

php_flag register_long_arrays on

More info:
http://www.php.net/manual/en/ini.core.php#ini.register-long-arrays

Popularity: 18%

« Previous Page Next Page »


damonparker.org is proudly powered by WordPress
Entries (RSS) and Comments (RSS).

copyright © 2002-2008 damonparker.org. all rights reserved.

Close
E-mail It