Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

BugFix: 2.2m 051112 Install - SQL File does not exist


Guest

Recommended Posts

On windows platforms the installation scripts fail when trying to create the database tables using oscommerce.sql, reporting:

 

SQL file does not exist: /install/oscommerce.sql

 

There are two files that have the same defective path-detection logic. The first, in the file install/templates/pages/install_2.php is not serious because it only results in the path being displayed to the user. The second, in the file install/templates/pages/install_3.php causes the error above when the path is empty.

 

The code attempts to get the path to the current script using the PHP function getenv() and assign it to $script_filename but this returns an empty result. Shortly after it builds a path variable $dir_fs_www_root from the script's path, and it is used later to prefix the path to oscommerce.sql.

 

When $dir_fs_www_root is empty the SQL file isn't found and osCommerce reports the error mentioned above.

 

The fix is to add a few lines of additional code to the files to detect and correct the empty assignment.

 

In install/templates/pages/install_2.php at or around line 77:

<?php
} else {
 $script_filename = getenv('PATH_TRANSLATED');
 if (empty($script_filename)) {
$script_filename = getenv('SCRIPT_FILENAME');
 }

 // TJ's FIX for Windows "SQL File does not exist: install/oscommerce.sql" error
 $ver = 100*intval(substr(PHP_VERSION,0,1)) + 10*intval(substr(PHP_VERSION,2,1))
 + intval(substr(PHP_VERSION,4,1));

 if (empty($script_filename) && $ver >= 410) { // PHP 4.1 onwards has 'superglobals'
$script_filename = $_SERVER['SCRIPT_FILENAME'];
if (empty($script_filename)) { // force the standard path in case it still failed
  $script_filename = $_SERVER['PATH_TRANSLATED'].'/install/index.php';
}
 } // END OF FIX

 $script_filename = str_replace('\\', '/', $script_filename);

 

In install/templates/pages/install_3.php at or around line 13:

$script_filename = getenv('PATH_TRANSLATED');
if (empty($script_filename)) {
 $script_filename = getenv('SCRIPT_FILENAME');
}

// TJ's FIX for Windows "SQL File does not exist: install/oscommerce.sql" error
$ver = 100*intval(substr(PHP_VERSION,0,1)) + 10*intval(substr(PHP_VERSION,2,1))
  + intval(substr(PHP_VERSION,4,1));

if (empty($script_filename) && $ver >= 410) { // PHP 4.1 onwards has 'superglobals'
 $script_filename = $_SERVER['SCRIPT_FILENAME'];
 if (empty($script_filename)) { // force the standard path in case it still failed
$script_filename = $_SERVER['PATH_TRANSLATED'].'/install/index.php';
 }
} // END OF FIX

$script_filename = str_replace('\\', '/', $script_filename);

 

--------

TJ.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...