Last active
November 11, 2018 16:18
-
-
Save DardanIljazi/febeae745fc6a81ffb773ca10b202806 to your computer and use it in GitHub Desktop.
CreateUser.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>SharedHosting: Create user</title> | |
<style> | |
body { | |
background-color: #2980b9; | |
font-family: 'Open Sans', sans-serif; | |
} | |
h1, h2 { | |
text-align: center; | |
color: white; | |
} | |
input[type=text], input[type=password], select { | |
width: 100%; | |
padding: 12px 20px; | |
margin: 8px 0; | |
display: inline-block; | |
border: 1px solid #ccc; | |
border-radius: 4px; | |
box-sizing: border-box; | |
} | |
input[type=submit] { | |
width: 100%; | |
background-color: #34495e; | |
color: white; | |
padding: 14px 20px; | |
margin: 8px 0; | |
border: none; | |
border-radius: 4px; | |
cursor: pointer; | |
} | |
input[type=submit]:hover { | |
background-color: #34495e; | |
} | |
#svglogocontainer { | |
width: 100%; | |
text-align: center; | |
} | |
#svglogo { | |
max-height: 20vh; | |
} | |
form | |
( | |
max-width: | |
50 | |
% | |
; | |
) | |
</style> | |
</head> | |
<body> | |
<h1>SharedHosting</h1> | |
<div id="svglogocontainer"> | |
<svg id="svglogo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 95.8 97"> | |
<defs> | |
<style>.cls-1 { | |
fill: #fff; | |
fill-opacity: 1; | |
}</style> | |
</defs> | |
<title>sharedhosting</title> | |
<!-- Icon by Daily icons https://thenounproject.com/rajkumarraja835/ --> | |
<g id="g24"> | |
<rect id="rect4" class="cls-1" x="34.8" y="67.8" width="6" height="6.86"/> | |
<rect id="rect6" class="cls-1" x="44.9" y="67.8" width="6" height="6.86"/> | |
<rect id="rect8" class="cls-1" x="55" y="67.8" width="6" height="6.86"/> | |
<rect id="rect10" class="cls-1" x="34.8" y="22.3" width="6" height="6.86"/> | |
<rect id="rect12" class="cls-1" x="44.9" y="22.3" width="6" height="6.86"/> | |
<rect id="rect14" class="cls-1" x="55" y="22.3" width="6" height="6.86"/> | |
<path id="path16" class="cls-1" | |
d="M23,60.7v8H6.5v9.7H0V97H18.6V78.4H12.5V74.7H23v8.8H72.8V74.7H83.3v3.7H77.2V97H95.8V78.4H89.3V68.7H72.8V51.5h4.4v6.3H95.8V39.2H77.2v6.3H72.8V28.3H89.3V18.6h6.4V0H77.2V18.6h6.1v3.7H72.8V13.5H23v8.8H12.5V18.6h6.1V0H0V18.6H6.5v9.7H23V45.5H18.6V39.2H0V57.8H18.6V51.5H23ZM12.6,91H6V84.4h6.6Zm77.2,0H83.2V84.4h6.6Zm-23-13.5H29V65H66.8ZM83.2,45.2h6.6v6.6H83.2ZM83.2,6h6.6v6.6H83.2ZM6,6h6.6v6.6H6ZM29,19.5H66.8V32H29ZM12.6,51.8H6V45.2h6.6Zm16.4,3V42.3H66.8V54.7Z"/> | |
<rect id="rect18" class="cls-1" x="34.8" y="45.1" width="6" height="6.86"/> | |
<rect id="rect20" class="cls-1" x="44.9" y="45.1" width="6" height="6.86"/> | |
<rect id="rect22" class="cls-1" x="55" y="45.1" width="6" height="6.86"/> | |
</g> | |
</svg> | |
</div> | |
<form method="post"> | |
<h2>Add new user and website</h2> | |
User name: <input type="text" name="UserName" value="" placeholder="Username"><br> | |
User password: <input type="password" name="UserPassword" value="" placeholder="Password"><br> | |
User website: <input type="text" name="UserWebsite" value="" placeholder="website.com"><br> | |
<input type="submit" value="Create new user/website"> | |
</form> | |
<?php | |
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
preg_match("/^\d.\d/", phpversion(), $PHP_ACTUAL_VERSION); | |
if (isset($_POST['UserName']) && isset($_POST['UserPassword']) && isset($_POST['UserWebsite'])) { | |
echo shell_exec('sudo /var/www/default/createuser.sh ' . $_POST['UserName'] . ' ' . $_POST['UserPassword'] . ' ' . $_POST['UserWebsite']); | |
echo shell_exec('sudo service nginx configtest'); | |
echo shell_exec('sudo service nginx restart'); | |
echo shell_exec('sudo service php' . $PHP_ACTUAL_VERSION . '-fpm restart'); | |
echo "<h2 style='color: #f1c40f;'>Script executed (but does it work ?) Check it !</h2>"; | |
} else { | |
echo "<h2 style='color: #f1c40f;'>Could not create the user. Not all inputs were filled. Redo it again</h2>"; | |
} | |
} | |
?> | |
<script src="https://code.jquery.com/jquery-3.3.1.min.js" | |
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | |
<script> | |
$(function () { | |
$('form').submit(function (event) { | |
console.log('submit called'); | |
if ($("input[name=UserName").val() == "" || $("input[name=UserPassword").val() == "" || $("input[name=UserWebsite").val() == "") { | |
alert('Please fill all inputs (Username, Password, Website)'); | |
event.preventDefault(); | |
} else { | |
alert('INFORMATION: The web server is going to reload and the page will be shown as unreachable. Reload it !'); | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment