0

I need to install a module in x-cart 4.4.4 (https://help.x-cart.com/index.php?title=X-Cart:X-PDF_Invoices).

X-cart is in the root directory, but installed modules are in root/modules. The installation instructions suggest unpacking and moving all module directories into the root directory for installation.

This is something I cannot do - the contents of the module includes files and folders with the same names as those found in the root directory.

Instead I have unpacked the contents into a subdirectory of root/modules/. Within the installation script I have changed the cwd to root whch fixes files not found errors, but when it gets to the x-cart install.php it breaks and I get an error (no error showing in nginx logs).

For example:

//change cwd to root
chdir(str_replace('modules/X_PDF', '', __DIR__));

if (!@include('./top.inc.php')) {
    die('X-Cart not found in '.dirname(__FILE__));
}

if (!@include('./init.php')) {
    die('init.php not found. Please, unpack ' . $module_definition['name'] . ' module in <xcart> directory');
}

Here we require the x-cart install script. File path is correct and script is being called.

require_once $xcart_dir . '/include/install.php';
MP_Webby
  • 916
  • 1
  • 11
  • 35

1 Answers1

0

This patch works for me in 4.7.6 version.

You have to adapt the module's skin files and modules/XPDF/*.php files to your custom dir.

Index: include/install.php
--- include/install.php
+++ include/install.php
@@ -500,7 +500,7 @@ function func_init_xcart() {
 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $install_language_charset; ?>" />
 <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
 <title><?php echo_lng('install_wiz', 'product', $installation_product); ?></title>
-<link rel="stylesheet" type="text/css" href="skin/common_files/css/install.css" />
+<link rel="stylesheet" type="text/css" href="../../skin/common_files/css/install.css" />
 
 <style type="text/css">
 <?php
@@ -1064,6 +1064,7 @@ function query_upload($filename)
     global $xcart_dir, $sql_obj;
 
     $fp = @fopen($xcart_dir.XC_DS.$filename, 'rb');
+    $fp = $fp ?: @fopen($filename, 'rb');
     if ($fp === false) {
         echo_lng('upload_cannot_open', 'file', $filename, 'status', status(false));
         return 0;
Index: install-xpdf.php
--- install-xpdf.php
+++ install-xpdf.php
@@ -55,6 +55,13 @@ $module_definition = array (
     'is_installed'   => 'func_is_installed',
 );
 
+
+$module_definition['sql_files'] = array(
+    getcwd() . '/sql/'.$module_definition['prefix'].'_remove.sql',
+    getcwd() . '/sql/'.$module_definition['prefix'].'.sql',
+    getcwd() . '/sql/'.$module_definition['prefix'].'_lng_US.sql',
+);
+
 if (
     isset($_POST['params'])
     && isset($_POST['params']['install_type'])
@@ -65,6 +72,8 @@ if (
     );
 }
 
+chdir(str_replace('root/modules', '/', __DIR__));
+
 if (!@include('./top.inc.php')) {
     die('X-Cart not found in '.dirname(__FILE__));
 }
@@ -73,7 +82,7 @@ if (!file_exists('skin')) {
     die('Wrong X-Cart version');
 }
 
-if (!@include(dirname(__FILE__).'/init.php')) {
+if (!@include(getcwd().'/init.php')) {
     die('init.php not found. Please, unpack ' . $module_definition['name'] . ' module in &lt;xcart&gt; directory');
 }
 

By the way, you can install the module manually Just

1) patch your X-Cart using these files

./include/history_order.php.patch
./include/func/func.mail.php.patch
./include/process_order.php.patch
./process_order.php.patch

2) Apply these sql files

sql/x-pdf_lng_US.sql
sql/x-pdf.sql

http://help.x-cart.com/index.php?title=X-Cart:Applying_Patches

Ildar Amankulov
  • 526
  • 4
  • 19