Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 03-30-2012, 03:52 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've never even heard of that error before. Have you tried contacting your host?
Reply With Quote
  #3  
Old 03-30-2012, 04:58 AM
S!p S!p is offline
 
Join Date: May 2010
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When i load this script from url work fine. Only after include get error.
It`s from code (js) but i don`t know what it means:

PHP Code:
            function dead(wat
            { 
                
alert("Server side error. Dying:" wat); 
            } 
            function 
cback(datatextStatus
            { 
                if (
textStatus == "success"
                { 
                    var 
lines data.split("\n"); 
                    
mark lines[0]; 
                    if (
mark == 0) die(3); 
                    var 
line
                    var 
scrollme = new Array(); 
                    for(var 
1lines.lengthi++) 
                    { 
                        
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); 
                    } 
Reply With Quote
  #4  
Old 04-02-2012, 03:14 PM
S!p S!p is offline
 
Join Date: May 2010
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

any ideas?
Reply With Quote
  #5  
Old 04-02-2012, 03:34 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your error is from this piece of code:
PHP Code:
 function dead(wat
            { 
                
alert("Server side error. Dying:" wat); 
            } 
You put that in there for a reason, and it's spitting out "wat" for you, so what does that tell you?
Reply With Quote
  #6  
Old 04-02-2012, 03:38 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you putting that in a forum block? In a forum block you are supposed to return the output as a string, not output it directly. Anyway, it looks like this line:

Code:
$.get("<?php echo($_SERVER["PHP_SELF"]); ?>?mark=" + mark, cback);

Isn't working as expected, but I have no idea why.
Reply With Quote
  #7  
Old 04-03-2012, 10:41 AM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by S!p View Post
any ideas?
Your code isn't designed to be embedded within a page the way you're doing it.

The javascript is parsing the output of the current page, looking for the items the PHP is generating. Since the PHP is just being called, and not being output properly, it's not finding it, and failing.

Modify the code so the PHP is within an external file, embed the HTML you need in a block, and use the AJAX call to call that external PHP file.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:32 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08139 seconds
  • Memory Usage 2,323KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete