Skip to content

Commit 4b62701

Browse files
committed
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.
1 parent 5afda40 commit 4b62701

File tree

3 files changed

+51
-38
lines changed

3 files changed

+51
-38
lines changed

config.php.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
session_start();
44
//You can change these:
55
define("NAME", '##name##'); //Website name
6+
define("TITLE", "##title##");
67
define("WEB_URL", "##url##"); //Used for links
78
define("MAILER_NAME", "##mailer##"); //Mailer name
89
define("MAILER_ADDRESS", "##mailer_email##"); //Mailer address

install.php

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
$mysqli = new mysqli($_POST['server'],$_POST['dbuser'],$_POST['dbpassword'],$_POST['database']);
2424

2525
if ($mysqli->connect_errno) {
26-
$message .= sprintf(_("Connection failed: %s\n"), $mysqli->connect_error);
26+
$message .= sprintf(_("Connection failed: %s\n"), $mysqli->connect_error);
2727
}
2828

2929
if (isset($_POST['url']) && filter_var($_POST['url'], FILTER_VALIDATE_URL) === false)
@@ -44,6 +44,10 @@
4444
$messages[] = _("Mailer name");
4545
}
4646

47+
if (0 == strlen(trim($_POST['title']))){
48+
$messages[] = _("Title");
49+
}
50+
4751
if (0 == strlen(trim($_POST['mailer_email']))){
4852
$messages[] = _("Mailer email");
4953
}
@@ -66,7 +70,7 @@
6670
}
6771
if (isset($messages))
6872
{
69-
$message .= _("Please set");
73+
$message .= _("Please enter");
7074
$message .= implode(", ", $messages);
7175
}
7276
}
@@ -108,6 +112,7 @@
108112
//Create config
109113
$config = file_get_contents("config.php.template");
110114
$config = str_replace("##name##", $_POST['servername'], $config);
115+
$config = str_replace("##title##", $_POST['title'], $config);
111116
$config = str_replace("##url##", $_POST['url'], $config);
112117
$config = str_replace("##mailer##", $_POST['mailer'], $config);
113118
$config = str_replace("##mailer_email##", $_POST['mailer_email'], $config);
@@ -131,57 +136,64 @@
131136
<?php
132137
if (!empty($message))
133138
{
134-
?>
135-
<p class="alert alert-danger"><?php echo $message; ?></p>
136-
<?php
139+
?>
140+
<p class="alert alert-danger"><?php echo $message; ?></p>
141+
<?php
137142
}
138143
?>
144+
<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>
145+
139146
<form method="post" action="." class="clearfix install">
140147
<section class="install-section clearfix">
141148
<h2><?php echo _("Website details");?></h2>
142-
<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>
149+
<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>
143150

144-
<div class="form-group clearfix">
145-
<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>
146-
<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>
147-
</div>
148-
<summary><?php echo _("Also an email address for mailer would be nice :)");?></summary>
149-
<div class="form-group clearfix">
150-
<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>
151-
<div class="col-sm-6"><label for="mailer_email"><?php echo _("Email");?>: </label><input type="email" name="mailer_email" value="<?php echo ((isset($_POST['mailer_email']))?htmlspecialchars($_POST['mailer_email'], ENT_QUOTES):'');?>" id="mailer_email" placeholder="<?php echo _("Email");?>" class="form-control" required></div>
152-
</div>
151+
<div class="form-group clearfix">
152+
<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>
153+
<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>
154+
</div>
155+
<summary><?php echo _("A title that you want to be shown on the top of the page.");?></summary>
156+
<div class="form-group clearfix">
157+
<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>
158+
<div class="col-sm-6"></div>
159+
</div>
160+
<summary><?php echo _("Also an email address for mailer would be nice :)");?></summary>
161+
<div class="form-group clearfix">
162+
<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>
163+
<div class="col-sm-6"><label for="mailer_email"><?php echo _("Email");?>: </label><input type="email" name="mailer_email" value="<?php echo ((isset($_POST['mailer_email']))?htmlspecialchars($_POST['mailer_email'], ENT_QUOTES):'');?>" id="mailer_email" placeholder="<?php echo _("Email");?>" class="form-control" required></div>
164+
</div>
153165
</section>
154166
<section class="install-section clearfix">
155167
<h2><?php echo _("Database connection");?></h2>
156168
<summary><?php echo _("We need database connection to be able to create tables. Please check that your account has the permission needed to do that.");?></summary>
157169

