added old project files
This commit is contained in:
		
							
								
								
									
										23
									
								
								php/checkSessionValidity.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										23
									
								
								php/checkSessionValidity.php
									
									
									
									
									
										Executable 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
									
								
							
							
						
						
									
										10
									
								
								php/checkpasswd.php
									
									
									
									
									
										Executable 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
									
								
							
							
						
						
									
										20
									
								
								php/database.php
									
									
									
									
									
										Executable 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
									
								
							
							
						
						
									
										36
									
								
								php/db/getmoviefromdb.php
									
									
									
									
									
										Executable 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
									
								
							
							
						
						
									
										42
									
								
								php/db/savemovietodb.php
									
									
									
									
									
										Executable 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
									
								
							
							
						
						
									
										32
									
								
								php/getmoviedata.php
									
									
									
									
									
										Executable 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
									
								
							
							
						
						
									
										56
									
								
								php/getseriesdata.php
									
									
									
									
									
										Executable 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));
 | 
			
		||||
 ?>
 | 
			
		||||
							
								
								
									
										47
									
								
								php/mergescripts/getmoviejsondata.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										47
									
								
								php/mergescripts/getmoviejsondata.php
									
									
									
									
									
										Executable 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;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 ?>
 | 
			
		||||
							
								
								
									
										46
									
								
								php/mergescripts/getthumbnailsmovies.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										46
									
								
								php/mergescripts/getthumbnailsmovies.php
									
									
									
									
									
										Executable 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");
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 ?>
 | 
			
		||||
							
								
								
									
										39
									
								
								php/mergescripts/getthumbnailstvshows.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										39
									
								
								php/mergescripts/getthumbnailstvshows.php
									
									
									
									
									
										Executable 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");
 | 
			
		||||
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 ?>
 | 
			
		||||
		Reference in New Issue
	
	Block a user