added old project files

This commit is contained in:
lukas 2020-05-16 20:41:32 +02:00
parent 177e267e18
commit b264ae0ee2
21 changed files with 796 additions and 0 deletions

76
css/basicvideo.css Executable file
View File

@ -0,0 +1,76 @@
.movietile{
height: 330px;
width: 200px;
float: left;
margin: 10px;
background-color: #F0F0F0;
position: relative;
cursor: pointer;
border-radius: 25px;
}
.movietile:hover{
opacity: 0.7;
}
.movietile-text{
position: absolute;
text-align: center; /* todo doesnt work */
bottom: 0;
}
.movietile-thumbnail{
height: 300px;
border-radius: 25px;
}
#moviespace{
}
#moviespace-video{
max-width: 100%;
max-height: 100%;
width: 100%;
height: 100%;
display: inline-block;
vertical-align: middle;
}
.hideit{
display: none;
}
.moviespace-heading{
float: left;
margin-left: 20px;
margin-top: 20px;
}
.moviespace-backbutton{
float: left;
cursor: pointer;
color: white;
background-color: #404D5E;
border: none;
transition: all 0.2s ease-in-out;
width: 20%;
height: 40px;
margin-top: 20px;
margin-bottom: 20px;
}
.moviespace-backbutton:hover{
background: #E0B612;
color: white;
}
.btnloadmore{
/* position: absolute;
bottom:0%; */
}

6
css/index__2.css Executable file
View File

@ -0,0 +1,6 @@
#thevideo {
max-width: 100%;
max-height: 100%;
display: inline-block;
vertical-align: middle;
}

3
css/login.css Executable file
View File

@ -0,0 +1,3 @@
.hideit{
display: none;
}

0
css/movies.css Executable file
View File

1
css/series.css Executable file
View File

@ -0,0 +1 @@

37
index.php Executable file
View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Lukis Filme</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/login.js"></script>
<link rel="stylesheet" href="css/login.css">
</head>
<body>
<div class="col-sm-8 text-left">
<h1>Lukis Filme</h1>
<h4>Bitte Passwort eingeben:</h4>
<div class="alert alert-danger hideit mypassalert">
<strong>Achtung!</strong> Du hast scheinbar das falsche Passwort eingegeben.
</div>
<hr>
<div class="col-sm-4">
<form id="myform" action="index.php" method="post">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input type="password" size="20" maxlength="20" name="pass" placeholder="Passwort" required class="form-control">
</div>
<input type="submit" value="Login" class="btn btn-default">
</form>
</div>
</div>
</body>
</html>

27
js/login.js Executable file
View File

@ -0,0 +1,27 @@
$(document).ready(function() {
$("#myform").submit(function(event) {
event.preventDefault();
// console.log($("#myform").serialize());
checkpasswd($("#myform").serialize());
//
});
});
function checkpasswd(data) {
// console.log(data);
$.post('php/checkpasswd.php', data, function(retdata){
if (retdata.valid == true) {
//successfully logged in
sessionStorage.LAST_ACTIVITY = Math.round(new Date().getTime() / 1000);
document.cookie = "LAST_ACTIVITY="+Math.round(new Date().getTime() / 1000);
window.location ="movies.php";
return true;
}else {
$(".mypassalert").show();
setTimeout(function () {
$(".mypassalert").hide();
}, 2000);
}
},'json');
}

94
js/movies.js Executable file
View File

