cLogin.php:
Requirements: PHP5 & You must be using your own domain name with zenfolio.
Replace ZENFOLIOURL with your Zenfolio URL
Replace YOURDOMAIN with your Web site Domain
*This script is incomplete, but still functional.
function callback($argument){
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $argument);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$site = curl_exec($ch);
curl_close($ch);
return $site;
}
function getRealm($photosetID, $passWord){
$argument = "http://www.zenfolio.com/api/1.2/zfapi.asmx/LoadPhotoSet?photosetId=$photosetID";
$dsp = callback($argument);
$xml = simplexml_load_string($dsp);
$realmid = $xml->TitlePhoto->AccessDescriptor->RealmId;
$argument = "http://www.zenfolio.com/api/1.2/zfapi.asmx/KeyringAddKeyPlain?keyring=&realmId=$realmid&password=$passWord";
$dsp = callback($argument);
$xml = simplexml_load_string($dsp);
if(!$xml->faultcode):
$finalkey = $xml[0];
setrawcookie("zf_keyring", urldecode($finalkey), time()+3600, "/", "YOURDOMAIN", 0);
header("Location: http://YOURZENFOLIOURL/p".$photosetID);
else:
echo "NAY";
endif;
}
if(isset($_POST['submit']) && isset($_POST['gcode']) && isset($_POST['password']) && isset($_POST['private'])):
if(preg_match('/^p\d+$/', $_POST['gcode']) && preg_match('/^[A-Za-z0-9]+$/', $_POST['password'])):
$photosetID = str_replace("p", "", $_POST['gcode']);
getRealm($photosetID, $_POST['password']);
else:
return false;
endif;
endif;
HTML FORM:
<p style="width:236px; margin:16px 0px 0px 20px; font-weight:bold;">To view your album enter your gallery number and passcode.</p>
<form style="width:236px; margin:16px 0px 0px 20px;" method="post" action="/classes/cLogin.php">
<p><label style="float:left; width:70px; margin-right:6px; font-size:12px">Gallery #:</label><input style="background:#226286; color:#FFF; border:solid 1px #1a5576;" mce_style="background:#226286; color:#FFF; border:solid 1px #1a5576;" type="text" name="gcode" id="gcode" /></p>
<p><label style="float:left; width:70px; margin-right:6px; font-size:12px">Passcode:</label><input style="background:#226286; color:#FFF; border:solid 1px #1a5576;" mce_style="background:#226286; color:#FFF; border:solid 1px #1a5576;" type="password" name="password" id="password" /></p>
<p style="visibility:hidden;" mce_style="visibility:hidden;"><input type="hidden" name="private" id="private" value="true" /></p>
<p><input type="image" src="../images/loginbtn.png" mce_src="/forums/images/loginbtn.png" name="submit" id="submit" value="Login" style="margin:10px 0px 0px 0px; border:0;" mce_style="margin:10px 0px 0px 0px; border:0;" border="0" /></p>
</form>