예제 #1
0
파일: comment.php 프로젝트: shifter/ospap2
<?php

require_once 'cls/clsAlbum.php';
require_once 'cls/clsComment.php';
require_once 'cls/clsPicture.php';
$objComment = new clsComment();
$objComment->getFromRequest();
$objComment->load();
$objPicture = new clsPicture();
$objPicture->getFromRequest();
$objPicture->load();
$objAlbum = new clsAlbum($objPicture->get('album_id'));
if ($strSubAction == 'edit') {
    if ($objComment->isNew() && !$objAlbum->canPostComment($objUser)) {
        throw new Exception('exception_accessdenied');
    }
    if (!$objComment->canEdit($objUser)) {
        throw new Exception('exception_accessdenied');
    }
    $objAlbum->addBreadcrumbs($objBreadcrumbs);
    $objBreadcrumbs->add($objPicture->get('name'), 'index.php?action=picture&' . $objPicture->getIDPair());
    $objBreadcrumbs->add('Post comment', 'comment.php?action=edit&' . $objPicture->getIDPair() . '&' . $objComment->getIDPair());
    $objCommentTemplate = new clsTemplate('editcomment');
    $objCommentTemplate->setText('HIDDEN', $objComment->getHiddenField('id'));
    $objCommentTemplate->setText('HIDDEN', $objPicture->getHiddenField('id'));
    $objCommentTemplate->setText('HIDDEN', "<input type='hidden' name='action' value='comment'>");
    $objCommentTemplate->setText('HIDDEN', "<input type='hidden' name='subaction' value='save'>");
    if ($objUser) {
        $objCommentTemplate->setText('NAME', '<strong>' . $objUser->get('username') . '</strong>');
    } else {
        $objCommentTemplate->setText('NAME', $objComment->getTextField('username'));
예제 #2
0
<?php

require_once 'cls/clsAlbum.php';
require_once 'cls/clsPicture.php';
print "<span class='recentheader'>New Pictures</span>";
$arrPictures = clsPicture::getRecentPictures($objUser, 5);
foreach ($arrPictures as $objPicture) {
    $objPicture = new clsPicture($objPicture->get('id'));
    $objAlbum = new clsAlbum($objPicture->get('album_id'));
    print "<p>";
    print $objPicture->getHtmlThumbnail(100, 100) . "<br>";
    print "<a href='index.php?action=picture&" . $objPicture->getIDPair() . "' class='recentlink'>" . $objPicture->get('title') . "</a> <span class='recentdate'>in</span> <a href='index.php?action=albums&" . $objAlbum->getIDPair() . "' class='recentlink'>" . $objAlbum->get('name') . "</a><br>";
    print "<span class='recentdate'>" . $objPicture->getUsername() . "<br>";
    print time_to_text(strtotime($objPicture->get('date'))) . "</span>";
    print "</p>";
}
예제 #3
0
파일: picture.php 프로젝트: shifter/ospap2
require_once 'include/messages.php';
session_start();
clsSetting::load_settings();
try {
    if (!isset($_SESSION['objUser'])) {
        $objUser = clsUser::getCookie();
    } else {
        $objUser = $_SESSION['objUser'];
    }
    $objPicture = new clsPicture();
    $objPicture->getFromRequest(array('id'));
    $objPicture->load();
    if ($objPicture->isnew()) {
        throw new Exception('exception_invalidrequest');
    }
    $objAlbum = new clsAlbum($objPicture->get('album_id'));
    if (!$objAlbum->canView($objUser)) {
        throw new Exception('exception_invalidrequest');
    }
    if (isset($_REQUEST['tn']) || isset($_REQUEST['action']) && $_REQUEST['action'] == 'tn') {
        $intWidth = isset($_REQUEST['w']) ? $_REQUEST['w'] : -1;
        $intHeight = isset($_REQUEST['h']) ? $_REQUEST['h'] : -1;
        if (!is_numeric($intWidth) || $intWidth < 0 || $intWidth > MAX_X) {
            throw new Exception('exception_invalidrequest');
        }
        if (!is_numeric($intHeight) || $intHeight < 0 || $intHeight > MAX_Y) {
            throw new Exception('exception_invalidrequest');
        }
        $objThumbnail = clsThumbnail::getThumbnail($objUser, $objPicture->get('id'), $intWidth, $intHeight, $objAlbum);
        if (is_string($objThumbnail)) {
            throw new Exception($objThumbnail);
예제 #4
0
파일: picture.php 프로젝트: shifter/ospap2
require_once 'cls/clsParameters.php';
require_once 'cls/clsPicture.php';
require_once 'cls/clsTemplate.php';
require_once 'cls/clsThumbnail.php';
require_once 'cls/clsUser.php';
require_once 'cls/clsVote.php';
$objBreadcrumbs->add('Albums', 'index.php?action=albums');
$objPicture = new clsPicture();
$objPicture->getFromRequest();
$objPicture->load();
$objPrevPicture = $objPicture->getPrev();
$objNextPicture = $objPicture->getNext();
if ($objPicture->isNew()) {
    throw new Exception('exception_invalidrequest');
}
if (!$objPicture->get('confirmed')) {
    header("Location: index.php?action=upload&subaction=preview");
    die;
}
/* Check for access. */
$objAlbum = new clsAlbum($objPicture->get('album_id'));
if (!$objAlbum->canView($objUser)) {
    throw new Exception('exception_accessdenied');
}
$objAlbum->addBreadcrumbs($objBreadcrumbs);
//		$strMiniMenu = "<li><a href='index.php?action=picture&subaction=edit&" . $objPicture->getIDPair() . "'>Create Album</a></li>";
//		$objTemplate->setText('MINIMENU', "<ul>$strMiniMenu</ul>");
if ($strSubAction == '') {
    $objTemplate->setText('PAGETITLE', "Viewing " . $objPicture->get('title'));
    $objBreadcrumbs->add($objPicture->get('title'), "index.php?action=picture&" . $objPicture->getIDPair());
    if ($objPicture->canEdit($objUser)) {
예제 #5
0
파일: rss.php 프로젝트: shifter/ospap2
require_once 'cls/clsSetting.php';
require_once 'cls/clsUser.php';
session_start();
clsSetting::load_settings();
try {
    if (!isset($_SESSION['objUser'])) {
        $objUser = clsUser::getCookie();
    } else {
        $objUser = $_SESSION['objUser'];
    }
    header("Content-type: application/xhtml+xml");
    $arrPictures = clsPicture::getRecentPictures($objUser, 10);
    $url = "http://" . $_SERVER['HTTP_HOST'] . "/" . preg_replace("/\\/[a-zA-Z0-9.]*\$/", "/index.php", $_SERVER['PHP_SELF']);
    print "<?xml version='1.0' encoding='UTF-8'?>\n<!-- generator='OSPAP2' -->\n<rss version='2.0'\n\txmlns:content='http://purl.org/rss/1.0/modules/content/'\n\txmlns:wfw='http://wellformedweb.org/CommentAPI/'\n\txmlns:dc='http://purl.org/dc/elements/1.1/'\n\t>\n\n<channel>\n\t<title>" . SITE_NAME . "</title>\n\t<link>{$url}</link>\n\t<description>" . SITE_DESCRIPTION . "</description>\n\t<generator>http://www.javaop.com/~ron/ospap2</generator>\n\t<language>en</language>\n";
    foreach ($arrPictures as $objPicture) {
        $objPicture = new clsPicture($objPicture->get('id'));
        $link = "http://" . $_SERVER['HTTP_HOST'] . "/" . preg_replace("/\\/[a-zA-Z0-9.]*\$/", "/index.php?action=picture&amp;" . $objPicture->getIDPair(), $_SERVER['PHP_SELF']);
        print "\t<item>\n";
        print "\t\t<title>" . $objPicture->get('title') . "</title>\n";
        print "\t\t<link>{$link}</link>\n";
        print "\t\t<comments>{$link}</comments>\n";
        print "\t\t<pubDate>" . date("D M j Y G:i:s T", strtotime($objPicture->get('date'))) . "</pubDate>\n";
        print "\t\t<dc:creator>" . $objPicture->getFrom('user', 'username') . "</dc:creator>\n";
        print "\t\t<category><![CDATA[" . $objPicture->getFrom('album', 'name') . "]]></category>\n";
        print "\t\t<guid isPermaLink=\"true\">{$link}</guid>\n";
        print "\t\t<description><![CDATA[" . cut_text($objPicture->get('caption'), 200) . "<br><br>" . $objPicture->getHtmlThumbnail(150, 150) . "]]></description>\n";
        print "\t\t<content:encoded><![CDATA[" . $objPicture->get('caption') . "<br><br>" . $objPicture->getHtml() . "]]></content:encoded>\n";
        print "\t\t<wfw:commentRss>" . $_SERVER['PHP_SELF'] . "</wfw:commentRss>\n";
        print "\t</item>\n";
    }
    print "</channel>\n";
예제 #6
0
파일: clsAlbum.php 프로젝트: shifter/ospap2
 public static function markSeen($objUser, $objAlbum = null)
 {
     if (!$objAlbum || $objAlbum->isNew()) {
         $arrPictures = clsDB::getListStatic('picture');
     } else {
         $arrPictures = $objAlbum->getForeignObjects('picture');
     }
     foreach ($arrPictures as $objPicture) {
         $objPicture = new clsPicture($objPicture->get('id'));
         $objPicture->setViewed($objUser);
     }
 }
예제 #7
0
파일: upload.php 프로젝트: shifter/ospap2
    if ($objPicture->get('user_id') != $user_id) {
        throw new Exception('exception_accessdenied');
    }
    /* Make sure that users can only edit their own pictures. */
    $objPicture->delete();
    $objPicture->save();
    header("Location: index.php?action=upload&subaction=preview");
}
if ($strSubAction == 'preview') {
    $objTemplate->setText('PAGETITLE', "Pending Pictures");
    $objBreadcrumbs->add('Upload', 'index.php?action=upload');
    $objBreadcrumbs->add('Pending', 'index.php?action=upload&subaction=preview');
    $arrPictures = clsPicture::getPending($objUser);
    print "You have <strong>" . sizeof($arrPictures) . "</strong> pictures waiting for attention" . ($objUser ? "" : " (note: unsaved images from all guests will appear here)") . ":<br><br>";
    foreach ($arrPictures as $objPicture) {
        $objPicture = new clsPicture($objPicture->get('id'));
        $objAlbum = new clsAlbum($objPicture->get('album_id'));
        $objTemplate = new clsTemplate('preview');
        $objTemplate->setText('HIDDEN', $objPicture->getHiddenField('id'));
        $objTemplate->setText('ALBUM', $objPicture->getCombo('album_id', clsDB::getOptionsFromList($objAlbum->getPostableAlbums($objUser), 'name', 'id', "Select an album")));
        $objTemplate->setText('ID', $objPicture->get('id'));
        $objTemplate->setText('IMAGE', $objPicture->getHtmlThumbnail(250, 250));
        /* TODO: Customizable? */
        $objTemplate->setText('NAME', $objPicture->get('original_name'));
        $objTemplate->setText('WIDTH', $objPicture->get('width'));
        $objTemplate->setText('HEIGHT', $objPicture->get('height'));
        $objTemplate->setText('SAVEDELETE', $objPicture->getCombo('subaction', array('confirm' => 'Keep', 'delete' => 'Don\'t keep'), null, true));
        $objTemplate->setText('TITLE', $objPicture->getTextField('title'));
        $objTemplate->setText('CAPTION', $objPicture->getTextArea('caption'));
        $objTemplate->setText('SUBMIT', $objPicture->getSubmit('Save'));
        print $objTemplate->get();