curl_setopt($chnl, CURLOPT_CONNECTTIMEOUT, $timeout); $htmlForVotes = curl_exec($chnl); curl_close($chnl); $vote = match('/<span itemprop="ratingCount">(.*)<\\/span>/', $htmlForVotes, 1); return $vote; } // match html from imdb foreach (match_all('/<tr class="(even|odd)">(.*?)<\\/tr>/ms', $html, 2) as $m) { $rank++; $id = match('/<td class="titleColumn">.*?<a href="\\/title\\/(tt\\d+)\\/.*?"/msi', $m, 1); $title = match('/<td class="titleColumn">.*?<a.*?>(.*?)<\\/a>/msi', $m, 1); $year = match('/<td class="titleColumn">.*?<span.*?>\\((.*?)\\)<\\/span>/msi', $m, 1); $rating = match('/<td class="ratingColumn">.*?<strong.*?>(.*?)<\\/strong>/msi', $m, 1); $poster = match('/<td class="posterColumn">.*?<img src="(.*?)"/msi', $m, 1); $votesURL = "http://www.imdb.com/title/" . $id . "/"; $votes = getvotes($votesURL); // create each movie object and set the variables $movie = new Movie(); $movie->setId($id); $movie->setRank($rank); $movie->setTitle($title); $movie->setYear($year); $movie->setRating($rating); $movie->setVotes($votes); // insert $movie objects into an array array_push($top10Movies, $movie); // stop at 10 if ($rank == 10) { break; } }
<?php set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include 'aur.inc'; include 'pkgfuncs.inc'; function getvotes($pkgid) { $dbh = db_connect(); $pkgid = mysql_real_escape_string($pkgid); $result = db_query("SELECT UsersID,Username FROM PackageVotes LEFT JOIN Users on (UsersID = ID) WHERE PackageID = {$pkgid} ORDER BY Username", $dbh); return $result; } $SID = $_COOKIE['AURSID']; $pkgid = $_GET['ID']; $votes = getvotes($pkgid); $account = account_from_sid($SID); if ($account == 'Trusted User' || $account == 'Developer') { ?> <html> <body> <h3><?php echo account_from_sid($SID); ?> </h3> <h2>Votes for <a href="packages.php?ID=<?php echo $pkgid; ?> "><?php echo pkgname_from_id($pkgid); ?> </a></h2>