@ -0,0 +1,94 @@
//global variables:
var loadedVideos =0;
var allmovies = null;
var tempmovies = [];
var tempscrollposition = null;
$(document).ready(function() {
$.post('php/db/getmoviefromdb.php','action=all',function(data){
//console.log(data);
allmovies = data;
tempmovies = allmovies.data;
loadNewPreviews(20);
},'json');
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
loadNewPreviews(10);
console.log("loadnew");
}
});
$('.moviespace-backbutton').click(function() {
$('#moviespace').hide();
$('.moviespace-videospace').html("");
$('.movielist').show();
$(window).scrollTop(tempscrollposition);
});
$("#moviesearch-form").submit(false);
$("#moviesearch").change(function(event) {
console.log("change...");
search();
});
$('#moviesearch-button').click(function(event) {
search();
});
$('.btnloadmore').click(function() {
loadNewPreviews(10);
});
});
function search() {
$(".movielist").html("");
tempmovies = [];
loadedVideos = 0;
for (var i in allmovies.data) {
if(allmovies.data[i].name.toUpperCase().includes($("#moviesearch").val().toUpperCase())){
tempmovies.push(allmovies.data[i]);
}
}
console.log(tempmovies.length);
if(tempmovies.length < 15){
loadNewPreviews(tempmovies.length);
}else{
loadNewPreviews(15);
}
}
function loadNewPreviews(number) {
for (var i = 0; i < number; i++) {
if (loadedVideos < tempmovies.length) { //maybe TODO
loadMoviePreview(tempmovies[loadedVideos]);
loadedVideos++;
}
}
}
function loadMoviePreview(data) {
var preview = $("<div class='movietile'><div class='movietile-thumbnail'><img style='max-width: 100%;max-height:100%;border-radius: 25px;' src='rsc/thumbnails/"+data.thumbnail+"'></img></div><div class='movietile-text'>"+data.name+"</div></div>");
$(".movielist").append(preview);
preview.click(function(event) {
tempscrollposition = $(window).scrollTop();
$('.movielist').hide();
var thisvideo = tempmovies[$(this).index()];
$('#moviespace').show();
$('.moviespace-videospace').html("<video id='moviespace-video' controls><source src='../Filme/"+thisvideo.url+"'></video>");
$('.moviespace-heading').html(thisvideo.name);
$.post('rsc/moviedatajson/'+thisvideo.name+'.json','',function(data){
console.log(data);
$('.moviespace-infospace').html(data.overview);
},'json');
});
}

55
js/series.js Executable file
View File

@ -0,0 +1,55 @@
var tempscrollposition = 0;
$(document).ready(function() {
$.post('php/getseriesdata.php','action=getallseries',function(data){
console.log(data);
// console.log("post finished");
for (var num in data.data) {
//insert a tile for each TV show...
var previewtvshow = $("<div class='movietile'><div class='movietile-thumbnail'><img style='max-width: 100%;max-height:100%;' src=\"rsc/thumbnailsseries/"+data.data[num].thumbnail+"\"></img></div><div class='movietile-text'>"+data.data[num].name+"</div></div>");
$(".movielist").append(previewtvshow);
previewtvshow.click(function(event) {
var clickeditem = data.data[$(this).index()];
tempscrollposition = $(window).scrollTop();
$('.movielist').hide();
console.log(clickeditem);
$.post('php/getseriesdata.php','action=getseries&seriesname='+clickeditem.name,function(data){
console.log(data);
// TODO
// var seasons = [];
/*
var seasonold = "";
for (var n in data.data) {
var filename = data.data[n].name;
var season = filename.substring(filename.length-5,filename.length-3); // TODO:
if (season != seasonold) {
seasons.push(season);
seasonold = season;
}
}
console.log("This tv show has "+seasons.length+" seasons");*/
$('.episodelist').html("");
for (var i in data.data) {
var episode = $("<div class='movietile'><div class='movietile-thumbnail'><img style='max-width: 100%;max-height:100%;' src=\"rsc/thumbnailsseries/"+data.data[i].thumbnail+"\"></img></div><div class='movietile-text'>"+data.data[i].name+"</div></div>");
$('.episodelist').append(episode);
episode.click(function(event) {
var clickeditem = data.data[$(this).index()];
console.log(clickeditem);
$('.episodelist').hide();
$('#moviespace').show();
$('.moviespace-videospace').html("<video id='moviespace-video' controls><source src='../Serien/"+clickeditem.url+"'></video>");
$('.moviespace-heading').html(clickeditem.name);
});
}
},'json');
$('.episodelist').show();
});
}
},'json');
});

79
movies.php Executable file
View File

