Fix #21 - ability to change title

Add define("TITLE", "<title>") to your config.php file if you're updating and want to use this feature.
This commit is contained in:
Vojtěch Sajdl 2018-03-10 00:32:06 +01:00
parent 5afda409c1
commit 4b62701974
No known key found for this signature in database
GPG Key ID: 5D4EB1361A272390
3 changed files with 51 additions and 38 deletions

View File

@ -3,6 +3,7 @@
session_start(); session_start();
//You can change these: //You can change these:
define("NAME", '##name##'); //Website name define("NAME", '##name##'); //Website name
define("TITLE", "##title##");
define("WEB_URL", "##url##"); //Used for links define("WEB_URL", "##url##"); //Used for links
define("MAILER_NAME", "##mailer##"); //Mailer name define("MAILER_NAME", "##mailer##"); //Mailer name
define("MAILER_ADDRESS", "##mailer_email##"); //Mailer address define("MAILER_ADDRESS", "##mailer_email##"); //Mailer address

View File

@ -44,6 +44,10 @@ if (isset($_POST['server']))
$messages[] = _("Mailer name"); $messages[] = _("Mailer name");
} }
if (0 == strlen(trim($_POST['title']))){
$messages[] = _("Title");
}
if (0 == strlen(trim($_POST['mailer_email']))){ if (0 == strlen(trim($_POST['mailer_email']))){
$messages[] = _("Mailer email"); $messages[] = _("Mailer email");
} }
@ -66,7 +70,7 @@ if (isset($_POST['server']))
} }
if (isset($messages)) if (isset($messages))
{ {
$message .= _("Please set"); $message .= _("Please enter");
$message .= implode(", ", $messages); $message .= implode(", ", $messages);
} }
} }
@ -108,6 +112,7 @@ if(isset($_POST['server']) && empty($message))
//Create config //Create config
$config = file_get_contents("config.php.template"); $config = file_get_contents("config.php.template");
$config = str_replace("##name##", $_POST['servername'], $config); $config = str_replace("##name##", $_POST['servername'], $config);
$config = str_replace("##title##", $_POST['title'], $config);
$config = str_replace("##url##", $_POST['url'], $config); $config = str_replace("##url##", $_POST['url'], $config);
$config = str_replace("##mailer##", $_POST['mailer'], $config); $config = str_replace("##mailer##", $_POST['mailer'], $config);
$config = str_replace("##mailer_email##", $_POST['mailer_email'], $config); $config = str_replace("##mailer_email##", $_POST['mailer_email'], $config);
@ -136,15 +141,22 @@ if (!empty($message))
<?php <?php
} }
?> ?>
<summary><?php echo _("We will ask you some basic questions about your website. Most of the settings can be later edited in the config.php file.");?></summary>
<form method="post" action="." class="clearfix install"> <form method="post" action="." class="clearfix install">
<section class="install-section clearfix"> <section class="install-section clearfix">
<h2><?php echo _("Website details");?></h2> <h2><?php echo _("Website details");?></h2>
<summary><?php echo _("We need a name for your status page and a url, so we can mail users link for forgotten password etc.");?></summary> <summary><?php echo _("We need a name for your status page (shown behind page title after the dash) and a url of your server status installation (i.e. <a href='#'>https://example.com/status</a> - without the trailing slash), so we can mail users link for forgotten password etc...");?></summary>
<div class="form-group clearfix"> <div class="form-group clearfix">
<div class="col-sm-6"><label for="servername"><?php echo _("Name");?>: </label><input type="text" name="servername" value="<?php echo ((isset($_POST['servername']))?htmlspecialchars($_POST['servername'], ENT_QUOTES):'');?>" id="servername" placeholder="<?php echo _("Name");?>" class="form-control" required></div> <div class="col-sm-6"><label for="servername"><?php echo _("Name");?>: </label><input type="text" name="servername" value="<?php echo ((isset($_POST['servername']))?htmlspecialchars($_POST['servername'], ENT_QUOTES):'');?>" id="servername" placeholder="<?php echo _("Name");?>" class="form-control" required></div>
<div class="col-sm-6"><label for="url"><?php echo _("Url");?>: </label><input type="url" name="url" value="<?php echo ((isset($_POST['url']))?htmlspecialchars($_POST['url'], ENT_QUOTES):'');?>" id="url" placeholder="<?php echo _("Url");?>" class="form-control" required></div> <div class="col-sm-6"><label for="url"><?php echo _("Url");?>: </label><input type="url" name="url" value="<?php echo ((isset($_POST['url']))?htmlspecialchars($_POST['url'], ENT_QUOTES):'');?>" id="url" placeholder="<?php echo _("Url");?>" class="form-control" required></div>
</div> </div>
<summary><?php echo _("A title that you want to be shown on the top of the page.");?></summary>
<div class="form-group clearfix">
<div class="col-sm-6"><label for="title"><?php echo _("Title");?>: </label><input type="text" name="title" value="<?php echo ((isset($_POST['title']))?htmlspecialchars($_POST['title'], ENT_QUOTES):'Server Status');?>" id="title" placeholder="<?php echo _("Title");?>" class="form-control" required></div>
<div class="col-sm-6"></div>
</div>
<summary><?php echo _("Also an email address for mailer would be nice :)");?></summary> <summary><?php echo _("Also an email address for mailer would be nice :)");?></summary>
<div class="form-group clearfix"> <div class="form-group clearfix">
<div class="col-sm-6"><label for="mailer"><?php echo _("Name");?>: </label><input type="text" name="mailer" value="<?php echo ((isset($_POST['mailer']))?htmlspecialchars($_POST['mailer'], ENT_QUOTES):'');?>" id="mailer" placeholder="<?php echo _("Name");?>" class="form-control" required></div> <div class="col-sm-6"><label for="mailer"><?php echo _("Name");?>: </label><input type="text" name="mailer" value="<?php echo ((isset($_POST['mailer']))?htmlspecialchars($_POST['mailer'], ENT_QUOTES):'');?>" id="mailer" placeholder="<?php echo _("Name");?>" class="form-control" required></div>

View File

@ -50,7 +50,7 @@ class Template{
</div> </div>
<div class="navbar-left hidden-xs"> <div class="navbar-left hidden-xs">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li><a href="<?php echo WEB_URL;?>/"><h1><?php echo _("Service Status");?></h1></a></li> <li><a href="<?php echo WEB_URL;?>/"><h1><?php echo _((defined('TITLE')?TITLE:"Service Status"));?></h1></a></li>
</ul> </ul>
</div><!--/.nav-collapse --> </div><!--/.nav-collapse -->