Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: new server/chat

  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    new server/chat

    I just got a new VPS server, and for some reason my chat wont work anymore. Im thinking something is just not turned on, or something.. but i really have no clue why it isnt working.

    The entire chat code:

    PHP Code:
    <?

        
    if(isset($_POST['id'])){
    $id2 $_POST['id'];

        
    $result mysql_query("DELETE FROM babble WHERE id='$id2'"$db);
        }
        function 
    colorify_ip($ip)
        {
            
    $parts explode("."$ip);
            
    $color sprintf("%02s"dechex($parts[1])) .
                     
    sprintf("%02s"dechex($parts[2])) .
                     
    sprintf("%02s"dechex($parts[3]));
            return 
    $color;
        }
        

     function 
    add_line($msg) {


    $babble explode("¶"$msg);

    $username $babble[0];
    $message $babble[1];

    $result00 mysql_query("SELECT * FROM userinf WHERE username='$username'");
    $retval100 mysql_fetch_array($result00);

    $view 'all';
    include 
    'forum_tags.php';
    $babble2 strip_tags($message);
    $babble str_replace($search$replace$babble2);
    //mysql_query("UPDATE userinf SET lastpost='".$babble."' WHERE username='$username' ");
    mysql_query("UPDATE userinf SET lastposttime='".time()."' WHERE username='$username' ");
    $check explode(" "$message4);
    $check1 explode(" "$message3);
    $check2 explode(" "$message3);


    $banhours $retval100['bantime']/12;

    $bantime = (60*60)*$banhours;

    $time = (time()-$userinf['bantime2']);

    $time2 = ($bantime $time)/60/60;

    $time3 ceil($time2);

    if(
    $retval100['bantime2'] >= (time()-$bantime) && $retval100['admin']!='1') {


        
    $date date("M dS  h:i:s a");

    $result mysql_query("SELECT chat_channel,lastban,banned,chatmod,lastpost,admin,clan,ccode,xpos,ypos,zpos,username,ename,a_res1,a_res3,a_res2,a_none,erank,score,bactiv,holiday,prtct,ltime FROM userinf WHERE username='$username'"$db);
    $retval1 mysql_fetch_array($result);

    $bantime $retval1['lastban'] + 144;
    $banhours ceil($retval100['bantime']/12);

    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Error',babble='You can not talk in the chat, you are banned for $banhours more hours.',view='$username'");
    }else{

    if(
    $check[1] == '/pm' || $check[1] == '/msg'){
        
    $date date("M dS  h:i:s a");
    $to $check[2];
    $message2 $check[3];
    $babble4 strip_tags($message2);
    $babble3 str_replace($search$replace$babble4);
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='$username (private)',babble=' ".$babble3."',view='$to',type='private_to'");
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Private to $to',babble=' ".$babble3."',view='$username',type='private_from'");

    }elseif(
    $check2[1] == '/whois'){
        
    $date date("M dS  h:i:s a");
    $user $check2[2];
    $result1000 mysql_query("SELECT * FROM userinf WHERE username='$user' OR id='$user'");

    if(!
    mysql_num_rows($result1000)) {
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Event',babble=' There is no player by that username, or id number.',view='$username'");

    }else{
    $retval11000 mysql_fetch_array($result1000);

    $babble4 strip_tags($message2);
    $babble3 str_replace($search$replace$babble4);
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Event',babble=' <a target=\"main\" href=\"profile.php?username=".$retval11000['username']."\">".$retval11000['username']." (#".$retval11000['id'].")</a> is level ".$retval11000['level']."',view='$username'");
    }

    }elseif(
    $check2[1] == '/warn'){

        
    $date date("M dS  h:i:s a");
    $message2 $check2[2];
    $babble4 strip_tags($message2);
    $babble3 str_replace($search$replace$babble4);
    if(
    $retval100['chatmod']=='yes'){
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Mod Warning|$username',babble=' ".$babble3."',view='all'");
    }
    }elseif(
    $check2[1] == '/me' || $check2[1] == '/em'){

        
    $date date("M dS  h:i:s a");
    $message2 $check2[2];
    $babble4 strip_tags($message2);
    $babble3 str_replace($search$replace$babble4);
    if(
    $retval100['chatmod']=='yes'){
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='RPG|$username',babble=' ".$babble3."',view='all'");
    }
    }elseif(
    $check2[1] == '/announce'){

        
    $date date("M dS  h:i:s a");
    $message2 $check2[2];
    $babble4 strip_tags($message2);
    $babble3 str_replace($search$replace$babble4);
    if(
    $retval100['chatmod']=='yes'){
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Mod Announcement|$username',babble=' ".$babble3."',view='all'");
    }
    }elseif(
    $check2[1] == '/ban'){
    $date date("M dS  h:i:s a");
    $userban $check2[2];
    $babble4 strip_tags($message2);
    $babble3 str_replace($search$replace$babble4);
    if(
    $retval100['chatmod']=='yes'){

    $result1000 mysql_query("SELECT * FROM userinf WHERE username='$userban'");
    $retval11000 mysql_fetch_array($result1000);

    $bantime $retval11000['lastban'] + 12;
    $banhours $bantime/12;

    mysql_query("UPDATE userinf SET bantime='$bantime',lastban='$bantime',bantime2='".time()."' WHERE username='$userban' ");


    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Mod Warning|$username',babble=' $userban has been banned from the chat. ($banhours hours.)',view='all'");
    }
    }elseif(
    $check2[1] == '/unban'){
    $date date("M dS  h:i:s a");
    $userban $check2[2];
    $babble4 strip_tags($message2);
    $babble3 str_replace($search$replace$babble4);
    if(
    $retval100['chatmod']=='yes'){

    $result1000 mysql_query("SELECT * FROM userinf WHERE username='$userban'");
    $retval11000 mysql_fetch_array($result1000);

    $bantime $retval11000['lastban'] - 12;
    $banhours $bantime/12;

    mysql_query("UPDATE userinf SET bantime='0',lastban='$bantime',bantime2='0' WHERE username='$userban' ");


    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Mod Warning|$username',babble=' $userban has been unbanned from the chat.',view='all'");
    }
    }elseif(
    $check1[1] == '/r' || $check1[1] == '/reply'){
        
    $date date("M dS  h:i:s a");
    $message2 $check1[2];

    $result1000 mysql_query("SELECT MAX(id) FROM babble WHERE view='$username' AND type='private_to'");
    $retval11000 mysql_fetch_array($result1000);

    $result100 mysql_query("SELECT * FROM babble WHERE id='".$retval11000['MAX(id)']."'");
    $retval1100 mysql_fetch_array($result100);
    $to $retval1100['author'];

    $checkto explode(" "$to);
    $too $checkto[0];

    $babble4 strip_tags($message2);
    $babble3 str_replace($search$replace$babble4);
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='$username (private)',babble=' ".$babble3."',view='$too',type='private_to'");
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Private to $to',babble=' ".$babble3."',view='$username',type='private_from'");

    }elseif(
    $check1[1] == '/c' || $check1[1] == '/channel'){

    $channel $check1[2];
    $date date("M dS  h:i:s a");
    if(
    $channel == 'newbie' || $channel == 'mods'){

    mysql_query("UPDATE userinf SET chat_channel='$channel' WHERE username='$username' ");
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Event',babble='<font color=\"009000\"><i>You are now in the <u>$channel</u> channel.</i></font>',view='$username'");

    }else{
    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='Event',babble='<font color=\"009000\"><i>$channel is not a valid chat channel</i></font>',view='$username'");

    }

    }else{
    IF(
    $babble==$retval100['lastpost']) { }



    elseif(
    $babble=='') { } else {

        
    $date date("M dS  h:i:s a");

    mysql_query("INSERT INTO babble SET id='',posttime='$date',author='$username',babble='".$babble."',view='$view'");



    }
    mysql_query("UPDATE userinf SET lastpost='".$babble."' WHERE username='$username' ");

    }
    }
    }


        
        function 
    refresh() {



    $result '';

    $tmp2 mysql_query("SELECT * FROM userinf WHERE username='".$_SESSION['username_strat']."'");
         
    $retval12 mysql_fetch_array($tmp2);
         
    $babblequery mysql_query("SELECT * FROM babble WHERE clan_id='0' AND view='all' OR view='".$_SESSION['username_strat']."' ORDER BY id DESC LIMIT 100");
    $babble2query mysql_query("SELECT MAX(id) FROM babble WHERE clan_id='0' AND view='all'");
    $babble2row mysql_fetch_array($babble2query);
    $babble3query mysql_query("SELECT * FROM babble WHERE clan_id='0' AND id='".$babble2row['MAX(id)']."'");
    $babble3row mysql_fetch_array($babble3query);
    $result .= "<div class=\"date\"><center>Last Post: ".$babble3row['posttime']."</center></div>";
    $result .= "<br>";
    $result .= "<table width=\"100%\" cellpadding=\"1px\" cellspacing=\"0\" frame=\"above\">\n";
    while (
    $babblerow mysql_fetch_array($babblequery)) {

    $chat wordwrap($babblerow['babble'], 26"\n"true);

          IF(
    $retval12['chatmod']=='yes') {
            
    //$result .= "<tr><td width=\"25px\"><form method=\"POST\" action=\"newchat.php\"><input class=\"sdinw\" type=\"submit\" value=\"X\"><input type=\"hidden\" name=\"id\" value=\"".$babblerow['id']."\"> -</td>\n";
        
    }
            
    $result .= "<td width=\"10\"></td>";
            
    $result .= "<td><p>";

    if(
    $babblerow['type'] == "private_to"){
    $author1 explode(" "$babblerow['author']);
             
    $author $author1[0];
             
    $text $author1[1];
             
    $result .= "<font size=\"1\" color=\"0000FF\"><b>$author $text</b>: $chat</p></font></td></tr>\n";

    }elseif(
    $babblerow['type'] == "private_from"){
    $author1 explode(" "$babblerow['author']);
       
    $text1 $author1[0];
       
    $text2 $author1[1];
       
    $author $author1[2];
         
    $result .= "<font size=\"1\" color=\"0000FF\"><b>$text1 $text2 $author</b>: $chat</p></font></td></tr>\n";

    }else{

    $author explode("|",$babblerow['author']);
    $author1 $author[0];
    $author2 $author[1];


           if(
    $babblerow['author']!="Event" && $babblerow['author']!="Error" && $author1!="Mod Warning" && $author1!="Mod Announcement" && $author1!="RPG"){


           
    $tmp mysql_query("SELECT * FROM userinf WHERE username='".$babblerow['author']."'");
           
    $retval1 mysql_fetch_array($tmp);
           


    echo 
    "";
           
           if(
    $retval1['admin'] == 1){
              
    $result .= "<font size=\"1\"><b><font color=\"CC0000\">".$babblerow['author']."</font></b>: $chat</p></font></td></tr>\n";
           }else{
              
    $result .= "<font size=\"1\"><b><font color=\"000000\">".$babblerow['author']."</font></b>: $chat</p></font></td></tr>\n";
           }
           
    }elseif(
    $author1 == "Mod Warning"){

              
    $result .= "<font size=\"1\"><b><font color=\"CC0000\"><a title=\"$author2\">$author1</a></font></b>: <font color=\"CC0000\">$chat</font></td></tr>\n";

    }elseif(
    $author1 == "RPG"){

           
    $tmp2 mysql_query("SELECT * FROM userinf WHERE username='$author2'");
           
    $retval2 mysql_fetch_array($tmp2);

              if(
    $retval2['admin'] == 1){
              
    $result .= "<font size=\"1\"><b><i><font color=\"CC0000\">$author2</font></i></b><i> $chat</i></p></font></td></tr>\n";
           }else{
              
    $result .= "<font size=\"1\"><b><i><font color=\"000000\">$author2</font></i></b><i> $chat</i></p></font></td></tr>\n";
           }
           
    }elseif(
    $babblerow['author'] == "Error"){

              
    $result .= "<font size=\"1\"><b><font color=\"CC0000\">".$babblerow['author']."</font></b>: <font color=\"CC0000\">$chat</font></td></tr>\n";

    }elseif(
    $author1 == "Mod Announcement"){

              
    $result .= "<font size=\"1\"><b><font color=\"009000\"><a title=\"$author2\">$author1</a></font></b>: <font color=\"009000\">$chat</font></td></tr>\n";

    }else{
              
    $result .= "<font size=\"1\"><b><i><font color=\"009000\">".$babblerow['author']."</font></i></b>: <font color=\"009000\">$chat</font></td></tr>\n";

    }
    }
      
    $result .= "</form>";
        }
        
    $result .= "</table>\n";
        
    return 
    $result;
        }
        
        
    $sajax_request_type "GET";
        
    sajax_init();
        
    sajax_export("add_line""refresh");
        
    sajax_handle_client_request();    
    ?>
    <html>
    <head>
        <title>Chat</title>

        <script>
        <?
        sajax_show_javascript
    ();
        
    ?>
        
        var check_n = 0;
        var old_data = "--";
        
        function refresh_cb(new_data) {    
            if (new_data != old_data) {
                document.getElementById("wall").innerHTML = new_data;
                setTimeout("refresh()", 1000);
                old_data = new_data;
            } else {
                setTimeout("refresh()", 2500);
            }
            document.getElementById("status").innerHTML = "";
        }
        
        function refresh() {
            document.getElementById("status").innerHTML = "";
            x_refresh(refresh_cb);
        }
        
        function add_cb() {
            // we don't care..
        }

        function add() {
            var line;
            var handle;
            handle = document.getElementById("handle").value;
            line = document.getElementById("line").value;
            if (line == "") 
                return;
            sajax_request_type = "POST";
            x_add_line("" + handle + "¶ " + line, add_cb);
            document.getElementById("line").value = "";
        }
        </script>

    <SCRIPT TYPE="text/javascript">

    <!--

    function popup(mylink, windowname)

    {

    if (! window.focus)return true;

    var href;

    if (typeof(mylink) == 'string')

       href=mylink;

    else

       href=mylink.href;

    window.open(href, windowname, 'width=600,height=700,scrollbars=yes');

    return false;

    }

    //-->


    </SCRIPT>
    <link rel="stylesheet" type="text/css" href="images/chatstyle.css">

    </head>
    <? 

    ?>

    <body onload="refresh();">

    <form name="f" action="#" onsubmit="add();return false;">
    <center>
        <input type="hidden" name="handle" id="handle" value="<? echo($userinf['username']); ?>"
            onfocus="this.select()" style="width:100px;">
    <input type="text" name="line" id="line" maxlength="255" value=""
            onfocus="this.select()"
            style="width:110px;">
          <input type="button" name="check" value="Post message"
            onclick="add(); return false;">
    <center>
    <div id="wall">
    <?
    /*$babblequery = mysql_query("SELECT * FROM babble WHERE view='all' OR view='".$userinf['username']."' ORDER BY id DESC LIMIT 100");
    echo "<table width=\"100%\" cellpadding=\"1px\" cellspacing=\"0\" frame=\"above\">\n";
    while ($babblerow = mysql_fetch_array($babblequery)) {
        IF($userinf['chatmod']=='yes') {
            echo "<tr><td width=\"25px\"><form method=\"POST\" action=\"newchat.php\"><input class=\"sdinw\" type=\"submit\" value=\"X\"><input type=\"hidden\" name=\"id\" value=\"".$babblerow['id']."\"> -</td>\n";
        }
            echo "<td width=\"10\"></td>";
            echo "<td><p><i><small>".$babblerow['posttime']."</small></i><br>\n";

           $result = mysql_query("SELECT * FROM userinf WHERE username='".$babblerow['author']."'");
           $retval1 = mysql_fetch_array($result);
           if($retval1['admin'] == 1){
              echo "<a target=\"_top\" href=\"profile.php?username=".$babblerow['author']."\"><b><font color=\"CC0000\">".$babblerow['author']."</font></b></a>:&nbsp;". $babblerow['babble']."</p></td></tr>\n";
           }else{
              echo "<a target=\"_top\" href=\"profile.php?username=".$babblerow['author']."\"><b><font color=\"FFFFFF\">".$babblerow['author']."</font></b></a>:&nbsp;". $babblerow['babble']."</p></td></tr>\n";
           }
      echo "</form>";
        }
        echo "</table>\n";
     */
     
    ?>
    </div>

        <div id="status"><em>Loading..</em></div>
    </form>
        
    </body>
    </html>
    The Post message text box appears, but it isnt collecting any of the data from the database to display the messages. Any insight as to why this isnt working would be great. Thanks

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    What does your error log say?

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    it doesnt give an error. Its just returns a blank... and i do have the htaccess php errors turned on

  • #4
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    oh.. i just found an "error log" in the VPS manager.. (sorry im new to this and didnt see it :P)

    i think this is the error:

    [client 142.177.90.14] PHP Notice: Undefined offset: 1 in /var/www/vhosts/playsovereignty.com/httpdocs/strat/newchat.php on line 257, referer: http://76.12.21.9/strat/newchat.php

    which in the code is:

    PHP Code:
    <?$author explode("|",$babblerow['author']);
    $author1 $author[0];
    $author2 $author[1];
    ?>

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,092
    Thanks
    2
    Thanked 322 Times in 314 Posts
    Your code is using short open tags and none of the mysql_query() statements have any error checking, error reporting, or error recovery logic. It could be one or both of these that are preventing the code from doing anything or telling you why it is not working.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #6
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    putting this in instead of what was getting the error makes it work fine:

    PHP Code:
    <?
    //$author = explode("|", $babblerow['author']);
    $author1 "test";
    $author2 "test2";
    ?>
    so obviously this is the problem.. but why?

  • #7
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    $babblerow['author'] doesn't seem to contain the pipe("|") delimiter.

  • #8
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    have a look at this I'll try to help you out if you like it
    a-mazed.com

  • #9
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    interesting information


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •