Exemple #1
0
 public function testSearchDVD()
 {
     $this->assertTrue(sizeof(search_dvd($this->the_title)) > 0, "{$this->the_title} should be in db");
 }
<?php

session_start();
require_once "dvd-db.php";
require_once "dvd-util.php";
include "../dvd-lib-common/head.php";
if (array_key_exists('part_title', $_POST) | array_key_exists('part_title', $_GET)) {
    if (array_key_exists('part_title', $_POST)) {
        $part_title = $_POST['part_title'];
    } else {
        $part_title = $_GET['part_title'];
    }
    $dvds = search_dvd($part_title);
    if (sizeof($dvds) > 0) {
        if (sizeof($dvds) == 1) {
            #display single dvd
            echo "<h2>One match found: </h2><br />\n<table cellpadding=5>\n";
            echo "<tr><th>Title</th><td>{$dvds[0][0]}</td></tr>\n";
            echo "<th>Release Year</th><td>{$dvds[0][1]}</td></tr>\n";
            echo "<th>Director</th><td>{$dvds[0][2]}</td></tr>\n";
            echo "<th>Rating</th><td>{$dvds[0][3]}</td></tr>\n";
            echo "<th>Genre</th><td>{$dvds[0][4]}</td></tr>\n";
            echo "</table><hr />";
        } else {
            echo "<h2>Possible Matches</h2><br />";
            echo "<table cellpadding=5>\n<tr><th>Title</th><th>Release Year</th>\n\t\t\t\t <th>Director</th><th>Rating</th><th>Genre</th></tr>";
            foreach ($dvds as $dvd) {
                echo "<tr>\n";
                echo "<td><a href='view_dvd.php?part_title={$dvd[0]}'>{$dvd[0]}</a></td>";
                for ($i = 1; $i < sizeof($dvd); $i++) {
                    echo "<td>{$dvd[$i]}</td>";
Exemple #3
0
    $attributes = $xml->attributes();
    $XmlMode = $attributes["XmlMode"];
    $ProtocolVersion = $attributes["ProtocolVersion"];
    $LibraryVersion = $attributes["LibraryVersion"];
    $LibraryName = $attributes["LibraryName"];
    $ClientName = $attributes["ClientName"];
    // Use requested version
    $xmlRoot->setAttribute("ProtocolVersion", $ProtocolVersion);
    checkVersion($ProtocolVersion, LIBDVDETECT_PROTOCOL_VERSION);
    $mysqli = connect_server();
    // Check connection
    if (!$mysqli) {
        $ResponseText = "Cannot connect to database.\nSQL Error: " . mysqli_connect_error();
        throw new Exception($ResponseText, XMLRESULT_SQL_ERROR);
    }
    search_dvd($mysqli, $xml, $rsDVDVMGM);
    $found = buildResults($domtree, $mysqli, $xmlRoot, null, $rsDVDVMGM, $ProtocolVersion);
    if (!$found) {
        $Result = XMLRESULT_NOT_FOUND;
        $ResponseText = "No data found for '" . $xml->Search . "'";
    } else {
        $Result = XMLRESULT_SUCCESS;
        $ResponseText = "Operation successful";
    }
    // free result set
    $rsDVDVMGM->close();
    $rsDVDVMGM = null;
} catch (Exception $e) {
    $Result = $e->getCode();
    $ResponseText = $e->getMessage();
}