예제 #1
0
function blocks_big_block($row)
{
    $pntable = pnDBGetTables();
    if (!pnSecAuthAction(0, 'Bigblock::', "{$row['title']}::", ACCESS_READ)) {
        return;
    }
    $today = getdate();
    $day = $today["mday"];
    if ($day < 10) {
        $day = "0{$day}";
    }
    $month = $today["mon"];
    if ($month < 10) {
        $month = "0{$month}";
    }
    $year = $today["year"];
    $tdate = "{$year}-{$month}-{$day}";
    $column =& $pntable['stories_column'];
    $articles = getArticles("{$column['time']} LIKE '%{$tdate}%'\n                             AND {$column['ihome']} = 0\n                             AND {$column['counter']} > 0", "{$column['counter']} DESC", "1");
    if (empty($articles)) {
        return;
    } else {
        $info = genArticleInfo($articles[0]);
        if (pnSecAuthAction(0, 'Stories::Story', "{$info['aid']}:{$info['cattitle']}:{$info['sid']}", ACCESS_READ) && pnSecAuthAction(0, 'Topics::Topic', "{$info['topicname']}::{$info['tid']}", ACCESS_READ)) {
            $links = genArticleLinks($articles[0]);
            $preformat = genArticlePreformat($info, $links);
            $content = '<span class="pn-normal">' . _BIGSTORY . '</span><br /><br />';
            $content .= $preformat['title'];
        } else {
            return;
        }
    }
    if (empty($row['title'])) {
        $row['title'] = _TODAYBIG;
    }
    if (empty($content)) {
        return;
    }
    $row['content'] = $content;
    return themesideblock($row);
}
예제 #2
0
function blocks_past_block($row)
{
    $catid = pnVarCleanFromInput('catid');
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $oldnum = pnConfigGetVar('perpage');
    if (!pnSecAuthAction(0, 'Pastblock::', "{$row['title']}::", ACCESS_READ)) {
        return;
    }
    if (pnUserLoggedIn()) {
        $storyhome = pnUserGetVar('storynum');
    } else {
        $storyhome = pnConfigGetVar('storyhome');
    }
    // Break out options from our content field
    $vars = pnBlockVarsFromContent($row['content']);
    // Defaults
    if (empty($storynum)) {
        $storynum = 10;
    }
    if (empty($vars['limit'])) {
        $vars['limit'] = 10;
    }
    $storynum = $vars['limit'];
    $column =& $pntable['stories_column'];
    if (!isset($catid) || $catid == '') {
        $articles = getArticles("{$column['ihome']}=0", "{$column['time']} DESC", $storynum, $storyhome);
    } else {
        $articles = getArticles("{$column['catid']}={$catid}", "{$column['time']} DESC", $storynum, $storyhome);
    }
    $time2 = "";
    setlocale(LC_TIME, pnConfigGetVar('locale'));
    $boxstuff = "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\" class=\"pn-normal\">\n";
    $vari = 0;
    $see = 0;
    foreach ($articles as $article) {
        $info = genArticleInfo($article);
        $links = genArticleLinks($info);
        $preformat = genArticlePreformat($info, $links);
        // a little bit tricky to remove the bold property from link description
        // (2001-11-15, hdonner)
        $preformat['title'] = str_replace("pn-title", "pn-normal", $preformat['title']);
        if (!pnSecAuthAction(0, 'Stories::Story', "{$info['aid']}:{$info['cattitle']}:{$info['sid']}", ACCESS_READ) || !pnSecAuthAction(0, 'Topics::Topic', "{$info['topicname']}::{$info['tid']}", ACCESS_READ)) {
            continue;
        }
        $see = 1;
        ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $info['time'], $datetime2);
        $datetime2 = ml_ftime("" . _DATESTRING2 . "", mktime($datetime2[4], $datetime2[5], $datetime2[6], $datetime2[2], $datetime2[3], $datetime2[1]));
        $datetime2 = ucfirst($datetime2);
        if ($time2 == $datetime2) {
            $boxstuff .= "<tr><td valign=\"top\"><big><strong>&middot;</strong></big></td>" . "<td valign=\"top\" width=\"100%\"><span class=\"pn-normal\">" . $preformat['title'] . "&nbsp;({$info['comments']})</span></td></tr>\n";
        } else {
            $boxstuff .= "<tr><td colspan=\"2\"><b>{$datetime2}</b></td></tr>\n" . "<tr><td valign=\"top\"><big><strong>&middot;</strong></big></td>" . "<td valign=\"top\" width=\"100%\"><span class=\"pn-normal\">{$preformat['title']}&nbsp;({$info['comments']})</span></td></tr>\n";
            $time2 = $datetime2;
        }
        $vari++;
        if ($vari == $vars['limit']) {
            $usernum = pnUserGetVar('storynum');
            if (!empty($usernum)) {
                $storynum = $usernum;
            } else {
                $storynum = pnConfigGetVar('storyhome');
            }
            $min = $oldnum + $storynum;
            $boxstuff .= "<tr><td>&nbsp;</td><td valign=\"top\"><a class=\"pn-normal\"";
            if (!isset($catid)) {
                $boxstuff .= "href=\"modules.php?op=modload&amp;name=Search&amp;file=index&amp;action=search&amp;overview=1&amp;active_stories=1\"><b>" . _OLDERARTICLES . "</b></a></td></tr>\n";
            } else {
                $boxstuff .= "href=\"modules.php?op=modload&amp;name=Search&amp;file=index&amp;action=search&amp;overview=1&amp;active_stories=1&amp;stories_cat[0]={$catid}\"><b>" . _OLDERARTICLES . "</b></a></td></tr>\n";
            }
        }
    }
    $boxstuff .= "</table>";
    if ($see == 1) {
        if (empty($row['title'])) {
            $row['title'] = _PASTARTICLES;
        }
        $row['content'] = $boxstuff;
        return themesideblock($row);
    }
}