public static function recordVote($objPicture, $objUser, $strIP, $intVote) { /* TODO: Uncomment this. */ // if(clsVote::canVote($objPicture, $objUser, $strIP)) // throw new Exception('exception_internalerror'); if (!is_numeric($intVote)) { throw new Exception('exception_internalerror'); } if ($intVote < 0 || $intVote > MAX_VOTE) { throw new Exception('exception_internalerror'); } $objVote = new clsVote(); $objVote->set('picture_id', $objPicture->get('id')); $objVote->set('user_id', $objUser ? $objUser->get('id') : 0); $objVote->set('ip', $strIP); $objVote->set('vote', $intVote); $objVote->save(); }
if ($strSubAction == 'save') { if (!$objPicture->canEdit($objUser)) { throw new Exception('exception_accessdenied'); } $objPicture->getFromRequest(array('id', 'title', 'caption', 'confirmed')); $objPicture->save(); header("Location: index.php?action=picture&" . $objPicture->getIDPair()); } if ($strSubAction == 'vote') { if (!$objAlbum->canRate($objUser)) { throw new Exception('exception_accessdenied'); } if (!clsVote::canVote($objPicture, $objUser, $_SERVER['REMOTE_ADDR'])) { throw new Exception('exception_accessdenied'); } clsVote::recordVote($objPicture, $objUser, $_SERVER['REMOTE_ADDR'], $_REQUEST['vote']); header("Location: index.php?action=picture&" . $objPicture->getIDPair()); } if ($strSubAction == 'link') { $objTemplate->setText('PAGETITLE', "Linking to " . $objPicture->get('title')); /* Get the script path */ $strBasePath = htmlentities("http://" . $_SERVER['HTTP_HOST'] . preg_replace("/\\/[a-zA-Z0-9._]*\$/", "", $_SERVER['PHP_SELF']) . "/"); $strPicturePath = $strBasePath . "picture.php?" . $objPicture->getIDPair(); $strPicturePath2 = $strBasePath . "pictures/" . $objPicture->get('id') . ".jpg"; $strThumbnailPath = $strBasePath . "thumbnails/"; $strPagePath = $strBasePath . "index.php?action=picture&" . $objPicture->getIDPair(); print "<h5>HTML to embed this image</h5>"; print "<pre>"; print "<img src='{$strPicturePath2}'>"; print "</pre>"; print "or";