Pastoid

Limiting Interesting Photos by License.

The page you are looking at now is at this URL: http://pastoid.com/ao7

This paste was last updated on February 23, 2009 at 10:05 pm.

Pasted Coderaw

<?php
 
/* poorly documented, CC-usable interesting photo getter. http://mikelietz.org/code/flickr-ccgettr.php */
 
$arrayfile = "flickr-array.txt";
 
require_once("phpflickr/phpFlickr.php");
 
    $f = new phpFlickr( /* put yours here */ );
    $f->enableCache("fs",/* put yours here */);
 
    $thisPhoto = "";
 
    $allPhotos = array();
 
 
    $fh = fopen($arrayfile,'w') or die("Can't open file");
 
    for ($i=1; $i < 8; $i++) { // last seven days
 
        $date = date("Y-m-d",strtotime("-$i days"));
 
        $recent = $f->interestingness_getList($date,array("license,media"),500,1 );
 
            foreach ($recent['photo'] as $photo) {
 
            $license = $photo['license'];
        $media = $photo['media'];
 
 
		/*
		 * Here's the important bit. The modulus (%) 3
		 * gets rid of #3 and #6 - the ones that are no-derivs
		 * according to this list: 
		 * http://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html		
		 */		  	 
 
            if ((($license % 3) != 0) and ($media = 'photo')) 
                {
 
                $thisPhoto =  "<a href='http://flickr.com/photos/{$photo['owner']}/{$photo['id']}/'>";
                $thisPhoto .=     "<img border='0' alt='" . ($photo['title'] != "" ? $photo['title-'] : "(untitled)") .
                    "' src='" . $f->buildPhotoURL($photo,"Square")."'>" . "</a>";
 
            $thisPhoto .= "<a href='http://flickr.com/photo_zoom.gne?id={$photo["id"]}&size=l'>all sizes</a>";
 
            $totalPhotos = array_push ($allPhotos, $thisPhoto);
            fwrite($fh,"$thisPhoto\n");
 
        } // if statement
        } // foreach loop
    } // for loop
 
    fclose($fh);
 
// one random photo
echo $allPhotos[array_rand($allPhotos)];
 
?>

Toggle wordwrap

Referring DomainHits
Unknown Referer 127
pastoid.com 14
mail.google.com 2
74.125.113.132 1
Is this paste spam?
<Hide