Beispiel #1
0
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
$mysqli = new mysqli($db_hostname, $db_username, $db_password, $db_database);
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}
header("Access-Control-Allow-Origin: *");
$cmd = getValue("cmd");
if ($cmd == "films") {
    $response = listFilms();
    header('Content-type: application/json');
    echo json_encode($response);
} else {
    if ($cmd == "actors") {
        $response = listActors(getValue("film_id"));
        header('Content-type: application/json');
        echo json_encode($response);
    } else {
        echo "\n  <html>\n    <body>\n      <h1>API</h1>\n      <ul>\n        <li>\n          <h2>List All Films</h2>\n\n          <h3>Parameters:</h3>\n          <ul>\n            <li>cmd=films</li>\n\n          </ul>\n\n          <h3>Returns:</h3>\n          <p>All films</p>\n\n          <h3>Example:</h3>\n          <p><a href='FilmsAndActors.php?cmd=films'>?cmd=films</a></p>\n          <pre>\n            [ ['1','ACADEMY DINOSAUR'],['2','ACE GOLDFINGER'],['3','ADAPTATION HOLES'] ... ]\n          </pre>\n        </li>\n\n        <li>\n          <h2>List All Actors</h2>\n\n          <h3>Parameters:</h3>\n          <ul>\n            <li>cmd=actors</li>\n            <li>film_id=id (optional)</li>\n          </ul>\n\n          <h3>Returns:</h3>\n          <p>All actors in specified film.  If the film is not specified, all actors are returned.</p>\n\n          <h3>Example:</h3>\n          <p><a href='FilmsAndActors.php?cmd=actors&film_id=1'>?cmd=actors&film_id=1</a></p>\n          <pre>\n            [['7','GRACE','MOSTEL'],['47','JULIA','BARRYMORE'] ... ]\n          </pre>\n        </li>\n\n      </ul>\n    </body>\n  </html>\n  ";
    }
}
function listFilms()
{
    global $mysqli;
    $response = [];
    $query = "SELECT film_id, title FROM film";
    $res = $mysqli->query($query) or die(mysqli_error($mysqli));
    while ($row = $res->fetch_assoc()) {
        $response[] = $row;
    }
Beispiel #2
0
    } else {
        $srcimage = "images/no_movie_poster.jpg";
    }
    $tablemovied .= "<tr><td><img src='" . $srcimage . "' /></td>";
    $tablemovied .= "<td>" . $movie->original_title . "</td>";
    $tablemovied .= "<td>" . $movie->overview . "</td>";
    $tablemovied .= "<td>" . $vidlinks . "</td></tr></table>";
    $tablemovied = str_replace('"', '´', $tablemovied);
    return $tablemovied;
}
if ($_POST["btnsub"]) {
    $actnam = $_POST['txtsrch'];
    $actnam = str_replace(" ", "+", $actnam);
    $actorbi = "1";
    if ($selsearch != "2") {
        $tableactors = listActors($actnam);
    } else {
        $tablemovies = mb_listMovies($actnam);
        $actorbi = "2";
    }
} else {
    if ($_GET['id']) {
        $actorid = base64_decode($_GET['id']);
        if ($actorid . length > 0) {
            $tablemovies = listMovies();
            $actorbi = "2";
            //header('location:index.php');
        }
    } else {
        if ($_GET['mid']) {
            $movieid = base64_decode($_GET['mid']);