5
1
Fork 0
mirror of https://github.com/Anvilcraft/jensmemes synced 2024-11-25 06:22:30 +01:00

Frontend Fixes

This commit is contained in:
ITbyHF 2020-09-02 22:45:09 +02:00
parent 00ea30c03f
commit 6c16f3cf4f
5 changed files with 119 additions and 20 deletions

6
website/.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
config.php
dbcon.php
static/
.htaccess
.idea
Neuer Ordner

View file

@ -1,7 +1,4 @@
<?php <?php
include ('../dbcon.php');
$clientIP =$_SERVER['REMOTE_ADDR']; $clientIP =$_SERVER['REMOTE_ADDR'];
$tk = $_COOKIE['token']; $tk = $_COOKIE['token'];
$sql = "UPDATE `token` SET `latest-ip` = '$clientIP' WHERE `token` = '$tk'; $sql = "UPDATE `token` SET `latest-ip` = '$clientIP' WHERE `token` = '$tk';

View file

@ -2,9 +2,11 @@
<?php <?php
global $cats; global $cats;
foreach ($cats as $cate) { foreach ($cats as $cate) {
$parts = explode(":", $cate); $parts = explode(":", $cate);
$cname = str_replace(' ', '_', $cate->name);
echo ' echo '
<div id="' . $cate->name . '"> <div id="' . $cname . '">
<h2>' . $cate->name . '</h2>'; <h2>' . $cate->name . '</h2>';
$memeobj = json_decode(file_get_contents("https://jensmemes.tilera.xyz/api/memes?category=" . $cate->id)); $memeobj = json_decode(file_get_contents("https://jensmemes.tilera.xyz/api/memes?category=" . $cate->id));
$memes = $memeobj->memes; $memes = $memeobj->memes;
@ -31,6 +33,7 @@ foreach ($cats as $cate) {
'; ';
} }
} }
mysqli_free_result( $db_ergJens );
echo '</div><br clear="all">'; echo '</div><br clear="all">';
} }

72
website/incl/memecat.php Normal file
View file

@ -0,0 +1,72 @@
<?php
$catobj = json_decode(file_get_contents("https://jensmemes.tilera.xyz/api/categories"));
$cats = $catobj->categories;
echo '
<script>
$(document).ready(function(){
$(\'#show\').on(\'change\', function() {
';
global $cats;
$c2 = 0;
foreach ($cats as $cate){
$cname = str_replace(' ', '_',$cate->name);
if($c2==0){
echo '
if(this.value=="'.$cname.'"){
';
foreach ($cats as $catdis) {
if($catdis->name!=$cate->name){
$cat_dis = str_replace(" ", '_', $catdis->name);
echo '$("#'.$cat_dis.'").hide();';
}
}
echo '
$("#'.$cname.'").show();
}';
$c2=1;
}else{
echo '
else if(this.value=="'.$cname.'"){
';
foreach ($cats as $catdis) {
if($catdis->name!=$cate->name){
$cat_dis = str_replace(" ", '_', $catdis->name);
echo '$("#'.$cat_dis.'").hide();';
}
}
echo '
$("#'.$cname.'").show();
}';
}
}
echo '
});
});
</script>';
echo '
<div id="themediv">
<p>Anzeigen:</p>
<select id="show">
';
global $cats;
$c = 0;
foreach ($cats as $cate) {
$cname = str_replace(' ', '_', $cate->name);
if($c==0){
echo '<option value="'.$cname.'" selected>'.$cname.'</option>';
$c=1;
}
echo '<option value="'.$cname.'">'.$cname.'</option>';
}
echo '</select></div>';
?>

View file

@ -79,24 +79,12 @@
</select> </select>
</div> </div>
<div id="themediv">
<p>Anzeigen::</p>
<select id='show'>
<option value="0" selected>All</option>
<option value="1">JensMemes</option>
<option value="2">Realtox Memes</option>
<option value="3">Hendrik Memes</option>
<option value="4">Random Memes</option>
<option value="5">Hide all Memes</option>
</select>
</div>
<?php <?php
include('incl/memecat.php');
$tokencookie = $_COOKIE['token']; $tokencookie = $_COOKIE['token'];
if (!empty($tokencookie)) { if (!empty($tokencookie)) {
echo '<b style="color:red;">Authentifiziert</b>'; echo '<b style="color:red;">Authentifiziert</b>';
} ?> } ?>
<form method='post' action='https://jensmemes.tilera.xyz/api/upload' enctype='multipart/form-data'>
<input type="file" id="real-file" hidden="hidden" name="file[]" multiple="" /> <input type="file" id="real-file" hidden="hidden" name="file[]" multiple="" />
<button type="button" id="custom-button">Browse...</button> <button type="button" id="custom-button">Browse...</button>
<span id="custom-text"></span> <span id="custom-text"></span>
@ -105,7 +93,7 @@
echo ' echo '
<input type="text" name="token" id="token" placeholder="Token">'; <input type="text" name="token" id="token" placeholder="Token">';
} else { } else {
echo '<input type="hidden" name="token" value="' . $tokencookie . '">'; echo '<input type="hidden" id="tokenform" name="token" value="' . $tokencookie . '">';
} }
?> ?>
<label for="type">Memetype</label> <label for="type">Memetype</label>
@ -117,15 +105,48 @@
?> ?>
</select> </select>
<button id="btn-close-CSS"></button>
<i id="msg"></i>
<script type="text/javascript">
$(document).ready(function (e) {
$('#btn-close-CSS').on('click', function () {
var form_data = new FormData();
var ins = document.getElementById('real-file').files.length;
var backend_url = 'https://jensmemes.tilera.xyz/api/upload';
for (var x = 0; x < ins; x++) {
form_data.append("file[]", document.getElementById('real-file').files[x]);
}
var token = $('#tokenform').val();
var cat = $('#type').val();
form_data.append('token', token);
form_data.append('category', cat);
$.ajax({
url: backend_url,
dataType: 'text',
cache: false,
contentType: false,
processData: false,
data: form_data,
type: 'post',
success: function (response) {
$('#msg').html(response);
},
error: function (response) {
$('#msg').html(response);
}
});
});
});
</script>
<center><input type='submit' name='submit' id="btn-close-CSS" value=''></center>
</form>
</div> </div>
<br> <br>
<br> <br>
<?php <?php
include "dbcon.php";
include 'incl/img.php'; include 'incl/img.php';
include 'incl/clientIP.php'; include 'incl/clientIP.php';
?> ?>