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;
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()
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()
{
$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"] . "";
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;
}
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)
$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;
}
'pass' => $_POST['pass'],
'name' => $_POST['name'],
'admin' => $_POST['admin'],
+ 'lang' => $_POST['lang']
));
if (do_install()) {
$_POST['Page'] = 6;
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),
$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();
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);