Exemplo n.º 1
0
function request_treatment($html_content, $keywords)
{
    $matches = array();
    if (preg_match("#([0-9]+) résultat[s]{0,1} trouvé[s]{0,1} dans les titres de films.#", $html_content, $matches) == 0) {
        return generate_no_search_results($keywords);
    } else {
        return generate_search_results($html_content, $keywords, $matches[1]);
    }
}
Exemplo n.º 2
0
    $moviematchestag = generate_movies_tags($results, $searchResultsDocument, $limit);
    $resultsTag->appendChild($opensearchQueryTag);
    $resultsTag->appendChild($openSearchTotResultTag);
    $resultsTag->appendChild($moviematchestag);
    $searchResultsDocument->appendChild($resultsTag);
    return $searchResultsDocument->saveXML();
}
/* generate an error xml */
function error_xml()
{
    $errorDocument = createDocument();
    $error = $errorDocument->CreateElement('error');
    $content = $errorDocument->CreateTextNode(utf8_encode('You need to search for something first.'));
    $error->appendChild($content);
    $errorDocument->appendChild($error);
    return $errorDocument->saveXML();
}
$matches = array();
if (preg_match("^title=(.+)\$^", $_SERVER['QUERY_STRING'], $matches) == 0) {
    echo error_xml();
} else {
    $keywords = $matches[1];
    $search = new imdbsearch();
    $search->setsearchname($keywords);
    $results = $search->results();
    if (count($results) > 0) {
        echo generate_search_results($keywords, $results, 3);
    } else {
        echo generate_no_search_results($keywords);
    }
}