From 8f1b1ffcf04da08193da51544487afa6647ad225 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 24 Jun 2009 04:04:28 +1200 Subject: mysql or pgsql required (not mysql) --- install.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'install.php') diff --git a/install.php b/install.php index 570b08edf..4e54ba870 100644 --- a/install.php +++ b/install.php @@ -48,7 +48,7 @@ function checkPrereqs() $pass = false; } - $reqs = array('gd', 'mysql', 'curl', + $reqs = array('gd', 'curl', 'xmlwriter', 'mbstring', 'gettext'); @@ -58,6 +58,10 @@ function checkPrereqs() $pass = false; } } + if (!checkExtension('pgsql') && !checkExtension('mysql')) { + ?>

Cannot mysql or pgsql extension. You need one or the other:

Cannot write config file to:

-- cgit v1.2.3-54-g00ecf From 4d42bc7690da6cb87b4526c25e5447d06ba12212 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 24 Jun 2009 04:07:15 +1200 Subject: missing word (find) added --- install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'install.php') diff --git a/install.php b/install.php index 4e54ba870..103c367c3 100644 --- a/install.php +++ b/install.php @@ -59,7 +59,7 @@ function checkPrereqs() } } if (!checkExtension('pgsql') && !checkExtension('mysql')) { - ?>

Cannot mysql or pgsql extension. You need one or the other:

Cannot find mysql or pgsql extension. You need one or the other:

Date: Wed, 24 Jun 2009 04:31:52 +1200 Subject: added dbtype to the installer form --- install.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'install.php') diff --git a/install.php b/install.php index 103c367c3..233a05550 100644 --- a/install.php +++ b/install.php @@ -126,12 +126,14 @@ function showForm()

Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.

  • - - -

    Database hostname

    + + MySQL
    + PostgreSQL
    +

    Database type

  • +
  • - +

    Database name

  • -- cgit v1.2.3-54-g00ecf From 3fe182e86503a9e95183fe6d641e511a4d3eb0f1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 23 Jun 2009 17:37:01 +1200 Subject: added dbtype detection - and only install mysql stuff if mysql selected --- install.php | 114 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 46 deletions(-) (limited to 'install.php') diff --git a/install.php b/install.php index 233a05550..61156e937 100644 --- a/install.php +++ b/install.php @@ -126,14 +126,20 @@ function showForm()

    Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.

  • + + +

    Database hostname

    +
  • +
  • + - MySQL
    - PostgreSQL
    + MySQL
    + PostgreSQL

    Database type

  • - +

    Database name

  • @@ -145,7 +151,7 @@ function showForm()
  • -

    Database password

    +

    Database password (optional)

  • @@ -169,6 +175,7 @@ function handlePost() '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"; - $res = writeConf($sitename, $sqlUrl, $fancy); - if (!$res) { - updateStatus("Can't write config file.", true); - showForm(); - return; - } - updateStatus("Done!"); if ($path) $path .= '/'; updateStatus("You can visit your new Laconica site."); ?> @@ -262,6 +233,57 @@ function handlePost() '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"; + $res = writeConf($sitename, $sqlUrl, $fancy); + if (!$res) { + updateStatus("Can't write config file.", true); + showForm(); + return; + } + updateStatus("Done!"); + } function writeConf($sitename, $sqlUrl, $fancy) { $res = file_put_contents(INSTALLDIR.'/config.php', -- cgit v1.2.3-54-g00ecf From 343e2010ae276fa4ca5e56c40eb6f06cd01a6136 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 23 Jun 2009 17:43:46 +1200 Subject: connect to pg working --- install.php | 97 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 44 deletions(-) (limited to 'install.php') 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() '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"; -- cgit v1.2.3-54-g00ecf From 4f9c3b50e7103498f06f7c9b0a232bcda5bf17b8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 23 Jun 2009 18:01:03 +1200 Subject: install.php works for postgres --- install.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'install.php') diff --git a/install.php b/install.php index 9f48c919d..1b8b7655c 100644 --- a/install.php +++ b/install.php @@ -244,6 +244,45 @@ function pgsql_db_installer($host, $database, $username, $password, $sitename) { updateStatus("Checking database..."); $conn = pg_connect($connstring); + updateStatus("Running database script..."); + //wrap in transaction; + pg_query($conn, 'BEGIN'); + $res = runDbScript(INSTALLDIR.'/db/laconica_pg.sql', $conn, 'pgsql'); + + 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, 'pgsql'); + if ($res === false) { + updateStatus(sprintf("Can't run %d script.", $name), true); + showForm(); + return; + } + } + pg_query($conn, 'COMMIT'); + + updateStatus("Writing config file..."); + if (empty($password)) { + $sqlUrl = "pgsql://$username@$host/$database"; + } + else { + $sqlUrl = "pgsql://$username:$password@$host/$database"; + } + $res = writeConf($sitename, $sqlUrl, $fancy); + if (!$res) { + updateStatus("Can't write config file.", true); + showForm(); + return; + } + updateStatus("Done!"); + } function mysql_db_installer($host, $database, $username, $password, $sitename) { @@ -305,7 +344,7 @@ function writeConf($sitename, $sqlUrl, $fancy) return $res; } -function runDbScript($filename, $conn) +function runDbScript($filename, $conn, $type='mysql') { $sql = trim(file_get_contents($filename)); $stmts = explode(';', $sql); @@ -314,8 +353,13 @@ function runDbScript($filename, $conn) if (!mb_strlen($stmt)) { continue; } - $res = mysql_query($stmt, $conn); + if ($type == 'mysql') { + $res = mysql_query($stmt, $conn); + } elseif ($type=='pgsql') { + $res = pg_query($conn, $stmt); + } if ($res === false) { + updateStatus("FAILED SQL: $stmt"); return $res; } } -- cgit v1.2.3-54-g00ecf From 1b3c4f2c52e2f983470b8b4e0ffd911694ab2eb5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Jun 2009 21:49:44 +1200 Subject: quote identifiers and type='psql' needs to be written to config.php --- install.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'install.php') diff --git a/install.php b/install.php index 1b8b7655c..e73e20ab6 100644 --- a/install.php +++ b/install.php @@ -332,7 +332,7 @@ function mysql_db_installer($host, $database, $username, $password, $sitename) { } updateStatus("Done!"); } -function writeConf($sitename, $sqlUrl, $fancy) +function writeConf($sitename, $sqlUrl, $fancy, $type='mysql') { $res = file_put_contents(INSTALLDIR.'/config.php', ""); return $res; } -- cgit v1.2.3-54-g00ecf From d591e24eac5f37dbff7b17ac039c2e8bc0a33653 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Jun 2009 21:53:37 +1200 Subject: typo in config variable and pass type='pgsql' in to writeConf --- install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'install.php') diff --git a/install.php b/install.php index e73e20ab6..096746d4a 100644 --- a/install.php +++ b/install.php @@ -275,7 +275,7 @@ function pgsql_db_installer($host, $database, $username, $password, $sitename) { else { $sqlUrl = "pgsql://$username:$password@$host/$database"; } - $res = writeConf($sitename, $sqlUrl, $fancy); + $res = writeConf($sitename, $sqlUrl, $fancy, 'pgsql'); if (!$res) { updateStatus("Can't write config file.", true); showForm(); @@ -341,7 +341,7 @@ function writeConf($sitename, $sqlUrl, $fancy, $type='mysql') ($fancy ? "\$config['site']['fancy'] = true;\n\n":''). "\$config['db']['database'] = \"$sqlUrl\";\n\n". ($type == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n" . - "\$config['db']['dbtype'] = \"$type\";\n\n" : ''). + "\$config['db']['type'] = \"$type\";\n\n" : ''). "?>"); return $res; } -- cgit v1.2.3-54-g00ecf