Skip to content
Snippets Groups Projects
Commit 55480ed0 authored by Bob Mottram's avatar Bob Mottram
Browse files

Add confirm screen for initial setup via web admin

parent bf9c50e8
No related branches found
No related tags found
No related merge requests found
......@@ -112,6 +112,11 @@ do
cp "$webadmin_install_dir/index.prev" "$webadmin_install_dir/setup_installing.html"
fi
# Replace the setup confirm screen with the main index
if [ -f "$webadmin_install_dir/setup_confirm.html" ]; then
cp "$webadmin_install_dir/index.prev" "$webadmin_install_dir/setup_confirm.html"
fi
# set permissions for web admin site at freedombone.local
chown www-data:www-data "$webadmin_install_dir/index.html"
......
......@@ -539,7 +539,9 @@ function web_admin_setup_login {
# and copy it to the index
cp "$webadmin_install_dir/index.html" "$webadmin_install_dir/index.prev"
cp "$webadmin_install_dir/setup.html" "$webadmin_install_dir/setup.prev"
cp "$webadmin_install_dir/setup_confirm_template.html" "$webadmin_install_dir/setup_confirm.html"
sed -i "s|WEBADMINPASSWORD|${webadmin_password}|g" "$webadmin_install_dir/setup.prev"
sed -i "s|WEBADMINPASSWORD|${webadmin_password}|g" "$webadmin_install_dir/setup_confirm.html"
cp "$webadmin_install_dir/setup.prev" "$webadmin_install_dir/index.html"
# if initial setup has not yet happened then create
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Refresh" content="30">
<style>
#headerpic {
width: 60%;
height: auto;
margin-right : auto;
margin-left : auto;
min-width : 220px;
}
#welcomeicon {
width: 20%;
height: auto;
margin-right : auto;
margin-left : auto;
min-width : 100px;
}
.header {
text-align: center;
padding: 32px;
}
#iconpic {
width: 20%;
height: auto;
margin-right : auto;
margin-left : auto;
min-width : 120px;
}
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
max-width: 600px;
margin: auto;
text-align: center;
font-family: arial;
clear: both;
}
.card input[type=text] {
width: 90%;
clear: both;
text-align: center;
}
.appurl {
color: grey;
font-size: 100%;
}
.welcomeheader {
color: black;
font-size: 200%;
font-weight: bold;
}
.welcometext {
color: black;
font-size: 90%;
}
.logintext {
color: black;
font-size: 120%;
font-weight: bold;
color: #981737;
}
button {
border: none;
outline: 0;
display: inline-block;
padding: 8px;
color: white;
background-color: #000;
text-align: center;
cursor: pointer;
width: 100%;
font-size: 18px;
}
a {
text-decoration: none;
color: black;
}
button:hover, a:hover {
opacity: 0.7;
}
.chip {
display: inline-block;
padding: 0 25px;
height: 50px;
font-size: 70%;
line-height: 50px;
border-radius: 25px;
background-color: #f1f1f1;
}
.chip img {
float: left;
margin: 0 10px 0 -25px;
height: 50px;
width: 50px;
border-radius: 50%;
}
</style>
</head>
<body>
<div class="card">
<div class="header">
<img id="headerpic" class="img-responsive" src="images/logo.png"><br>
<img id="welcomeicon" class="img-responsive" src="images/login.png">
<p class="welcometext">Have you written down or saved the login credentials?</p>
<p class="logintext">Username: admin<br>
Password: WEBADMINPASSWORD
</p>
<br>
<form action="setupconfirm.php" method="post">
<p><input type="radio" name="setupconfirm" value="0" checked>No
<input type="radio" name="setupconfirm" value="1">Yes</p><br><br>
<input type="submit" name="setupconfirmsubmit" value="Continue" />
</form>
<br>
</div>
</div>
</body>
</html>
......@@ -4,8 +4,8 @@ if (isset($_POST['setup'])) {
$my_username = htmlspecialchars($_POST['my_username']);
$default_domain_name = htmlspecialchars($_POST['default_domain_name']);
if(!file_exists("setup.txt")) {
$setup_file = fopen("setup.txt", "w") or die("Unable to create setup file");
if(!file_exists(".temp_setup.txt")) {
$setup_file = fopen(".temp_setup.txt", "w") or die("Unable to create setup file");
fwrite($setup_file, $my_username.",".$default_domain_name."\n");
fclose($);
}
......
<?php
$output_filename = "index.html";
if (isset($_POST['setupconfirmsubmit'])) {
if(isset($_POST['setupconfirm'])) {
$confirm = htmlspecialchars($_POST['setupconfirm']);
if($confirm == "1") {
if(file_exists(".temp_setup.txt")) {
exec('mv .temp_setup.txt setup.txt');
}
if(file_exists("setup.txt")) {
$output_filename = "setup_installing.html";
}
}
}
}
$htmlfile = fopen("$output_filename", "r") or die("Unable to open $output_filename");
echo fread($htmlfile,filesize("$output_filename"));
fclose($htmlfile);
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment