Skip to content

Commit

Permalink
less eyesores, tooltips
Browse files Browse the repository at this point in the history
added:
- tooltips
- better login page
- better config panel
  • Loading branch information
x35gaming committed Nov 26, 2019
1 parent fbbfdb0 commit a250b3e
Show file tree
Hide file tree
Showing 20 changed files with 383 additions and 70 deletions.
7 changes: 5 additions & 2 deletions admin/adminchats.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
// admin chats display
session_start();
$conf = json_decode(file_get_contents("../config.json"),true); // converts the chat.json file into an array
$bannedwords=explode(", ",file_get_contents("../core/flatchat_modules/noswearing/bannedwords.array"));// set banned words list for defilth module
require_once("../core/flatchat_modules/noswearing/defilth.php"); // init Defilth module.

if (password_verify($_SESSION["passwd"],$conf["password-hash"])) {//check passwd
require_once("../core/php_libs/Parsedown/Parsedown.php"); // init parsedown.
$Parsedown = new Parsedown(); // create a parsedown object to parse markdown.
$count=1;
$chats = json_decode(file_get_contents("../chats/chats.json"),true); // converts the chat.json file into an array
foreach($chats as $i) { //loop through $chats and convert to html
echo("<div class=\"message\"> <b> <div class=\"user\">". $Parsedown->line(htmlspecialchars($i["user"]))."</b>:"); // USERNAME
echo("</div><div class=\"msg\">" . $Parsedown->text(str_replace("\r\n","\r\n<br>",htmlspecialchars($i["msg" ]))). "<div class=\"msgid\">id:$count</div>"); // Message
echo("<div class=\"message\"> <b> <div class=\"user\">". admindefilth($Parsedown->line(htmlspecialchars($i["user"])),$bannedwords)."</b>:"); // USERNAME
echo("</div><div class=\"msg\">" . admindefilth($Parsedown->text(str_replace("\r\n","\r\n<br>",htmlspecialchars($i["msg" ]))),$bannedwords). "<div class=\"msgid\">id:$count</div>"); // Message

require("../core/admin/assets/delmsg.php");
echo"</div></div>"; // close the chats div
Expand Down
5 changes: 3 additions & 2 deletions admin/confedit.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
block {
display:inline-flex

display:inline-flex;
padding:10px;
border-radius:10px;
}
122 changes: 108 additions & 14 deletions admin/confedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,81 @@
session_start();
?>
<style>
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}

.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
input[type=submit]:hover {
background-color: #45a049;
}
html{
background:gray;
color:#555;
}
h1{
color:#333;
}
input[type=text], select, textarea {
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: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
block {
float: top;
display:block;
border:3px solid red;
border:3px ridge #666;
font-family : Verdana, Geneva, sans-serif;
padding:10px;
border-radius:10px;
background:rgb(230,230,230);
}
</style>
<?php
Expand Down Expand Up @@ -39,58 +109,82 @@
$admsgno="checked";
$admsgyes="";
};

if ($conf["defilth-words-admin"] == "true"){
$admdefilthyes="checked";
$admdefilthno="";
} else {
$admdefilthno="checked";
$admdefithyes="";
};
$directory = '../themes';
$scanned_directory = array_diff(scandir($directory), array('..', '.'));
$available = "<select name=\"theme\">\r\n<option value=\"{$conf["theme"]}\">select a theme</option>\r\n";
foreach ($scanned_directory as $nnn => $themename) {
$available .= "<option value=\"$themename\">$themename</option>\r\n";
};
$available .= "</select>\r\n";

$available2 = "<select name=\"secondary-theme\">\r\n<option value=\"{$conf["secondary-theme"]}\">select a theme</option>\r\n";
foreach ($scanned_directory as $nnn => $themename) {
$available2 .= "<option value=\"$themename\">$themename</option>\r\n";
};
$available2 .= "</select>\r\n";

$links= json_encode($conf["links"],JSON_PRETTY_PRINT + JSON_UNESCAPED_SLASHES);
echo <<<CONFIGURATION_FORM
<form method="post">
<block>
<h1>SEO</h1>
<p> title: </p>
<p> Title: </p>
<input type="text" value="{$conf["title"]}" name="title">
<p> description: </p>
<p class="tooltip"> Description: <span class="tooltiptext">a short summary of your site</span></p>
<textarea cols="40" rows="2" name="seodesc">{$conf["seodesc"]}</textarea>
</block>
<br>
<block>
<h1> Customization </h1>
<p> theme: </p>
<p class="tooltip"> Front page theme: <span class="tooltiptext">e.g a very well stylized theme for your front page</span></p>
{$available}
<p> links: </p>
<p class="tooltip"> Alternate theme: <span class="tooltiptext">e.g a more readable theme, for docs and whatever doesnt need to be punchy</span></p>
{$available2}
<p class="tooltip"> Secondary theme pages: <span class="tooltiptext">a list of page ids in Json format</span></p>
<textarea cols="40" rows="10" type="text" name="secondarypages">{$conf["secondarypages"]}</textarea>
<p class="tooltip"> links: <span class="tooltiptext">a list of links for the top toolbar, formatted in JSON</span></p>
<textarea cols="40" rows="10" type="text" name="links">{$links}</textarea>
<p> footer: </p>
<p class="tooltip"> Footer: <span class="tooltiptext">[NOTE: only supported by some themes] text for the footer at the bottom.</span></p>
<textarea cols="40" rows="10" type="text" name="footertext">{$conf["footertext"]}</textarea>
<p> background image: </p>
<p class="tooltip"> Background image: <span class="tooltiptext">[NOTE: only some themes support this] the url for your chosen background image</span></p>
<input type="text" name="backgroundimg" value="{$conf["backgroundimg"]}">
</block>
<br>
<block>
<h1>Admin Account</h1>
<p> name: </p>
<p> Name: </p>
<input type="text" name="adminuser" value="{$conf["adminuser"]}">
<p> hash: </p>
<p> Hash: </p>
<input type="text" name="password-hash" value="{$conf["password-hash"]}"><br>generate a hash:<br>
<iframe width="320" height="100" frameborder="0" style="display:inline" src="passhash.php"></iframe>
</block>
<br>
<block>
<h1>chat</h1>
<p> block <b>swear words</b>: </p>
<h1>Chat:</h1>
<p> Block <b>swear words</b>: </p>
<input type="radio" name="defilth-words" value="true" $defyes> Yes<br>
<input type="radio" name="defilth-words" value="false" $defno> No<br>
<p class="tooltip"> Filter swear words on admin panel: <span class="tooltiptext">Does the same as the option above, but on the admin panel</span></p><br>
<input type="radio" name="defilth-words-admin" value="true" $admsgyes> Yes, keep me safe :)<br>
<input type="radio" name="defilth-words-admin" value="false" $admsgno> No<br>
<p> forum name: </p>
<input type="text" name="forumtitle" value="{$conf["forumtitle"]}">
<p>admin join msgs:</p>
<input type="radio" name="adminjoinmsg" value="true" $admsgyes> Yes, annoy me!<br>
<input type="radio" name="adminjoinmsg" value="false" $admsgno> No<br>
</block>
<br>
<block>
<h1> submit changes: </h1>
click the <em>"apply"</em> button to save changes<br><br>
<input type="submit" value="apply">
</block>
</form>
Expand Down
Binary file added admin/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 48 additions & 11 deletions admin/index.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
<?php
session_start();
?>
<form method="post">
<input type="password" placeholder="password" name="passwd">
<input type="submit" value="verify">
</form><br>
<a href="./manage.php">log in via Session >></a>
<html>

<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Flatchat login</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU"
crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400" rel="stylesheet">
<link rel="stylesheet" href="login.css">
</head>

<body>

<div id="form_wrapper">
<div id="form_left">
<img src="icon.png" alt="computer icon">
</div><form method="post">
<div id="form_right">
<h1>Admin Login</h1>
<div class="input_container">
<i class="fas fa-user"></i>
<input placeholder="Username" type="text" name="Username" id="field_email" class='input_field'>
</div>
<div class="input_container">
<i class="fas fa-lock"></i>
<input placeholder="Password" type="password" name="Password" id="field_password" class='input_field'>
</div>
<input type="submit" value="Login" id='input_submit' class='input_field'>
<span id='create_account'>
<a href="./manage.php">Log in via session &#x27A1; </a>
</span>
</form></div>
</div>

</body>

</html>
<?php
$conf = json_decode(file_get_contents("../config.json"),true);
if (isset($_POST["passwd"])) {
if(password_verify($_POST["passwd"],$conf["password-hash"])){
$_SESSION['passwd']=$_POST["passwd"];
echo "<script>window.location.href=\"./manage.php\"</script>";
};

if (isset($_POST["Username"])) {
if ($_POST["Username"] == $conf["adminuser"]) {
if (isset($_POST["Password"])) {
if(password_verify($_POST["Password"],$conf["password-hash"])){
$_SESSION['passwd']=$_POST["Password"];
echo "<script>window.location.href=\"./manage.php\"</script>";
};
}
}
};
Loading

0 comments on commit a250b3e

Please sign in to comment.