@ -0,0 +1,79 @@
<?php
include "php/checkSessionValidity.php"
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/movies.css">
<link rel="stylesheet" href="css/basicvideo.css">
<script type="text/javascript" src="js/movies.js"></script>
<title></title>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link active" href="movies.php">Movies</a>
</li>
<li class="nav-item">
<a class="nav-link " href="series.php">TV Shows</a>
</li>
</ul>
<form id="moviesearch-form" class="form-inline my-2 my-lg-0">
<input id="moviesearch" class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button id="moviesearch-button" class="btn btn-outline-success my-2 my-sm-0" type="button">Search</button>
</form>
</nav>
<div class="container-fluid" style="height:100%">
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-8">
<div class="movielist">
</div>
<div id="moviespace" class="hideit">
<div class="moviespace-backbutton">Back to Movies</div>
<div class="moviespace-heading">Moviename</div>
<div class="moviespace-videospace"></div>
<div class="moviespace-infospace"></div>
</div>
</div>
<div class="col-sm-2">
</div>
</div>
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm">
<button class="btn btn-info btnloadmore" type="button" >Load more...</button>
</div>
</div>
</div>
</body>
</html>

23
php/checkSessionValidity.php Executable file
View File

@ -0,0 +1,23 @@
<?php
if(isset($_COOKIE['LAST_ACTIVITY']))
{
if (time() - $_COOKIE['LAST_ACTIVITY'] > 86400) {
// last activity is more than 10 minutes ago
session_destroy();
echo "you are logged out because of the 10 minutes...";
exit();
} else {
// update last activity timestamp
//echo "updated timestamp";
//printf("timestamp updated %d seconds left", 3600 - (time() - $_SESSION['LAST_ACTIVITY']));
$_COOKIE['LAST_ACTIVITY'] = time();
}
}else
{
echo "no cookie...";
exit();
}
?>

10
php/checkpasswd.php Executable file
View File

@ -0,0 +1,10 @@
<?php
if ($_POST['pass'] == "42answertoeverything") {
echo json_encode(array('valid' => true));
}else {
echo json_encode(array('valid' => false));
}
?>

20
php/database.php Executable file
View File

@ -0,0 +1,20 @@
<?php
$server = "172.17.0.2";
// $user = "mediacenter";
// $password = "lqdZ5bcsqI9eXaN9";
$user = "mediacenter";
$password = "w3xSBWWqvBFaLzmC";
$database = "mediacenter";
$link = new mysqli($server, $user, $password,$database);
if(mysqli_connect_errno())
{
echo "connecton failed... nr: ". mysqli_connect_errno(). " -- " . mysqli_connect_error();
}
echo "\n\nseas\n";
?>

36
php/db/getmoviefromdb.php Executable file
View File

@ -0,0 +1,36 @@
<?php
$server = "172.17.0.2";
$user = "mediacenter";
$password = "w3xSBWWqvBFaLzmC";
$database = "mediacenter";
$data = new class{};
$link = new mysqli($server, $user, $password,$database);
if(mysqli_connect_errno())
{
echo "connecton failed... nr: ". mysqli_connect_errno(). " -- " . mysqli_connect_error();
}
if (isset($_POST['action'])) {
$action = $_POST['action'];
if ($action == "all") {
$query = "SELECT * FROM `movies`";
$result = mysqli_query($link,$query);
$resultnumber = $result->num_rows;
$data->data = array();
while($row = $result->fetch_assoc()) {
array_push($data->data, array('name' => $row['name'],'url' => $row['URL'],'thumbnail' => $row['thumbnail'] ));
}
}
}
echo(json_encode($data));
?>

42
php/db/savemovietodb.php Executable file
View File

@ -0,0 +1,42 @@
<?php
$server = "172.17.0.2";
$user = "mediacenter";
$password = "w3xSBWWqvBFaLzmC";
$database = "mediacenter";
$link = new mysqli($server, $user, $password,$database);
if(mysqli_connect_errno())
{
echo "connecton failed... nr: ". mysqli_connect_errno(). " -- " . mysqli_connect_error();
}
$myobj->error = false;
$list = scandir("../../../Filme");
$myobj->data = array();
foreach ($list as $moviename) {
if (strpos($moviename, '.mp4') !== false) {
$name = substr($moviename, 0, -4);
$url = str_replace(" ","%20",$moviename);
$thumbnail = str_replace(" ","%20",str_replace(".mp4",".jpg",$moviename));
echo($name . "\n");
//check if movie already exists:
$query = "SELECT * FROM `movies` WHERE `name` = '$name'";
$result = mysqli_query($link,$query);
$resultnumber = $result->num_rows;
if ($resultnumber > 0) {
echo($name . "already exists!\n\n");
}else {
//save movies to db
$query = "INSERT INTO `movies` (`id`, `name`, `URL`, `thumbnail`) VALUES (NULL, '$name', '$url', '$thumbnail')";
$result = mysqli_query($link,$query);
}
}
}
?>

32
php/getmoviedata.php Executable file
View File

@ -0,0 +1,32 @@
<?php
$data = array('error' => true);
$myobj = new class{};
if (isset($_POST['action'])) {
$action = $_POST['action'];
if ($action == "getmovies") {
$myobj->error = false;
$list = scandir("../../Filme");
$myobj->data = array();
foreach ($list as $moviename) {
if (strpos($moviename, '.mp4') !== false) {
array_push($myobj->data,(object) array( 'name' => substr($moviename, 0, -4),
'url'=>str_replace(" ","%20",$moviename),
'thumbnail' => str_replace(" ","%20",str_replace(".mp4",".jpg",$moviename))));
}
}
} else {
// code...
}
}else {
$myobj->error = true;
}
echo(json_encode($myobj));
?>

56
php/getseriesdata.php Executable file
View File

@ -0,0 +1,56 @@
<?php
$data = array('error' => true);
$myobj = new class{};
if (isset($_POST['action'])) {
$action = $_POST['action'];
if ($action == "getallseries") {
$myobj->error = false;
$list = scandir("../../Serien");
$myobj->data = array();
foreach ($list as $moviename) {
if ($moviename !== ".." && $moviename !== "." && $moviename !== "index.html") {
array_push($myobj->data,(object) array( 'name' => $moviename,
'url'=>str_replace(" ","%20",$moviename),
'thumbnail' => str_replace(" ","%20",$moviename.".jpg")));
}
}
} elseif ($action == "getseries") {
if (isset($_POST['seriesname'])) {
$myobj->error = false;
$seriesname = $_POST['seriesname'];
$list = scandir("../../Serien/".$seriesname);
//echo(json_encode($list));
$myobj->data = array();
foreach ($list as $moviename) {
if ($moviename !== ".." && $moviename !== ".") {
$tempdata = new class{};
array_push($myobj->data,(object) array( 'name' => substr($moviename, 0, -4),
'url'=>str_replace(" ","%20",$seriesname."/".$moviename),
'thumbnail' => str_replace(" ","%20",str_replace(".mp4",".jpg",$seriesname."/".$moviename)),
'seasons' => array()));
}
}
}else {
$myobj->error = true;
}
}else {
// code...
}
}else {
$myobj->error = true;
}
echo(json_encode($myobj));
?>

View File

@ -0,0 +1,47 @@
<?php
$list = scandir("../../../Filme");
$path = "../rsc/thumbnails/"; //TODO
$data = new class{};
for($i=2;$i<=count($list)-1;$i++){
if (strpos($list[$i], '.mp4') !== false) {
$list[$i]=str_replace(' ', '%20', substr($list[$i], 0, -4));
//TODO
if (file_exists($path.str_replace('%20', ' ', $list[$i]).".jpg")) { //TODO
echo "exists!\n";
}else {
echo("exists not: ".str_replace('%20', ' ', $list[$i]).".jpg\n");
$moviename = $list[$i];
$year = 0;
if( preg_match( '!\(([^\)]+)\)!', $list[$i], $match ) ){
$text = $match[0];
$year = $match[1];
$moviename = str_replace($text,"",$list[$i]);
echo $text."\n\n";
}
$query = "https://api.themoviedb.org/3/search/movie?api_key=9fd90530b11447f5646f8e6fb4733fb4&language=de-DE&include_adult=true&query=".$moviename;
//$query = "https://api.themoviedb.org/3/search/movie?api_key=9fd90530b11447f5646f8e6fb4733fb4&language=de-DE&include_adult=true&query=eeeeeee";
$result = json_decode(file_get_contents($query));
if ($result->total_results == 0) {
echo("\n\nno result found for".$moviename);
}else {
$moviedata = $result->results[0];
echo json_encode($moviedata);
file_put_contents ('./'.str_replace('%20', ' ', $list[$i]).'.json', json_encode($moviedata));
// $data->{$moviedata->title} = $moviedata;
}
}
}
}
?>

View File

@ -0,0 +1,46 @@
<?php
$list = scandir("../../../Filme");
$path = "../../rsc/thumbnails/";
for($i=2;$i<=count($list)-1;$i++){
if (strpos($list[$i], '.mp4') !== false) {
$list[$i]=str_replace(' ', '%20', substr($list[$i], 0, -4));
if (file_exists($path.str_replace('%20', ' ', $list[$i]).".jpg")) {
echo "exists!\n";
}else {
echo("exists not: ".str_replace('%20', ' ', $list[$i]).".jpg");
$moviename = $list[$i];
$year = 0;
if( preg_match( '!\(([^\)]+)\)!', $list[$i], $match ) ){
$text = $match[0];
$year = $match[1];
$moviename = str_replace($text,"",$list[$i]);
echo $text."\n\n";
}
$query = "https://api.themoviedb.org/3/search/movie?api_key=9fd90530b11447f5646f8e6fb4733fb4&language=en-US&include_adult=true&query=".$moviename;
$result = json_decode(file_get_contents($query));
if ($result->total_results == 0) {
echo("\n\nno result found for".$moviename);
}else {
if ($year != 0) {
for ($n=0; $n < count($result->results); $n++) {
if(strpos($result->results[$n]->release_date, $year) !== false)
{
copy("http://image.tmdb.org/t/p/w342/".$result->results[$n]->poster_path, $path.str_replace('%20', ' ', $list[$i]).".jpg");
}
}
}else {
echo("http://image.tmdb.org/t/p/original/".$result->results[0]->poster_path."\n\n");
copy("http://image.tmdb.org/t/p/w342/".$result->results[0]->poster_path, $path.str_replace('%20', ' ', $list[$i]).".jpg");
}
}
}
}
}
?>

View File

@ -0,0 +1,39 @@
<?php
$list = scandir("../../../Serien");
$path = "../../rsc/thumbnailsseries/";
for($i=2;$i<=count($list)-1;$i++){
echo $list[$i];
$list[$i]=str_replace(' ', '%20',$list[$i]);
if (file_exists($path.str_replace('%20', ' ', $list[$i]).".jpg")) {
echo "exists!\n";
}else {
echo("exists not: ".str_replace('%20', ' ', $list[$i]).".jpg");
$moviename = $list[$i];
$year = 0;
if( preg_match( '!\(([^\)]+)\)!', $list[$i], $match ) ){
$text = $match[0];
$year = $match[1];
$moviename = str_replace($text,"",$list[$i]);
echo $text."\n\n";
}
$query = "https://api.themoviedb.org/3/search/tv?api_key=9fd90530b11447f5646f8e6fb4733fb4&language=en-US&include_adult=true&query=".$moviename;
$result = json_decode(file_get_contents($query));
if ($result->total_results == 0) {
echo("\n\nno result found for".$moviename);
}else {
echo("http://image.tmdb.org/t/p/original/".$result->results[0]->poster_path."\n\n");
copy("http://image.tmdb.org/t/p/w342/".$result->results[0]->poster_path, $path.str_replace('%20', ' ', $list[$i]).".jpg");
}
}
}
?>

67
series.php Executable file
View File

@ -0,0 +1,67 @@
<?php
include "php/checkSessionValidity.php"
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/series.css">
<link rel="stylesheet" href="css/basicvideo.css">
<script type="text/javascript" src="js/series.js"></script>
<title></title>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link " href="movies.php">Movies</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="series.php">TV Shows</a>
</li>
</ul>
<form id="moviesearch-form" class="form-inline my-2 my-lg-0">
<input id="moviesearch" class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button id="moviesearch-button" class="btn btn-outline-success my-2 my-sm-0" type="button">Search</button>
</form>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-8">
<div class="movielist"></div>
<div class="seasonlist hideit"></div>
<div class="episodelist hideit"></div>
<div id="moviespace" class="hideit">
<div class="moviespace-backbutton">Back to Movies</div>
<div class="moviespace-heading">Moviename</div>
<div class="moviespace-videospace"></div>
</div>
</div>
<div class="col-sm-2">
</div>
</div>
</div>
</body>
</html>