auth("write"); } else { if (isset($_GET['frob'])) { $auth_token = $f->auth_getToken($_GET['frob']); $_SESSION['phpFlickr_auth_token'] = $auth_token; } $f->setToken($_SESSION['phpFlickr_auth_token']); echo "Authentication with Flickr successful.

"; } flush(); echo "Processing Album Data...

"; flush(); $albumdata = unserialize(file_get_contents($pathtoalbumdb . "albumdb.dat")); // this part appears to list the albums if ( ($_GET['gallery'] == "" ) || ($_GET['i'] == "") ) { if ($_GET['gallery'] == "" ) { } if (($_SESSION[$k.'count'] > 0) || ($_SESSION[$k.'notallowed'] > 0) || ($_SESSION[$k.'exists'] > 0)) { echo "Total Images uploaded: " . $_SESSION[$k.'count'] . "
"; echo "Total Unsupported Files skipped: " . $_SESSION[$k.'notallowed'] . "
"; echo "Total pre-existing skipped: " . $_SESSION[$k.'exists'] . "
"; } $_SESSION[$k.'count'] = 0; $_SESSION[$k.'notallowed'] = 0; $_SESSION[$k.'exists'] = 0; for($k = 0; $k < count($albumdata); $k++) { if (($albumdata[$k] != "PEAR") && ($albumdata[$k] != "phpFlickr")) { //an ugly hack, but gallery can end up adding the PEAR directory to the database, so skip over it if it's there. echo "To transfer " . $albumdata[$k] . ", click here
"; flush(); } } } // this part appears to do the photo uploading. else { //Does a photoset for this album already exist? //It might do. Let's check //but not every time... if ( $_GET['setid'] != "" ) { $setpresent = true; } else { $setpresent = false; //Could still exist, but we'd be resuming $sets = $f->photosets_getList(); for ($n = 0; $n < count($sets); $n++) { if ($sets[photoset][$n][title] == $albumdata[$k]) { $setpresent = true; //set the id $setid = $sets[photoset][$n][id]; } //if } // for } // else flush(); $data = file_get_contents("./" . $albumdata[$k] . "/photos.dat"); $data = unserialize($data); echo "There are " . count($data) . " items found in this album.
"; for ($j = 0; $j < 4000; $j++) echo $j; flush(); // loops through the images for ($i = 0; $i < count($data); $i++) { flush(); //Image name $name = $data[$i]->image->name; //Image type $type = $data[$i]->image->type; //Description $description = $data[$i]->caption; //Tags $tags = str_replace(" ", ",", $data[$i]->keywords); $comment = ""; for($j = 0; $j < count($data[$i]->comments); $j++) { $comment .= "\n\n".$data[$i]->comments[$j]->name. " said: " . $data[$i]->comments[$j]->commentText; } //Add to description of photo $description .= $comment; //Does the photo exist in the photoset (if the photoset exists)? $photoexists = false; if ($setid != "") { $photos = $f->photosets_getPhotos($setid); for ($p = 0; $p < count($photos[photo]); $p++) { if ($photos[photo][$p][title] == $name) { $photoexists = true; } // if }//for }//if //Check good file extension $good = false; for ($m = 0; $m < count($allowed); $m++) { if ($allowed[$m] == $type) { $good = true; }//if }//for flush(); // echo "Total Images uploaded: " . $_SESSION[$k.'count'] . "
"; // echo "Total Unsupported Files skipped: " . $_SESSION[$k.'notallowed'] . "
"; // echo "Total pre-existing skipped: " . $_SESSION[$k.'exists'] . "
"; if ( $good && !$photoexists ) { //i.e. if the file has a valid extension and isn't already in the set... echo "
"; echo ""; echo ""; echo ($i+1).": Uploading the image titled '". $name . "' with a description '". $description ."' and tags '".$tags."'
"; // Generate extra bytes of data to force a flush. echo ""; flush(); $photoid = $f->sync_upload("./" . $albumdata[$k] . "/" . $name . "." . $type, $name, $description, $tags, $public, $friends, $family); $_SESSION[$k.'count'] += 1; // *** // *** this appears to reset phpFlickr somehow, perhaps it's because this // *** is missing some sort of call to finish the upload? don't know. // *** -eric // *** //Not sure why the 'refresh' below is necessary. //Without it, when calling either of the functions below I get a "#112 Method not found" error. $f->phpFlickr($api_key, $secret, false); if ($setid == "") { //create set with photo as Primary photo echo "Creating new set: \'" . $albumdata[$k] . "\'
"; flush(); $setid = $f->photosets_create($albumdata[$k], "", $photoid); $setid = $setid[id]; } else { //add photo to set echo "Adding photo to set.
"; flush(); $r = $f->photosets_addPhoto($setid, $photoid); if (!$r) { echo "
Error adding photo (Set ID: $setid Photo ID: $photoid)
Trying again...
"; flush(); $r = $f->photosets_addPhoto($setid, $photoid); if (!$r) { die("
Error adding photo (Set ID: $setid Photo ID: $photoid)
"); flush(); } } } //Now make the date on the photo correct, if the data is in the photos.dat file //If there is a year set, assume that the data in this file is true if ($data[$i]->itemCaptureDate[year] != "" && $useExif == false ) { //construct the date line according to the MYSQL format $date = $data[$i]->itemCaptureDate[year] . "-" . $data[$i]->itemCaptureDate[mon] . "-" . $data[$i]->itemCaptureDate[mday] . " " . $data[$i]->itemCaptureDate[hours] . ":" . $data[$i]->itemCaptureDate[minutes] . ":" . $data[$i]->itemCaptureDate[seconds]; //Set it - again needs the refresh... $f->phpFlickr($api_key, $secret, false); $f->photos_setDates($photoid, $date ); }//if }//if else { if (!$good) { $_SESSION[$k.'notallowed'] += 1; echo "The file " . $name . "." . $type . " wasn't uploaded, because it is of a type Flickr won't allow."; }//if if ($photoexists) { $_SESSION[$k.'exists'] += 1; echo "The file " . $name . "." . $type . " wasn't uploaded, because it appears to already be in the photoset."; }//if }//else echo "
"; flush(); // Generate extra bytes of data to force a flush. echo ""; flush(); }// for if (($_SESSION[$k.'count'] > 0) || ($_SESSION[$k.'notallowed'] > 0) || ($_SESSION[$k.'exists'] > 0)) { echo "Total Images uploaded: " . $_SESSION[$k.'count'] . "
"; echo "Total Unsupported Files skipped: " . $_SESSION[$k.'notallowed'] . "
"; echo "Total pre-existing skipped: " . $_SESSION[$k.'exists'] . "
"; } $_SESSION[$k.'count'] = 0; $_SESSION[$k.'notallowed'] = 0; $_SESSION[$k.'exists'] = 0; echo '

Return to List

'; } ?>