Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $link = "http://mosaica.ru/poll/foto/32077"; // Ссылка на страницу с голосованием
- header("Content-Type: text/html; charset=utf-8");
- require_once "phpQuery.php";
- $load_page = file_get_contents($link);
- $document = phpQuery::newDocument(substr($load_page, strpos($load_page, '<fieldset class="form-wrapper" id="edit-foto">'), strpos($load_page, '<div id="competition-general-rules">') - strpos($load_page, '<fieldset class="form-wrapper" id="edit-foto">') - 21));
- $photos = $document->find(".fieldset-wrapper > fieldset");
- $title = "Мой любимый горячий напиток!";
- $list_link = Array();
- $list_people = Array();
- $list_rating = Array();
- $list_preview = Array();
- foreach ($photos as $photo) {
- $rate = substr(pq($photo)->find(".image_info .counter")->text(), 16);
- $list_rating[] = str_pad(substr(pq($photo)->find(".image_info .counter")->text(), 16), 4, "0", STR_PAD_LEFT);
- $list_link[] = pq($photo)->find(".image_preview > a")->attr("href");
- $list_preview[] = pq($photo)->find(".image_preview > a > img")->attr("src");
- $list_people[] = pq($photo)->find(".image_info .title")->text();
- }
- array_multisort($list_rating, SORT_DESC, SORT_NUMERIC, $list_people, $list_link, $list_preview);
- for($i = 0; $i < count($list_rating); $i++) {
- $content .= "<div class=\"item\"><div class=\"pull-right\"><code>" .($i + 1) . "</code></div><img class=\"img-polaroid\" src=\"" . $list_preview[$i] . "\" width=\"200\" align=\"center\" style=\"margin:5px 40px 5px 5px\" /><span style=\"font-size:16px;font-weight:bold\">" . $list_people[$i] . "</span> (<strong>" . intval($list_rating[$i]) . "</strong>)\n<div style=\"margin:-30px 0 0\" class=\"pull-right\"><a href=\"" . $list_link[$i] . "\" target=\"_blank\">Посмотреть полную фотографию</a></div></div><div style=\"clear:both\"></div>\n";
- }
- $in = Array("{CONTENT}", "{PEOPLE}", "{TITLE}");
- $out = Array("$content", count($list_rating), "$title");
- $template = file_get_contents("index.tpl");
- $template = str_replace($in, $out, $template);
- echo $template;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement