Conditional config files generation - prevents overwrite during upgrade.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 20 Oct 2009 21:47:33 +0000 (21:47 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 20 Oct 2009 21:47:33 +0000 (21:47 +0000)
12 files changed:
CHANGELOG.txt
admin/db/maintenance_db.inc
admin/inst_lang.php
company/0/installed_extensions.php [deleted file]
config.default.php [new file with mode: 0644]
config.php [deleted file]
config_db.php [deleted file]
includes/session.inc
install/index.php
install/save.php
installed_extensions.php [deleted file]
lang/installed_languages.inc [deleted file]

index 6e1977d998626f1ab18171f5d104d6d7d096b68b..e40ca10e510904c6bcec2bf0bad05dacd72d80f1 100644 (file)
@@ -19,6 +19,23 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+
+20-Oct-2009 Janusz Dobrowolski
+! Conditional config files generation - prevents overwrite during upgrade.
+$ /config.php (removed)
+  /installed_extensions.php (removed)
+  /company/0/installed_extensions.php (removed)
+  /config.default.php  (new initial default)
+  /config_db.php (removed initial version)
+  /admin/inst_lang.php (removed initial version)
+  /admin/db/maintenance_db.inc
+  /includes/session.inc
+  /install/index.php
+  /install/save.php
+  /lang/installed_languages.inc (removed initial version)
+$ Moving control to install wizard when config file does not exists.
+$ /index.php
+
 18-Oct-2009 Janusz Dobrowolski (merged changes for 2.1.7 from main branch)
 ! Added html_entity_decode() in db_escape() for correct INSERT>SELECT>INSERT sequences.
 $ /includes/db/connect_db.inc
index f018ea1dda67586bd5b88b330d5694772de102ee..ceccb076fcb715ad2e6553b5bae020201ccfb7f9 100644 (file)
@@ -60,7 +60,6 @@ function array_natsort($aryData, $strIndex, $strSortBy, $strSortType=false)
 function write_config_db($new = false)
 {
        global $path_to_root, $def_coy, $db_connections, $tb_pref_counter;
-       include_once($path_to_root . "/config_db.php");
 
        if ($new)
                $tb_pref_counter++;
@@ -99,7 +98,7 @@ function write_config_db($new = false)
 
        $filename = $path_to_root . "/config_db.php";
        // Check if the file exists and is writable first.
-       if (file_exists($filename) && is_writable($filename))
+       if (!file_exists($filename) || (is_writable($path_to_root) && is_writable($filename)))
        {
                if (!$zp = fopen($filename, 'w'))
                {
@@ -199,6 +198,73 @@ function write_extensions($extensions=null, $company = -1)
        return true;
 }
 
+function write_lang()
+{
+       global $path_to_root, $installed_languages, $dflt_lang;
+
+       $conn = array_natsort($installed_languages, 'code', 'code');
+       $installed_languages = $conn;
+       //reset($installed_languages);
+       $n = count($installed_languages);
+       $msg = "<?php\n\n";
+
+       $msg .= "/* How to make new entries here\n\n";
+       $msg .= "-- if adding languages at the beginning of the list, make sure it's index is set to 0 (it has ' 0 => ')\n";
+       $msg .= "-- 'code' should match the name of the directory for the language under \\lang\n";
+       $msg .= "-- 'name' is the name that will be displayed in the language selection list (in Users and Display Setup)\n";
+       $msg .= "-- 'rtl' only needs to be set for right-to-left languages like Arabic and Hebrew\n\n";
+       $msg .= "*/\n\n\n";
+
+       $msg .= "\$installed_languages = array (\n";
+       if ($n > 0)
+           $msg .= "\t0 => ";
+       for ($i = 0; $i < $n; $i++)
+       {
+               if ($i > 0)
+                       $msg .= "\t\tarray ";
+               else
+                       $msg .= "array ";
+               $msg .= "('code' => '" . $installed_languages[$i]['code'] . "', ";
+               $msg .= "'name' => '" . $installed_languages[$i]['name'] . "', ";
+               $msg .= "'encoding' => '" . $installed_languages[$i]['encoding'] . "'";
+               if (isset($installed_languages[$i]['rtl']) && $installed_languages[$i]['rtl'])
+                       $msg .= ", 'rtl' => true),\n";
+               else
+                       $msg .= "),\n";
+       }
+
+       $msg .= "\t);\n";
+       $msg .= "\n\$dflt_lang = '$dflt_lang';\n?>\n";
+
+       $path = $path_to_root . "/lang";
+       $filename = $path.'/installed_languages.inc';
+       // Check if directory exists and is writable first.
+       if (file_exists($path) && is_writable($path))
+       {
+               if (!$zp = fopen($filename, 'w'))
+               {
+                       display_error(_("Cannot open the languages file - ") . $filename);
+                       return false;
+               }
+               else
+               {
+                       if (!fwrite($zp, $msg))
+                       {
+                               display_error(_("Cannot write to the language file - ") . $filename);
+                               fclose($zp);
+                               return false;
+                       }
+                       // Close file
+                       fclose($zp);
+               }
+       }
+       else
+       {
+               display_error(_("The language files folder ") . $path . _(" is not writable. Change its permissions so it is, then re-run the operation."));
+               return false;
+       }
+       return true;
+}
 
 function db_create_db($connection)
 {
index 9c8ea4b555cbe1c565ae026864b1f2a3d0081968..214a1dceb4d79823ab9c39b497f6f1eab04f0ff9 100644 (file)
@@ -44,74 +44,6 @@ function check_data()
        return true;
 }
 
-function write_lang()
-{
-       global $path_to_root, $installed_languages, $dflt_lang;
-       include_once($path_to_root . "/lang/installed_languages.inc");
-
-       $conn = array_natsort($installed_languages, 'code', 'code');
-       $installed_languages = $conn;
-       //reset($installed_languages);
-       $n = count($installed_languages);
-       $msg = "<?php\n\n";
-
-       $msg .= "/* How to make new entries here\n\n";
-       $msg .= "-- if adding languages at the beginning of the list, make sure it's index is set to 0 (it has ' 0 => ')\n";
-       $msg .= "-- 'code' should match the name of the directory for the language under \\lang\n";
-       $msg .= "-- 'name' is the name that will be displayed in the language selection list (in Users and Display Setup)\n";
-       $msg .= "-- 'rtl' only needs to be set for right-to-left languages like Arabic and Hebrew\n\n";
-       $msg .= "*/\n\n\n";
-
-       $msg .= "\$installed_languages = array (\n";
-       if ($n > 0)
-           $msg .= "\t0 => ";
-       for ($i = 0; $i < $n; $i++)
-       {
-               if ($i > 0)
-                       $msg .= "\t\tarray ";
-               else
-                       $msg .= "array ";
-               $msg .= "('code' => '" . $installed_languages[$i]['code'] . "', ";
-               $msg .= "'name' => '" . $installed_languages[$i]['name'] . "', ";
-               $msg .= "'encoding' => '" . $installed_languages[$i]['encoding'] . "'";
-               if (isset($installed_languages[$i]['rtl']) && $installed_languages[$i]['rtl'])
-                       $msg .= ", 'rtl' => true),\n";
-               else
-                       $msg .= "),\n";
-       }
-
-       $msg .= "\t);\n";
-       $msg .= "\n\$dflt_lang = '$dflt_lang';\n?>\n";
-
-       $filename = $path_to_root . "/lang/installed_languages.inc";
-       // Check if the file exists and is writable first.
-       if (file_exists($filename) && is_writable($filename))
-       {
-               if (!$zp = fopen($filename, 'w'))
-               {
-                       display_error(_("Cannot open the languages file - ") . $filename);
-                       return false;
-               }
-               else
-               {
-                       if (!fwrite($zp, $msg))
-                       {
-                               display_error(_("Cannot write to the language file - ") . $filename);
-                               fclose($zp);
-                               return false;
-                       }
-                       // Close file
-                       fclose($zp);
-               }
-       }
-       else
-       {
-               display_error(_("The language file ") . $filename . _(" is not writable. Change its permissions so it is, then re-run the operation."));
-               return false;
-       }
-       return true;
-}
-
 //---------------------------------------------------------------------------------------------
 
 function handle_submit()
diff --git a/company/0/installed_extensions.php b/company/0/installed_extensions.php
deleted file mode 100644 (file)
index 390ab59..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-/*
-       Do not edit this file manually. This copy of global file is overwritten
-       by extensions editor.
-*/
-
-$installed_extensions = array (
-       );
-?>
\ No newline at end of file
diff --git a/config.default.php b/config.default.php
new file mode 100644 (file)
index 0000000..a709a9e
--- /dev/null
@@ -0,0 +1,202 @@
+<?php
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+    //--------------------------------------------------
+
+       // User configurable variables
+       //---------------------------------------------------
+
+       /*Show debug messages returned from an error on the page.
+       Debugging info level also determined by settings in PHP.ini
+       if $debug=1 show debugging info, dont show if $debug=0 */
+
+if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root']))
+       die("Restricted access");
+       // Log file for error/warning messages. Should be set to any location
+       // writable by www server. When set to empty string logging is switched off. 
+       // Special value 'syslog' can be used for system logger usage (see php manual).
+       //$error_logfile = '';
+       $error_logfile = dirname(__FILE__).'/tmp/errors.log';
+       $debug                  = 1;
+       $show_sql               = 0;
+       $go_debug               = 1;
+       $pdf_debug              = 0;
+       // set $sql_trail to 1 only if you want to perform bugtracking sql trail
+       // Warning: this produces huge amount of data in sql_trail table.
+       // Don't forget switch the option off and flush the table manually after 
+       // trail, or your future backup files are overloaded with unneeded data.
+       //
+       $sql_trail              = 0; // save all sql queries in sql_trail
+       $select_trail   = 0; // track also SELECT queries
+       if ($go_debug == 1)
+       {
+               error_reporting(E_ALL);
+               ini_set("display_errors", "On");
+       }
+       else
+       {
+               error_reporting(E_USER_WARNING|E_USER_ERROR|E_USER_NOTICE);
+               // ini_alter("error_reporting","E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR|E_PARSE");
+               ini_set("display_errors", "On");
+       }
+
+       if($error_logfile != '') {
+               ini_set("error_log", $error_logfile);
+               ini_set("ignore_repeated_errors", "On");
+               ini_set("log_errors", "On");
+       }               
+       // Main Title
+       $app_title = "FrontAccounting";
+       // application version
+       $version                = "2.2 RC";
+
+       // Build for development purposes
+       $build_version  = date("d.m.Y", filemtime("$path_to_root/CHANGELOG.txt"));
+
+       // Powered by
+       $power_by               = "FrontAccounting";
+       $power_url              = "http://frontaccounting.net";
+
+       /* use popup windows for views */
+       $use_popup_windows = 1;
+
+       /* use date picker for all date fields */
+       $use_date_picker = 1;
+
+       /* use Audit Trails in GL */
+       $use_audit_trail = 0;
+
+       /* use old style convert (income and expense in BS, PL) */
+       $use_oldstyle_convert = 0;
+
+       /* Integrated base Wiki Help URL or null if not used */
+       //$help_base_url = $path_to_root.'/modules/wiki/index.php?n='._('Help').'.';
+       $help_base_url = null;
+
+       /* per user data/cache directory */
+       $comp_path = $path_to_root.'/company';
+
+       /* allow alpha characters in accounts. 0 = numeric, 1 = alpha numeric, 2 = uppercase alpha numeric */
+       $accounts_alpha = 0;
+
+       /* Date systems. 0 = traditional, 1 = Jalali used by Iran, nabour countries, Afghanistan and some other Central Asian nations,
+       2 = Islamic used by other arabic nations */
+       $date_system = 0;
+
+       /* email stock location if order below reorder-level */
+       $loc_notification = 0;
+
+       /* print_invoice_no. 0 = print reference number, 1 = print invoice number */
+       $print_invoice_no = 0;
+
+       $dateformats    = array("MMDDYYYY", "DDMMYYYY", "YYYYMMDD");
+       $dateseps               = array("/", ".", "-", " ");
+       $thoseps                = array(",", ".", " ");
+       $decseps                = array(".", ",");
+
+       $pagesizes              = array("Letter", "A4"); // default PDF pagesize
+
+       /* Default border and spacing for tables */
+       /* Should be moved to CSS */
+
+       if (!isset($_SESSION['bordercolor']))
+               $_SESSION['bordercolor'] = "#8cacbb";
+       $table_style    = "cellpadding=3 border=1 bordercolor='".$_SESSION['bordercolor']."' class='tablestyle'";
+       $table_style2   = "cellpadding=3 border=1 bordercolor='#cccccc' class='tablestyle2'";
+
+       /* Accounts Payable */
+       /* System check to see if quantity charged on purchase invoices exceeds the quantity received.
+       If this parameter is checked the proportion by which the purchase invoice is an overcharge
+       referred to before reporting an error */
+
+       $check_qty_charged_vs_del_qty = true;
+
+       /* System check to see if price charged on purchase invoices exceeds the purchase order price.
+       If this parameter is checked the proportion by which the purchase invoice is an overcharge
+       referred to before reporting an error */
+
+       $check_price_charged_vs_order_price = True;
+
+       $config_allocation_settled_allowance = 0.005;
+
+       // Internal configurable variables
+       //-----------------------------------------------------------------------------------
+
+       /* Whether to display the demo login and password or not */
+
+       $allow_demo_mode = false;
+
+       /* for uploaded item pictures */
+       $pic_width              = 80;
+       $pic_height     = 50;
+       $max_image_size = 500;
+
+       /* skin for Business Graphics, 1, 2 or 3 */
+       $graph_skin     = 1;
+
+/*     
+       Before upgrade from pre-2.2 FA you have to move here your customized
+       security roles definitions. If you have used standard roles, you
+       can simply uncomment following two arrays. After upgrade both arrays need 
+       to be deleted or commented out. You may wish to change user roles to
+       new better defined in Users Setup. Old not used roles can be set inactive 
+       or deleted.
+*/
+/* Standard FA2.1 Security Group definitions
+
+       $security_headings = array(
+                       _("Inquiries"),
+                       _("Accountant"),
+                       _("System Administrator"),
+       );
+
+       $security_groups = array(
+                       array(1,2),
+                       array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,16),
+                       array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20),
+       );
+*/
+
+       //MySQL Backup and Restore Settings
+
+if(isset($_SESSION["wa_current_user"])) {
+       define("BACKUP_PATH", $comp_path.'/'.user_company()."/backup/");
+}
+       // static js files path
+       $js_path = $path_to_root.'/js/';
+       // standard external js scripts included in all files
+       $js_static = array('JsHttpRequest.js', 'behaviour.js', 'utils.js', 'inserts.js');
+       // additional js source included in header
+       $js_lib = $js_userlib = array();
+
+if (!defined('ICON_EDIT'))
+{
+       define("ICON_EDIT", "edit.gif");        
+       define("ICON_DELETE", "delete.gif");    
+       define("ICON_ADD", "ok.gif");   
+       define("ICON_UPDATE", "ok.gif");        
+       define("ICON_OK", "ok.gif");    
+       define("ICON_CANCEL", "cancel.png");    
+       define("ICON_GL", "gl.png");    
+       define("ICON_PRINT", "print.png");      
+       define("ICON_PDF", "pdf.gif");  
+       define("ICON_DOC", "invoice.gif");      
+       define("ICON_CREDIT", "credit.gif");    
+       define("ICON_RECEIVE", "receive.gif");  
+       define("ICON_DOWN", "download.gif");    
+       define("ICON_MONEY", "money.png");      
+       define("ICON_REMOVE", "remove.png");    
+       define("ICON_REPORT", "report.png");    
+       define("ICON_VIEW", "view.gif");        
+       define("ICON_SUBMIT", "ok.gif");
+       define("ICON_ESCAPE", "escape.png");    
+}
+?>
\ No newline at end of file
diff --git a/config.php b/config.php
deleted file mode 100644 (file)
index c39a3e3..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-<?php
-/**********************************************************************
-    Copyright (C) FrontAccounting, LLC.
-       Released under the terms of the GNU General Public License, GPL, 
-       as published by the Free Software Foundation, either version 3 
-       of the License, or (at your option) any later version.
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
-***********************************************************************/
-    //--------------------------------------------------
-
-       // User configurable variables
-       //---------------------------------------------------
-
-       /*Show debug messages returned from an error on the page.
-       Debugging info level also determined by settings in PHP.ini
-       if $debug=1 show debugging info, dont show if $debug=0 */
-
-if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root']))
-       die("Restricted access");
-       // Log file for error/warning messages. Should be set to any location
-       // writable by www server. When set to empty string logging is switched off. 
-       // Special value 'syslog' can be used for system logger usage (see php manual).
-       //$error_logfile = '';
-       $error_logfile = dirname(__FILE__).'/tmp/errors.log';
-       $debug                  = 1;
-       $show_sql               = 0;
-       $go_debug               = 1;
-       $pdf_debug              = 0;
-       // set $sql_trail to 1 only if you want to perform bugtracking sql trail
-       // Warning: this produces huge amount of data in sql_trail table.
-       // Don't forget switch the option off and flush the table manually after 
-       // trail, or your future backup files are overloaded with unneeded data.
-       //
-       $sql_trail              = 0; // save all sql queries in sql_trail
-       $select_trail   = 0; // track also SELECT queries
-       if ($go_debug == 1)
-       {
-               error_reporting(E_ALL);
-               ini_set("display_errors", "On");
-       }
-       else
-       {
-               error_reporting(E_USER_WARNING|E_USER_ERROR|E_USER_NOTICE);
-               // ini_alter("error_reporting","E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR|E_PARSE");
-               ini_set("display_errors", "On");
-       }
-
-       if($error_logfile != '') {
-               ini_set("error_log", $error_logfile);
-               ini_set("ignore_repeated_errors", "On");
-               ini_set("log_errors", "On");
-       }               
-       // Main Title
-       $app_title = "FrontAccounting";
-       // application version
-       $version                = "2.2 Beta";
-
-       // Build for development purposes
-       $build_version  = date("d.m.Y", filemtime("$path_to_root/CHANGELOG.txt"));
-
-       // Powered by
-       $power_by               = "FrontAccounting";
-       $power_url              = "http://frontaccounting.net";
-
-       /* use popup windows for views */
-       $use_popup_windows = 1;
-
-       /* use date picker for all date fields */
-       $use_date_picker = 1;
-
-       /* use Audit Trails in GL */
-       $use_audit_trail = 0;
-
-       /* use old style convert (income and expense in BS, PL) */
-       $use_oldstyle_convert = 0;
-
-       /* Integrated base Wiki Help URL or null if not used */
-       //$help_base_url = $path_to_root.'/modules/wiki/index.php?n='._('Help').'.';
-       $help_base_url = null;
-
-       /* per user data/cache directory */
-       $comp_path = $path_to_root.'/company';
-
-       /* allow alpha characters in accounts. 0 = numeric, 1 = alpha numeric, 2 = uppercase alpha numeric */
-       $accounts_alpha = 0;
-
-       /* Date systems. 0 = traditional, 1 = Jalali used by Iran, nabour countries, Afghanistan and some other Central Asian nations,
-       2 = Islamic used by other arabic nations */
-       $date_system = 0;
-
-       /* email stock location if order below reorder-level */
-       $loc_notification = 0;
-
-       /* print_invoice_no. 0 = print reference number, 1 = print invoice number */
-       $print_invoice_no = 0;
-
-       $dateformats    = array("MMDDYYYY", "DDMMYYYY", "YYYYMMDD");
-       $dateseps               = array("/", ".", "-", " ");
-       $thoseps                = array(",", ".", " ");
-       $decseps                = array(".", ",");
-
-       $pagesizes              = array("Letter", "A4"); // default PDF pagesize
-
-       /* Default border and spacing for tables */
-       /* Should be moved to CSS */
-
-       if (!isset($_SESSION['bordercolor']))
-               $_SESSION['bordercolor'] = "#8cacbb";
-       $table_style    = "cellpadding=3 border=1 bordercolor='".$_SESSION['bordercolor']."' class='tablestyle'";
-       $table_style2   = "cellpadding=3 border=1 bordercolor='#cccccc' class='tablestyle2'";
-
-       /* Accounts Payable */
-       /* System check to see if quantity charged on purchase invoices exceeds the quantity received.
-       If this parameter is checked the proportion by which the purchase invoice is an overcharge
-       referred to before reporting an error */
-
-       $check_qty_charged_vs_del_qty = true;
-
-       /* System check to see if price charged on purchase invoices exceeds the purchase order price.
-       If this parameter is checked the proportion by which the purchase invoice is an overcharge
-       referred to before reporting an error */
-
-       $check_price_charged_vs_order_price = True;
-
-       $config_allocation_settled_allowance = 0.005;
-
-       // Internal configurable variables
-       //-----------------------------------------------------------------------------------
-
-       /* Whether to display the demo login and password or not */
-
-       $allow_demo_mode = false;
-
-       /* for uploaded item pictures */
-       $pic_width              = 80;
-       $pic_height     = 50;
-       $max_image_size = 500;
-
-       /* skin for Business Graphics, 1, 2 or 3 */
-       $graph_skin     = 1;
-
-/*     
-       Before upgrade from pre-2.2 FA you have to move here your customized
-       security roles definitions. If you have used standard roles, you
-       can simply uncomment following two arrays. After upgrade both arrays need 
-       to be deleted or commented out. You may wish to change user roles to
-       new better defined in Users Setup. Old not used roles can be set inactive 
-       or deleted.
-*/
-/* Standard FA2.1 Security Group definitions
-
-       $security_headings = array(
-                       _("Inquiries"),
-                       _("Accountant"),
-                       _("System Administrator"),
-       );
-
-       $security_groups = array(
-                       array(1,2),
-                       array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,16),
-                       array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20),
-       );
-*/
-
-       //MySQL Backup and Restore Settings
-
-if(isset($_SESSION["wa_current_user"])) {
-       define("BACKUP_PATH", $comp_path.'/'.user_company()."/backup/");
-}
-       // static js files path
-       $js_path = $path_to_root.'/js/';
-       // standard external js scripts included in all files
-       $js_static = array('JsHttpRequest.js', 'behaviour.js', 'utils.js', 'inserts.js');
-       // additional js source included in header
-       $js_lib = $js_userlib = array();
-
-if (!defined('ICON_EDIT'))
-{
-       define("ICON_EDIT", "edit.gif");        
-       define("ICON_DELETE", "delete.gif");    
-       define("ICON_ADD", "ok.gif");   
-       define("ICON_UPDATE", "ok.gif");        
-       define("ICON_OK", "ok.gif");    
-       define("ICON_CANCEL", "cancel.png");    
-       define("ICON_GL", "gl.png");    
-       define("ICON_PRINT", "print.png");      
-       define("ICON_PDF", "pdf.gif");  
-       define("ICON_DOC", "invoice.gif");      
-       define("ICON_CREDIT", "credit.gif");    
-       define("ICON_RECEIVE", "receive.gif");  
-       define("ICON_DOWN", "download.gif");    
-       define("ICON_MONEY", "money.png");      
-       define("ICON_REMOVE", "remove.png");    
-       define("ICON_REPORT", "report.png");    
-       define("ICON_VIEW", "view.gif");        
-       define("ICON_SUBMIT", "ok.gif");
-       define("ICON_ESCAPE", "escape.png");    
-}
-?>
\ No newline at end of file
diff --git a/config_db.php b/config_db.php
deleted file mode 100644 (file)
index 1c06397..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-/*Connection Information for the database
-- $def_coy is the default company that is pre-selected on login
-
-- host is the computer ip address or name where the database is the default is localhost assuming that the web server is also the sql server
-
-- user is the user name under which the database should be accessed - need to change to the mysql (or other DB) user set up for purpose
-  NB it is not secure to use root as the user with no password - a user with appropriate privileges must be set up
-
-- password is the password the user of the database requires to be sent to authorise the above database user
-
-- DatabaseName is the name of the database as defined in the RDMS being used. Typically RDMS allow many databases to be maintained under the same server.
-  The scripts for MySQL provided use the name logicworks */
-
-
-$def_coy = 0;
-
-/*--- for advanced users, manually install, uncomment this, fill in the correct information and erase the rows below
-$tb_pref_counter = 1;
-
-$db_connections = array (
-       0 => array ('name' => 'Training Co.',
-               'host' => 'localhost',
-               'dbuser' => 'your_db_user_name',
-               'dbpassword' => 'your_db_password',
-               'dbname' => 'your_db_name',
-               'tbpref' => '0_')
-       );
-*/
-
-$tb_pref_counter = 0;
-
-$db_connections = array ();
-
-?>
\ No newline at end of file
index 04acec518543dc53ddc940be48a8f0bc6ad933d3..734c17036f9d2160bf55d535380c7f01f284323f 100644 (file)
@@ -165,7 +165,7 @@ header("Cache-control: private");
 get_text_init();
 
 // Page Initialisation
-if (!isset($_SESSION['languages'])) 
+if (!isset($_SESSION['language'])) 
 {
        load_languages(); // sets also default $_SESSION['language']
 }
index 7ba272d47f6ed941151922f8fd650ab4c7d98a83..569245493f6ed427558624d2b947dfc56a14df3a 100644 (file)
@@ -21,6 +21,7 @@ if(!isset($_GET['sessions_checked']) || $_GET['sessions_checked'] != 'true')
 {
        // Set session variable
        $_SESSION['session_support'] = '<font class="good">Enabled</font>';
+       $_SESSION['message'] = '';
        // Reload page
        header('Location: index.php?sessions_checked=true');
        exit(0);
@@ -87,8 +88,15 @@ function change_os(type) {
                <center>
                        <img src="<?php echo $path_to_root; ?>/themes/default/images/logo_frontaccounting.png" width="250" height="50" alt="Logo" />
                </center>
-
-
+<?php
+ if(file_exists($path_to_root.'/config.php')) { 
+?><div style="width: 700px; padding: 10px; margin-bottom: 5px; border: 1px solid #FF0000; background-color: #FFDBDB;"><b>Error:</b> Seems you have FrontAccounting application already installed.<BR>
+After logging as an admin to first installed company you can:
+<ul>
+<li> Add more companies using Add/Update Companies under Setup tab;</li>
+<li> Upgrade FA version using Upgrade Software under Setup tab.</li>
+</ul></div>
+<?php exit; } ?>
                <?php
                if(isset($_SESSION['message']) AND $_SESSION['message'] != '') {
                        ?><div style="width: 700px; padding: 10px; margin-bottom: 5px; border: 1px solid #FF0000; background-color: #FFDBDB;"><b>Error:</b> <?php echo $_SESSION['message']; ?></div><?php
@@ -159,9 +167,9 @@ function change_os(type) {
                </tr>
                <tr>
                        <td style="color: #666666;">config_db.php</td>
-                       <td><?php if(is_writable($path_to_root.'/config_db.php')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($path_to_root.'/config_db.php')) { echo '<font class="bad">File Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
+                       <td><?php if(is_writable($path_to_root)) { echo '<font class="good">Writeable</font>'; } elseif(file_exists($path_to_root.'/config_db.php')) { echo '<font class="bad">File Exists</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
                        <td style="color: #666666;">modules/</td>
-                       <td><?php if(is_writable($path_to_root.'/modules/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($path_to_root.'/lang/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
+                       <td><?php if(is_writable($path_to_root.'/modules/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($path_to_root.'/modules/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
                </tr>
                <tr>
                        <td style="color: #666666;">lang/</td>
index facba388023fd0d12373970195782b271b0d1f04..b11263a3e3d2836ac75ae25fa4d495e9ecaeb1e8 100644 (file)
@@ -295,9 +295,33 @@ if ($admin_password != $admin_repassword)
 }
 // End admin user details code
 
+if (!file_exists($path_to_root . "/config.php")) {
+       copy($path_to_root. "/config.default.php", $path_to_root. "/config.php");
+}
+
 include_once($path_to_root . "/includes/db/connect_db.inc");
 include_once($path_to_root . "/admin/db/maintenance_db.inc");
-include_once($path_to_root . "/config_db.php");
+
+if (!file_exists($path_to_root . "/installed_extensions.php")) {
+       $next_extension_id = 1;
+       write_extensions(array());
+       write_extensions(array(),0);
+}
+if (!file_exists($path_to_root . "/lang/installed_languages.inc")) {
+       $installed_languages = array (
+               0 => array ('code' => 'en_GB', 'name' => 'English', 'encoding' => 'iso-8859-1'));
+       $dflt_lang = 'en_GB';
+       write_lang();
+}
+
+if (file_exists($path_to_root . "/config_db.php"))
+       include_once($path_to_root . "/config_db.php");
+ else
+{
+       $def_coy = 0;
+       $tb_pref_counter = 0;
+       $db_connections = array ();
+}
 
 $id = count($db_connections);
 if ($table_prefix != "" && $id > 0)
@@ -360,7 +384,6 @@ if (!$db)
 session_unset();
 session_destroy();
 $_SESSION = array();
-
 header("Location: ".$path_to_root."/index.php");
 exit();
 
diff --git a/installed_extensions.php b/installed_extensions.php
deleted file mode 100644 (file)
index 8afb638..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-/* List of installed additional modules and plugins. If adding extensions manually 
-       to the list make sure they have unique, so far not used extension_ids as a keys,
-       and $next_extension_id is also updated.
-       
-       'name' - name for identification purposes;
-       'type' - type of extension: 'module' or 'plugin'
-       'path' - FA root based installation path
-       'filename' - name of module menu file, or plugin filename; related to path.
-       'tab' - index of the module tab (new for module, or one of standard module names for plugin);
-       'title' - is the menu text (for plugin) or new tab name
-       'active' - current status of extension
-       'acc_file' - (optional) file name with $security_areas/$security_sections extensions; 
-               related to 'path'
-       'access' - security area code in string form
-*/
-
-$next_extension_id = 1; // unique id for next installed extension
-
-$installed_extensions = array (
-       );
-?>
\ No newline at end of file
diff --git a/lang/installed_languages.inc b/lang/installed_languages.inc
deleted file mode 100644 (file)
index 158bab0..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-/* How to make new entries here
-
--- if adding languages at the beginning of the list, make sure it's index is set to 0 (it has ' 0 => ')
--- 'code' should match the name of the directory for the language under \lang
--- 'name' is the name that will be displayed in the language selection list (in Users and Display Setup)
--- 'rtl' only needs to be set for right-to-left languages like Arabic and Hebrew
-
-*/
-
-
-$installed_languages = array (
-       0 => array ('code' => 'en_GB', 'name' => 'English', 'encoding' => 'iso-8859-1'),
-               array ('code' => 'en_US', 'name' => 'English (US)', 'encoding' => 'iso-8859-1'),
-       );
-
-$dflt_lang = 'en_GB';
-?>
\ No newline at end of file