158-
<div class="form-group clearfix">
159-
<div class="col-sm-6"><label for="server"><?php echo _("Server");?>: </label><input type="text" name="server" value="<?php echo ((isset($_POST['server']))?htmlspecialchars($_POST['server'], ENT_QUOTES):'');?>" id="server" placeholder="<?php echo _("Server");?>" class="form-control" required></div>
160-
<div class="col-sm-6"><label for="database"><?php echo _("Database");?>: </label><input type="text" name="database" value="<?php echo ((isset($_POST['database']))?htmlspecialchars($_POST['database'], ENT_QUOTES):'');?>" id="database" placeholder="<?php echo _("Database");?>" class="form-control" required></div>
161-
</div>
162-
<div class="form-group clearfix">
163-
<div class="col-sm-6"><label for="dbuser"><?php echo _("User");?>: </label><input type="text" name="dbuser" value="<?php echo ((isset($_POST['dbuser']))?htmlspecialchars($_POST['dbuser'], ENT_QUOTES):'');?>" id="dbuser" placeholder="<?php echo _("User");?>" class="form-control" required></div>
164-
<div class="col-sm-6"><label for="dbpassword"><?php echo _("Password");?>: </label><input type="password" name="dbpassword" value="<?php echo ((isset($_POST['dbpassword']))?htmlspecialchars($_POST['dbpassword'], ENT_QUOTES):'');?>" id="dbpassword" placeholder="<?php echo _("Password");?>" class="form-control" required></div>
165-
</div>
170+
<div class="form-group clearfix">
171+
<div class="col-sm-6"><label for="server"><?php echo _("Server");?>: </label><input type="text" name="server" value="<?php echo ((isset($_POST['server']))?htmlspecialchars($_POST['server'], ENT_QUOTES):'');?>" id="server" placeholder="<?php echo _("Server");?>" class="form-control" required></div>
172+
<div class="col-sm-6"><label for="database"><?php echo _("Database");?>: </label><input type="text" name="database" value="<?php echo ((isset($_POST['database']))?htmlspecialchars($_POST['database'], ENT_QUOTES):'');?>" id="database" placeholder="<?php echo _("Database");?>" class="form-control" required></div>
173+
</div>
174+
<div class="form-group clearfix">
175+
<div class="col-sm-6"><label for="dbuser"><?php echo _("User");?>: </label><input type="text" name="dbuser" value="<?php echo ((isset($_POST['dbuser']))?htmlspecialchars($_POST['dbuser'], ENT_QUOTES):'');?>" id="dbuser" placeholder="<?php echo _("User");?>" class="form-control" required></div>
176+
<div class="col-sm-6"><label for="dbpassword"><?php echo _("Password");?>: </label><input type="password" name="dbpassword" value="<?php echo ((isset($_POST['dbpassword']))?htmlspecialchars($_POST['dbpassword'], ENT_QUOTES):'');?>" id="dbpassword" placeholder="<?php echo _("Password");?>" class="form-control" required></div>
177+
</div>
166178
</section>
167179
<section class="install-section clearfix">
168180
<h2><?php echo _("User");?></h2>
169181
<summary><?php echo _("And finally, we need info to create a new user. You don't have to provide it, but then... No status page admin...");?></summary>
170-
<div class="form-group">
171-
<div class="col-sm-6"><label for="name"><?php echo _("Name");?>: </label><input type="text" maxlength="50" name="name" value="<?php echo ((isset($_POST['name']))?htmlspecialchars($_POST['name'], ENT_QUOTES):'');?>" id="name" placeholder="<?php echo _("Name");?>" class="form-control" required></div>
172-
<div class="col-sm-6"><label for="surname"><?php echo _("Surname");?>: </label><input type="text" maxlength="50" name="surname" value="<?php echo ((isset($_POST['surname']))?htmlspecialchars($_POST['surname'], ENT_QUOTES):'');?>" id="surname" placeholder="<?php echo _("Surname");?>" class="form-control" required></div>
173-
</div>
174-
<div class="form-group">
175-
<div class="col-sm-6"><label for="username"><?php echo _("Username");?>:</label><input type="text" maxlength="50" name="username" value="<?php echo ((isset($_POST['username']))?htmlspecialchars($_POST['username'], ENT_QUOTES):'');?>" id="username" placeholder="<?php echo _("Username");?>" class="form-control" required></div>
176-
<div class="col-sm-6"><label for="email"><?php echo _("Email");?>:</label><input type="email" maxlength="60" name="email" value="<?php echo ((isset($_POST['email']))?htmlspecialchars($_POST['email'], ENT_QUOTES):'');?>" id="email" placeholder="<?php echo _("Email");?>" class="form-control" required><input type="hidden" name="permission" value="0"></div>
177-
</div>
178-
<div class="form-group">
179-
<div class="col-sm-6"><label for="password"><?php echo _("Password");?>:</label><input type="password" name="password" value="<?php echo ((isset($_POST['password']))?htmlspecialchars($_POST['password'], ENT_QUOTES):'');?>" id="password" placeholder="<?php echo _("Password");?>" class="form-control" required></div>
180-
<div class="col-sm-6">
181-
<input type="hidden" value="0" name="permission">
182-
<button type="submit" class="btn btn-success pull-right"><?php echo _("Run install!");?></button>
182+
<div class="form-group">
183+
<div class="col-sm-6"><label for="name"><?php echo _("Name");?>: </label><input type="text" maxlength="50" name="name" value="<?php echo ((isset($_POST['name']))?htmlspecialchars($_POST['name'], ENT_QUOTES):'');?>" id="name" placeholder="<?php echo _("Name");?>" class="form-control" required></div>
184+
<div class="col-sm-6"><label for="surname"><?php echo _("Surname");?>: </label><input type="text" maxlength="50" name="surname" value="<?php echo ((isset($_POST['surname']))?htmlspecialchars($_POST['surname'], ENT_QUOTES):'');?>" id="surname" placeholder="<?php echo _("Surname");?>" class="form-control" required></div>
185+
</div>
186+
<div class="form-group">
187+
<div class="col-sm-6"><label for="username"><?php echo _("Username");?>:</label><input type="text" maxlength="50" name="username" value="<?php echo ((isset($_POST['username']))?htmlspecialchars($_POST['username'], ENT_QUOTES):'');?>" id="username" placeholder="<?php echo _("Username");?>" class="form-control" required></div>
188+
<div class="col-sm-6"><label for="email"><?php echo _("Email");?>:</label><input type="email" maxlength="60" name="email" value="<?php echo ((isset($_POST['email']))?htmlspecialchars($_POST['email'], ENT_QUOTES):'');?>" id="email" placeholder="<?php echo _("Email");?>" class="form-control" required><input type="hidden" name="permission" value="0"></div>
189+
</div>
190+
<div class="form-group">
191+
<div class="col-sm-6"><label for="password"><?php echo _("Password");?>:</label><input type="password" name="password" value="<?php echo ((isset($_POST['password']))?htmlspecialchars($_POST['password'], ENT_QUOTES):'');?>" id="password" placeholder="<?php echo _("Password");?>" class="form-control" required></div>
192+
<div class="col-sm-6">
193+
<input type="hidden" value="0" name="permission">
194+
<button type="submit" class="btn btn-success pull-right"><?php echo _("Run install!");?></button>
195+
</div>
183196
</div>
184-
</div>
185197
</section>
186198
</form>
187199
<?php

template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static function render_header($page_name, $admin = false){
5050
</div>
5151
<div class="navbar-left hidden-xs">
5252
<ul class="nav navbar-nav">
53-
<li><a href="<?php echo WEB_URL;?>/"><h1><?php echo _("Service Status");?></h1></a></li>
53+
<li><a href="<?php echo WEB_URL;?>/"><h1><?php echo _((defined('TITLE')?TITLE:"Service Status"));?></h1></a></li>
5454
</ul>
5555
</div><!--/.nav-collapse -->
5656

0 commit comments

Comments
 (0)