function getMovie($id)
{
    $movies = getMovies();
    foreach ($movies as $movie) {
        if ($movie['id'] == $id) {
            return $movie;
        }
    }
    return [];
}
<?
$params = json_decode(file_get_contents('php://input'), true );

if($params['data']['fn'] == 'movies'){
  getMovies();
}
if($params['data']['fn'] == 'single_movie'){
  getSingleMovie();
}

if($params['data']['fn'] == 'submit_form'){
  submitForm();
}

if($params['data']['fn'] == 'nasapic'){
  nasaPic();
}
if($params['data']['fn'] == 'pass_submit'){
  passSubmit();
}
function nasaPic(){
  $apikey = 'Yw2XghQ0bP5YaF10rz8bsRCTD7pBBXSOKSyZxhuz';
  $endpoint = 'https://api.nasa.gov/planetary/apod?api_key='.$apikey.'&format=JSON';
  // setup curl to make a call to the endpoint
  $session = curl_init($endpoint);
  // indicates that we want the response back
  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  // exec curl and get the data back
  $data = curl_exec($session);
  // close curl session once finished retrieveing data
  curl_close($session);
		<a href="changePassword.php">Change Password</a><br>
		<a href="logout.php">Logout</a>
	</div>
	
	<table id="main">
		<tr><td colspan="4">
			<h1><?php 
echo "Welcome " . $_SESSION['name'];
?>
!</h1>
			<h2>Choose a Movie Title</h2>
			<form method="post">
				<select size=1 name="movieID">
					<option value="-1">Choose A Movie Title (sorted alphabetically)</option>
					<?php 
$movieTitles = getMovies();
// loop through options with foreach
foreach ($movieTitles as $movie) {
    echo "<option value='" . $movie['movieID'] . "'>" . $movie['title'] . "</option>";
}
?>
				</select>
				<input type="submit" value="Search"><img src="popcorn-icon.png">

		</td></tr>
		
		<tr><td id="space" colspan="4"></td></tr>
		
		<tr><td colspan="4"><h2>Filter Movies By Director, Genre, and/or Rating</h2></td></tr>
			
		<tr><td>
예제 #4
0
        <a href="movie.php?tag=Adventure">Adventure</a>
      </li>
      <li>
        <a href="movie.php?tag=Thriller">Thriller</a>
      </li>
      <li>
        <a href="movie.php">All Categories</a>
      </li>
    </ul>
  </div>
  <div class="right">
    <?php 
$itempage = 1;
$tag = '';
$people = '';
$jsonData = getMovies($itempage, $tag, $people);
$json = json_decode($jsonData);
?>

    <table>
      <tr class="movie">
        <?php 
$count = 0;
for ($i = 0; $i < count($json); $i++) {
    $data = $json[$i];
    if ($count < 5) {
        $count++;
        ?>
            <td class="item"><div class="center"><img src = "<?php 
        echo $data->imgurl;
        ?>
/* Configuration */
$imdbStartingPoint = ['http://www.imdb.com/search/title?at=0&num_votes=10000,&release_date=2000,&sort=user_rating,desc&title_type=feature&user_rating=2.0,8.0', 'http://www.imdb.com/search/title?at=0&num_votes=10000,&release_date=2000,&sort=user_rating,asc&title_type=feature&user_rating=2.0,8.0', 'http://www.imdb.com/search/title?at=0&num_votes=10000,&release_date=2000,&sort=user_rating,desc&start=2000&title_type=feature&user_rating=2.0,8.0'];
$imdbCommentPageMask = "http://www.imdb.com/title/#id/reviews?start=#offset";
$outputFile = 'imdb-comments-' . date('Ymd-Hi') . ".csv";
/* Initialize */
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
$fh = fopen($outputFile, "w");
/* Loop over IMDB listings too obtain comments */
$id = 0;
foreach ($imdbStartingPoint as $imdbUrl) {
    $result = getUrl($curl, $imdbUrl);
    $movies = getMovies($result);
    foreach ($movies as $movieId) {
        $offsets = [0];
        // Initilize offsets with 0 offset
        $commentUrl = $imdbCommentPageMask;
        $commentUrl = str_replace("#id", $movieId, $commentUrl);
        for ($i = 0; $i < count($offsets); $i++) {
            $currentOffset = $offsets[$i];
            $commentUrlWithOffset = str_replace("#offset", $currentOffset, $commentUrl);
            $commentsPage = getUrl($curl, $commentUrlWithOffset);
            /* Look for more pages and update offset array */
            $paging = getCommentsPages($commentsPage);
            foreach ($paging as $pageOffset) {
                if (!in_array($pageOffset, $offsets)) {
                    array_push($offsets, $pageOffset);
                    print "Got new offset for {$movieId}: {$pageOffset}. Adding to offsets\n";
예제 #6
0
<?php

$page_title = 'Browse Movies';
include '_header.php';
include 'fun.inc.php';
?>
<link REL="SHORTCUT ICON" HREF="http://www.teachnet-uk.org.uk/2006%20Projects/ICT-Access_Database/AccessDB/Images/dvd-icon.jpg">
<p></p>


<?php 
$list = getGenre();
foreach ($list as $value) {
    echo '<form action="ViewGenresMovies.php" method="post">';
    echo '<p><div name=' . $value . '><p>';
    echo $value;
    echo '<table name="' . $value . '"align="center" cellspacing="3"  cellpadding="3" width="75%" style="border:dotted">
	<tr><td align="left">Title</td><td align="left">Date of Release</td><td align="left">Genres</td><td align="left"></td></tr>';
    getMovies($value);
    echo '</table>';
    echo '<label><input type="submit" value="More..."/><input name="cat" type="hidden" value="' . $value . '"/></label>';
    echo '</p></div></p>';
    echo '</form>';
}
?>



<?php 
include '_footer.php';
예제 #7
0
        echo "<br>";
        echo "<span class='title'>Movie Length: </span><span class='titleValue'>" . $row['MOVIELENGTH'] . "</span><span class='rating'>&nbsp;&nbsp;&nbsp;<img src='includes/likes.png'/ title='Users Rating'>" . number_format($row['RATING'] / 10 * 100, 0) . "%</span>";
        echo "<br>";
        echo "<span class='title'>Movie Release Year: </span><span class='titleValue'>" . $row['MOVIERELEASEYEAR'] . "</span>";
        echo "<div class='more-details-div'>";
        echo "<span class='title'>Producer: </span> <span class='titleValue'>" . $row['PRODUCER'] . "</span>&nbsp;&nbsp;";
        echo "<span class='title'>Genre: </span> <span class='titleValue'>" . $row['GENRE'] . "</span>";
        echo "<br>";
        echo "<span class='title'>Director: </span> <span class='titleValue'>" . $row['DIRECTOR'] . "</span>&nbsp;&nbsp;";
        echo "<span class='title'>Language: </span> <span class='titleValue'>" . $row['LANGUAGE'] . "</span>";
        echo "<br>";
        echo "<span class='title'>Movie Studio: </span> <span class='titleValue'>" . $row['STUDIO'] . "</span>&nbsp;&nbsp;";
        echo "<span class='title'>Description: </span> <span class='titleValue'>" . $row['DESCRIPTION'] . "</span>";
        $actorQuery = "select firstname, lastname, role from actor, starsin where actor.ACTORID = starsin.ACTORID and starsin.MOVIEID=" . $row['MOVIEID'];
        $actors = oci_parse($conn, $actorQuery);
        oci_execute($actors);
        while (($actorrow = oci_fetch_array($actors, OCI_BOTH)) != false) {
            echo "<br>";
            echo "<span class='title'>Actor: </span> <span class='titleValue'>" . $actorrow['FIRSTNAME'] . " " . $actorrow['LASTNAME'] . "</span>&nbsp;&nbsp;";
            echo "<span class='title'>Actor Role: </span> <span class='titleValue'>" . $actorrow['ROLE'] . "</span>";
        }
        echo "</div>";
        echo "</div>";
    }
}
getMovies(null, $conn);
?>
</div>
<?php 
include 'footer.php';
oci_close($conn);
예제 #8
0
<?php

require_once ROOT_PATH . 'php/functions/lib_searchMovies.php';
/* Verify if the variable $_POST['requete] is set and not null */
if (isset($_POST['requete']) && $_POST['requete'] != NULL) {
    /* 
        We create a variable $... to facilitate writing of the SQL query , but also to prevent any evil who would use the PHP or JS,
        with htmlspecialchars().
    */
    $request = $_POST['requete'];
    $movies = getMovies($connect, $request);
    if ($movies !== false) {
        foreach ($movies as $row) {
            ?>
				
                <div class="col-md-3 portfolio-item">
                    <div class="thumbnail">
                        <b><?php 
            echo '' . $row['Title'] . '';
            ?>
</b>
                    </div><!-- /.thumbnail -->
                </div><!-- /.portfolio-item --> 

<?php 
        }
    } else {
        ?>
            <div class="col-md-3 portfolio-item">
                <div class="thumbnail">
                    <b>No results</b>
예제 #9
0
<?php

require_once ROOT_PATH . "php/configs/configs.php";
require_once ROOT_PATH . 'php/functions/lib_searchMovies.php';
$movies = getMovies($connect);
if ($movies !== false) {
    foreach ($movies as $row) {
        ?>
			<div class="col-md-3 portfolio-item">
                <div class="thumbnail">
                    <b><?php 
        echo '' . $row['Title'] . '';
        ?>
</b>
                </div><!-- /.thumbnail -->
        	</div><!-- /.portfolio-item -->
<?php 
    }
} else {
    ?>
        <div class="col-md-3 portfolio-item">
            <div class="thumbnail">
                <b>No results</b>
            </div><!-- /.thumbnail -->
        </div><!-- /.portfolio-item -->
<?php 
}
예제 #10
0
<?php

require __DIR__ . '/includes/config.php';
require __DIR__ . '/includes/functions.php';
$query = urldecode($_GET['query']);
$page = (int) $_GET['page'];
$movies = getMovies();
if (!empty($query)) {
    $movies = searchMovies($movies, $query);
}
$movies = sortMovies($movies);
$movies = array_chunk($movies, 16);
$pages = count($movies);
if ($page < 1) {
    $page = 1;
}
if ($page > $pages) {
    $page = $pages;
}
$movies = $movies[$page - 1];
foreach ($movies as $i => $movie) {
    ?>
<div class="movie" onclick="window.location='<?php 
    echo $www;
    ?>
movie.php?id=<?php 
    echo $movie['id'];
    ?>
'">
	<div class="movie-poster">
		<a href="<?php 
예제 #11
0
<?php

require_once 'functions.php';
$connection = new mysqli('localhost', 'root', '', 'collectionsdb');
if ($connection->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
if (isset($_POST["json"])) {
    $movieObj = json_decode($_POST["json"], true);
}
$func = $_POST["func"];
if ($func == "save") {
    $newlyAddedMovieId = saveMovie($connection, $movieObj);
    echo json_encode(getMovies($connection, $newlyAddedMovieId));
} else {
    if ($func == "loadAll") {
        echo json_encode(getMovies($connection, 0));
    }
}
$connection->close();