5
1
Fork 0
mirror of https://github.com/Anvilcraft/jensmemes synced 2024-11-12 04:52:24 +01:00
This commit is contained in:
LordMZTE 2020-06-25 20:47:16 +02:00
commit aaa8b17c8a
6 changed files with 184 additions and 0 deletions

0
.gitignore vendored Normal file
View file

1
README.md Normal file
View file

@ -0,0 +1 @@
# JensMemes

9
website/dbcon.php Normal file
View file

@ -0,0 +1,9 @@
<?php
$con = mysqli_connect("localhost","root","PASSWORT","jensmeme");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>

116
website/index.php Normal file
View file

@ -0,0 +1,116 @@
<!DOCTYPE html>
<html>
<head>
<title>JensMemes v2</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-lightbox/0.7.0/bootstrap-lightbox.css">
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css">
</head>
<body class="">
<div class="col-lg m-auto">
<div class="col-lg-12">
<center>Eine zentrale Seite für alle Jens Memes!</center><br>
<div class="form-control m-auto bg-dark text-light" style="max-width:100%">
<form method='post' action='' enctype='multipart/form-data'>
<input type="file" name="file[]" id="file" multiple>
<?php
$tokencookie = $_COOKIE['token'];
if(empty($tokencookie)){
echo '
<input type="text" name="token" id="token" placeholder="Token">';
} else{
echo '<b style="color:red;">Authentifiziert.</b>';
}
?>
<input type='submit' name='submit' value='Upload'>
</form>
</div>
<br>
<br>
<?php
//UPLOAD
if(isset($_POST['submit'])){
include('uploadOK.php');
$home_dir = "images/".md5($tokencookie)."/";
if($home_dir=="images//"){
$home_dir = "images/".md5($_POST['token'])."/";
}
mkdir($home_dir);
$resultMaxUpl=mysqli_query($con, "select * from token WHERE token='$tokencookie' OR token='$tokenpost'")or die('Error In Session');
$rowMaxUpl=mysqli_fetch_array($resultMaxUpl);
$MaxUpl = $rowMaxUpl['uploadsLast24H'];
$MaxUpl++;
$sqlMaxUpl = "UPDATE token SET token='$MaxUpl' WHERE token='$tokencookie' OR token='$tokenpost'";
mysqli_query($con, $sqlMaxUpl);
if($uploadOK){
if($MaxUpl<=20){
$countfiles = count($_FILES['file']['name']);
for($i=0;$i<$countfiles;$i++){
$filename = $_FILES['file']['name'][$i];
move_uploaded_file($_FILES['file']['tmp_name'][$i],$home_dir.$filename);
}
if(empty($_COOKIE['token'])){
$setCookie = $_POST['token'];
setcookie("token",$setCookie,time()+(3600*720));
echo "Cookie mit Inhalt gesetzt: ".$setCookie;
}else{
echo "Cookie auf neustem Stand.";
}
} else{
echo "Maximales Upload Limit für heute erreicht. Bitte warten...";
}
} else{
echo "Unautorized!";
}
}
//BILDER ANZEIGEN
$files = glob("images/*/*");
for ($i=0; $i<count($files); $i++)
{
$image = $files[$i];
$supported_file = array(
'gif',
'jpg',
'jpeg',
'png'
);
$ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
if (in_array($ext, $supported_file)) {
echo "<div class='kasten'>";
echo "
<a href='$image'><img class='Bilder_' src='$image' /></a>\n
";
echo "</div>";
} elseif ($ext == "mp4") {
// echo basename($image);
echo "<div class='kasten'>";
echo '<a href="'.$image.'"><video src=' . $image . ' controls class="Videos_" ></video></a>';
echo "</div>";
}
else {
continue;
}
}
?>
</div>
</body>
</html>

37
website/style.css Normal file
View file

@ -0,0 +1,37 @@
.Bilder_ {
padding: 10px;
max-width: 300px;
max-height:150px;
vertical-align: bottom;
display: block;
margin-top:auto;
margin-bottom:auto;
margin-left:auto;
margin-right:auto;
}
.Videos_ {
padding: 10px;
max-width: 300px;
max-height:150px;
margin-top:auto;
margin-bottom:auto;
margin-left:auto;
margin-right:auto;
display: block;
}
.kasten{
background: #555555;
margin-left: 10px;
margin-bottom: 10px;
border: 5px solid grey;
float:left;
width: 300px;
height: 250px;
}
body{
background: #676767;
}

21
website/uploadOK.php Normal file
View file

@ -0,0 +1,21 @@
<?php
include('dbcon.php');
$tokencookie = $_COOKIE['token'];
$resulttoken=mysqli_query($con, "select * from token WHERE token='$tokencookie'")or die('Error In Session');
$rowtoken=mysqli_fetch_array($resulttoken);
$tokenpost = $_POST['token'];
$resultpost=mysqli_query($con, "select * from token WHERE token='$tokenpost'")or die('Error In Session');
$rowpost=mysqli_fetch_array($resultpost);
if(!empty($rowtoken) || !empty($rowpost)){
$uploadOK = true;
//echo "<b>Authenticated.</b>";
}else{
$uploadOK = false;
echo "unauthenticated.";
}
?>