/** * Function to display banners in all pages */ function pnBannerDisplay($type = 0) { // test on config settings if (pnConfigGetVar('banners') != 1) { return ' '; } // added check for numeric type - markwest if (!is_numeric($type)) { return ' '; } list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); $column =& $pntable['banner_column']; $bresult = $dbconn->Execute("SELECT count(*) AS count FROM {$pntable['banner']}\n\t\t\t\t\t\t\t\tWHERE {$column['type']} = {$type}"); list($numrows) = $bresult->fields; // we no longer need this, free the resources $bresult->Close(); /* Get a random banner if exist any. */ /* More efficient random stuff, thanks to Cristian Arroyo from http://www.planetalinux.com.ar */ if ($numrows > 1) { $numrows = $numrows - 1; mt_srand((double) microtime() * 1000000); $bannum = mt_rand(0, $numrows); } else { $bannum = 0; } $column =& $pntable['banner_column']; $query = buildSimpleQuery('banner', array('bid', 'imageurl', 'clickurl'), "{$column['type']} = {$type}", '', 1, $bannum); $bresult2 = $dbconn->Execute($query); list($bid, $imageurl, $clickurl) = $bresult2->fields; // we no longer need this, free the resources $bresult2->Close(); $myIP = pnConfigGetVar('myIP'); $myhost = getenv("REMOTE_ADDR"); if ($myIP == $myhost) { // do nothing } else { $dbconn->Execute("UPDATE {$pntable['banner']}\n SET {$column['impmade']}={$column['impmade']}+1\n WHERE {$column['bid']}=" . pnVarPrepForStore($bid) . ""); } if ($numrows > 0) { $aborrar = $dbconn->Execute("SELECT {$column['cid']},{$column['imptotal']},\n {$column['impmade']}, {$column['clicks']},\n {$column['date']}\n FROM {$pntable['banner']}\n WHERE {$column['bid']}=" . pnVarPrepForStore($bid) . ""); list($cid, $imptotal, $impmade, $clicks, $date) = $aborrar->fields; $aborrar->Close(); /* Check if this impression is the last one and print the banner */ if ($imptotal == $impmade) { $column =& $pntable['bannerfinish_column']; $dbconn->Execute("INSERT INTO {$pntable['bannerfinish']}\n ( {$column['bid']}, {$column['cid']}, {$column['impressions']}, {$column['clicks']}, {$column['datestart']}, {$column['dateend']} )\n VALUES (NULL, '" . pnVarPrepForStore($cid) . "', '" . pnVarPrepForStore($impmade) . "', '" . pnVarPrepForStore($clicks) . "', '" . pnVarPrepForStore($date) . "', now())"); $dbconn->Execute("DELETE FROM {$pntable['banner']} WHERE {$column['bid']}=" . pnVarPrepForStore($bid) . ""); } if ($type == 1 or $type == 2 or $type == 0) { echo "<a href=\"banners.php?op=click&bid={$bid}\" target=\"_blank\" title=\"{$clickurl}\"><img src=\"{$imageurl}\" border=\"0\" alt=\"" . _CLICK . "\"></a>"; } else { $content = "<a href=\"banners.php?op=click&bid={$bid}\" target=\"_blank\" title=\"{$clickurl}\"><img src=\"{$imageurl}\" border=\"0\" alt=\"" . _CLICK . "\"></a>"; return $content; } } }
function admin_main_poll() { list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); $column =& $pntable['poll_desc_column']; $myquery = buildSimpleQuery('poll_desc', array('polltitle', 'pollid'), language_sql('p'), "{$column['pollid']} DESC", 1); $result = $dbconn->Execute($myquery); list($pollTitle, $pid) = $result->fields; if (pnSecAuthAction(0, 'Polls::', "{$pollTitle}::{$pid}", ACCESS_EDIT)) { OpenTable(); echo "<center><font class=\"pn-normal\">" . _CURRENTPOLL . ": " . pnVarPrepForDisplay($pollTitle) . "</font></center>"; CloseTable(); } }
function PrintPage($sid) { list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); // grab the actual story from the database $column =& $pntable['stories_column']; $result = $dbconn->Execute("SELECT {$column['title']},\n {$column['time']},\n {$column['hometext']},\n {$column['bodytext']},\n {$column['topic']},\n {$column['notes']},\n {$column['cid']},\n {$column['aid']}\n FROM {$pntable['stories']} where {$column['sid']} = '" . pnVarPrepForStore($sid) . "'"); list($title, $time, $hometext, $bodytext, $topic, $notes, $cid, $aid) = $result->fields; if (!isset($title) || $title == '') { include 'header.php'; echo _DBSELECTERROR; include 'footer.php'; exit; } if ($dbconn->ErrorNo() != 0) { include 'header.php'; echo _DBSELECTERROR; include 'footer.php'; exit; } // Get data for "autorise check" // Just a temp. solution; // Print.php needs completely redesign by using getArticles() and genArticleInfo() // fix for Stories::Story, Topics::Topic [larsneo] // find out the cattitle if ($cid == 0) { // Default category $cattitle = "" . _ARTICLES . ""; } else { $catcolumn =& $pntable['stories_cat_column']; $catquery = buildSimpleQuery('stories_cat', array('title'), "{$catcolumn['catid']} = {$cid}"); $catresult = $dbconn->Execute($catquery); list($cattitle) = $catresult->fields; } // find out the topictext $topicscolumn =& $pntable['topics_column']; $topicquery = buildSimpleQuery('topics', array('topictext', 'topicname'), "{$topicscolumn['topicid']} = {$topic}"); $topicresult = $dbconn->Execute($topicquery); list($topictext, $topicname) = $topicresult->fields; if (pnSecAuthAction(0, 'Stories::Story', "{$aid}:{$cattitle}:{$sid}", ACCESS_READ) && pnSecAuthAction(0, 'Topics::Topic', "{$topicname}::{$topic}", ACCESS_READ)) { // user is authorised to view Stories::Story and Topics::Topic // Increment the read counter $column =& $pntable['stories_column']; $dbconn->Execute("UPDATE {$pntable['stories']} SET {$column['counter']}={$column['counter']}+1 WHERE {$column['sid']}='" . pnVarPrepForStore($sid) . "'"); $time = $result->UnixTimeStamp($time); $cWhereIsPerso = WHERE_IS_PERSO; if (!empty($cWhereIsPerso)) { include "modules/NS-Multisites/print.inc.php"; } else { $themesarein = ""; $ThemeSel = pnUserGetTheme(); } /* with this code there's no output if wiki is removed [larsneo] pnModAPILoad('Wiki', 'user'); list($title, $hometext, $bodytext, $notes) = pnModAPIFunc('wiki', 'user', 'transform', array('objectid' => $sid, 'extrainfo' => array($title, $hometext, $bodytext, $notes))); */ // call hooks list($title, $hometext, $bodytext, $notes) = pnModCallHooks('item', 'transform', '', array($title, $hometext, $bodytext, $notes)); echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" . "<html>\n" . "<head><title>" . pnConfigGetVar('sitename') . "</title>\n"; if (defined("_CHARSET") && _CHARSET != "") { echo "<META HTTP-EQUIV=\"Content-Type\" " . "CONTENT=\"text/html; charset=" . _CHARSET . "\">\n"; } //changed to local stylesheet //echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"".$themesarein."themes/$ThemeSel/style/style.css\">"; echo "<style type=\"text/css\">\n" . "<!--\n" . ".print-title {\n" . "background-color: transparent;\n" . "color: #990000;\n" . "font-family: Verdana, Arial, sans-serif;\n" . "font-size: 14px;\n" . "font-weight: bold;\n" . "text-decoration: none;\n" . "}\n" . ".print-sub {\n" . "background-color: transparent;\n" . "color: #000000;\n" . "font-family: Verdana, Arial, sans-serif;\n" . "font-size: 11px;\n" . "font-weight: normal;\n" . "text-decoration: none;\n" . "}\n" . ".print-normal {\n" . "background-color: transparent;\n" . "color: #000000;\n" . "font-family: Verdana, Arial, sans-serif;\n" . "font-size: 12px;\n" . "font-weight: normal;\n" . "text-decoration: none;\n" . "}\n" . ".print {\n" . "color: #000000;\n" . "background-color: #FFFFFF;\n" . "}\n" . "-->\n" . "</style>\n"; echo "</head>\n" . "<body class=\"print\" bgcolor=\"#FFFFFF\" text=\"#000000\">\n" . "\n<table border=\"0\" width=\"85%\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#FFFFFF\">\n" . "<tr><td>\n" . "<table border=\"0\" width=\"100%\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#FFFFFF\">\n" . "<tr><td>\n" . "<img src=\"" . WHERE_IS_PERSO . "images/" . pnConfigGetVar('site_logo') . "\" border=\"0\" alt=\"" . pnConfigGetVar('sitename') . "\">\n" . "<br /><br />\n" . "<b><font class=\"print-title\">" . pnVarPrepHTMLDisplay($title) . "</font></b><br /><br />\n" . "<font class=\"print-sub\">" . pnVarPrepHTMLDisplay($cattitle) . " / " . pnVarPrepHTMLDisplay($topictext) . "<br />\n" . "<b>" . _DATE . ":</b> " . ml_ftime(_DATETIMEBRIEF, $time) . "</font>\n" . "</td></tr>\n" . "<tr><td>\n" . "<font class=\"print-normal\">" . pnVarPrepHTMLDisplay($hometext) . "<br /><br />\n"; if (!empty($bodytext)) { echo pnVarPrepHTMLDisplay($bodytext) . "<br />\n"; } if (!empty($notes)) { echo pnVarPrepHTMLDisplay($notes) . "<br />\n"; } else { echo "<br />\n"; } echo "</font>\n" . "</td></tr>\n" . "<tr><td>\n" . "<hr size=\"1\"><font class=\"print-normal\">\n" . "" . _COMESFROM . " " . pnConfigGetVar('sitename') . "<br />\n" . "<a class=\"print-normal\" href=\"" . pnGetBaseURL() . "\">" . pnGetBaseURL() . "</a>\n" . "<br /><br />\n" . "" . _THEURL . "" . "<br />\n" . "<a class=\"print-normal\" href=\"" . pnGetBaseURL() . "modules.php?op=modload&name=News&file=article&sid={$sid}\">" . pnGetBaseURL() . "modules.php?op=modload&name=News&file=article&sid={$sid}" . "</a>\n" . "</font>\n" . "</td></tr>\n" . "</table>\n</td></tr>\n</table>\n" . "</body>\n" . "</html>\n"; } else { // user is not authorised to view Stories::Story and Topics::Topic include 'header.php'; echo _BADAUTHKEY; include 'footer.php'; exit; } }