= '500') { $sql = "ALTER DATABASE `" . Dba::escape($database) . "` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci"; $db_results = mysql_query($sql); } if(Config::get('lang') != 'en_US') { $sql = "UPDATE `preference` SET `value`='" . Config::get('lang') . "' WHERE `id`=31"; $db_results = mysql_query($sql); $sql = "UPDATE `user_preference` SET `value`='" .Config::get('lang') ."' WHERE `preference`=31"; $db_results = mysql_query($sql); } return true; } // install_insert_db /** * install_create_config * attempts to write out the config file * if it can't write it out it will prompt the * user to download the config file. */ function install_create_config($web_path,$username,$password,$hostname,$database) { $data['database_username'] = $username; $data['database_password'] = $password; $data['database_hostname'] = $hostname; $data['database_name'] = $database; $data['web_path'] = $web_path; Config::set_by_array($data,'1'); /* Attempt to make DB connection */ $dbh = Dba::dbh(); /* First Test The Variables they've given us to make sure that they actually work! */ // Connect to the DB if(!is_resource($dbh)) { Error::add('general',"Database Connection Failed Check Hostname, Username and Password"); return false; } if (!$db_selected = @mysql_select_db($database, $dbh)) { Error::add('general',"Database Selection Failure Check Existance of $database"); return false; } $final = generate_config($data); $browser = new Browser(); $browser->downloadHeaders('ampache.cfg.php','text/plain',false,filesize('config/ampache.cfg.php.dist')); echo $final; exit(); return true; } // install_create_config /** * install_create_account * this creates your initial account and sets up the preferences for the -1 user and you */ function install_create_account($username,$password,$password2) { if (!strlen($username) OR !strlen($password)) { Error::add('general',_('No Username/Password specified')); return false; } if ($password !== $password2) { Error::add('general',_('Passwords do not match')); return false; } $dbh = Dba::dbh(); if (!is_resource($dbh)) { Error::add('general','Database Connection Failed:' . mysql_error()); return false; } $db_select = @mysql_select_db(Config::get('database_name'),$dbh); if (!$db_select) { Error::add('general','Database Select Failed:' . mysql_error()); return false; } $username = Dba::escape($username); $password = Dba::escape($password); $insert_id = User::create($username,'Administrator','',$password,'100'); if (!$insert_id) { Error::add('general',"Insert of Base User Failed " . mysql_error()); return false; } // Fix the system users preferences User::fix_preferences('-1'); return true; } // install_create_account ?>