forked from GNUsocial/gnu-social
added dbtype detection - and only install mysql stuff if mysql selected
This commit is contained in:
parent
ac7d8163c6
commit
3fe182e865
42
install.php
42
install.php
@ -126,14 +126,20 @@ function showForm()
|
|||||||
<p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
|
<p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
<label for="host">Hostname</label>
|
||||||
|
<input type="text" id="host" name="host" />
|
||||||
|
<p class="form_guide">Database hostname</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
|
||||||
<label for="dbtype">Type</label>
|
<label for="dbtype">Type</label>
|
||||||
<input type="radio" name="dbtype" id="fancy-mysql" value="enable" checked='checked' /> MySQL<br />
|
<input type="radio" name="dbtype" id="fancy-mysql" value="mysql" checked='checked' /> MySQL<br />
|
||||||
<input type="radio" name="dbtype" id="dbtype-pgsql" value="" /> PostgreSQL<br />
|
<input type="radio" name="dbtype" id="dbtype-pgsql" value="pgsql" /> PostgreSQL<br />
|
||||||
<p class="form_guide">Database type</p>
|
<p class="form_guide">Database type</p>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<label for="host">Name</label>
|
<label for="database">Name</label>
|
||||||
<input type="text" id="database" name="database" />
|
<input type="text" id="database" name="database" />
|
||||||
<p class="form_guide">Database name</p>
|
<p class="form_guide">Database name</p>
|
||||||
</li>
|
</li>
|
||||||
@ -145,7 +151,7 @@ function showForm()
|
|||||||
<li>
|
<li>
|
||||||
<label for="password">Password</label>
|
<label for="password">Password</label>
|
||||||
<input type="password" id="password" name="password" />
|
<input type="password" id="password" name="password" />
|
||||||
<p class="form_guide">Database password</p>
|
<p class="form_guide">Database password (optional)</p>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<input type="submit" name="submit" class="submit" value="Submit" />
|
<input type="submit" name="submit" class="submit" value="Submit" />
|
||||||
@ -169,6 +175,7 @@ function handlePost()
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
$host = $_POST['host'];
|
$host = $_POST['host'];
|
||||||
|
$dbtype = $_POST['dbtype'];
|
||||||
$database = $_POST['database'];
|
$database = $_POST['database'];
|
||||||
$username = $_POST['username'];
|
$username = $_POST['username'];
|
||||||
$password = $_POST['password'];
|
$password = $_POST['password'];
|
||||||
@ -212,8 +219,28 @@ function handlePost()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch($dbtype) {
|
||||||
|
case 'mysql': mysql_db_installer($host, $database, $username, $password, $sitename);
|
||||||
|
break;
|
||||||
|
case 'pgsql': pgsql_db_installer($host, $database, $username, $password, $sitename);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
if ($path) $path .= '/';
|
||||||
|
updateStatus("You can visit your <a href='/$path'>new Laconica site</a>.");
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function pgsql_db_installer($host, $database, $username, $password, $sitename) {
|
||||||
|
echo 'TODO'; exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mysql_db_installer($host, $database, $username, $password, $sitename) {
|
||||||
updateStatus("Starting installation...");
|
updateStatus("Starting installation...");
|
||||||
updateStatus("Checking database...");
|
updateStatus("Checking database...");
|
||||||
|
|
||||||
$conn = mysql_connect($host, $username, $password);
|
$conn = mysql_connect($host, $username, $password);
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
updateStatus("Can't connect to server '$host' as '$username'.", true);
|
updateStatus("Can't connect to server '$host' as '$username'.", true);
|
||||||
@ -246,6 +273,7 @@ function handlePost()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStatus("Writing config file...");
|
updateStatus("Writing config file...");
|
||||||
$sqlUrl = "mysqli://$username:$password@$host/$database";
|
$sqlUrl = "mysqli://$username:$password@$host/$database";
|
||||||
$res = writeConf($sitename, $sqlUrl, $fancy);
|
$res = writeConf($sitename, $sqlUrl, $fancy);
|
||||||
@ -255,13 +283,7 @@ function handlePost()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateStatus("Done!");
|
updateStatus("Done!");
|
||||||
if ($path) $path .= '/';
|
|
||||||
updateStatus("You can visit your <a href='/$path'>new Laconica site</a>.");
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeConf($sitename, $sqlUrl, $fancy)
|
function writeConf($sitename, $sqlUrl, $fancy)
|
||||||
{
|
{
|
||||||
$res = file_put_contents(INSTALLDIR.'/config.php',
|
$res = file_put_contents(INSTALLDIR.'/config.php',
|
||||||
|
Loading…
Reference in New Issue
Block a user