session_start();
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
* To make this work, you must first go create an API key under Flickr
* Services. This should be the URL:
* http://www.flickr.com/services/api/
*
* Once the API key is created, you have to edit the configuration.
* You can do this by listing your registered keys:
* http://www.flickr.com/services/api/registered_keys.gne
*
* Set the Application Title to: Gallery2Flickr
* Set the Callback URL to:
* http://www.yourdomain.com/path/to/gallery/albums/go.php
*
* Take the API Key and the Shared Secret provided and enter them below:
*/
//These are the variables you have to set
$api_key = "";
$secret = "";
//Do you want to let flickr handle the EXIF data in the file, or use the date taken stored by Gallery?
//No other data is taken from Gallery - only date taken, so all other EXIF data will be handled by flickr, if present
//Default lets flickr handle it
$useExif = true;
//How do you want to upload your photos? 1 is visible to that category, 0 is hidden to that category
//To upload privately, set all of these to 0
$public = "1";
$friends = "1";
$family = "1";
//Allowed extensions
$allowed_ext = "jpg, JPG, jpeg, JPEG, gif, GIF, png, PNG";
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Put the allowed extentions into an array
$allowed = explode(', ', $allowed_ext);
$k = $_GET['gallery'];
//$i = $_GET['i'];
$setid = $_GET['setid'];
if (!isset($_SESSION[$k.'count']))
{
$_SESSION[$k.'count'] = 0;
}
if (!isset($_SESSION[$k.'notallowed']))
{
$_SESSION[$k.'notallowed'] = 0;
}
if (!isset($_SESSION[$k.'exists']))
{
$_SESSION[$k.'exists'] = 0;
}
class AlbumItem {}
class Image {}
class Album {}
class Comment {}
require_once("phpFlickr.php");
$f = new phpFlickr($api_key, $secret, false);
if (!isset($_SESSION['phpFlickr_auth_token']) && !isset($_GET['frob']))
{
$f->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 "