summaryrefslogtreecommitdiff
path: root/install.php
diff options
context:
space:
mode:
authorBrenda Wallace <shiny@cpan.org>2009-06-23 17:43:46 +1200
committerBrenda Wallace <shiny@cpan.org>2009-07-15 18:45:45 +1200
commit343e2010ae276fa4ca5e56c40eb6f06cd01a6136 (patch)
tree1f626837be145c16640687f4851d5e2d2493d577 /install.php
parent3fe182e86503a9e95183fe6d641e511a4d3eb0f1 (diff)
connect to pg working
Diffstat (limited to 'install.php')
-rw-r--r--install.php97
1 files changed, 53 insertions, 44 deletions
diff --git a/install.php b/install.php
index 61156e937..9f48c919d 100644
--- a/install.php
+++ b/install.php
@@ -204,21 +204,21 @@ function handlePost()
$fail = true;
}
- if (empty($password)) {
- updateStatus("No password specified.", true);
- $fail = true;
- }
+// if (empty($password)) {
+// updateStatus("No password specified.", true);
+// $fail = true;
+// }
if (empty($sitename)) {
updateStatus("No sitename specified.", true);
$fail = true;
}
- if($fail){
- showForm();
- return;
- }
-
+ if($fail){
+ showForm();
+ return;
+ }
+
switch($dbtype) {
case 'mysql': mysql_db_installer($host, $database, $username, $password, $sitename);
break;
@@ -233,46 +233,55 @@ function handlePost()
<?php
}
- function pgsql_db_installer($host, $database, $username, $password, $sitename) {
- echo 'TODO'; exit;
- }
+function pgsql_db_installer($host, $database, $username, $password, $sitename) {
+ $connstring = "dbname=$database host=$host user=$username";
- function mysql_db_installer($host, $database, $username, $password, $sitename) {
- updateStatus("Starting installation...");
- updateStatus("Checking database...");
-
- $conn = mysql_connect($host, $username, $password);
- if (!$conn) {
- updateStatus("Can't connect to server '$host' as '$username'.", true);
- showForm();
- return;
- }
- updateStatus("Changing to database...");
- $res = mysql_select_db($database, $conn);
- if (!$res) {
- updateStatus("Can't change to database.", true);
- showForm();
- return;
- }
- updateStatus("Running database script...");
- $res = runDbScript(INSTALLDIR.'/db/laconica.sql', $conn);
+ //No password would mean trust authentication used.
+ if (!empty($password)) {
+ $connstring .= " password=$password";
+ }
+ updateStatus("Starting installation...");
+ updateStatus("Checking database...");
+ $conn = pg_connect($connstring);
+
+}
+
+function mysql_db_installer($host, $database, $username, $password, $sitename) {
+ updateStatus("Starting installation...");
+ updateStatus("Checking database...");
+
+ $conn = mysql_connect($host, $username, $password);
+ if (!$conn) {
+ updateStatus("Can't connect to server '$host' as '$username'.", true);
+ showForm();
+ return;
+ }
+ updateStatus("Changing to database...");
+ $res = mysql_select_db($database, $conn);
+ if (!$res) {
+ updateStatus("Can't change to database.", true);
+ showForm();
+ return;
+ }
+ updateStatus("Running database script...");
+ $res = runDbScript(INSTALLDIR.'/db/laconica.sql', $conn);
+ if ($res === false) {
+ updateStatus("Can't run database script.", true);
+ showForm();
+ return;
+ }
+ foreach (array('sms_carrier' => 'SMS carrier',
+ 'notice_source' => 'notice source',
+ 'foreign_services' => 'foreign service')
+ as $scr => $name) {
+ updateStatus(sprintf("Adding %s data to database...", $name));
+ $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn);
if ($res === false) {
- updateStatus("Can't run database script.", true);
+ updateStatus(sprintf("Can't run %d script.", $name), true);
showForm();
return;
}
- foreach (array('sms_carrier' => 'SMS carrier',
- 'notice_source' => 'notice source',
- 'foreign_services' => 'foreign service')
- as $scr => $name) {
- updateStatus(sprintf("Adding %s data to database...", $name));
- $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn);
- if ($res === false) {
- updateStatus(sprintf("Can't run %d script.", $name), true);
- showForm();
- return;
- }
- }
+ }
updateStatus("Writing config file...");
$sqlUrl = "mysqli://$username:$password@$host/$database";