Esempio n. 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);
}
Esempio n. 2
0
/**
 * get the user's theme
 * <br />
 * This function will return the current theme for the user.
 * Order of theme priority:
 *  - page-specific
 *  - category
 *  - user
 *  - system
 *
 * @public
 * @return string the name of the user's theme
 **/
function pnUserGetTheme()
{
    static $theme;
    if (isset($theme)) {
        return $theme;
    }
    // Page-specific theme
    $pagetheme = pnVarCleanFromInput('theme');
    if (!empty($pagetheme)) {
        $themeinfo = pnThemeInfo($pagetheme);
        if ($themeinfo && $themeinfo['active']) {
            $theme = $pagetheme;
            return $pagetheme;
        }
    }
    // set a new theme for the user
    $pagetheme = pnVarCleanFromInput('newtheme');
    if (!empty($pagetheme) && !pnConfigGetVar('theme_change')) {
        $themeinfo = pnThemeInfo($pagetheme);
        if ($themeinfo && $themeinfo['active']) {
            if (pnUserLoggedIn()) {
                $uid = pnUserGetVar('uid');
                $dbconn =& pnDBGetConn(true);
                $pntable =& pnDBGetTables();
                $column =& $pntable['users_column'];
                $sql = "UPDATE {$pntable['users']}\n                        SET {$column['theme']}='" . pnVarPrepForStore($pagetheme) . "'\n                        WHERE {$column['uid']}='" . pnVarPrepForStore($uid) . "'";
                $dbconn->Execute($sql);
            } else {
                pnSessionSetVar('theme', $pagetheme);
            }
            $theme = $pagetheme;
            return $pagetheme;
        }
    }
    // eugenio themeover 20020413
    // override the theme per category or story
    // precedence is story over category override
    list($sid, $file) = pnVarCleanFromInput('sid', 'file');
    if (pnModGetName() == 'News' && (!empty($sid) || strtolower($file) == 'article')) {
        $modinfo = pnModGetInfo(pnModGetIDFromName('News'));
        include_once 'modules/' . $modinfo['directory'] . '/funcs.php';
        $pntable =& pnDBGetTables();
        $results = getArticles("{$pntable['stories_column']['sid']}='" . (int) pnVarPrepForStore($sid) . "'", "", "");
        if (is_array($results) && count($results) > 0) {
            $info = genArticleInfo($results[0]);
            $themeinfo = pnThemeInfo($info['catthemeoverride']);
            if ($themeinfo && $themeinfo['active']) {
                $theme = $info['catthemeoverride'];
                return $theme;
            }
            $themeinfo = pnThemeInfo($info['themeoverride']);
            if ($themeinfo && $themeinfo['active']) {
                $theme = $info['themeoverride'];
                return $theme;
            }
        }
    }
    // User theme
    if (!pnConfigGetVar('theme_change')) {
        if (pnUserLoggedIn()) {
            $usertheme = pnUserGetVar('theme');
        } else {
            $usertheme = pnSessionGetVar('theme');
        }
        $themeinfo = pnThemeInfo($usertheme);
        if ($themeinfo && $themeinfo['active']) {
            $theme = $usertheme;
            return $usertheme;
        }
    }
    // default site theme
    $defaulttheme = pnConfigGetVar('Default_Theme');
    $themeinfo = pnThemeInfo($defaulttheme);
    if ($themeinfo && $themeinfo['active']) {
        $theme = $defaulttheme;
        return $theme;
    }
    return false;
}
Esempio n. 3
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);
    }
}