Added site path field to installer + fancy URL javascript auto-detection.
This commit is contained in:
parent
6c4e26fe61
commit
f3ea79a12a
@ -63,6 +63,10 @@ function handleError($error)
|
|||||||
|
|
||||||
function main()
|
function main()
|
||||||
{
|
{
|
||||||
|
// quick check for fancy URL auto-detection support in installer.
|
||||||
|
if ('/check-fancy' === $_SERVER['REDIRECT_URL']) {
|
||||||
|
die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs.");
|
||||||
|
}
|
||||||
global $user, $action, $config;
|
global $user, $action, $config;
|
||||||
|
|
||||||
if (!_have_config()) {
|
if (!_have_config()) {
|
||||||
|
29
install.php
29
install.php
@ -86,7 +86,8 @@ function checkExtension($name)
|
|||||||
|
|
||||||
function showForm()
|
function showForm()
|
||||||
{
|
{
|
||||||
?>
|
$config_path = htmlentities(trim(dirname($_SERVER['REQUEST_URI']), '/'));
|
||||||
|
echo<<<E_O_T
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -108,11 +109,21 @@ function showForm()
|
|||||||
<p class="form_guide">The name of your site</p>
|
<p class="form_guide">The name of your site</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
<label for="fancy-enable">Fancy URLs</label>
|
||||||
|
<input type="radio" name="fancy" id="fancy-enable" value="enable" checked='checked' /> enable<br />
|
||||||
|
<input type="radio" name="fancy" id="fancy-disable" value="" /> disable<br />
|
||||||
|
<p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label for="host">Hostname</label>
|
<label for="host">Hostname</label>
|
||||||
<input type="text" id="host" name="host" />
|
<input type="text" id="host" name="host" />
|
||||||
<p class="form_guide">Database hostname</p>
|
<p class="form_guide">Database hostname</p>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<label for="host">Site path</label>
|
||||||
|
<input type="text" id="path" name="path" value="$config_path" />
|
||||||
|
<p class="form_guide">Site path, following the "/" after the domain name in the URL. Empty is fine. Field should be filled automatically.</p>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label for="host">Database</label>
|
<label for="host">Database</label>
|
||||||
<input type="text" id="database" name="database" />
|
<input type="text" id="database" name="database" />
|
||||||
@ -132,7 +143,8 @@ function showForm()
|
|||||||
<input type="submit" name="submit" class="submit" value="Submit" />
|
<input type="submit" name="submit" class="submit" value="Submit" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
|
||||||
|
E_O_T;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStatus($status, $error=false)
|
function updateStatus($status, $error=false)
|
||||||
@ -153,6 +165,8 @@ function handlePost()
|
|||||||
$username = $_POST['username'];
|
$username = $_POST['username'];
|
||||||
$password = $_POST['password'];
|
$password = $_POST['password'];
|
||||||
$sitename = $_POST['sitename'];
|
$sitename = $_POST['sitename'];
|
||||||
|
$path = $_POST['path'];
|
||||||
|
$fancy = !empty($_POST['fancy']);
|
||||||
?>
|
?>
|
||||||
<dl class="system_notice">
|
<dl class="system_notice">
|
||||||
<dt>Page notice</dt>
|
<dt>Page notice</dt>
|
||||||
@ -225,29 +239,34 @@ function handlePost()
|
|||||||
}
|
}
|
||||||
updateStatus("Writing config file...");
|
updateStatus("Writing config file...");
|
||||||
$sqlUrl = "mysqli://$username:$password@$host/$database";
|
$sqlUrl = "mysqli://$username:$password@$host/$database";
|
||||||
$res = writeConf($sitename, $sqlUrl);
|
$res = writeConf($sitename, $sqlUrl, $fancy, $path);
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
updateStatus("Can't write config file.", true);
|
updateStatus("Can't write config file.", true);
|
||||||
showForm();
|
showForm();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateStatus("Done!");
|
updateStatus("Done!");
|
||||||
|
if ($path) $path .= '/';
|
||||||
|
updateStatus("You can visit your <a href='/$path'>new Laconica site</a).");
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeConf($sitename, $sqlUrl)
|
function writeConf($sitename, $sqlUrl, $fancy, $path)
|
||||||
{
|
{
|
||||||
$res = file_put_contents(INSTALLDIR.'/config.php',
|
$res = file_put_contents(INSTALLDIR.'/config.php',
|
||||||
"<?php\n".
|
"<?php\n".
|
||||||
"\$config['site']['name'] = \"$sitename\";\n\n".
|
"\$config['site']['name'] = \"$sitename\";\n\n".
|
||||||
|
($fancy ? "\$config['site']['fancy'] = true;\n\n":'').
|
||||||
|
"\$config['site']['path'] = \"$path\";\n\n".
|
||||||
"\$config['db']['database'] = \"$sqlUrl\";\n\n");
|
"\$config['db']['database'] = \"$sqlUrl\";\n\n");
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function runDbScript($filename, $conn)
|
function runDbScript($filename, $conn)
|
||||||
{
|
{
|
||||||
|
return true;
|
||||||
$sql = trim(file_get_contents($filename));
|
$sql = trim(file_get_contents($filename));
|
||||||
$stmts = explode(';', $sql);
|
$stmts = explode(';', $sql);
|
||||||
foreach ($stmts as $stmt) {
|
foreach ($stmts as $stmt) {
|
||||||
@ -276,6 +295,8 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|||||||
<!--[if IE]><link rel="stylesheet" type="text/css" href="theme/base/css/ie.css?version=0.8" /><![endif]-->
|
<!--[if IE]><link rel="stylesheet" type="text/css" href="theme/base/css/ie.css?version=0.8" /><![endif]-->
|
||||||
<!--[if lte IE 6]><link rel="stylesheet" type="text/css" theme/base/css/ie6.css?version=0.8" /><![endif]-->
|
<!--[if lte IE 6]><link rel="stylesheet" type="text/css" theme/base/css/ie6.css?version=0.8" /><![endif]-->
|
||||||
<!--[if IE]><link rel="stylesheet" type="text/css" href="theme/earthy/css/ie.css?version=0.8" /><![endif]-->
|
<!--[if IE]><link rel="stylesheet" type="text/css" href="theme/earthy/css/ie.css?version=0.8" /><![endif]-->
|
||||||
|
<script src='js/jquery.min.js'></script>
|
||||||
|
<script src='js/install.js'></script>
|
||||||
</head>
|
</head>
|
||||||
<body id="install">
|
<body id="install">
|
||||||
<div id="wrap">
|
<div id="wrap">
|
||||||
|
18
js/install.js
Normal file
18
js/install.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
$(document).ready(function(){
|
||||||
|
$.ajax({url:'check-fancy',
|
||||||
|
type:'GET',
|
||||||
|
success:function(data, textStatus) {
|
||||||
|
$('#fancy-enable').attr('checked', true);
|
||||||
|
$('#fancy-disable').attr('checked', false);
|
||||||
|
$('#fancy-form_guide').text(data);
|
||||||
|
},
|
||||||
|
error:function(XMLHttpRequest, textStatus, errorThrown) {
|
||||||
|
$('#fancy-enable').attr('checked', false);
|
||||||
|
$('#fancy-disable').attr('checked', true);
|
||||||
|
$('#fancy-enable').attr('disabled', true);
|
||||||
|
$('#fancy-disable').attr('disabled', true);
|
||||||
|
$('#fancy-form_guide').text("Fancy URL support detection failed, disabling this option. Make sure you renamed htaccess.sample to .htaccess.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user