Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/php
- <?php
- $movieName = $_POST["movieName"];
- //echo "Movie Name: [$movieName] <br/>";
- $movieName = preg_replace('/[^a-zA-Z0-9-_() .]/','',$movieName);
- //echo "Searching for: [$movieName] <br/><br/>";
- $neg = 0;
- $pos = 0;
- $ntl = 0;
- $tot = 0;
- // open file and fill up the neg, pos and ntl values from it
- $handle = fopen("<a http file", "r"); // this works!
- if ($handle) {
- while ($buffer = fgets($handle, 1024)) {
- // filter output based on the movie name
- if (strpos($buffer, $movieName) !== false) {
- //echo "[$buffer]";
- //echo "<br/>";
- preg_match_all('!\d+!', $buffer, $matches);
- $results = count($matches[0]);
- $num = $matches[0][$results-1];
- if (strpos($buffer, "negative") !== false) {
- $neg = $num;
- } else if (strpos($buffer, "neutral") !== false) {
- $ntl = $num;
- } else {
- $pos = $num;
- }
- } else {
- //echo "Ignoring [$buffer] <br/>";
- }
- }
- fclose($handle);
- } else {
- echo "Unable to open output file from S3. Make sure the file is public!";
- die();
- }
- $tot = $neg + $pos + $ntl;//echo "Pos: $pos, Neg: $neg, Ntl: $ntl, Total: $tot";
- $rating = ((($ntl*5)+($pos*10))/$tot);
- //echo "<br/>Rating: $rating";
- //echo "<br/>";
- /////////////////// IMDB /////////////////////
- $movieName = preg_replace('/[ ]/','+',$movieName);
- $uri = "http://worldweatheronline.com/feed/weather.ashx?q=schruns,austria&format=json&num_of_days=5&key=8f2d1ea151085304102710";
- //echo "URI: [$uri] <br/>";
- header('Content-Type: application/json');
- $file = file_get_contents($uri);
- $error = error_get_last();
- echo $error['message'];
- echo $file;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement