Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Protože lenost je taky cesta.
- * User: Thebys
- * Date: 6. 4. 2015
- * Time: 1:50
- * vezme to statickou stránku galerie, vytáhne to všechny obrázky jejichž cesta obsahuje thumb a náhodný to zobrazí s odkazem do galerie...
- * */
- $dom = new DOMDocument;
- $galerie = file_get_contents("obsah/fotogalerie.php");
- $galerie = mb_convert_encoding($galerie, 'HTML-ENTITIES', "UTF-8");
- $dom->loadHTML($galerie);
- $images = $dom->getElementsByTagName('img');
- $thumbs = array();
- $i = 0;
- foreach ($images as $image) {
- if (strpos($image->getAttribute("src"), "thumbs") !== FALSE) {
- $thumbs[$i] = $image->getAttribute("src");
- $i++;
- } else {
- continue;
- }
- }
- $thumbURL = $thumbs[rand(0, (count($thumbs) - 1))];
- echo "<span class=\"boxh\">Náhodný obrázek z galerie</span>";
- echo "<div class=\"nahodnyObrazek\">";
- echo "<a href=\"index.php?s=obsah/fotogalerie\"><img src=\"$thumbURL\"></a>";
- echo "</div>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement