Ejemplo n.º 1
0
function themeheader()
{
    $sitename = pnConfigGetVar('sitename');
    $banners = pnConfigGetVar('banners');
    echo "</head>";
    echo "<body>" . "<br>";
    if (pnModAvailable('Banners')) {
        pnBannerDisplay();
    }
    echo "<br>" . "<table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" width=\"100%\" align=\"center\"><tr><td bgcolor=\"{$GLOBALS['bgcolor1']}\">" . "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" bgcolor=\"{$GLOBALS['bgcolor1']}\"><tr><td>" . "<a href=\"index.php\"><img src=\"" . WHERE_IS_PERSO . "images/logo.gif\" Alt=\"" . _WELCOMETO . " {$sitename}\" border=\"0\"></a>" . "</td><td align=\"right\">" . '<form action="modules.php" method="post">' . '<input type="hidden" name="name" value="Search">' . '<input type="hidden" name="file" value="index">' . '<input type="hidden" name="op" value="modload">' . '<input type="hidden" name="action" value="search">' . '<input type="hidden" name="overview" value="1">' . '<input type="hidden" name="active_stories" value="1">' . '<input type="hidden" name="bool" value="AND">' . '<input type="hidden" name="stories_cat" value="">' . '<input type="hidden" name="stories_topics" value="">' . '<div align="right"><font class="pn-normal">' . _SEARCH . '&nbsp;</font>' . "<input class=\"pn-text\" NAME=\"q\" TYPE=\"text\" VALUE=\"\">&nbsp;\n" . '</div>' . '</form>' . "</td></tr></table></td></tr><tr><td valign=\"top\" width=\"100%\" bgcolor=\"{$GLOBALS['bgcolor1']}\">" . "<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">\n          <tr><td valign=\"top\" width=\"150\" bgcolor=\"{$GLOBALS['bgcolor1']}\">";
    blocks('left');
    echo "<img src=\"images/global/pix.gif\" border=\"0\" width=\"100%\" height=\"1\" alt=\"\">\n          </td>\n          <td>&nbsp;&nbsp;</td>\n          <td valign=\"top\">";
    if ($GLOBALS['index'] == 1) {
        blocks('centre');
    }
}
Ejemplo n.º 2
0
/**
 * display block
 *
 * @param        array       $blockinfo     a blockinfo structure
 * @return       output      the rendered bock
 */
function FlashChatBridge_Onlineblock_display($blockinfo)
{
    if (!SecurityUtil::checkPermission('FlashChatBridge:Onlineblock:', "::", ACCESS_READ)) {
        return false;
    }
    if (!pnModAvailable('FlashChatBridge') || !pnUserLoggedIn()) {
        return false;
    }
    //pnModLoad("FlashChatBridge");
    $Users = pnModAPIFunc('FlashChatBridge', 'user', 'getChatterList');
    $count = count($Users);
    $render = pnRender::getInstance('FlashChatBridge', false);
    $render->assign('Users', $Users);
    $render->assign('Count', $count);
    $blockinfo['content'] = $render->fetch('flashchatbridge_block_online.htm');
    return pnBlockThemeBlock($blockinfo);
}
Ejemplo n.º 3
0
/**
 * display block
 *
 * @param        array       $blockinfo     a blockinfo structure
 * @return       output      the rendered bock
 */
