X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=install.php;h=c222afa7b5fc34083be68b358c6f50a87891c12d;hb=628a9371082531908a023618ad4216a2f254f481;hp=32915200b29054f92bb433f06c6b89087448a393;hpb=a325144fa0ba769de1cdb554cac04e0116912b66;p=quix0rs-gnu-social.git
diff --git a/install.php b/install.php
index 32915200b2..c222afa7b5 100644
--- a/install.php
+++ b/install.php
@@ -1,7 +1,7 @@
Config file "config.php" already exists.
Require PHP version 5 or greater.
Require PHP version 5.2.3 or greater.
Cannot load required extension:
Cannot find mysql or pgsql extension. You need one or the other:
Cannot write config file to:
On your server, try this command: chmod a+w
Cannot write avatar directory: /avatar/
- On your server, try this command: chmod a+w /avatar/
-
- return false;
+ // Check the subdirs used for file uploads
+ $fileSubdirs = array('avatar', 'background', 'file');
+ foreach ($fileSubdirs as $fileSubdir) {
+ $fileFullPath = INSTALLDIR."/$fileSubdir/";
+ if (!is_writable($fileFullPath)) {
+ ?>Cannot write directory:
+ On your server, try this command: chmod a+w
+
@@ -120,12 +130,15 @@ function showForm()
Database hostname
-
-
- Site path, following the "/" after the domain name in the URL. Empty is fine. Field should be filled automatically.
+
+
+ MySQL
+ PostgreSQL
+ Database type
+
-
+
Database name
@@ -137,7 +150,7 @@ function showForm()
- Database password
+ Database password (optional)
@@ -161,11 +174,11 @@ function handlePost()
@@ -173,100 +186,181 @@ 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);
+ if($fail){
showForm();
- return;
- }
- }
- updateStatus("Writing config file...");
- $sqlUrl = "mysqli://$username:$password@$host/$database";
- $res = writeConf($sitename, $sqlUrl, $fancy, $path);
- if (!$res) {
- updateStatus("Can't write config file.", true);
- showForm();
return;
}
- updateStatus("Done!");
+
+ switch($dbtype) {
+ case 'mysql': mysql_db_installer($host, $database, $username, $password, $sitename, $fancy);
+ break;
+ case 'pgsql': pgsql_db_installer($host, $database, $username, $password, $sitename, $fancy);
+ break;
+ default:
+ }
if ($path) $path .= '/';
- updateStatus("You can visit your new Laconica sitenew Laconica site.");
?>
server_encoding != 'UTF8') {
+ updateStatus("Laconica requires UTF8 character encoding. Your database is ". htmlentities($record->server_encoding));
+ showForm();
+ return false;
+ }
+
+ 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, 'pgsql');
+ if (!$res) {
+ updateStatus("Can't write config file.", true);
+ showForm();
+ return;
+ }
+ updateStatus("Done!");
+
+}
+
+function mysql_db_installer($host, $database, $username, $password, $sitename, $fancy) {
+ 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(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, $type='mysql')
{
$res = file_put_contents(INSTALLDIR.'/config.php',
"");
return $res;
}
-function runDbScript($filename, $conn)
+function runDbScript($filename, $conn, $type='mysql')
{
-return true;
$sql = trim(file_get_contents($filename));
$stmts = explode(';', $sql);
foreach ($stmts as $stmt) {
@@ -274,8 +368,13 @@ return true;
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;
}
}
@@ -290,13 +389,13 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Install Laconica
-
+
-
-
-
+
+
+