$fileName = upload($source); echo $fileName . "<br/>"; echo $source . "<br/>"; if ($fileName != null) { $db = new MongoHQ(array('collectionName' => 'watched')); $csv = new parseCSV($fileName); $csv->auto(); $data = $csv->data; //print_r($data); if ($source == "imdb") { $movies = IMDB::buildMovies($data); var_dump(Movie::toMoviesDB($movies)); $db->saveMany(Movie::toMoviesDB($movies)); } else { if ($source == "google") { $hashMap = buildHash($data); $db_movies = $db->find(); $mismatched = array(); foreach (Movie::toMovies($db_movies) as $movie) { $title = $movie->TITLE; //echo "<br/><div>[" . $$movie->POSITION . "] processing movie title: " . $title . " [db/rotten]</div>"; if (isset($hashMap[hkey($title)])) { $rating = intval($hashMap[hkey($title)]['Rate']); $movie->RATING = $rating; //echo "<div>" . $movie->RATING . "</div>"; $db->save($movie->get()); } else { $mismatched[] = $title; } } foreach ($mismatched as $title) {
} if ($ver != "") { $where .= $where != "" ? " AND " : ""; $where .= "ver='" . $ver . "'"; } if ($count != "") { $limit = " LIMIT 0," . $count; } if ($where != "") { $sql .= " WHERE " . $where; } $sql .= " ORDER BY ver" . $sort . $limit; $res = $db_access->query($sql); $content = "<h1 class='center_simply'>Downloads</h1>\n<table>\n<tr><th>File</th><th>Arch</th><th>Version</th><th>Date</th><th>md5</th><th>Downloads</th></tr>\n"; while (($entry = $db_access->fetch_array($res)) !== false) { $content .= "<tr>" . "<td><a href='" . $link . "dwnld&id=" . $entry['id'] . "&hash=" . buildHash("dwnld", $entry['id']) . "' title='" . $entry['name'] . "'>" . $entry['descr'] . "</a></td>" . "<td>" . archImg($entry['arch']) . "</td>" . "<td>" . $entry['ver'] . "</td>" . "<td>" . $entry['date'] . "</td>" . "<td>" . $entry['checksum'] . "</td>" . "<td>" . $entry['downloads'] . "</td>" . "</tr>\n"; } $content .= "</table>"; } } if ($content == "") { // nothing to tell ... die; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>Downloads</title>