예제 #1
0
/** Connect to Database
 * @return    object ADONewConnection    ADODB db handle
 */
function dbconnect($dbhost, $dbuname, $dbpass, $dbname, $dbtype = 'mysql')
{
    $connectString = "{$dbtype}://{$dbuname}:{$dbpass}@{$dbhost}/{$dbname}";
    global $ADODB_FETCH_MODE;
    $dbconn =& ADONewConnection($dbtype);
    $dbh = $dbconn->Connect($dbhost, $dbuname, $dbpass, $dbname);
    $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
    // if we get an error, log it and die
    if ($dbh === false) {
        error_log("connect string: {$connectString}");
        error_log("error: " . $dbconn->ErrorMsg());
        // show error and die
        PN_DBMsgError($dbconn, __FILE__, __LINE__, "Error connecting to db");
    } else {
        return $dbconn;
    }
}
예제 #2
0
function httpreferer()
{
    global $HTTP_SERVER_VARS;
    /*** 
     * Here we set up some variables for the rest of the script. 
     * if you want to see whats going on, set $DEBUG to 1 
     * I use $HTTP_HOST here because i dont want to deal with the need to have 
     * to see if $nuke_url is set correctly and whatnot. if you prefer to use 
     * $nuke_url isntead of HTTP_HOST, just uncomment the appropriate lines. 
     */
    $DEBUG = 0;
    $HTTP_REFERER = getenv('HTTP_REFERER');
    $HTTP_HOST = getenv('HTTP_HOST');
    // nkame: PWS/IIS doesn't put those variables in the environment
    if (empty($HTTP_HOST)) {
        $HTTP_HOST = 'http://' . $HTTP_SERVER_VARS['HTTP_HOST'];
        $HTTP_REFERER = $HTTP_SERVER_VARS['HTTP_REFERER'];
    }
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    if ($DEBUG == 1) {
        echo "HTTP_HOST = " . $HTTP_HOST . "<br> HTTP_REFERER = " . $HTTP_REFERER . "<br>";
    }
    /*** 
     * This is the first thing we need to check. what this does is see if  
     * HTTP_HOST is anywhere in HTTP_REFERER. This is so we dont log hits coming 
     * from our own domain. 
     */
    if (!ereg("{$HTTP_HOST}", $HTTP_REFERER)) {
        /*** 
         * If $HTTP_REFERER is not set, set $HTTP_REFERER to value "bookmark" 
         * This is to show how many people have this bookmarked or type in the 
         * URL into the browser. also so we dont have empty referers. 
         */
        if ($HTTP_REFERER == "") {
            $HTTP_REFERER = "bookmark";
        }
        // grab a reference to our table column defs for easier reading below
        $column =& $pntable['referer_column'];
        /*** 
         * Lets select from the table where we have $HTTP_REFERER (whether it be 
         * a valid referer or 'bookmark'. if we return 1 row, that means someones 
         * used this referer before and update the set appropriatly.  
         * 
         * If we dont have any rows (it returns 0), we have a new entry in the 
         * table, update accordingly. 
         * 
         * After we figure out what SQL statement we are using, lets perform the 
         * query and we're done ! 
         */
        $check_sql = "SELECT count({$column['rid']}) as c \n                      FROM {$pntable['referer']} \n                      WHERE {$column['url']} = '" . $HTTP_REFERER . "'";
        $result = $dbconn->Execute($check_sql);
        if ($result === false) {
            PN_DBMsgError($dbconn, __FILE__, __LINE__, "Error accesing to the database");
        }
        $row = $result->fields;
        $count = $row[0];
        if ($count == 1) {
            $update_sql = "UPDATE {$pntable['referer']}\n                           SET {$column['frequency']} = {$column['frequency']} + 1\n                           WHERE {$column['url']} = '" . $HTTP_REFERER . "'";
        } else {
            /***
             * "auto-increment" isn't portable so we have to use the standard
             * interface for grabbing sequence numbers.  The underlying
             * implementation handles the correct method for the RDBMS we are
             * using.
             */
            $rid = $dbconn->GenId($pntable['referer'], true);
            $update_sql = "INSERT INTO {$pntable['referer']}\n                             ({$column['rid']},\n                              {$column['url']},\n                              {$column['frequency']})\n                           VALUES\n                             (" . pnVarPrepForStore($rid) . ",\n                              '" . pnVarPrepForStore($HTTP_REFERER) . "',\n                              1)";
        }
        $result = $dbconn->Execute($update_sql);
        if ($result === false) {
            error_log("error in referer.php, " . __LINE__ . ", sql='{$update_sql}'");
            PN_DBMsgError($dbconn, __FILE__, __LINE__, "Error accesing to the database");
        }
        if ($DEBUG == 1) {
            echo "<br>" . $check_sql . "<br>" . $update_sql . "<br>";
        }
    }
}
예제 #3
0
function print_details()
{
    /* show error page */
    // Request access to the global variables we need
    global $fontface, $fontsize, $docroot, $REQUEST_URI, $PHP_SELF;
    global $bgcolor, $textcolor;
    global $currentlang;
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $sitename = pnConfigGetVar('sitename');
    $reportlevel = pnConfigGetVar('reportlevel');
    $funtext = pnConfigGetVar('funtext');
    $top = pnConfigGetVar('top');
    if (pnConfigGetVar('multilingual') == 1) {
        $queryalang = "WHERE (alanguage='{$currentlang}' OR alanguage='')";
        /* top stories */
    } else {
        $queryalang = "";
    }
    global $HTTP_SERVER_VARS;
    global $doc;
    $doc = getenv('REDIRECT_URL');
    if (empty($HTTP_SERVER_VARS['HTTP_HOST'])) {
        $server = getenv('HTTP_HOST');
    } else {
        $server = $HTTP_SERVER_VARS['HTTP_HOST'];
    }
    $doc = "http://{$server}{$doc}";
    include "header.php";
    OpenTable();
    ?>
<a class="pn-logo"><?php 
    echo "" . _ERR404 . "";
    ?>
</a><br>
<font class="pn-logo-small"><?php 
    echo "" . _ERRPAGENF . "&nbsp;";
    echo $doc;
    ?>
 </font><hr>
<?php 
    echo "<font class=\"pn-normal\">" . _ERRSORRY . ", {$doc}, ";
    echo "" . _ERRDOESNTEXIST . " \" {$sitename} \"<P></font>";
    if ($reportlevel != 0) {
        echo "<p><font style=\"pn-normal\">";
        echo "" . _ERRMAILED . "";
    }
    if ($funtext != 0) {
        fun();
    }
    ?>
<br><p>
<a class="pn-storytitle"><?php 
    echo "" . _ERRCOMMONM . "";
    ?>
</a><br>
<font class="pn-normal"><?php 
    echo "" . _ERRCOMMONH . "";
    ?>
 <?php 
    echo "{$sitename}";
    ?>
:
<UL>
<LI><?php 
    echo "" . _ERRURLEND . "";
    ?>
 <CODE>.htm</CODE> - <STRONG><?php 
    echo "" . _ERRALLPAGES . " \"{$sitename}\" " . _ERRENDWITH . "";
    ?>
 <CODE>.php</CODE></STRONG>
<LI><?php 
    echo "" . _ERRUPPERCASE . "";
    ?>
 - <STRONG><?php 
    echo "" . _ERRALLLOWER . "";
    ?>
</STRONG>
</UL></font></p>
<a class="pn-storytitle"><?php 
    echo "" . _ERRPOPPAGES . "";
    ?>
</a><br>
<?php 
    /***
     * fifers: don't know what the $alanguage does here.  left it in
     * because it always seems to be empty and I wasn't sure what it
     * was doing!
     */
    $column =& $pntable['stories_column'];
    $sql = "SELECT {$column['sid']}, {$column['title']}, {$column['time']}, {$column['counter']} FROM {$pntable['stories']} ORDER BY {$column['counter']} DESC";
    $result = $dbconn->SelectLimit($sql, $top);
    if ($result === false) {
        PN_DBMsgError($dbconn, __FILE__, __LINE__, "Error");
    }
    if (!$result->EOF) {
        echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n" . "<font class=\"pn-title\">{$top} " . _READSTORIES . "</font><br><br>\n";
        $lugar = 1;
        while (list($sid, $title, $time, $counter) = $result->fields) {
            if ($counter > 0) {
                $mode = pnUserGetVar('umode');
                if (!empty($mode)) {
                    $commentlink = "&amp;mode={$mode}";
                } else {
                    $commentlink = '&amp;mode=thread';
                }
                echo "<font class=\"pn-normal\">&nbsp;{$lugar}:</font> <a href=\"modules.php?op=modload&amp;name=News&amp;file=article&amp;sid={$sid}{$commentlink}\">{$title}</a><font class=\"pn-normal\"> - ({$counter} " . _READS . ")</font><br>\n";
                $lugar++;
            }
            $result->MoveNext();
        }
        echo "</td></tr></table><br>\n";
    }
    ?>
</font><br>
<a class="pn-storytitle"><?php 
    echo "" . _ERRTRYHOME . "";
    ?>
</a></br>
<font class="pn-normal"><?php 
    echo "" . _ERRSTARTHERE . "";
    ?>
 <A HREF="/"> <?php 
    echo "{$sitename}</a> " . _ERRHP;
    ?>
.</font>
<p>
<a class="pn-storytitle"><?php 
    echo "" . _SEARCH . "";
    ?>
</a></br>
<font class="pn-normal"><?php 
    echo "" . _ERRFOPTION . "";
    ?>
.
<CENTER><form action="modules.php" method=post>
<!-- Credit to Mayday (mayday6971) for fix -->
<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="">
<input type="hidden" name="op" value="modload">
<input type="hidden" name="name" value="Search">
<input type="hidden" name="file" value="index">
<input type="hidden" name="action" value="search">
<input type="hidden" name="overview" value="1">
<font size="-1" color="#000000"><br><b>
<?php 
    echo "" . _SEARCH . "";
    ?>
 <?php 
    echo $sitename;
    ?>
</b><br>
<input class="pn-text" type=name name=query size="25"></font></form></CENTER>

<CENTER><form action="modules.php" method=post>
<!-- Credit to Mayday (mayday6971) for fix -->
<input type="hidden" name="active_stories" value="1">
<input type="hidden" name="stories_author" value="">
<input type="hidden" name="bool" value="AND">
<input type="hidden" name="stories_cat" value="">
<input type="hidden" name="q" value=""> 
<input type="hidden" name="op" value="modload">
<input type="hidden" name="name" value="Search">
<input type="hidden" name="file" value="index">
<input type="hidden" name="action" value="search">
<input type="hidden" name="overview" value="1">
<FONT size="-1"><BR><B><?php 
    echo "" . _SEARCH . "";
    ?>
</B><?php 
    echo "" . _TOPIC . "";
    ?>
<BR>
<!-- Topic Selection -->
<?php 
    echo "<select class=\"pn-text\" NAME=\"topic\"onChange='submit()'>";
    $column =& $pntable['topics_column'];
    $query = "SELECT {$column['tid']}, {$column['topictext']}\n          FROM {$pntable['topics']}\n          ORDER BY {$column['topictext']}";
    $toplist = $dbconn->Execute($query);
    echo "<option value=\"\">" . _SELECTTOPIC . "</option>\n";
    while (list($topicid, $topics) = $toplist->fields) {
        $toplist->MoveNext();
        if ($topicid == $topic) {
            $sel = "selected ";
        }
        echo "<option {$sel} value=\"{$topicid}\">{$topics}</option>\n";
        $sel = "";
    }
    echo "</select>";
    ?>
 </FONT></FORM></CENTER>
</p>
<a href="#" onload="type_text()"></a>
<?php 
    CloseTable();
    include "footer.php";
}
예제 #4
0
function checkuserblock($row)
{
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    if (!isset($row['bid'])) {
        $row['bid'] = '';
    }
    if (pnUserLoggedIn()) {
        $uid = pnUserGetVar('uid');
        $column =& $pntable['userblocks_column'];
        $sql = "SELECT {$column['active']} FROM " . $pntable['userblocks'] . " WHERE " . $column['bid'] . "='" . pnVarPrepForStore($row['bid']) . "' AND " . $column['uid'] . "=" . pnVarPrepForStore($uid);
        $result = $dbconn->Execute($sql);
        if ($result === false) {
            PN_DBMsgError($dbconn, __FILE__, __LINE__, "Error <br>{$sql}");
        }
        if ($result->EOF) {
            $uid = pnVarPrepForStore($uid);
            $row['bid'] = pnVarPrepForStore($row['bid']);
            $sql = "INSERT INTO {$pntable['userblocks']} ({$column['uid']}, {$column['bid']}, {$column['active']}) VALUES (" . pnVarPrepForStore($uid) . ", '{$row['bid']}', '1')";
            $result = $dbconn->Execute($sql);
            if ($result === false) {
                PN_DBMsgError($dbconn, __FILE__, __LINE__, "Error <br>{$sql}");
            }
            return true;
        } else {
            list($active) = $result->fields;
            return $active;
        }
    } else {
        return false;
    }
}