View Single Post
  #1  
Old 03-29-2012, 09:08 PM
S!p S!p is offline
 
Join Date: May 2010
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Error in php block - Server side error.

Hi, when i try to include php file in block i`ll always get error:

Quote:
Server side error. Dying: 1
What`s wrong?

PHP Code:
<?php
/*
 * =============================================================================
 * SourceMod ChatLog v1.2 WebUI Example
 * Reads a chatlog database for sourcemod and prints the sauce, in ajaxxx!
 *
 * (C)2009 Nephyrin@doublezen.net
 * =============================================================================
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 * 
 * 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.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
*/

//
// This is a SIMPLE example. Modify it as you wish. Keep in mind that it is GPL
// Licensed.
//
$START_ROWS 50// How many lines of chat we should display to start.

// $DB_HOST [$DB_PORT] $DB_USER $DB_PASS $DB_DATABASE
$DB_HOST="localhost";
$DB_PORT="3306";
$DB_USER="****";
$DB_PASS="*****";
$DB_DATABASE="****";

// Gives a nicer back-end ID for the javascript.
function cleanId($in)
{
    return 
preg_replace("/[^0-9a-zA-Z]/""_"$in);
}
function 
formatRow($R)
{
    
$class;
    if (
$R['team'] == 3)
        
$class "bluename";
    elseif (
$R['team'] == 2)
        
$class "redname";
    else
        
$class "greyname";

    
$team "";
    
$dead "";
    if (
$R['type'] & 2)
        
$team "[TEAM] ";
    if (
$R['type'] & 1)
        
$dead "<span class=\"deadname\">*DEAD*</span> ";
    
$date date("n/j g:i:sa"$R['date']);
    
$id cleanId($R['srvid']);
    return 
"$id\x01<span class=\"line\"><span class=\"timestamp\">$date </span>$dead<span class=\"$class\">$team$R[name]: </span>$R[text]</span><br />";
}

$SQL = @mysql_connect($DB_PORT "$DB_HOST:$DB_PORT$DB_HOST$DB_USER$DB_PASS);
if (!
$SQL) die("Failed to connect to MySQL Database");
@
mysql_select_db($DB_DATABASE) or die("MySQL Failure: " mysql_error());

if (
$mark $_GET['mark'] + 0):
    if (
$mark == -1)
        
$Q "SELECT name,seqid,type,srvid,team,text,UNIX_TIMESTAMP(`date`) AS `date` FROM `chatlogs` ORDER BY `seqid` DESC LIMIT $START_ROWS";
    else
        
$Q "SELECT name,seqid,type,srvid,team,text,UNIX_TIMESTAMP(`date`) AS `date` FROM `chatlogs` WHERE `seqid` > $mark ORDER BY `seqid` DESC";

    
$Q = @mysql_query($Q$SQL) or die("MySQL Failure: " mysql_error());
    
$ar = array();
    
$R mysql_fetch_array($Q);
    if (!
$R)
    {
        
// No new data, echo same mark back
        
echo($mark);
        exit();
    }
    
$newmark $R['seqid'];
    do
    {
        
array_push($arformatRow($R));
    } while (
$R mysql_fetch_array($Q));
    
array_push($ar$newmark); // Add mark to bottom (top once reversed)
    
$ar array_reverse($ar);// Query selects rows in reverse order, and mark is on bottom
    
echo(implode("\n"$ar));
else:
    
$Q "SELECT DISTINCT `srvid` FROM `chatlogs`";
    
$Q = @mysql_query($Q$SQL) or die("MySQL Failure: " mysql_error());
    
$PB "";
    
$PS "";
    while (
$R mysql_fetch_row($Q))
    {
        
$id cleanId($R[0]);
        
$PB .= "<div class=\"dat\">
                <div class=\"dhead\">Server \"
$R[0]\"</div>
                <div class=\"dbody\" id=\"dbody_
$id\">
                    <div class=\"dtext\" id=\"dat_
$id\"></div>
                    <div id=\"dscrollto_
$id\"></div>
                </div>
            </div>\n"
;
        
$PS .= "srvz.push(\"$id\");\n";
    }
    echo 
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>ChatLog Simple WebUI</title>
        <script type="text/javascript" src="./jquery-1.3.min.js"></script>
        <script type="text/javascript">
            var srvz = new Array();
            var mark = -1;
            var loading = 1;
            <?php echo($PS); ?>
            function dead(wat)
            {
                alert("Server side error. Dying:" + wat);
            }
            function cback(data, textStatus)
            {
                if (textStatus == "success")
                {
                    var lines = data.split("\n");
                    mark = lines[0];
                    if (mark + 0 == 0) die(3);
                    var line;
                    var scrollme = new Array();
                    for(var i = 1; i < lines.length; i++)
                    {
                        line = lines[i].split("\x01");
                        // 0 srvid
                        // 1 string
                        // Formatted serverside
                        if ($("#dscrollto_" + line[0]).offset().top <= $("#dbody_" + line[0]).height() + $("#dbody_" + line[0]).offset().top)
                            if (!scrollme[line[0]]) scrollme[line[0]] = true;
                        if (line.length != 2) return dead("1");
                        var box = $("#dat_" + line[0]);
                        if (!box) return dead("2");
                        if (loading)
                        {
                            box.html(line[1]);
                            loading = 0;
                        }
                        else
                        {
                            box.append(line[1]);
                        }
                        box.children(".line:last").fadeIn(500);
                    }
                    for (var sid in scrollme)
                    {
                        
                        // Scroll it, thanks to learningjquery.com!
                        var divOffset = $("#dbody_" + sid).offset().top;
                        var endOffset = $("#dscrollto_" + sid).offset().top;
                        var Scroll = endOffset - divOffset;
                        $("#dbody_" + sid).animate({scrollTop: '+=' + Scroll + 'px'}, 500);
                    }
                }
                window.setTimeout("proc()", 2000);
            }
            function proc()
            {
                $.get("<?php echo($_SERVER["PHP_SELF"]); ?>?mark=" + mark, cback);
            }
        </script>
        <style>
            body
            {
                background-color: #333;
            }
            .dat
            {
                border: 1px solid #000;
                background-color: #EEE;
                padding: 10px;
                margin: 10px;
                width: 700px;
                margin-left: auto;
                margin-right: auto;
            }
            .dbody
            {
                height: 250px;
                width: 700px;
                overflow: auto;
            }
            .dhead
            {
                font-weight: bold;
                font-size: 120%;
            }
            .dtext
            {
                padding-left: 7em;
            }
            .line
            {
                position: relative;
                margin-left: -7em;
                display: none;
            }
            .redname
            {
                color: red;
                font-weight: bold;
            }
            .bluename
            {
                color: blue;
                font-weight: bold;
            }
            .greyname
            {
                color: grey;
                font-weight: bold;
            }
            .deadname
            {
                color: grey;
                font-weight: bold;
                font-style: italic;
            }
            .timestamp
            {
                font-size: 80%;
                font-color: black;
                font-style: italic;
            }
        </style>
    </head>
    <body onload="javascript:proc()">
    <?php echo($PB); ?>
    </body>
    </html>
<?php endif; ?>
Thanks for help!
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01220 seconds
  • Memory Usage 1,896KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete