Archive for July, 2010

Ultimate SEO URLs 5 small bugfix

Tuesday, July 27th, 2010

I noticed that some stores with multiple languages were behaving strange: If you click a given link, the store changed it’s display language.

Examining this problem further, I found that the culprit was in the “Main” link, which had to open the store’s main page, but it was switching the active language as well.

So, to duplicate the error, you have to create a link to any page, with some parameters. Then you create a new link to index.php WITHOUT ANY PARAMETERS.

The result is that the parameters from the first link are DUPLICATED in the second link.
You can reproduce the error by adding this code to any page:

echo tep_href_link('index.php', 'param1=xx&amp;param2=xy').'< br />';
echo tep_href_link('index.php');

It will show something like:

http://domain.tld/index.php?param1=xx&amp;param2=xy
http://domain.tld/index.php?param1=xx&amp;param2=xy

These parameters in the latter shouldn’t be here, correct?

The solution is quite simple, and involves adding 2 lines to the file includes/modules/ultimate_seo_urls5/classes/usu.php, in the function public function href_link.

I will let you think about it a little. Contact me if you need help in fixing this 😉

Correcting “USU5 could not find a valid base filename, please inform the developer. in …”

Tuesday, July 27th, 2010

I upgraded this osCommerce contribution after finding a small bug, and got this error while running an utility I wrote.

For a better explanation, I usually write scripts to help updating the store, cleaning databases, or even generating google sitemaps, but keep these scripts is a subdirectory of  the main script, to avoid messing too much and forgetting to delete potentially dangerous scripts.

So, when I was trying to run to insert a new option to a batch of products, I had this error displayed:

"Warning:  USU5 could not find a valid base filename, please  inform the developer. in ..."

Sure enough, this “bug” was located in the file application_top.php, in a new function added in r119. As the problem is due to this script’s location being outside the main dir, the solution was quite simple.  I added a few lines checking if the directory in use is different from the catalog’s dir, and simply returned a correct value overriding the function. In other words:

Locate in includes/application_top.php the lines

        /**
	* USU5 function to return the base filename
	*/
	function usu5_base_filename() {
		// Probably won't get past SCRIPT_NAME unless this is reporting cgi location
		$base = new ArrayIterator( array( 'SCRIPT_NAME', 'PHP_SELF', 'REQUEST_URI', 'ORIG_PATH_INFO', 'HTTP_X_ORIGINAL_URL', 'HTTP_X_REWRITE_URL' ) );
		while ( $base-&gt;valid() ) {
			if ( array_key_exists(  $base-&gt;current(), $_SERVER ) &amp;&amp; !empty(  $_SERVER[$base-&gt;current()] ) ) {
				if ( false !== strpos( $_SERVER[$base-&gt;current()], '.php' ) ) {
					preg_match( '@[a-z0-9_]+\.php@i', $_SERVER[$base-&gt;current()], $matches );
					if ( is_array( $matches ) &amp;&amp; ( array_key_exists( 0, $matches ) )
																		&amp;&amp; ( substr( $matches[0], -4, 4 ) == '.php' )
																		&amp;&amp; ( is_readable( $matches[0] ) || ( false !== strpos( $_SERVER[$base-&gt;current()], 'ext/modules/' ) ) ) ) {
						return $matches[0];
					}
				}
			}
			$base-&gt;next();
		}
		// Some odd server set ups return / for SCRIPT_NAME and PHP_SELF when accessed as mysite.com (no index.php) where they usually return /index.php
		if ( ( $_SERVER['SCRIPT_NAME'] == '/' ) || ( $_SERVER['PHP_SELF'] == '/' ) ) {
			return 'index.php';
		}
		trigger_error( 'USU5 could not find a valid base filename, please inform the developer.', E_USER_WARNING );
	} // End function
// set php_self in the local scope
	$PHP_SELF = usu5_base_filename();

and change for

        /**
	* USU5 function to return the base filename
	*/
	function usu5_base_filename() {
		// Probably won't get past SCRIPT_NAME unless this is reporting cgi location
		$base = new ArrayIterator( array( 'SCRIPT_NAME', 'PHP_SELF', 'REQUEST_URI', 'ORIG_PATH_INFO', 'HTTP_X_ORIGINAL_URL', 'HTTP_X_REWRITE_URL' ) );
		while ( $base-&gt;valid() ) {
			if ( array_key_exists(  $base-&gt;current(), $_SERVER ) &amp;&amp; !empty(  $_SERVER[$base-&gt;current()] ) ) {
				if ( false !== strpos( $_SERVER[$base-&gt;current()], '.php' ) ) {
					// ignore processing if this script is not running in the catalog directory
					if( dirname($_SERVER[$base-&gt;current()]).'/' != DIR_WS_CATALOG){
						return $_SERVER[$base-&gt;current()];
					}
					preg_match( '@[a-z0-9_]+\.php@i', $_SERVER[$base-&gt;current()], $matches );
					if ( is_array( $matches ) &amp;&amp; ( array_key_exists( 0, $matches ) )
																		&amp;&amp; ( substr( $matches[0], -4, 4 ) == '.php' )
																		&amp;&amp; ( is_readable( $matches[0] ) || ( false !== strpos( $_SERVER[$base-&gt;current()], 'ext/modules/' ) ) ) ) {
						return $matches[0];
					}
				}
			}
			$base-&gt;next();
		}
		// Some odd server set ups return / for SCRIPT_NAME and PHP_SELF when accessed as mysite.com (no index.php) where they usually return /index.php
		if ( ( $_SERVER['SCRIPT_NAME'] == '/' ) || ( $_SERVER['PHP_SELF'] == '/' ) ) {
			return 'index.php';
		}
		trigger_error( 'USU5 could not find a valid base filename, please inform the developer.', E_USER_WARNING );
	} // End function
// set php_self in the local scope
	$PHP_SELF = usu5_base_filename();
 
Let me know if yout tried this modification.

Random humor

Monday, July 26th, 2010
Everyone knows one (or more)

Everyone knows one (or more)

Cutting Master 2 (compatible with Corel Draw X5)

Friday, July 2nd, 2010

Today I was trying to install my Craft Robo for use with Corel X5, and found several forum threads asking for the newest version of CM2 to use with Corel X5.
Amazingly, Graphtec’s sites in UK and USA are still providing the older versions (1.61 and 1.70 respectively), which are not recognized by Corel X5.

I then searched the Japanese site and found version 1.71, which worked like a charm with X5.

So, you can find download the new version here. Or in this page (in Japanese).

Let me know if this post helped you in the comments below. Cheers!