示例#1
0
 public static function canVote($objPicture, $objUser, $strIP)
 {
     $objAlbum = new clsAlbum($objPicture->get('album_id'));
     if (!$objAlbum->canRate($objUser)) {
         return false;
     }
     if (clsVote::hasVoted($objPicture, $objUser, $strIP)) {
         return false;
     }
     return true;
 }
示例#2
0
    $objEditTemplate->setText('TITLE', $objPicture->getTextField('title'));
    $objEditTemplate->setText('CAPTION', $objPicture->getTextArea('caption', 4, 45));
    $objEditTemplate->setText('CONFIRMED', $objPicture->getCheckNoJavascript('confirmed'));
    $objEditTemplate->setText('SUBMIT', $objPicture->getSubmit('Save'));
    print $objEditTemplate->get();
}
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/";