From 8f1b1ffcf04da08193da51544487afa6647ad225 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 24 Jun 2009 04:04:28 +1200 Subject: [PATCH 01/13] mysql or pgsql required (not mysql) --- install.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install.php b/install.php index 570b08edf4..4e54ba8700 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:

From 4d42bc7690da6cb87b4526c25e5447d06ba12212 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 24 Jun 2009 04:07:15 +1200 Subject: [PATCH 02/13] missing word (find) added --- install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.php b/install.php index 4e54ba8700..103c367c33 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: [PATCH 03/13] added dbtype to the installer form --- install.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/install.php b/install.php index 103c367c33..233a05550e 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

  • From 3fe182e86503a9e95183fe6d641e511a4d3eb0f1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 23 Jun 2009 17:37:01 +1200 Subject: [PATCH 04/13] added dbtype detection - and only install mysql stuff if mysql selected --- install.php | 114 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 46 deletions(-) diff --git a/install.php b/install.php index 233a05550e..61156e9371 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', From 343e2010ae276fa4ca5e56c40eb6f06cd01a6136 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 23 Jun 2009 17:43:46 +1200 Subject: [PATCH 05/13] connect to pg working --- install.php | 97 +++++++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/install.php b/install.php index 61156e9371..9f48c919de 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"; From 4f9c3b50e7103498f06f7c9b0a232bcda5bf17b8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 23 Jun 2009 18:01:03 +1200 Subject: [PATCH 06/13] install.php works for postgres --- install.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index 9f48c919de..1b8b7655c6 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; } } From 6b710092061d885a358dc07c8153324e36677965 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 25 Jun 2009 21:59:33 +1200 Subject: [PATCH 07/13] removed semicolons from comments (mucks up logic in install.php) and fixed stray commas that stopped it parsing as valid SQL --- db/laconica_pg.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/laconica_pg.sql b/db/laconica_pg.sql index dae8b8fafe..3683273a3e 100644 --- a/db/laconica_pg.sql +++ b/db/laconica_pg.sql @@ -120,6 +120,7 @@ create table notice ( conversation integer /*id of root notice in this conversation' */ references notice (id) + /* FULLTEXT(content) */ ); create index notice_profile_id_idx on notice using btree(profile_id); From b5fa0ac1d1b6b3e4ecd0f39fe086702cf19eccdf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 Jul 2009 18:48:39 +1200 Subject: [PATCH 08/13] added missing conversation id to notices Conflicts: db/laconica_pg.sql --- db/laconica_pg.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/laconica_pg.sql b/db/laconica_pg.sql index 3683273a3e..dae8b8fafe 100644 --- a/db/laconica_pg.sql +++ b/db/laconica_pg.sql @@ -120,7 +120,6 @@ create table notice ( conversation integer /*id of root notice in this conversation' */ references notice (id) - /* FULLTEXT(content) */ ); create index notice_profile_id_idx on notice using btree(profile_id); From f22ed5dc807392889a910d491b614c5d33efa8af Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Jun 2009 21:55:43 +1200 Subject: [PATCH 09/13] added group_block and group_alias tables --- db/laconica_pg.sql | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/db/laconica_pg.sql b/db/laconica_pg.sql index dae8b8fafe..92331181d7 100644 --- a/db/laconica_pg.sql +++ b/db/laconica_pg.sql @@ -499,6 +499,26 @@ create table design ( primary key (id) ); +create table group_block ( + group_id integer not null /* comment 'group profile is blocked from' */ references user_group (id), + blocked integer not null /* comment 'profile that is blocked' */references profile (id), + blocker integer not null /* comment 'user making the block'*/ references "user" (id), + modified timestamp /* comment 'date of blocking'*/ , + + primary key (group_id, blocked) +); + +create table group_alias ( + + alias varchar(64) /* comment 'additional nickname for the group'*/ , + group_id integer not null /* comment 'group profile is blocked from'*/ references user_group (id), + modified timestamp /* comment 'date alias was created'*/, + primary key (alias) + +); +create index group_alias_group_id_idx on group_alias (group_id); + + /* Textsearch stuff */ create index textsearch_idx on profile using gist(textsearch); From 186b5a1674ae345829b57c495f590140424e04ad Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Jun 2009 22:39:19 +1200 Subject: [PATCH 10/13] added design_id to user_group --- db/laconica_pg.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/laconica_pg.sql b/db/laconica_pg.sql index 92331181d7..e70573bfba 100644 --- a/db/laconica_pg.sql +++ b/db/laconica_pg.sql @@ -1,3 +1,4 @@ + design_id integer comment 'id of a design' references design(id), /* local and remote users have profiles */ create sequence profile_seq; @@ -390,6 +391,8 @@ create table user_group ( homepage_logo varchar(255) /* comment 'homepage (profile) size logo' */, stream_logo varchar(255) /* comment 'stream-sized logo' */, mini_logo varchar(255) /* comment 'mini logo' */, + design_id integer /*comment 'id of a design' */ references design(id), + created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */, modified timestamp /* comment 'date this record was modified' */ From fc3b11bff954c90b93a240d39e5aea3462d0158a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 Jul 2009 13:36:15 +1200 Subject: [PATCH 11/13] moved creation of design table earlier than user_group --- db/laconica_pg.sql | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/db/laconica_pg.sql b/db/laconica_pg.sql index e70573bfba..78791adaa3 100644 --- a/db/laconica_pg.sql +++ b/db/laconica_pg.sql @@ -1,4 +1,3 @@ - design_id integer comment 'id of a design' references design(id), /* local and remote users have profiles */ create sequence profile_seq; @@ -376,6 +375,20 @@ create table profile_block ( ); +create sequence design_seq; +create table design ( + id bigint default nextval('design_seq') /* comment 'design ID'*/, + backgroundcolor integer /* comment 'main background color'*/ , + contentcolor integer /*comment 'content area background color'*/ , + sidebarcolor integer /*comment 'sidebar background color'*/ , + textcolor integer /*comment 'text color'*/ , + linkcolor integer /*comment 'link color'*/, + backgroundimage varchar(255) /*comment 'background image, if any'*/, + disposition int default 1 /*comment 'bit 1 = hide background image, bit 2 = display background image, bit 4 = tile background image'*/, + primary key (id) +); + + create sequence user_group_seq; create table user_group ( @@ -489,19 +502,6 @@ create table file_to_post ( unique(file_id, post_id) ); -create sequence design_seq; -create table design ( - id bigint default nextval('design_seq') /* comment 'design ID'*/, - backgroundcolor integer /* comment 'main background color'*/ , - contentcolor integer /*comment 'content area background color'*/ , - sidebarcolor integer /*comment 'sidebar background color'*/ , - textcolor integer /*comment 'text color'*/ , - linkcolor integer /*comment 'link color'*/, - backgroundimage varchar(255) /*comment 'background image, if any'*/, - disposition int default 1 /*comment 'bit 1 = hide background image, bit 2 = display background image, bit 4 = tile background image'*/, - primary key (id) -); - create table group_block ( group_id integer not null /* comment 'group profile is blocked from' */ references user_group (id), blocked integer not null /* comment 'profile that is blocked' */references profile (id), From 1b3c4f2c52e2f983470b8b4e0ffd911694ab2eb5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Jun 2009 21:49:44 +1200 Subject: [PATCH 12/13] quote identifiers and type='psql' needs to be written to config.php --- install.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.php b/install.php index 1b8b7655c6..e73e20ab63 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; } From d591e24eac5f37dbff7b17ac039c2e8bc0a33653 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Jun 2009 21:53:37 +1200 Subject: [PATCH 13/13] typo in config variable and pass type='pgsql' in to writeConf --- install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index e73e20ab63..096746d4ae 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; }