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

Conformation when installing an app on webadmin

parent 709404e9
No related branches found
No related tags found
No related merge requests found
......@@ -509,10 +509,18 @@ function web_admin_onion_only {
# In onion only mode domain names or ddns codes
# don't need to be provided
web_admin_get_hostname
# shellcheck disable=SC2154
sed -i '/freedns_code/d' "$rootdir$webadmin_install_dir/app_add_template.html"
# shellcheck disable=SC2154
sed -i '/freedns_code/d' "$rootdir$webadmin_install_dir/app_add_confirm_template.html"
sed -i '/install_domain/d' "$rootdir$webadmin_install_dir/app_add_template.html"
sed -i '/install_domain/d' "$rootdir$webadmin_install_dir/app_add_confirm_template.html"
sed -i 's|onion_only=false;|onion_only=true;|g' "$rootdir$webadmin_install_dir/installapp.php"
sed -i 's|onion_only=false;|onion_only=true;|g' "$rootdir$webadmin_install_dir/installappconfirm.php"
sed -i 's|setup_domain.html|setup_installing.html|g' "$rootdir$webadmin_install_dir/setupconfirm.php"
}
......
<!DOCTYPE html>
<html>
<head>
<style>
#headerpic {
width: 60%;
height: auto;
margin-right : auto;
margin-left : auto;
min-width : 220px;
}
.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;
}
.proceedtext {
color: black;
font-size: 120%;
}
.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>
<br>
<p class="proceedtext">Install APPNAME now?</p>
<br>
<form action="installappconfirm.php" method="post">
<p>
<input type="radio" name="installconfirm" value="0" checked>No
<input type="radio" name="installconfirm" value="1">Yes
<input type="hidden" name="app_name" value="APPNAME">
<input type="hidden" name="install_domain" value="APPDOMAIN">
<input type="hidden" name="freedns_code" value="APPCODE">
</p>
<br><br>
<input type="submit" name="installconfirmsubmit" value="Continue" />
</form>
<br>
</div>
</div>
</body>
</html>
......@@ -100,7 +100,7 @@
<h1>APPNAME</h1>
<p class="appdesc">APPDESCRIPTION</p>
<form action="installapp.php" method="post">
<form action="installappconfirm.php" method="post">
<p><label>Domain:</label><input type="text" name="install_domain" value="APPNAME.HOSTNAME"></p>
<p><label><a href="https://freedns.afraid.org/dynamic">FreeDNS code</a>:</label><input type="text" name="freedns_code"></p>
<input type="hidden" name="app_name" value="APPNAME">
......
......@@ -22,36 +22,13 @@ if (isset($_POST['install'])) {
}
if($continue_install) {
if(file_exists("pending_removes.txt")) {
// Is this app in the pending_removes list?
if(exec('grep '.escapeshellarg("remove_".$app_name).' ./pending_removes.txt')) {
if(! exec('grep '.escapeshellarg("remove_".$app_name).'_running ./pending_removes.txt')) {
// Not Removing yet so remove from schedule
exec('sed -i "/'.escapeshellarg("remove_".$app_name).'/d ./pending_removes.txt');
}
else {
// Removing so don't continue
$continue_install=false;
}
}
}
}
if($continue_install) {
if(! file_exists("pending_installs.txt")) {
$pending_installs = fopen("pending_installs.txt", "w") or die("Unable to create installs file");
fclose($pending_installs);
}
if(! exec('grep '.escapeshellarg("install_".$app_name).' ./pending_installs.txt')) {
$pending_installs = fopen("pending_installs.txt", "a") or die("Unable to append to installs file");
fwrite($pending_installs, "install_".$app_name.",".$install_domain.",".$freedns_code."\n");
fclose($pending_installs);
$output_filename = "app_installing.html";
}
else {
// The app is already scheduled for installation
$output_filename = "app_scheduled.html";
// create the confirm screen populated with details for the app
exec('cp add_app_confirm_template.html add_app_confirm.html');
if(file_exists("add_app_confirm.html")) {
exec('sed -i "s|APPNAME|'.$app_name.'|g" add_app_confirm.html');
exec('sed -i "s|APPDOMAIN|'.$install_domain.'|g" add_app_confirm.html');
exec('sed -i "s|APPCODE|'.$freedns_code.'|g" add_app_confirm.html');
$output_filename = "add_app_confirm.html";
}
}
}
......
<?php
$output_filename = "apps_add.html";
if (isset($_POST['installconfirmsubmit'])) {
if(isset($_POST['installconfirm'])) {
$confirm = htmlspecialchars($_POST['installconfirm']);
if($confirm == "1") {
$app_name = htmlspecialchars($_POST['app_name']);
$install_domain = '';
$freedns_code = '';
// Note that this value can be changed by install_web_admin
$onion_only=false;
$continue_install=true;
if(! $onion_only) {
$install_domain = $_POST['install_domain'];
if (!strpos($install_domain, '.')) {
// No domain was provided
$continue_install=false;
}
$freedns_code = $_POST['freedns_code'];
}
if($continue_install) {
if(file_exists("pending_removes.txt")) {
// Is this app in the pending_removes list?
if(exec('grep '.escapeshellarg("remove_".$app_name).' ./pending_removes.txt')) {
if(! exec('grep '.escapeshellarg("remove_".$app_name).'_running ./pending_removes.txt')) {
// Not Removing yet so remove from schedule
exec('sed -i "/'.escapeshellarg("remove_".$app_name).'/d ./pending_removes.txt');
}
else {
// Removing so don't continue
$continue_install=false;
}
}
}
}
if($continue_install) {
if(! file_exists("pending_installs.txt")) {
$pending_installs = fopen("pending_installs.txt", "w") or die("Unable to create installs file");
fclose($pending_installs);
}
if(! exec('grep '.escapeshellarg("install_".$app_name).' ./pending_installs.txt')) {
$pending_installs = fopen("pending_installs.txt", "a") or die("Unable to append to installs file");
fwrite($pending_installs, "install_".$app_name.",".$install_domain.",".$freedns_code."\n");
fclose($pending_installs);
$output_filename = "app_installing.html";
}
else {
// The app is already scheduled for installation
$output_filename = "app_scheduled.html";
}
}
}
}
}
$htmlfile = fopen("$output_filename", "r") or die("Unable to open $output_filename");
echo fread($htmlfile,filesize("$output_filename"));
fclose($htmlfile);
// remove confirm screen
if(file_exists("add_app_confirm.html")) {
exec('rm add_app_confirm.html');
}
?>
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