예제 #1
0
파일: picture.php 프로젝트: shifter/ospap2
 /* Mark this picture as viewed. */
 $objPicture->setViewed($objUser);
 $objPictureTemplate = new clsTemplate('picture');
 if ($objPrevPicture) {
     $objPictureTemplate->setText('PREV', "<a href='index.php?action=picture&" . $objPrevPicture->getIDPair() . "'>Previous<br>" . $objPrevPicture->getHtmlThumbnail(64, 64) . "</a>");
 } else {
     $objPictureTemplate->setText('PREV', "<span class='disabled'>At the start</span>");
 }
 if ($objNextPicture) {
     $objPictureTemplate->setText('NEXT', "<a href='index.php?action=picture&" . $objNextPicture->getIDPair() . "'>Next<br>" . $objNextPicture->getHtmlThumbnail(64, 64) . "</a>");
 } else {
     $objPictureTemplate->setText('NEXT', "<span class='disabled'>At the end</span>");
 }
 $objPictureTemplate->setText('TITLE', $objPicture->get('title'));
 $objPictureTemplate->setText('USERNAME', $objPicture->getUsername());
 $objPictureTemplate->setText('PICTURE', $objPicture->getHtml());
 $objPictureTemplate->setText('CAPTION', "<span id='more' style='display: none;'>" . bbcode_format($objPicture->get('caption')) . "<br><a href='#' onClick='\$(\"more\").style.display=\"none\"; \$(\"less\").style.display=\"block\"'>Less</a></span>");
 $objPictureTemplate->setText('CAPTION', "<span id='less' style='display: inline;'>" . cut_text(bbcode_format($objPicture->get('caption')), MAX_CAPTION, "<br><a href='#' onClick='\$(\"less\").style.display=\"none\"; \$(\"more\").style.display=\"block\"'>More</a></span>"));
 $strCaption = cut_text(bbcode_format($objPicture->get('caption')), MAX_CAPTION, " (<a href='index.php?action=picture&all=1&" . $objPicture->getIDPair() . "'>more</a>)");
 /* Voting code. */
 if (clsVote::canVote($objPicture, $objUser, $_SERVER['REMOTE_ADDR'])) {
     $objPictureTemplate->setText('RATING', clsVote::getVoteField($objPicture));
 } else {
     if (clsVote::getVoteCount($objPicture)) {
         $objPictureTemplate->setText('RATING', "Ranked <span class='rating'>" . clsVote::getRating($objPicture) . "</span> / " . clsVote::getMaxRating() . " (" . clsVote::getVoteCount($objPicture) . " votes)");
     }
 }
 /* Commenting code. */
 $arrComments = $objPicture->getComments();
 foreach ($arrComments as $objComment) {
     $objComment = new clsComment($objComment->get('id'));
예제 #2
0
파일: rss.php 프로젝트: shifter/ospap2
    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";
    print "</rss>\n";
} catch (Exception $e) {
    $_SESSION['e'] = $e;
    header("Location: index.php?action=exception&message=" . $e->getMessage());
}