Mostra paginaRevisioni precedentiPuntano quiTorna su Questa pagina è in sola lettura. Puoi visualizzare il sorgente, ma non puoi modificarlo. Contatta l'amministratore se pensi che ci sia un errore. **Foto casuale** <php> include "/home/dneroni/carrimerci.it/cpmfetch/cpmfetch.php"; $objCpm1 = new cpm("/home/dneroni/carrimerci.it/cpmfetch/cpmfetch_config.php"); $options=array(windowtarget => “_blank” , 'imagewidth' => '150'); $objCpm1->cpm_viewRandomMedia(1,1,$options); </php> {{stars>1/5}} {{stars>-1/5}} {{stars>2}} <php> $base_url = "http://gallery.carrimerci.it/random/piwigo-random-backend.php"; echo file_get_contents($base_url . "?mode=html&cat_id=119"); </php> ~~NOCACHE~~ <html> <h1>Random image, no style</h1> <p>This <span id="random_image"> <script type="text/javascript" src="//gallery.carrimerci.it/random/piwigo-random-backend.php?element_name=cat&cat_id=8" async> </script> </span> is a random image</p> <h1>Specifying a category</h1> <div id="cat"> <script type="text/javascript" src="//gallery.carrimerci.it/random/piwigo-random-backend.php?element_name=cat&maximages=3&cat_id=8&" async> </script> </div> <h1>Several images at a time</h1> <div id="several"> <script type="text/javascript" src="//gallery.carrimerci.it/random/piwigo-random-backend.php?element_name=several&cat_id=8" async> </script> </div> <h1>Styling the images</h1> <div id="styled_random_image"> <style type="text/css" scoped> #styled_random_image img {border: solid 1px grey; padding:5px; margin:5px;} #styled_random_image img:hover {opacity: .8} #styled_random_image {text-align:right; display: inline; background-color: white;} @media all and (max-device-width: 599px), all and (max-width: 599px) { #styled_random_image {display: none} } </style> <script type="text/javascript" src="//gallery.carrimerci.it/random/piwigo-random-backend.php?element_name=styled_random_image&cat_id=8" async> </script> </div> </html> ---- <php> $cat_id = 119; $per_page = 2; $webapi1 = "http://gallery.carrimerci.it/ws.php?format=rest&method=pwg.categories.getImages&cat_id=$cat_id&per_page=$per_page" ; $strXml1 = file_get_contents($webapi1); $objXml1 = new SimpleXmlElement($strXml1); $piwigo = array(); $counter = 1; foreach($objXml1->images->image as $value) { $thumbs_string = strval($value->derivatives->square->url); $url_string = strval($value->categories->category->attributes()->page_url); $data_available = strval($value->categories->category->attributes()->page_url); //modify $piwigo[$counter]['thumb'] = $thumbs_string; $piwigo[$counter]['url'] = $url_string; $counter++; } foreach($piwigo as $value) { echo ' <a target="_blank" href="' . $value["url"] . '">' . '<img src="' . $value["thumb"] . '"></a>' . PHP_EOL; } ?> <hr> <p>DEMO OF THE WORKAROUD SOLUTION </p> <?php //we need to calculate the total number of pictures in the gallery $cat_id = "8"; $per_page = "10"; //number of latest pictures you want to show $webapi2 = "http://gallery.carrimerci.it/ws.php?format=rest&method=pwg.categories.getList&cat_id=&public=true"; $strXml2 = file_get_contents($webapi2); $objXml2 = new SimpleXmlElement($strXml2); $count_images = 0; foreach($objXml2->categories->category as $value) { $count_images += $value->attributes()->total_nb_images; } echo '<p>Calculated total images: ' . $count_images . ' => Calculated number of pages: ' . intval($count_images/$per_page) . '</p>'; //start parsing the web api output with the workaround logic $per_page1 = $per_page * 2; //we need to retrive double number of specified pages because $count_images/$per_page is float number. we will slice it at the end $pages1 = intval($count_images/$per_page1); // $webapi3 = "http://gallery.carrimerci.it/ws.php?format=rest&method=pwg.categories.getImages&order=date_available&per_page=" . $per_page1 . "&page=" . $pages1; echo '<p>The calculated Web Api request is: <strong>' . $webapi3 . '</strong></p>'; $strXml3 = file_get_contents($webapi3); $objXml3 = new SimpleXmlElement($strXml3); $piwigo2 = array(); $counter2 = 1; foreach($objXml3->images->image as $value) { $thumbs_string = strval($value->derivatives->square->url); $url_string = strval($value->categories->category->attributes()->page_url); $piwigo2[$counter2]['thumb'] = $thumbs_string; $piwigo2[$counter2]['url'] = $url_string; $counter2++; } $piwigo2 = array_reverse($piwigo2); $piwigo2 = array_slice($piwigo2, 0, $per_page); foreach($piwigo2 as $value) { echo ' <a target="_blank" href="' . $value["url"] . '">' . '<img src="' . $value["thumb"] . '"></a>' . PHP_EOL; } </php> Ultima modifica: 2021/05/14 21:31