function FlashChatBridge_Bannerchatblock_display($blockinfo)
{
    if (!SecurityUtil::checkPermission('FlashChatBridge:Bannerchatblock:', "::", ACCESS_READ)) {
        return false;
    }
    if (!pnModAvailable('FlashChatBridge') || !pnUserLoggedIn()) {
        return false;
    }
    $render = pnRender::getInstance('FlashChatBridge', false);
    $UserVars = pnUserGetVars(SessionUtil::getVar('uid'));
    $settings = pnModGetVar('FlashChatBridge');
    $settings['init_user'] = $UserVars['uname'];
    $settings['init_password'] = $UserVars['pass'];
    $settings['width'] = "100%";
    $settings['height'] = "150";
    $render->assign('settings', $settings);
    $blockinfo['content'] = $render->fetch('flashchatbridge_user_chat_banner.htm');
    return pnBlockThemeBlock($blockinfo);
}
Ejemplo n.º 4
0
include_once 'includes/pnAPI.php';
pnInit();
$currentlang = pnUserGetLang();
$currentlang = pnVarPrepForOS($currentlang);
if (file_exists("language/{$currentlang}/error.php")) {
    include "language/{$currentlang}/error.php";
} elseif (file_exists("language/eng/error.php")) {
    include "language/eng/error.php";
}
$reportlevel = pnConfigGetVar('reportlevel');
$funtext = pnConfigGetVar('funtext');
header('HTTP/1.1 404 Not Found');
include 'header.php';
if ($funtext == 0) {
    echo "<h2>" . _ERROR404_HEAD . "</h2>\n" . "<br /><br />\n" . "<strong>" . _ERROR404_TRY . "</strong><br />\n" . _ERROR404_TRY1 . "<br />\n" . "<a href=\"index.php\">" . _ERROR404_TRY2 . "</a><br />\n" . _ERROR404_TRY3 . "<br />\n" . _ERROR404_TRY4 . "\n";
    if (pnModAvailable('Search')) {
        echo '<br /><a href="' . pnVarPrepForDisplay(pnModURL('Search')) . '">' . _ERROR404_TRY5 . "</a>\n";
    }
} else {
    echo "<strong>" . _ERROR404_MAILSUBJECT . "</strong><br /><br />\n";
    echo _ERROR404_FUNTEXT;
}
function send_email()
{
    $adminmail = pnConfigGetVar('adminmail');
    $subject = "" . _ERROR404_MAILSUBJECT . "";
    $sitename = pnConfigGetVar('sitename');
    $remote_addr = pnServerGetVar('REMOTE_ADDR');
    $http_referer = pnServerGetVar('HTTP_REFERER');
    $redirect_url = pnServerGetVar('REDIRECT_URL');
    $server = pnServerGetVar('HTTP_HOST');
Ejemplo n.º 5
0
function search_downloads()
{
    list($q, $active_downloads, $bool, $startnum, $total) = pnVarCleanFromInput('q', 'active_downloads', 'bool', 'startnum', 'total');
    if (empty($active_downloads)) {
        return;
    }
    if (!pnModAvailable('Downloads')) {
        return;
    }
    $dbconn =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();
    $output =& new pnHTML();
    if (!isset($startnum) || !is_numeric($startnum)) {
        $startnum = 1;
    }
    if (isset($total) && !is_numeric($total)) {
        unset($total);
    }
    $w = search_split_query($q);
    $flag = false;
    // fifers: have to explicitly name the columns so that if the underlying DB column names change, the code to access them doesn't.  We use the column names in assoc array later...
    $column =& $pntable['downloads_downloads_column'];
    $query = "SELECT {$column['lid']} as lid, {$column['title']} as title, {$column['name']} as name, {$column['description']} as description, {$column['cid']} as cid FROM {$pntable['downloads_downloads']} WHERE \n";
    foreach ($w as $word) {
        if ($flag) {
            switch ($bool) {
                case 'AND':
                    $query .= ' AND ';
                    break;
                case 'OR':
                default:
                    $query .= ' OR ';
                    break;
            }
        }
        $query .= '(';
        // downloads
        $query .= "{$column['description']} LIKE '" . pnVarPrepForStore($word) . "' OR \n";
        $query .= "{$column['title']} LIKE '" . pnVarPrepForStore($word) . "' OR \n";
        $query .= "{$column['submitter']} LIKE '" . pnVarPrepForStore($word) . "' OR \n";
        $query .= "{$column['name']} LIKE '" . pnVarPrepForStore($word) . "' OR \n";
        $query .= "{$column['homepage']} LIKE '" . pnVarPrepForStore($word) . "' \n";
        $query .= ')';
        $flag = true;
    }
    $query .= " ORDER BY {$column['lid']}";
    if (empty($total)) {
        $total = 0;
        $countres =& $dbconn->Execute($query);
        // check for a db error
        if ($dbconn->ErrorNo() != 0) {
            return;
        }
        while (!$countres->EOF) {
            $row = $countres->GetRowAssoc(false);
            // we have a download id so get its category
            $column2 =& $pntable['downloads_categories_column'];
            $result2 =& $dbconn->Execute("SELECT {$column2['title']} \n\t\t\t\t\t\t\t\t\tFROM {$pntable['downloads_categories']} \n\t\t\t\t\t\t\t\t\tWHERE {$column2['cid']}={$row['cid']}");
            list($title) = $result2->fields;
            if (pnSecAuthAction(0, 'Downloads::Item', "{$row['title']}::{$row['lid']}", ACCESS_READ) && pnSecAuthAction(0, 'Downloads::Category', "{$title}::{$row['cid']}", ACCESS_READ)) {
                $total++;
            }
            $countres->MoveNext();
        }
    }
    $result = $dbconn->SelectLimit($query, 10, $startnum - 1);
    // check for a db error
    if ($dbconn->ErrorNo() != 0) {
        return;
    }
    if (!$result->EOF) {
        $output->Text(_DOWNLOADS . ': ' . $total . ' ' . _SEARCHRESULTS);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        // Rebuild the search string from previous information
        $url = "index.php?name=Search&amp;action=search&amp;active_downloads=1&amp;bool={$bool}&amp;q={$q}";
        $output->Text("<dl>");
        while (!$result->EOF) {
            $row = $result->GetRowAssoc(false);
            // we have a download id so get its category
            $column2 =& $pntable['downloads_categories_column'];
            $result2 =& $dbconn->Execute("SELECT {$column2['title']} \n\t\t\t\t\t\t\t\t\tFROM {$pntable['downloads_categories']} \n\t\t\t\t\t\t\t\t\tWHERE {$column2['cid']}={$row['cid']}");
            list($title) = $result2->fields;
            if (pnSecAuthAction(0, 'Downloads::Item', "{$row['title']}::{$row['lid']}", ACCESS_READ) && pnSecAuthAction(0, 'Downloads::Category', "{$title}::{$row['cid']}", ACCESS_READ)) {
                $row['description'] = strip_tags($row['description']);
                if (strlen($row['description']) > 128) {
                    $row['description'] = substr($row['description'], 0, 125) . '...';
                }
                $output->Text("<dt><a href=\"index.php?name=Downloads&amp;req=viewdownloaddetails&amp;lid={$row['lid']}\">" . pnVarPrepForDisplay($row[title]) . "</a></dt>");
                $output->Text("<dd>" . pnVarPrepForDisplay($row[description]) . "</dd>");
            }
            $result->MoveNext();
        }
        $output->Text("</dl>");
        // Mung URL for template
        $urltemplate = $url . "&amp;startnum=%%&amp;total={$total}";
        $output->Pager($startnum, $total, $urltemplate, 10);
    } else {
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(_SEARCH_NO_DOWNLOADS);
        $output->SetInputMode(_PNH_PARSEINPUT);
    }
    $output->Linebreak(3);
    return $output->GetOutput();
}
Ejemplo n.º 6
0
function search_faqs()
{
    list($q, $bool, $startnum, $total, $active_faqs) = pnVarCleanFromInput('q', 'bool', 'startnum', 'total', 'active_faqs');
    if (empty($active_faqs)) {
        return;
    }
    if (!pnModAvailable('FAQ')) {
        return;
    }
    $dbconn =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();
    $output =& new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    if (!isset($startnum) || !is_numeric($startnum)) {
        $startnum = 1;
    }
    if (isset($total) && !is_numeric($total)) {
        unset($total);
    }
    $w = search_split_query($q);
    $flag = false;
    $column =& $pntable['faqanswer_column'];
    $faqcatcol =& $pntable['faqcategories_column'];
    $query = "SELECT {$column['id_cat']} as id_cat, \n    \t\t\t\t{$column['question']} as question, \n    \t\t\t\t{$column['answer']} as answer,\n    \t\t\t\t{$faqcatcol['categories']} as categories\n              FROM {$pntable['faqanswer']} \n              LEFT JOIN {$pntable['faqcategories']} ON {$column['id_cat']}={$faqcatcol['id_cat']}\n              WHERE {$column['answer']} != \"\" AND \n";
    foreach ($w as $word) {
        if ($flag) {
            switch ($bool) {
                case 'AND':
                    $query .= ' AND ';
                    break;
                case 'OR':
                default:
                    $query .= ' OR ';
                    break;
            }
        }
        $query .= '(';
        // faqs
        $query .= "{$column['question']} LIKE '" . pnVarPrepForStore($word) . "' OR \n";
        $query .= "{$column['answer']} LIKE '" . pnVarPrepForStore($word) . "'\n";
        $query .= ')';
        $flag = true;
    }
    if (pnConfigGetVar('multilingual') == 1) {
        $query .= " AND ({$faqcatcol['flanguage']}='" . pnVarPrepForStore(pnUserGetLang()) . "' OR {$faqcatcol['flanguage']}='')";
    }
    $query .= " ORDER BY {$column['id']}";
    // get the total count with permissions!
    if (empty($total)) {
        $total = 0;
        $countres =& $dbconn->Execute($query);
        // check for a db error
        if ($dbconn->ErrorNo() != 0) {
            return;
        }
        while (!$countres->EOF) {
            $row = $countres->GetRowAssoc(false);
            if (pnSecAuthAction(0, "FAQ::", "{$row['categories']}::{$row['id_cat']}", ACCESS_READ)) {
                $total++;
            }
            $countres->MoveNext();
        }
    }
    $result = $dbconn->SelectLimit($query, 10, $startnum - 1);
    // check for a db error
    if ($dbconn->ErrorNo() != 0) {
        return;
    }
    if (!$result->EOF) {
        $output->Text(_FAQ . ': ' . $total . ' ' . _SEARCHRESULTS);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        // Rebuild the search string from previous information
        $url = "index.php?name=Search&amp;action=search&amp;active_faqs=1&amp;bool={$bool}&amp;q={$q}";
        $output->Text("<dl>");
        while (!$result->EOF) {
            $row = $result->GetRowAssoc(false);
            if (pnSecAuthAction(0, "FAQ::", "{$row['categories']}::{$row['id_cat']}", ACCESS_READ)) {
                $row['answer'] = strip_tags($row['answer']);
                if (strlen($row['answer']) > 128) {
                    $row['answer'] = substr($row['answer'], 0, 125) . '...';
                }
                $output->Text("<dt><a href=\"index.php?name=FAQ&amp;myfaq=yes&amp;id_cat={$row['id_cat']}\">" . pnVarPrepForDisplay($row[question]) . "</a></dt>");
                $output->Text("<dd>" . pnVarPrepForDisplay($row[answer]) . "</dd>");
            }
            $result->MoveNext();
        }
        $output->Text('</dl>');
        // Munge URL for template
        $urltemplate = $url . "&amp;startnum=%%&amp;total={$total}";
        $output->Pager($startnum, $total, $urltemplate, 10);
    } else {
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(_SEARCH_NO_FAQS);
        $output->SetInputMode(_PNH_PARSEINPUT);
    }
    $output->Linebreak(3);
    return $output->GetOutput();
}
Ejemplo n.º 7
0
function search_weblinks()
{
    list($active_weblinks, $startnum, $total, $q, $bool) = pnVarCleanFromInput('active_weblinks', 'startnum', 'total', 'q', 'bool');
    if (empty($active_weblinks)) {
        return;
    }
    if (!pnModAvailable('Web_Links')) {
        return;
    }
    $dbconn =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();
    $output =& new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    if (!isset($startnum) || !is_numeric($startnum)) {
        $startnum = 1;
    }
    if (isset($total) && !is_numeric($total)) {
        unset($total);
    }
    $w = search_split_query($q);
    $flag = false;
    $column =& $pntable['links_links_column'];
    $query = "SELECT {$column['url']} as url, {$column['title']} as title, {$column['description']} as description, {$column['lid']} as lid, {$column['cat_id']} as cat_id\n              FROM {$pntable['links_links']}\n              WHERE \n";
    foreach ($w as $word) {
        if ($flag) {
            switch ($bool) {
                case 'AND':
                    $query .= ' AND ';
                    break;
                case 'OR':
                default:
                    $query .= ' OR ';
                    break;
            }
        }
        $query .= '(';
        // web links
        $query .= "{$column['description']} LIKE '" . pnVarPrepForStore($word) . "' OR \n";
        $query .= "{$column['url']} LIKE '" . pnVarPrepForStore($word) . "' OR \n";
        $query .= "{$column['submitter']} LIKE '" . pnVarPrepForStore($word) . "' OR \n";
        $query .= "{$column['title']} LIKE '" . pnVarPrepForStore($word) . "' \n";
        $query .= ')';
        $flag = true;
    }
    $query .= " ORDER BY {$column['lid']}";
    // get the total count with permissions!
    if (empty($total)) {
        $total = 0;
        $countres =& $dbconn->Execute($query);
        // check for a db error
        if ($dbconn->ErrorNo() != 0) {
            return;
        }
        while (!$countres->EOF) {
            $row = $countres->GetRowAssoc(false);
            // we have a link id so get its category
            $column2 =& $pntable['links_categories_column'];
            $result2 =& $dbconn->Execute("SELECT {$column2['title']} \n\t\t\t\t\t\t\t\t\tFROM {$pntable['links_categories']} \n\t\t\t\t\t\t\t\t\tWHERE {$column2['cat_id']}={$row['cat_id']}");
            list($title) = $result2->fields;
            if (pnSecAuthAction(0, 'Web Links::Link', "{$title}:{$row['title']}:{$row['lid']}", ACCESS_READ) && pnSecAuthAction(0, 'Web Links::Category', "{$title}::{$row['cat_id']}", ACCESS_READ)) {
                $total++;
            }
            $countres->MoveNext();
        }
    }
    $result = $dbconn->SelectLimit($query, 10, $startnum - 1);
    // check for a db error
    if ($dbconn->ErrorNo() != 0) {
        return;
    }
    if (!$result->EOF) {
        $output->Text(_WEBLINKS . ': ' . $total . ' ' . _SEARCHRESULTS);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        // Rebuild the search string from previous information
        $url = "index.php?name=Search&amp;action=search&amp;active_weblinks=1&amp;bool={$bool}&amp;q={$q}";
        $output->Text("<dl>");
        while (!$result->EOF) {
            $row = $result->GetRowAssoc(false);
            // we have a link id so get its category
            $column2 =& $pntable['links_categories_column'];
            $result2 =& $dbconn->Execute("SELECT {$column2['title']} \n\t\t\t\t\t\t\t\t\tFROM {$pntable['links_categories']} \n\t\t\t\t\t\t\t\t\tWHERE {$column2['cat_id']}={$row['cat_id']}");
            list($title) = $result2->fields;
            if (pnSecAuthAction(0, 'Web Links::Link', "{$title}:{$row['title']}:{$row['lid']}", ACCESS_READ) && pnSecAuthAction(0, 'Web Links::Category', "{$title}::{$row['cat_id']}", ACCESS_READ)) {
                $output->Text("<dt><a href=\"" . pnVarPrepForDisplay($row['url']) . "\">" . pnVarPrepForDisplay($row['title']) . "</a></dt><dd>" . pnVarPrepHTMLDisplay($row['description']) . "</dd>");
            }
            $result->MoveNext();
        }
        $output->Text("</dl>");
        // Munge URL for template
        $urltemplate = $url . "&amp;startnum=%%&amp;total={$total}";
        $output->Pager($startnum, $total, $urltemplate, 10);
    } else {
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(_SEARCH_NO_LINKS);
        $output->SetInputMode(_PNH_PARSEINPUT);
    }
    $output->Linebreak(3);
    $flag = false;
    $column =& $pntable['links_categories_column'];
    $query = "SELECT {$column['cat_id']} as cat_id, {$column['title']} as title, {$column['cdescription']} as description\n              FROM {$pntable['links_categories']}\n              WHERE \n";
    foreach ($w as $word) {
        if ($flag) {
            switch ($bool) {
                case 'AND':
                    $query .= ' AND ';
                    break;
                case 'OR':
                default:
                    $query .= ' OR ';
                    break;
            }
        }
        $query .= '(';
        // web links
        $query .= "{$column['cdescription']} LIKE '" . pnVarPrepForStore($word) . "'\n";
        $query .= ')';
        $flag = true;
    }
    $query .= " ORDER BY {$column['cat_id']}";
    // get the total count with permissions!
    if (empty($total)) {
        $total = 0;
        $countres =& $dbconn->Execute($query);
        while (!$countres->EOF) {
            $row = $countres->GetRowAssoc(false);
            if (pnSecAuthAction(0, 'Web Links::Category', "{$title}:{$row['title']}:{$row['cat_id']}", ACCESS_READ)) {
                $total++;
            }
            $countres->MoveNext();
        }
    }
    $result = $dbconn->SelectLimit($query, 10, $startnum - 1);
    if (!$result->EOF) {
        $output->Text(_WEBLINKSCATEGORIES . ': ' . $total . ' ' . _SEARCHRESULTS);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        // Rebuild the search string from previous information
        $url = "index.php?name=Search&amp;action=search&amp;active_weblinks=1&amp;bool={$bool}&amp;q={$q}";
        $output->Text("<dl>");
        while (!$result->EOF) {
            $row = $result->GetRowAssoc(false);
            if (pnSecAuthAction(0, 'Web Links::Category', "{$row['title']}::{$row['cat_id']}", ACCESS_READ)) {
                $output->Text("<dt><a href=\"index.php?name=Web_Links&amp;req=viewlink&amp;cid=" . pnVarPrepForDisplay($row['cat_id']) . "\">" . pnVarPrepForDisplay($row['title']) . "</a></dt><dd>" . pnVarPrepHTMLDisplay($row['description']) . "</dd>");
            }
            $result->MoveNext();
        }
        $output->Text("</dl>");
        // Munge URL for template
        $urltemplate = $url . "&amp;startnum=%%&amp;total={$total}";
        $output->Pager($startnum, $total, $urltemplate, 10);
    } else {
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(_SEARCH_NO_LINKSCATEGORIES);
        $output->SetInputMode(_PNH_PARSEINPUT);
    }
    $output->Linebreak(3);
    return $output->GetOutput();
}
Ejemplo n.º 8
0
// ----------------------------------------------------------------------
// Original Author of file: Francisco Burzi
// Purpose of file:
// ----------------------------------------------------------------------
// include base api
include 'includes/pnAPI.php';
// start PN
pnInit();
// Get module
$module = pnVarCleanFromInput('module');
if (empty($module)) {
    // call for admin.php without module parameter
    pnRedirect(pnModURL('Admin', 'admin', 'adminpanel'));
    exit;
} else {
    if (!pnModAvailable($module) || !pnSecAuthAction(0, "{$module}::", '::', ACCESS_EDIT)) {
        // call for an unavailable module - either not available or not authorized
        header('HTTP/1.0 403 Access Denied');
        include 'header.php';
        echo 'Module <strong>' . pnVarPrepForDisplay($module) . '</strong> not available';
        include 'footer.php';
        exit;
    }
}
// get the module information
$modinfo = pnModGetInfo(pnModGetIDFromName($module));
if ($modinfo['type'] == 2 || $modinfo['type'] == 3) {
    // Redirect to new style admin panel
    pnRedirect(pnModURL($module, 'admin'));
    exit;
}
Ejemplo n.º 9
0
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Francisco Burzi
// Purpose of file: Displays a printer friendly (story) page
// ----------------------------------------------------------------------
include 'includes/pnAPI.php';
pnInit();
// get story id from input
$sid = pnVarCleanFromInput('sid');
if (empty($sid) || !is_numeric($sid) || !pnModAvailable('News')) {
    header('HTTP/1.0 404 Not Found');
    include 'header.php';
    echo _MODARGSERROR;
    include 'footer.php';
    exit;
}
if (!pnLocalReferer() && pnConfigGetVar('refereronprint')) {
    Header('HTTP/1.1 301 Moved Permanently');
    pnRedirect("index.php?name=News&file=article&sid={$sid}");
    exit;
} else {
    pnRedirect('index.php?name=News&file=article&sid=' . $sid . '&theme=Printer');
}
Ejemplo n.º 10
0
function admin_admin_main($var)
{
    include 'header.php';
    menu_draw();
    if (pnModAvailable('News')) {
        admin_main_automated();
        admin_main_article();
    }
    if (pnModAvailable('Polls')) {
        admin_main_poll();
    }
    include 'footer.php';
}
Ejemplo n.º 11
0
/**
* send an email
*
* e-mail messages should now be send with a pnModAPIFunc call to the mailer module
*
* @deprecated
* @param to $ - recipient of the email
* @param subject $ - title of the email
* @param message $ - body of the email
* @param headers $ - extra headers for the email
* @param html $ - message is html formatted
* @param debug $ - if 1, echo mail content
* @return bool true if the email was sent, false if not
*/
function pnMail($to, $subject, $message = '', $headers = '', $html = 0, $debug = 0)
{
    if (empty($to) || !isset($subject)) {
        return false;
    }
    // set initial return value until we know we have a valid return
    $return = false;
    // check if the mailer module is availble and if so call the API
    if (pnModAvailable('Mailer') && pnModAPILoad('Mailer', 'user')) {
        $return = pnModAPIFunc('Mailer', 'user', 'sendmessage', array('toaddress' => $to, 'subject' => $subject, 'headers' => $headers, 'body' => $message, 'headers' => $headers, 'html' => $html));
    }
    return $return;
}
Ejemplo n.º 12
0
    $type = pnConfigGetVar('starttype');
    $func = pnConfigGetVar('startfunc');
    $funcargs = explode(',', pnConfigGetVar('startargs'));
    $arguments = array();
    foreach ($funcargs as $funcarg) {
        if (!empty($funcarg)) {
            $argument = explode('=', $funcarg);
            $arguments[$argument[0]] = $argument[1];
        }
    }
} elseif (empty($module) && !empty($name)) {
    $module = $name;
}
// get module information
$modinfo = pnModGetInfo(pnModGetIDFromName($module));
if ($type != 'init' && !pnModAvailable($modinfo['name'])) {
    header('HTTP/1.0 404 Not Found');
    include 'header.php';
    echo 'Module <strong>' . pnVarPrepForDisplay($module) . '</strong> not available';
    include 'footer.php';
    exit;
}
if ($modinfo['type'] == 2 || $modinfo['type'] == 3) {
    // New-new style of loading modules
    if (empty($type)) {
        $type = 'user';
    }
    if (empty($func)) {
        $func = 'main';
    }
    if (!isset($arguments)) {
 /**
  * The class constructor.
  *
  * This function also tries to load a file called usemodules
  * which it expects in the calling modules pntemplates/config
  * folder.
  * This file contains lines like
  *
  * ---snip---
  * module1
  * module2
  * module3
  * ---snap---
  *
  * These modules plugins folders will be added to the plugins_dir
  * array to let a module use plugins from another module.
  *
  * If the usemodules file is not available we do not throw an
  * error message because this might be the usual case for
  * simple templates.
  *
  * @param   string   $module   The module for which this object is for
  */
 function pnRender($module = '')
 {
     // first, get a native Smarty object
     $this->Smarty();
     // Initialize the module property with the name of
     // the topmost module. Foor Hooks, Blocks, API Functions and others
     // you need to set this property to the name of the respective module!
     if (!$module) {
         $module = pnModGetName();
     }
     $this->module = $module;
     // begin holder tag (be nice to others)
     $this->left_delimiter = '<!--[';
     // end holder tag
     $this->right_delimiter = ']-->';
     //---- Plugins handling -----------------------------------------------
     // add the global PostNuke plugins directory
     if (is_dir('system/pnRender/plugins')) {
         array_push($this->plugins_dir, 'system/pnRender/plugins');
     } else {
         if (is_dir('modules/pnRender/plugins')) {
             array_push($this->plugins_dir, 'modules/pnRender/plugins');
         }
     }
     // add the global PostNuke plugins directory
     $modinfo = pnModGetInfo(pnModGetIDFromName('Xanthia'));
     $modpath = $modinfo['type'] == 3 ? 'system' : 'modules';
     array_push($this->plugins_dir, "{$modpath}/{$modinfo['directory']}/plugins");
     // uncomment for .8 until modtype=3 for system modules is implemented
     array_push($this->plugins_dir, "system/{$modinfo['directory']}/plugins");
     // add module specific plugins directories, if they exist
     $theme = pnUserGetTheme();
     $themepath = "themes/{$theme}/templates/modules/{$module}/plugins";
     if (file_exists($themepath)) {
         array_push($this->plugins_dir, $themepath);
     }
     $modinfo = pnModGetInfo(pnModGetIDFromName($module));
     $modpath = $modinfo['type'] == 3 ? 'system' : 'modules';
     $mod_plugs = "{$modpath}/{$modinfo['directory']}/pntemplates/plugins";
     // build the path to the config file for usemodules needed later
     $usemod_conf = "{$modpath}/{$modinfo['directory']}/pntemplates/config/usemodules";
     if (file_exists($mod_plugs)) {
         array_push($this->plugins_dir, $mod_plugs);
     }
     // add theme specific plugins directories, if they exist
     $themepath = "themes/{$theme}/plugins";
     if (file_exists($themepath)) {
         array_push($this->plugins_dir, $themepath);
     }
     // uncomment for .8 until modtype=3 for system modules is implemented
     $modpath = 'system';
     $mod_plugs = "{$modpath}/{$modinfo['directory']}/pntemplates/plugins";
     if (file_exists($mod_plugs)) {
         array_push($this->plugins_dir, $mod_plugs);
     }
     // load the config file
     if (file_exists($usemod_conf) && is_readable($usemod_conf)) {
         $additionalmodules = file($usemod_conf);
         if (is_array($additionalmodules)) {
             foreach ($additionalmodules as $addmod) {
                 $this->_add_plugins_dir(trim($addmod));
             }
         }
     }
     // check if the recent 'type' parameter in the URL is admin and if yes,
     // include (modules|system)/Admin/pntemplates/plugins to the plugins_dir array
     $type = pnVarCleanFromInput('type');
     if (!empty($type) && $type == 'admin') {
         array_push($this->plugins_dir, "modules/Admin/pntemplates/plugins");
         array_push($this->plugins_dir, "system/Admin/pntemplates/plugins");
     }
     //---- Cache handling -------------------------------------------------
     // use HTML cache system?
     $this->caching = pnModGetVar('pnrender', 'cache');
     $this->cache_lifetime = pnModGetVar('pnrender', 'lifetime');
     // HTML cache directory
     $this->cache_dir = pnConfigGetVar('temp') . '/pnRender_cache';
     //---- Compilation handling -------------------------------------------
     // check for updated templates?
     $this->compile_check = pnModGetVar('pnrender', 'compile_check');
     // force compile template always?
     $this->force_compile = pnModGetVar('pnrender', 'force_compile');
     // safe_mode?
     // This routine is taken from PostCalendar.
     // we don't need this code anymore due to change below
     //$safe_mode     = ini_get('safe_mode');
     //$safe_mode_gid = ini_get('safe_mode_gid');
     //$open_basedir  = ini_get('open_basedir');
     // don't use subdirectories when creating compiled/cached templates
     // this works better in a hosted environment
     $this->use_sub_dirs = false;
     //$this->use_sub_dirs = !((bool)$safe_mode ||
     //                      (bool)$safe_mode_gid ||
     //                      !empty($open_basedir));
     // cache directory (compiled templates)
     $this->compile_dir = pnConfigGetVar('temp') . '/pnRender_compiled';
     // compile id
     $this->compile_id = $this->module . '|' . $theme . '|' . pnUserGetLang();
     // initialize the cache ID
     $this->cache_id = '';
     // expose templates
     $this->expose_template = pnModGetVar('pnrender', 'expose_template') == true ? true : false;
     if (pnModAvailable('Xanthia')) {
         $this->userdb = 'userdb';
     }
     $this->register_block('nocache', 'pnRender_block_nocache', false);
 }
Ejemplo n.º 14
0
function search_comments()
{
    list($active_comments, $startnum, $total, $bool, $q) = pnVarCleanFromInput('active_comments', 'startnum', 'total', 'bool', 'q');
    if (empty($active_comments)) {
        return;
    }
    if (!pnModAvailable('Comments')) {
        return;
    }
    $dbconn =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();
    $output =& new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    if (!isset($startnum) || !is_numeric($startnum)) {
        $startnum = 1;
    }
    if (isset($total) && !is_numeric($total)) {
        unset($total);
    }
    $w = search_split_query($q);
    $flag = false;
    $column =& $pntable['comments_column'];
    $query = "SELECT {$column['subject']} as subject, {$column['tid']} as tid, ";
    $query .= "{$column['sid']} as sid, {$column['pid']} as pid, {$column['comment']} as comment FROM {$pntable['comments']} WHERE ";
    foreach ($w as $word) {
        if ($flag) {
            switch ($bool) {
                case 'AND':
                    $query .= ' AND ';
                    break;
                case 'OR':
                default:
                    $query .= ' OR ';
                    break;
            }
        }
        $query .= '(';
        $query .= "{$column['subject']} LIKE '" . pnVarPrepForStore($word) . "' OR ";
        $query .= "{$column['comment']} LIKE '" . pnVarPrepForStore($word) . "'";
        $query .= ')';
        $flag = true;
    }
    $query .= " ORDER BY {$column['subject']}";
    if (empty($total)) {
        $countres =& $dbconn->Execute($query);
        // check for a db error
        if ($dbconn->ErrorNo() != 0) {
            return;
        }
        $total = $countres->PO_RecordCount();
        $countres->Close();
    }
    $result = $dbconn->SelectLimit($query, 10, $startnum - 1);
    // check for a db error
    if ($dbconn->ErrorNo() != 0) {
        return;
    }
    if (!$result->EOF) {
        $output->Text(_COMMENTS . ': ' . $total . ' ' . _SEARCHRESULTS);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        // Rebuild the search string from previous information
        $url = "index.php?name=Search&amp;action=search&amp;active_comments=1&amp;bool={$bool}&amp;q={$q}";
        $output->Text('<dl>');
        while (!$result->EOF) {
            $row = $result->GetRowAssoc(false);
            $row['comment'] = strip_tags($row['comment']);
            if (strlen($row['comment']) > 128) {
                $row['comment'] = substr($row['comment'], 0, 125) . '...';
            }
            if ($row[subject] == "") {
                $row[subject] = "No title";
            }
            if ($row[pid] != 0) {
                // comment with parent posting
                $output->Text("<dt><a href=\"index.php?name=Comments&amp;req=showreply&amp;tid={$row['tid']}&amp;sid={$row['sid']}&amp;pid={$row['pid']}\">" . pnVarPrepHTMLDisplay($row[subject]) . "</a></dt>");
            } else {
                // comment without parent posting
                $output->Text("<dt><a href=\"index.php?name=Comments&amp;tid={$row['tid']}&amp;sid={$row['sid']}#{$row['tid']}\">" . pnVarPrepHTMLDisplay($row[subject]) . "</a></dt>");
            }
            $output->Text("<dd>" . pnVarPrepForDisplay($row[comment]) . "</dd>");
            $result->MoveNext();
        }
        $output->Text('</dl>');
        // Munge URL for template
        $urltemplate = $url . "&amp;startnum=%%&amp;total={$total}";
        $output->Pager($startnum, $total, $urltemplate, 10);
    } else {
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(_SEARCH_NO_COMMENTS);
        $output->SetInputMode(_PNH_PARSEINPUT);
    }
    $output->Linebreak(3);
    return $output->GetOutput();
}
Ejemplo n.º 15
0
/**
 * carry out hook operations for module
 * @author Jim McDonald <*****@*****.**>
 * @link http://www.mcdee.net
 * @param 'hookobject' the object the hook is called for - one of 'item', 'category' or 'module'
 * @param 'hookaction' the action the hook is called for - one of 'new', 'create', 'modify', 'update', 'delete', 'transform', 'display', 'modifyconfig', 'updateconfig'
 * @param 'hookid' the id of the object the hook is called for (module-specific)
 * @param 'extrainfo' extra information for the hook, dependent on hookaction
 * @param 'implode' implode collapses all display hooks into a single string - default to true for compatability with .7x
 * @return mixed string output from GUI hooks, extrainfo array for API hooks
 */
function pnModCallHooks($hookobject, $hookaction, $hookid, $extrainfo = array(), $implode = true)
{
    static $modulehooks;
    if (!isset($hookaction)) {
        return null;
    }
    if (isset($extrainfo['module']) && (pnModAvailable($extrainfo['module']) || strtolower($hookobject) == 'module')) {
        $modname = $extrainfo['module'];
    } else {
        $modname = pnModGetName();
    }
    if (!isset($modulehooks[strtolower($modname)])) {
        // Get database info
        $dbconn =& pnDBGetConn(true);
        $pntable =& pnDBGetTables();
        $hookstable = $pntable['hooks'];
        $hookscolumn =& $pntable['hooks_column'];
        // Get applicable hooks
        $sql = "SELECT {$hookscolumn['tarea']},\n\t\t\t\t\t   {$hookscolumn['tmodule']},\n\t\t\t\t\t   {$hookscolumn['ttype']},\n\t\t\t\t\t   {$hookscolumn['tfunc']},\n\t\t\t\t\t   {$hookscolumn['action']},\n\t\t\t\t\t   {$hookscolumn['object']}\n\t\t\t\tFROM {$hookstable}\n\t\t\t\tWHERE {$hookscolumn['smodule']} = '" . pnVarPrepForStore($modname) . "'";
        $result =& $dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
            return null;
        }
        $hooks = array();
        for (; !$result->EOF; $result->MoveNext()) {
            list($area, $module, $type, $func, $action, $object) = $result->fields;
            $hooks[] = array('area' => $area, 'module' => $module, 'type' => $type, 'func' => $func, 'action' => $action, 'object' => $object);
        }
        $modulehooks[strtolower($modname)] = $hooks;
    }
    $gui = false;
    $output = array();
    // Call each hook
    foreach ($modulehooks[strtolower($modname)] as $modulehook) {
        if ($modulehook['action'] == $hookaction && $modulehook['object'] == $hookobject) {
            if ($modulehook['area'] == 'GUI') {
                $gui = true;
                if (pnModAvailable($modulehook['module'], $modulehook['type']) && pnModLoad($modulehook['module'], $modulehook['type'])) {
                    $output[$modulehook['module']] = pnModFunc($modulehook['module'], $modulehook['type'], $modulehook['func'], array('objectid' => $hookid, 'extrainfo' => $extrainfo));
                }
            } else {
                if (pnModAvailable($modulehook['module'], $modulehook['type']) && pnModAPILoad($modulehook['module'], $modulehook['type'])) {
                    $extrainfo = pnModAPIFunc($modulehook['module'], $modulehook['type'], $modulehook['func'], array('objectid' => $hookid, 'extrainfo' => $extrainfo));
                }
            }
        }
    }
    // check what type of information we need to return
    // credit to the xaraya team for the eregi check
    // itevo
    if ($gui || strtolower($hookaction) == 'display' || strtolower($hookaction) == 'new' || strtolower($hookaction) == 'modify' || strtolower($hookaction) == 'modifyconfig') {
        if ($implode || empty($output)) {
            $output = implode("\n", $output);
        }
        return $output;
    } else {
        return $extrainfo;
    }
}
Ejemplo n.º 16
0
function search_stories()
{
    list($startnum, $active_stories, $total, $stories_topics, $stories_cat, $stories_author, $q, $bool) = pnVarCleanFromInput('startnum', 'active_stories', 'total', 'stories_topics', 'stories_cat', 'stories_author', 'q', 'bool');
    if (!isset($active_stories) || !$active_stories) {
        return;
    }
    if (!pnModAvailable('News')) {
        return;
    }
    $output =& new pnHTML();
    if (!isset($startnum) || !is_numeric($startnum)) {
        $startnum = 1;
    }
    if (isset($total) && !is_numeric($total)) {
        unset($total);
    }
    $dbconn =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();
    if (empty($bool)) {
        $bool = 'OR';
    }
    $flag = false;
    $storcol =& $pntable['stories_column'];
    $stcatcol =& $pntable['stories_cat_column'];
    $topcol =& $pntable['topics_column'];
    $query = '';
    $query1 = "SELECT {$storcol['sid']} as sid,\n                     {$topcol['tid']} as topicid,\n                     {$topcol['topicname']} as topicname,\n                     {$topcol['topictext']} as topictext,\n                     {$storcol['catid']} as catid,\n                     {$storcol['time']} AS fdate,\n                     {$storcol['title']} AS story_title,\n                     {$storcol['aid']} AS aid,\n                     {$stcatcol['title']} AS cat_title\n               FROM {$pntable['stories']}\n               LEFT JOIN {$pntable['stories_cat']} ON ({$storcol['catid']}={$stcatcol['catid']})\n               LEFT JOIN {$pntable['topics']} ON ({$storcol['topic']}={$topcol['tid']})\n               WHERE ";
    // hack to get this to work, but much better than what we had before
    //$query .= " 1 = 1 ";
    // words
    $w = search_split_query($q);
    if (isset($w)) {
        foreach ($w as $word) {
            if ($flag) {
                switch ($bool) {
                    case 'AND':
                        $query .= ' AND ';
                        break;
                    case 'OR':
                    default:
                        $query .= ' OR ';
                        break;
                }
            }
            $query .= '(';
            $query .= "{$storcol['title']} LIKE '" . pnVarPrepForStore($word) . "' OR ";
            $query .= "{$storcol['hometext']} LIKE '" . pnVarPrepForStore($word) . "' OR ";
            $query .= "{$storcol['bodytext']} LIKE '" . pnVarPrepForStore($word) . "' OR ";
            //$query .= "$storcol[comments] LIKE '".pnVarPrepForStore($word)."' OR ";
            $query .= "{$storcol['informant']} LIKE '" . pnVarPrepForStore($word) . "' OR ";
            $query .= "{$storcol['notes']} LIKE '" . pnVarPrepForStore($word) . "'";
            $query .= ')';
            $flag = true;
            $no_flag = false;
        }
    } else {
        $no_flag = true;
    }
    // topics
    if (isset($stories_topics) && !empty($stories_topics)) {
        $flag = false;
        $start_flag = false;
        // dont set AND/OR if nothing is in front
        foreach ($stories_topics as $v) {
            if (empty($v)) {
                continue;
            }
            if (!$no_flag and !$start_flag) {
                $query .= ' AND (';
                $start_flag = true;
            }
            if ($flag) {
                $query .= ' OR ';
            }
            $query .= "{$storcol['topic']}='" . pnVarPrepForStore($v) . "'";
            $flag = true;
        }
        if (!$no_flag and $start_flag) {
            $query .= ') ';
            $no_flag = false;
        }
    }
    // categories
    if (!is_array($stories_cat)) {
        $stories_cat[0] = '';
    }
    if (isset($stories_cat[0]) && !empty($stories_cat[0])) {
        if (!$no_flag) {
            $query .= ' AND (';
        }
        $flag = false;
        foreach ($stories_cat as $v) {
            if ($flag) {
                $query .= ' OR ';
            }
            $query .= "{$stcatcol['catid']}='" . pnVarPrepForStore($v) . "'";
            $flag = true;
        }
        if (!$no_flag) {
            $query .= ') ';
            $no_flag = false;
        }
    }
    // authors
    if (isset($stories_author) && $stories_author != '') {
        if (!$no_flag) {
            $query .= ' AND (';
        }
        $query .= "{$storcol['informant']}='" . pnVarPrepForStore($stories_author) . "'";
        $result =& $dbconn->Execute("SELECT {$pntable['users_column']['uid']} as pn_uid FROM {$pntable['users']} WHERE {$pntable['users_column']['uname']} LIKE '%" . pnVarPrepForStore($stories_author) . "%' OR {$pntable['users_column']['name']} LIKE '%" . pnVarPrepForStore($stories_author) . "%'");
        while (!$result->EOF) {
            $row = $result->GetRowAssoc(false);
            $query .= " OR {$storcol['aid']}={$row['pn_uid']}";
            $result->MoveNext();
        }
        if (!$no_flag) {
            $query .= ') ';
            $no_flag = false;
        }
    } else {
        $stories_author = '';
    }
    if (pnConfigGetVar('multilingual') == 1) {
        if (!empty($query)) {
            $query .= ' AND';
        }
        $query .= " ({$storcol['alanguage']}='" . pnVarPrepForStore(pnUserGetLang()) . "' OR {$storcol['alanguage']}='')";
    }
    if (empty($query)) {
        $query = '1';
    }
    $query .= " ORDER BY {$storcol['time']} DESC";
    $query = $query1 . $query;
    // get the total count with permissions!
    if (empty($total)) {
        $total = 0;
        $countres =& $dbconn->Execute($query);
        // check for a db error
        if ($dbconn->ErrorNo() != 0) {
            return;
        }
        while (!$countres->EOF) {
            $row = $countres->GetRowAssoc(false);
            if (pnSecAuthAction(0, 'Stories::Story', "{$row['aid']}:{$row['cat_title']}:{$row['sid']}", ACCESS_READ) && pnSecAuthAction(0, 'Topics::Topic', "{$row['topicname']}::{$row['topicid']}", ACCESS_READ)) {
                $total++;
            }
            $countres->MoveNext();
        }
    }
    $result = $dbconn->SelectLimit($query, 10, $startnum - 1);
    // check for a db error
    if ($dbconn->ErrorNo() != 0) {
        return;
    }
    if (!$result->EOF) {
        $output->Text(_STORIES_TOPICS . ': ' . $total . ' ' . _SEARCHRESULTS);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        // Rebuild the search string from previous information
        $url = 'index.php?name=Search&amp;action=search&amp;active_stories=1&amp;stories_author=' . pnVarPrepForDisplay($stories_author);
        if (isset($stories_cat) && $stories_cat) {
            foreach ($stories_cat as $v) {
                $url .= "&amp;stories_cat%5B%5D={$v}";
            }
        }
        if (isset($stories_topics) && $stories_topics) {
            foreach ($stories_topics as $v) {
                $url .= "&amp;stories_topics%5B%5D={$v}";
            }
        }
        $url .= '&amp;bool=' . pnVarPrepForDisplay($bool);
        if (isset($q)) {
            $url .= '&amp;q=' . pnVarPrepForDisplay($q);
        }
        $output->Text('<dl>');
        while (!$result->EOF) {
            $row = $result->GetRowAssoc(false);
            if (pnSecAuthAction(0, 'Stories::Story', "{$row['aid']}:{$row['cat_title']}:{$row['sid']}", ACCESS_READ) && pnSecAuthAction(0, 'Topics::Topic', "{$row['topicname']}::{$row['topicid']}", ACCESS_READ)) {
                $row['fdate'] = ml_ftime(_DATELONG, $result->UnixTimeStamp($row['fdate']));
                $output->Text('<dt><a href="index.php?name=News&amp;file=article&amp;sid=' . pnVarPrepForDisplay($row['sid']) . '">' . pnVarPrepHTMLDisplay($row['story_title']) . '</a></dt>');
                $output->Text('<dd>');
                $output->Text(pnVarPrepForDisplay($row['fdate']) . ' (');
                if (!empty($row['topicid'])) {
                    $output->Text($row['topictext']);
                }
                if (!empty($row['catid'])) {
                    $output->Text(' - ' . pnVarPrepHTMLDisplay($row['cat_title']));
                }
                $output->Text(')</dd>');
            }
            $result->MoveNext();
        }
        $output->Text('</dl>');
        // Munge URL for template
        $urltemplate = $url . "&amp;startnum=%%&amp;total={$total}";
        $output->Pager($startnum, $total, $urltemplate, 10);
    } else {
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(_SEARCH_NO_STORIES_TOPICS);
        $output->SetInputMode(_PNH_PARSEINPUT);
    }
    $output->Linebreak(3);
    return $output->GetOutput();
}
Ejemplo n.º 17
0
/**
 * carry out hook operations for module
 * @param hookobject the object the hook is called for - either 'item' or 'category'
 * @param hookaction the action the hook is called for - one of 'create', 'delete', 'transform', or 'display'
 * @param hookid the id of the object the hook is called for (module-specific)
 * @param extrainfo extra information for the hook, dependent on hookaction
 * @returns string
 * @return output from hooks
 */
function pnModCallHooks($hookobject, $hookaction, $hookid, $extrainfo)
{
    // Get database info
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $hookstable = $pntable['hooks'];
    $hookscolumn =& $pntable['hooks_column'];
    // Get applicable hooks
    $sql = "SELECT {$hookscolumn['tarea']},\n                   {$hookscolumn['tmodule']},\n                   {$hookscolumn['ttype']},\n                   {$hookscolumn['tfunc']}\n            FROM {$hookstable}\n            WHERE {$hookscolumn['smodule']} = '" . pnVarPrepForStore(pnModGetName()) . "'\n            AND {$hookscolumn['object']} = '" . pnVarPrepForStore($hookobject) . "'\n            AND {$hookscolumn['action']} = '" . pnVarPrepForStore($hookaction) . "'";
    $result = $dbconn->Execute($sql);
    if ($dbconn->ErrorNo() != 0) {
        return null;
    }
    $output = '';
    // Call each hook
    for (; !$result->EOF; $result->MoveNext()) {
        list($hookarea, $hookmodule, $hooktype, $hookfunc) = $result->fields;
        if ($hookarea == 'GUI') {
            if (pnModAvailable($hookmodule, $hooktype) && pnModLoad($hookmodule, $hooktype)) {
                $output .= pnModFunc($hookmodule, $hooktype, $hookfunc, array('objectid' => $hookid, 'extrainfo' => $extrainfo));
            }
        } else {
            if (pnModAvailable($hookmodule, $hooktype) && pnModAPILoad($hookmodule, $hooktype)) {
                $extrainfo = pnModAPIFunc($hookmodule, $hooktype, $hookfunc, array('objectid' => $hookid, 'extrainfo' => $extrainfo));
            }
        }
    }
    if ($hookaction == 'display') {
        return $output;
    } else {
        return $extrainfo;
    }
}
Ejemplo n.º 18
0
function search_sections()
{
    list($active_sections, $startnum, $total, $bool, $q) = pnVarCleanFromInput('active_sections', 'startnum', 'total', 'bool', 'q');
    if (empty($active_sections)) {
        return;
    }
    if (!pnModAvailable('Sections')) {
        return;
    }
    $dbconn =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();
    $output =& new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    if (!isset($startnum) || !is_numeric($startnum)) {
        $startnum = 1;
    }
    if (isset($total) && !is_numeric($total)) {
        unset($total);
    }
    $w = search_split_query($q);
    $flag = false;
    $seccol =& $pntable['seccont_column'];
    $query = "SELECT {$seccol['artid']} as id, {$seccol['title']} as title, {$seccol['secid']} as secid, {$seccol['content']} as content\n              FROM {$pntable['seccont']}\n              WHERE \n";
    foreach ($w as $word) {
        if ($flag) {
            switch ($bool) {
                case 'AND':
                    $query .= ' AND ';
                    break;
                case 'OR':
                default:
                    $query .= ' OR ';
                    break;
            }
        }
        $query .= '(';
        $query .= "{$seccol['title']} LIKE '" . pnVarPrepForStore($word) . "' OR \n";
        $query .= "{$seccol['content']} LIKE '" . pnVarPrepForStore($word) . "')\n";
        $flag = true;
    }
    if (pnConfigGetVar('multilingual') == 1) {
        $query .= " AND ({$seccol['slanguage']}='" . pnVarPrepForStore(pnUserGetLang()) . "' OR {$seccol['slanguage']}='')";
    }
    $query .= " ORDER BY {$seccol['artid']}";
    // get the total count with permissions!
    if (empty($total)) {
        $total = 0;
        $countres =& $dbconn->Execute($query);
        // check for a db error
        if ($dbconn->ErrorNo() != 0) {
            return;
        }
        while (!$countres->EOF) {
            $row = $countres->GetRowAssoc(false);
            // we know about the section id so let's get the section name
            $column2 =& $pntable['sections_column'];
            $result2 =& $dbconn->Execute("SELECT {$column2['secname']} FROM {$pntable['sections']} WHERE {$column2['secid']}={$row['secid']}");
            list($secname) = $result2->fields;
            if (pnSecAuthAction(0, "Sections::Section", "{$secname}::{$row['secid']}", ACCESS_READ) && pnSecAuthAction(0, "Sections::Article", "{$row['title']}:{$secname}:{$row['id']}", ACCESS_READ)) {
                $total++;
            }
            $countres->MoveNext();
        }
    }
    $result = $dbconn->SelectLimit($query, 10, $startnum - 1);
    // check for a db error
    if ($dbconn->ErrorNo() != 0) {
        return;
    }
    if (!$result->EOF) {
        $output->Text(_SECTIONS . ': ' . $total . ' ' . _SEARCHRESULTS);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        // Rebuild the search string from previous information
        $url = "index.php?name=Search&amp;action=search&amp;active_sections=1&amp;bool={$bool}&amp;q={$q}";
        $output->Text('<dl>');
        while (!$result->EOF) {
            $row = $result->GetRowAssoc(false);
            // we know about the section id so let's get the section name
            $column2 =& $pntable['sections_column'];
            $result2 =& $dbconn->Execute("SELECT {$column2['secname']} FROM {$pntable['sections']} WHERE {$column2['secid']}={$row['secid']}");
            list($secname) = $result2->fields;
            if (pnSecAuthAction(0, "Sections::Section", "{$secname}::{$row['secid']}", ACCESS_READ) && pnSecAuthAction(0, "Sections::Article", "{$row['title']}:{$secname}:{$row['id']}", ACCESS_READ)) {
                $row['content'] = strip_tags($row['content']);
                if (strlen($row['content']) > 128) {
                    $row['content'] = substr($row['content'], 0, 125) . '...';
                }
                $output->Text("<dt><a href=\"index.php?name=Sections&amp;req=viewarticle&amp;artid={$row['id']}\">" . pnVarPrepForDisplay($row[title]) . "</a></dt>");
                $output->Text("<dd>" . pnVarPrepForDisplay($row[content]) . "</dd>");
            }
            $result->MoveNext();
        }
        $output->Text('</dl>');
        // Munge URL for template
        $urltemplate = $url . "&amp;startnum=%%&amp;total={$total}";
        $output->Pager($startnum, $total, $urltemplate, 10);
    } else {
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(_SEARCH_NO_SECTIONS);
        $output->SetInputMode(_PNH_PARSEINPUT);
    }
    $output->Linebreak(3);
    return $output->GetOutput();
}
Ejemplo n.º 19
0
    if (empty($module)) {
        $module = $name;
    }
}
// get module information
$modinfo = pnModGetInfo(pnModGetIDFromName($module));
if ($modinfo['type'] == 2) {
    // New-new style of loading modules
    if (empty($type)) {
        $type = 'user';
    }
    if (empty($func)) {
        $func = "main";
    }
    // it should be $module not $name [class007]
    if (pnModAvailable($module)) {
        if (pnModLoad($module, $type)) {
            // Run the function
            $return = pnModFunc($module, $type, $func);
        } else {
            $return = false;
        }
    } else {
        $return = false;
    }
    // Sort out return of function.  Can be
    // true - finished
    // false - display error msg
    // text - return information
    if (empty($return) || $return == false) {
        // Failed to load the module
Ejemplo n.º 20
0
function user_user_main($var)
{
    include 'header.php';
    user_menu_draw();
    if (pnUserLoggedIn()) {
        $uname = pnUserGetVar('uname');
        if (pnModAvailable('Comments')) {
            user_main_last10com($uname);
        }
        if (pnModAvailable('News')) {
            user_main_last10submit($uname);
        }
        include 'footer.php';
    }
    // ?else
}
Ejemplo n.º 21
0
function blocks_online_block($row)
{
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    if (!pnSecAuthAction(0, 'Onlineblock::', "{$row['title']}::", ACCESS_READ)) {
        return;
    }
    $sessioninfocolumn =& $pntable['session_info_column'];
    $sessioninfotable = $pntable['session_info'];
    $sessioninfocolumn =& $pntable['session_info_column'];
    $sessioninfotable = $pntable['session_info'];
    $activetime = time() - pnConfigGetVar('secinactivemins') * 60;
    $query = "SELECT count( 1 )\n             FROM {$sessioninfotable}\n             WHERE {$sessioninfocolumn['lastused']} > {$activetime} AND {$sessioninfocolumn['uid']} >0\n\t\t  GROUP BY {$sessioninfocolumn['uid']}\n\t\t ";
    $result = $dbconn->Execute($query);
    $numusers = $result->RecordCount();
    $result->Close();
    $query2 = "SELECT count( 1 )\n             FROM {$sessioninfotable}\n              WHERE {$sessioninfocolumn['lastused']} > {$activetime} AND {$sessioninfocolumn['uid']} = '0'\n\t\t\t  GROUP BY {$sessioninfocolumn['ipaddr']}\n\t\t\t ";
    $result2 = $dbconn->Execute($query2);
    $numguests = $result2->RecordCount();
    $result2->Close();
    // Pluralise
    if ($numguests == 1) {
        $guests = _GUEST;
    } else {
        $guests = _GUESTS;
    }
    if ($numusers == 1) {
        $users = _MEMBER;
    } else {
        $users = _MEMBERS;
    }
    $content = "<span class=\"pn-normal\">" . _CURRENTLY . " " . pnVarPrepForDisplay($numguests) . " " . pnVarPrepForDisplay($guests) . " " . _AND . " " . pnVarPrepForDisplay($numusers) . " " . pnVarPrepForDisplay($users) . " " . _ONLINE . "<br />\n";
    if (pnUserLoggedIn()) {
        $content .= '<br />' . _YOUARELOGGED . ' <b>' . pnUserGetVar('uname') . '</b>.<br />';
        if (pnModAvailable('Messages')) {
            // display private messages only when module is active
            $column =& $pntable['priv_msgs_column'];
            $result2 = $dbconn->Execute("SELECT count(*) FROM {$pntable['priv_msgs']} WHERE {$column['to_userid']}=" . pnUserGetVar('uid'));
            list($numrow) = $result2->fields;
            // get unread messages
            $result3 = $dbconn->Execute("SELECT count(*) FROM {$pntable['priv_msgs']} WHERE {$column['to_userid']}=" . pnUserGetVar('uid') . " AND {$column['read_msg']}='0'");
            list($unreadrow) = $result3->fields;
            if ($numrow == 0) {
                $content .= '<br /></span>';
            } else {
                $content .= "<br />" . _YOUHAVE . " (<a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=Messages&amp;file=index\" title=\"" . _PRIVATEMSGS . "\">" . pnVarPrepForDisplay($numrow) . "</a>|<a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=Messages&amp;file=index\" title=\"" . _PRIVATEMSGNEW . "\">" . pnVarPrepForDisplay($unreadrow) . "</a>) ";
                if ($numrow == 1) {
                    $content .= _PRIVATEMSG;
                } elseif ($numrow > 1) {
                    $content .= _PRIVATEMSGS;
                }
                $content .= "</span><br />";
            }
        }
    } else {
        $content .= '<br />' . _YOUAREANON . '</span><br />';
    }
    if (empty($row['title'])) {
        $row['title'] = _WHOSONLINE;
    }
    $row['content'] = $content;
    return themesideblock($row);
}
Ejemplo n.º 22
0
/**
 * Clear render cached templates
 *
 * removed since version 1.3.0 of Zikula
 * @deprecated
 * @see Zikula_View::clear_cache()
 * @param module the module where to clear the cache, emptys = clear all caches
 * @return true or false
 */
function theme_userapi_render_clear_cache($args)
{
    // Security check
    if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerPermissionError();
    }

    LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array('theme_userapi_render_clear_cache', 'Zikula_View::clear_cache()')), E_USER_DEPRECATED);
    if(isset($args['module']) && !empty($args['module']) && pnModAvailable($args['module'])) {
        $view = Zikula_View::getInstance($args['module']);
        $res      = $view->clear_cache();
    } else {
        $renderer = Zikula_View::getInstance();
        $res      = $view->clear_all_cache();
    }

    return $res;
}