diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-05-13 09:00:22 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-05-13 09:00:22 +0000 |
commit | dccdeba838129a5a3805c7669ec0a6328269f738 (patch) | |
tree | c0be99c6f36c6d32330ae304a3d13e84a783dfb4 | |
parent | 1e9f582cf1dba653f45bbc5835fa662a3c163e69 (diff) | |
download | ampache-dccdeba838129a5a3805c7669ec0a6328269f738.tar.gz ampache-dccdeba838129a5a3805c7669ec0a6328269f738.tar.bz2 ampache-dccdeba838129a5a3805c7669ec0a6328269f738.zip |
first step of installer works, will finish later tomorrow morning
-rw-r--r-- | install.php | 54 | ||||
-rw-r--r-- | lib/debug.lib.php | 13 | ||||
-rw-r--r-- | lib/general.lib.php | 2 | ||||
-rw-r--r-- | lib/install.php | 37 | ||||
-rw-r--r-- | templates/show_install.inc | 8 | ||||
-rw-r--r-- | templates/show_install_lang.inc.php | 10 |
6 files changed, 54 insertions, 70 deletions
diff --git a/install.php b/install.php index 3156c548..5d24d352 100644 --- a/install.php +++ b/install.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 ampache.org + Copyright (c) 2001 - 2007 ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -22,38 +22,37 @@ // Set the Error level manualy... I'm to lazy to fix notices error_reporting(E_ALL ^ E_NOTICE); -require_once('lib/general.lib.php'); -require_once('lib/ui.lib.php'); -require_once('modules/horde/Browser.php'); -require_once('lib/install.php'); -require_once('lib/debug.lib.php'); -require_once('lib/class/user.class.php'); -require_once('lib/class/error.class.php'); -require_once('lib/gettext.php'); +require_once 'lib/general.lib.php'; +require_once 'lib/class/config.class.php'; +require_once 'lib/ui.lib.php'; +require_once 'lib/log.lib.php'; +require_once 'modules/horde/Browser.php'; +require_once 'lib/install.php'; +require_once 'lib/debug.lib.php'; +require_once 'lib/gettext.php'; -require_once('modules/vauth/dbh.lib.php'); -require_once('modules/vauth/init.php'); +require_once 'modules/vauth/dbh.lib.php'; +require_once 'modules/vauth/init.php'; if ($_SERVER['HTTPS'] == 'on') { $http_type = "https://"; } else { $http_type = "http://"; } $prefix = dirname(__FILE__); +Config::set('prefix',$prefix,'1'); $configfile = "$prefix/config/ampache.cfg.php"; -$conf_array = array('prefix' => $prefix,'font_size' => '12', 'bg_color1' => '#c0c0c0', 'font' => 'Verdana', 'error_color' => 'red'); -$conf_array['base_color1'] = "#a0a0a0"; -$conf_array['bg_color2'] = "#000000"; -conf($conf_array); - /* First things first we must be sure that they actually still need to install ampache */ if (!install_check_status($configfile)) { - access_denied(); + echo "Error: Config file detected, Ampache is already installed"; + exit; } +// Define that we are doing an install so the includes will work +define('INSTALL','1'); + /* Clean up incomming variables */ -$action = scrub_in($_REQUEST['action']); $web_path = scrub_in($_REQUEST['web_path']); $username = scrub_in($_REQUEST['local_username']); $password = $_REQUEST['local_pass']; @@ -62,11 +61,9 @@ $database = scrub_in($_REQUEST['local_db']); if ($_SERVER['HTTPS'] == 'on') { $http_type = "https://"; } else { $http_type = "http://"; } $php_self = $http_type . $_SERVER['HTTP_HOST'] . "/" . preg_replace("/^\/(.+\.php)\/?.*/","$1",$_SERVER['PHP_SELF']); -$error = new Error(); /* Catch the Current Action */ -switch ($action) { - +switch ($_REQUEST['action']) { case 'create_db': if (!install_insert_db($username,$password,$hostname,$database)) { require_once('templates/show_install.inc'); @@ -186,15 +183,14 @@ switch ($action) { header ("Content-Type: text/html; charset=" . conf('site_charset')); require_once('templates/show_install_account.inc.php'); - break; - + break; case 'init': /* First step of installation */ // Get the language $htmllang = $_POST['htmllang']; // Set the lang in the conf array - conf(array('lang'=>$htmllang)); + Config::set('lang',$htmllang,'1'); // We need the charset for the different languages $charsets = array('de_DE' => 'ISO-8859-15', @@ -209,16 +205,15 @@ switch ($action) { $charset = $charsets[$_POST['htmllang']]; // Set the site_charset in the conf array - conf(array('site_charset'=>$charsets[$_POST['htmllang']])); + Config::set('site_charset',$charsets[$_POST['htmllang']],'1'); // Now we make voodoo with the Load gettext mojo load_gettext(); // Page ready :) header ("Content-Type: text/html; charset=$charset"); - require_once('templates/show_install.inc'); - break; - + require_once 'templates/show_install.inc'; + break; default: /* Do some basic tests here... most common error, no mysql */ if (!function_exists('mysql_query')) { @@ -227,10 +222,9 @@ switch ($action) { $htmllang = "en_US"; header ("Content-Type: text/html; charset=UTF-8"); /* Show the language options first */ - require_once('templates/show_install_lang.inc.php'); + require_once 'templates/show_install_lang.inc.php'; break; - } // end action switch diff --git a/lib/debug.lib.php b/lib/debug.lib.php index 10ad838f..69825c68 100644 --- a/lib/debug.lib.php +++ b/lib/debug.lib.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -28,12 +28,11 @@ * connections, web paths etc.. */ -/*! - @function check_database - @discussion checks the local mysql db - and make sure life is good -*/ -function check_database($host,$username,$pass,$database) { +/** + * check_database + * checks the local mysql db and make sure life is good + */ +function check_database($host,$username,$pass) { $dbh = @mysql_connect($host, $username, $pass); diff --git a/lib/general.lib.php b/lib/general.lib.php index ff641e6f..c9283f08 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -343,7 +343,7 @@ function get_random_songs( $options, $matchlist) { $albums_where .= " OR song.album=" . $data[0]; } $albums_where = ltrim($albums_where," OR"); - $query = "SELECT song.id,song.size,song.time FROM song WHERE $albums_where ORDER BY song.track ASC"; + $query = "SELECT song.id,song.size,song.time FROM song WHERE $albums_where ORDER BY song.album,song.track ASC"; } elseif ($options['random_type'] == 'full_artist') { $query = "SELECT artist.id FROM song,artist WHERE song.artist=artist.id AND $where GROUP BY song.artist ORDER BY RAND() " . $limit_sql; diff --git a/lib/install.php b/lib/install.php index 0efdeaa7..4bf47b11 100644 --- a/lib/install.php +++ b/lib/install.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -19,17 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/*! - @header Install docuement - @discussion this document contains the functions needed to see if - ampache needs to be installed -*/ -/*! - @function split_sql - @discussion splits up a standard SQL dump file into distinct - sql queryies -*/ +/** + * split_sql + * splits up a standard SQL dump file into distinct + * sql queryies + */ function split_sql($sql) { $sql = trim($sql); $sql = ereg_replace("\n#[^\n]*\n", "\n", $sql); @@ -59,13 +54,12 @@ function split_sql($sql) { return($ret); } // split_sql -/*! - @function install_check_status() - @discussion this function checks to see if we actually - still need to install ampache. This function is - very important, we don't want to reinstall over top - of an existing install -*/ +/** + * install_check_status + * this function checks to see if we actually + * still need to install ampache. This function is + * very important, we don't want to reinstall over top of an existing install + */ function install_check_status($configfile) { /* @@ -81,11 +75,10 @@ function install_check_status($configfile) { Check and see if they've got _any_ account if they don't then they're cool */ - $results = read_config($GLOBALS['configfile'], 0, 0); - $dbh = check_database($results['local_host'],$results['local_username'],$results['local_pass']); + $results = parse_ini_file($GLOBALS['configfile']); + $dbh = check_database($results['database_hostname'],$results['database_username'],$results['database_password']); if (is_resource($dbh)) { - $db_select = mysql_select_db($results['local_db'],$dbh); $sql = "SELECT * FROM user"; $db_results = @mysql_query($sql, $dbh); @@ -94,8 +87,6 @@ function install_check_status($configfile) { } } - - /* Defaut to no */ return false; diff --git a/templates/show_install.inc b/templates/show_install.inc index 3aa38192..e0307e18 100644 --- a/templates/show_install.inc +++ b/templates/show_install.inc @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -24,7 +24,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $htmllang; ?>" lang="<?php echo $htmllang; ?>"> <head> <title>Ampache :: For The Love Of Music - Install</title> -<?php require_once(conf('prefix') . "/templates/install.css"); ?> +<link rel="stylesheet" href="templates/install.css" type="text/css" media="screen" /> </head> <body> <script src="lib/javascript-base.js" language="javascript" type="text/javascript"></script> @@ -35,7 +35,7 @@ <div id="text-box"> <div class="notify"> - <b><?php echo _("Requirements"); ?></b> + <b><?php echo _('Requirements'); ?></b> <p> <?php echo _("This Page handles the installation of the Ampache database and the creation of the ampache.cfg.php file. Before you continue please make sure that you have the following pre-requisites"); ?> </p> @@ -57,7 +57,7 @@ <?php echo _("Step 3 - Setup Initial Account"); ?><br /> <br /><br /> <span class="header2">Insert Ampache Database</span> - <?php echo $GLOBALS['error']->print_error('general'); ?> + <?php Error::display('general'); ?> <form method="post" action="<?php echo $http_type . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?action=create_db&htmllang=$htmllang&charset=$charset"; ?>" enctype="multipart/form-data" > <table> <tr> diff --git a/templates/show_install_lang.inc.php b/templates/show_install_lang.inc.php index 4a631dc0..2d1b8d65 100644 --- a/templates/show_install_lang.inc.php +++ b/templates/show_install_lang.inc.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -19,12 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ?> - +<?php if (INSTALL != '1') { exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$htmllang" lang="$htmllang"> <head> <title>Ampache :: Pour l'Amour de la Musique - Install</title> -<?php require_once(conf('prefix') . "/templates/install.css"); ?> +<link rel="stylesheet" href="templates/install.css" type="text/css" media="screen" /> </head> <body> <script src="lib/javascript-base.js" language="javascript" type="text/javascript"></script> @@ -34,7 +34,7 @@ </div> <div id="text-box"> <div class="notify"> - <b><?php echo _("Requirements"); ?></b> + <b><?php echo _('Requirements'); ?></b> <p> <?php echo _('This Page handles the installation of the Ampache database and the creation of the ampache.cfg.php file. Before you continue please make sure that you have the following pre-requisites'); ?> </p> @@ -50,7 +50,7 @@ <div class="content"> <b>Choose installation language.</b> <p> - <?php echo $GLOBALS['error']->print_error('general'); ?> + <?php Error::display('general'); ?> </p> <form method="post" action="<?php echo $http_type . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?action=init"; ?>" enctype="multipart/form-data" > |