From: Janusz Dobrowolski Date: Sat, 17 Jan 2015 19:03:22 +0000 (+0100) Subject: Fixed a couple of problems in installation procedures. X-Git-Tag: v2.4.2~19^2~264 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=577328a5a3a3d5cd6e2252798a355fa20a8f591e Fixed a couple of problems in installation procedures. --- diff --git a/admin/create_coy.php b/admin/create_coy.php index 80c74715..0366e76c 100644 --- a/admin/create_coy.php +++ b/admin/create_coy.php @@ -127,6 +127,8 @@ function handle_submit($selected_id) display_error(_("Error creating Database: ") . $conn['dbname'] . _(", Please create it manually")); $error = true; } else { + if (strncmp(db_get_version(), "5.6", 3) >= 0) + db_query("SET sql_mode = ''"); if (!db_import($path_to_root.'/sql/'.get_post('coa'), $conn, $selected_id)) { display_error(_('Cannot create new company due to bugs in sql file.')); $error = true; diff --git a/includes/current_user.inc b/includes/current_user.inc index 4f5e7898..89b475fd 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -473,12 +473,18 @@ function user_show_codes() function user_date_format() { - return $_SESSION["wa_current_user"]->prefs->date_format(); + global $SysPrefs; + + return isset($_SESSION["wa_current_user"]) ? + $_SESSION["wa_current_user"]->prefs->date_format() : $SysPrefs->dflt_date_fmt; } function user_date_display() { - return $_SESSION["wa_current_user"]->prefs->date_display(); + global $SysPrefs; + + return isset($_SESSION["wa_current_user"]) ? + $_SESSION["wa_current_user"]->prefs->date_display() : $SysPres->dflt_date_sep; } function user_date_sep() @@ -488,12 +494,14 @@ function user_date_sep() function user_tho_sep() { - return $_SESSION["wa_current_user"]->prefs->tho_sep(); + return isset($_SESSION["wa_current_user"]) ? + $_SESSION["wa_current_user"]->prefs->tho_sep() : 0; } function user_dec_sep() { - return $_SESSION["wa_current_user"]->prefs->dec_sep(); + return isset($_SESSION["wa_current_user"]) ? + $_SESSION["wa_current_user"]->prefs->dec_sep() : 0; } function user_theme() diff --git a/includes/db/connect_db_mysql.inc b/includes/db/connect_db_mysql.inc index 301d49dd..f4dda47c 100644 --- a/includes/db/connect_db_mysql.inc +++ b/includes/db/connect_db_mysql.inc @@ -183,8 +183,7 @@ function db_create_db($connection) { $db = mysql_connect($connection["host"] , $connection["dbuser"], $connection["dbpassword"]); - if (strncmp(db_get_version(), "5.6", 3) >= 0) - db_query("SET sql_mode = ''"); + if (!mysql_select_db($connection["dbname"], $db)) { $sql = "CREATE DATABASE IF NOT EXISTS " . $connection["dbname"] . ""; diff --git a/includes/db/connect_db_mysqli.inc b/includes/db/connect_db_mysqli.inc index 8900598a..7359a85c 100644 --- a/includes/db/connect_db_mysqli.inc +++ b/includes/db/connect_db_mysqli.inc @@ -182,11 +182,10 @@ function db_field_name($result, $n) function db_create_db($connection) { $db = mysqli_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"]); - if (strncmp(db_get_version(), "5.6", 3) >= 0) - db_query("SET sql_mode = ''"); + if (!mysqli_select_db($db, $connection["dbname"])) { - $sql = "CREATE DATABASE IF NOT EXISTS " . $connection["dbname"] . ""; + $sql = "CREATE DATABASE IF NOT EXISTS `" . $connection["dbname"] . "`"; if (!mysqli_query($db, $sql) || !mysqli_select_db($db, $connection["dbname"])) return 0; } diff --git a/includes/prefs/sysprefs.inc b/includes/prefs/sysprefs.inc index bf685768..ee3fa70b 100644 --- a/includes/prefs/sysprefs.inc +++ b/includes/prefs/sysprefs.inc @@ -21,7 +21,8 @@ class sys_prefs global $path_to_root; include $path_to_root.'/config.default.php'; - include $path_to_root.'/config.php'; + if (file_exists($path_to_root.'/config.php')) + include $path_to_root.'/config.php'; // set system wide preferences foreach(get_defined_vars() as $name => $value) diff --git a/install/index.php b/install/index.php index f617dfff..91fa3384 100644 --- a/install/index.php +++ b/install/index.php @@ -122,6 +122,9 @@ function install_connect_db() { $db = db_create_db($conn); if (!$db) { display_error(_("Cannot connect to database. User or password is invalid or you have no permittions to create database.")); + } else { + if (strncmp(db_get_version(), "5.6", 3) >= 0) + db_query("SET sql_mode = ''"); } return $db; } @@ -292,6 +295,7 @@ elseif(get_post('install_coas')) 'pass' => $_POST['pass'], 'name' => $_POST['name'], 'admin' => $_POST['admin'], + 'lang' => $_POST['lang'] )); if (do_install()) { $_POST['Page'] = 6; diff --git a/install/isession.inc b/install/isession.inc index acf14202..80843172 100644 --- a/install/isession.inc +++ b/install/isession.inc @@ -86,6 +86,9 @@ header("Cache-control: private"); include_once($path_to_root . "/config.default.php"); +$_SESSION['SysPrefs'] = new sys_prefs(); +$SysPrefs = &$_SESSION['SysPrefs']; + $inst_langs = array( 'C' => array ( 'name' => 'English', 'code' => 'C', 'encoding' => 'iso-8859-1'), 'ar_EG' => array ( 'name' => 'Arabic', 'code' => 'ar_EG', 'encoding' => 'utf-8', 'rtl' => true), @@ -119,6 +122,7 @@ if (!isset($_SESSION['language']) || !method_exists($_SESSION['language'], 'set_ $l = array_search_value($i_lang, $inst_langs, 'code'); $_SESSION['language'] = new language($l['name'], $l['code'], $l['encoding'], isset($l['rtl']) ? 'rtl' : 'ltr'); + } if (!isset($installed_languages)) $installed_languages = array(); @@ -150,8 +154,6 @@ html_cleanup($_POST); html_cleanup($_REQUEST); html_cleanup($_SERVER); -$SysPrefs = &$_SESSION['SysPrefs']; - // POST vars cleanup needed for direct reuse. // We quote all values later with db_escape() before db update. $_POST = strip_quotes($_POST);