Jump to content


Photo

Chat Pronto Em Php


  • Faça o login para participar
6 replies to this topic

#1 colombo

colombo

    Novato no fórum

  • Usuários
  • 9 posts
  • Sexo:Masculino
  • Localidade:Taboão da Serra

Posted 26/07/2010, 10:11

Oi pessoal.
Estou tentando fazer um chat...
Peguei esse codigo pronto de um colega, porém o mesmo está dando um erro de como se algum fecha-chave não tivesse sido colocado. Mas já cansei de verificar e parece ter todos.

Tem como alguem me ajudar, abraços.


<?
(empty($action))
  ShowLoginForm();
elseif ($action == "posts")
  ShowAddPosts();
elseif ($action == "users")
  showusers();
elseif ($action == "form")
  GetInput();
elseif ($action == "logo")
  showlogo();
elseif ($action == "enter")
  Login();

function ShowLoginForm() {
$time = date ("h:i A");


?>

        <b>Entre Com Seu Nick/Nome</b>
        <form name="chat" method="post" action="index.php" target="_top">
          <input type="text" name="nick" size="8" MAXLENGTH=9>
          <input type="hidden" name="action" value="enter">
          <input type="hidden" name="chat" value="Entrou no Chat as <?php echo $time; ?>">
          <input type="submit" name="Submit" value="Entrar">
        <script language="JavaScript">
         document.chat.nick.focus();
         </script>
        </form>

<?php

}

function Login() {

        global $HTTP_SESSION_VARS;
        global $chat;
        global $nick;

        session_start();
        session_register("nick", $nick);
        if ($skin=="") {
        setCookie ("skin","yellow.css", time()+30240000);}
  ?>
           
        <frameset rows="*,70" cols="*,115"  >

          <frame name="posts" src="index.php?action=posts&nick=<?php echo $nick; ?>&chat=<?php echo $chat; ?>" scrolling="auto" noresize frameborder="0" border="0">
          <frame name="user" src="index.php?action=users" scrolling="no" noresize" frameborder="0" border="0" >
          <frame name="form" src="index.php?action=form&nick=<?php echo $nick; ?>" scrolling="no" noresize" frameborder="0" border="0" >
          <frame name="logo" src="index.php?action=logo" scrolling="no" noresize" frameborder="0" border="0" >

        </frameset>
          <noframes>
          <body>

          <p>This page uses frames, but your browser doesn't support them.</p>

          </body>
          </noframes>
        </frameset>

  <?php
}

function GetInput() {

        global $HTTP_SESSION_VARS;
        global $chat;
        global $nick;
        global $skin;
        $skin = $_COOKIE["skin"]; // Recommended but requires PHP 4.1
        $activedir = "./style/";
        @chdir($activedir);
  if ($skin=="") {
  print '<link rel="stylesheet" href="./style/yellow.css" type="text/css">';}
  else { ?> <link rel="stylesheet" href="<? echo $activedir.$skin; ?>" type="text/css"><?
  }
  ?>
  <body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
        <form onSubmit="return doSubmit" name="chatform" method="post" action="index.php" target="posts" >

 <table border="0" cellpadding="1" >
 <tr>
 <td valign="top" class="avatars">

          <a href onClick="sendFace(1)"><img src="./img/smile.gif"</a>
          <a href onClick="sendFace(2)"><img src="./img/frown.gif"</a>
          <a href onClick="sendFace(3)"><img src="./img/bigsmile.gif"</a>
          <a href onClick="sendFace(4)"><img src="./img/angry.gif"</a>
          <a href onClick="sendFace(5)"><img src="./img/cool.gif"</a>
          <a href onClick="sendFace(6)"><img src="./img/tongue.gif"</a>
          <a href onClick="sendFace(7)"><img src="./img/huh.gif"</a>
          <a href onClick="sendFace(8)"><img src="./img/rolleyes.gif"</a>
          <a href onClick="sendFace(9)"><img src="./img/embarassed.gif"</a>
          <a href onClick="sendFace(10)"><img src="./img/lipsrsealed.gif"</a>
          <a href onClick="sendFace(11)"><img src="./img/kiss.gif"</a>
          <a href onClick="sendFace(12)"><img src="./img/cry.gif"</a>
          <a href onClick="sendFace(13)"><img src="./img/undecided.gif"</a>
          <a href onClick="sendFace(14)"><img src="./img/wink.gif"</a>
 </td><td valign="top" >
<select name="skin" style="font: 9.9px verdana; color: #000000; width=80px;" onChange="makecookie();">
<option>Selecionar Tema</option>
<?

        $handle=opendir('.');
                while ($file = readdir($handle)) {
                        if(is_file($file)) {
                                $filelist[] = $file; 
                        }
                }
                closedir($handle);

                asort($filelist);
                while (list ($key, $file) = each($filelist)) {
                        ereg(".gif | .jpg",$file); 
                                if ($file != "." && $file != ".." && (!is_dir($file))) {
                                        echo "<option value=\"".$file."\">".$file."</option>";
                                }
                }
                echo '</select>';

?>
</td></tr>
 <tr>
  <td valign="top">

          <input type="text" name="chat" size="35" MAXLENGTH=200 onkeypress="if (event.keyCode==13) setTimeout('document.chatform.chat.value=\'\'',20);">

          <input type="hidden" name="nick"  value="<?php echo $nick; ?>">
          <a href="javascript:void(doSubmit())"
        onMouseover="document.images['send'].src='./img/send2.gif'"
        onMouseout ="document.images['send'].src='./img/send1.gif'">
  <img src="./img/send1.gif" name="send" border=0 align="top"></a>
</td>
</tr></td>

          <input type="hidden" name="action" value="posts">
<script language="JavaScript">
document.chatform.chat.focus();
</script>
        </form>
</table>
      <script language="JavaScript">

function makecookie() {
var expireDate = new Date
expireDate.setMonth(expireDate.getMonth()+6)
document.cookie = "skin=" + document.chatform.skin.value + "; expires=" + expireDate.toGMTString()
parent.frames[1].document.location='index.php?action=users'
parent.frames[3].document.location='index.php?action=logo'
parent.frames[0].document.location='index.php?action=posts'
parent.frames[2].document.location='index.php?action=form&nick=<?php echo $nick; ?>'
document.chatform.chat.focus();
}


          function sendFace(faceNum)
          {
            switch(faceNum)
            {
              case 1:
                document.chatform.chat.value = document.chatform.chat.value + ' <img src='http://forum.wmonline.com.br/public/style_emoticons/default/smile.gif' class='bbc_emoticon' alt=':)' /> ';
                break;
              case 2:
                document.chatform.chat.value = document.chatform.chat.value + ' <img src='http://forum.wmonline.com.br/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' /> ';
                break;
              case 3:
                document.chatform.chat.value = document.chatform.chat.value + ' <img src='http://forum.wmonline.com.br/public/style_emoticons/default/biggrin.gif' class='bbc_emoticon' alt=':D' /> ';
                break;
              case 4:
                document.chatform.chat.value = document.chatform.chat.value + ' >( ';
                break;
              case 5:
                document.chatform.chat.value = document.chatform.chat.value + ' 8) ';
                break;
              case 6:
                document.chatform.chat.value = document.chatform.chat.value + ' <img src='http://forum.wmonline.com.br/public/style_emoticons/default/tongue.gif' class='bbc_emoticon' alt=':P' /> ';
                break;
              case 7:
                document.chatform.chat.value = document.chatform.chat.value + ' ??? ';
                break;
              case 8:
                document.chatform.chat.value = document.chatform.chat.value + ' :<img src='http://forum.wmonline.com.br/public/style_emoticons/default/smile.gif' class='bbc_emoticon' alt=':)' /> ';
                break;
              case 9:
                document.chatform.chat.value = document.chatform.chat.value + ' :-[ ';
                break;
              case 10:
                document.chatform.chat.value = document.chatform.chat.value + ' :-X ';
                break;
               case 11:
                document.chatform.chat.value = document.chatform.chat.value + ' :-* ';
                break;
              case 12:
                document.chatform.chat.value = document.chatform.chat.value + ' :\'( ';
                break;
              case 13:
                document.chatform.chat.value = document.chatform.chat.value + ' :-\\\ ';
                break;
              case 14:
                document.chatform.chat.value = document.chatform.chat.value + ' <img src='http://forum.wmonline.com.br/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' /> ';
                break;
            }
          document.chatform.chat.focus();

          }

        function doSubmit()
        {
          if(document.chatform.chat.value == '') {
            alert('Please enter some text!');
            document.chatform.chat.focus();
            return false;
          }

               document.chatform.chat.value = document.chatform.chat.value;
          document.chatform.submit();
          document.chatform.chat.value = '';
          document.chatform.chat.focus();
          return true;
        }
        </script>
  <?php
}

function showlogo() {

        global $HTTP_SESSION_VARS;
        global $skin;
        $activedir = "./style/";
        @chdir($activedir);

  if ($skin=="") {
  print '<link rel="stylesheet" href="./style/yellow.css" type="text/css">';}
  else { ?> <link rel="stylesheet" href="<? echo $activedir.$skin; ?>" type="text/css"><?
  }
  ?>
  <body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
  <b>Chat V.0.95</b></a><br>
  <b>By <a href="http://www.orkut.com.br/Main#Profile.aspx?uid=15446353553944723892&rl=t" title="DJ Panik" target="_blank">DJ Panik</a></b></a><br>

  <?
  }
function ShowAddPosts() {

        global $HTTP_SESSION_VARS;
        global $chat;
        global $nick;
        global $timeoutseconds;
        global $timestamp;
        global $timeout;
        global $skin;
        $activedir = "./style/";
        @chdir($activedir);
        $timeoutseconds         = 250;                        // Timeout value in seconds
        $timestamp=time();
        $timeout=$timestamp-$timeoutseconds;  

        print '<meta http-equiv="refresh" content="10;URL=index.php?action=posts&nick=<?php echo $nick; ?>">';

        echo '<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">';

  if ($skin=="") {
  print '<link rel="stylesheet" href="./style/yellow.css" type="text/css">';}
  else { ?> <link rel="stylesheet" href="<? echo $activedir.$skin; ?>" type="text/css"><?
  }

        include ("config.php");
        $svrConn = mysql_connect("$host", "$user", "$pass") or die("<b>Error:</b> Couldnt connect to database");
        $dbConn = mysql_select_db("$base", $svrConn) or die ("<b>Error:</b> Couldnt connect to database");
        $chat = strip_tags($chat,'<i><b><a>');

        
        if(!empty($chat)) {
                
                $strQuery = "insert into chatScript values(0, '$chat','$nick','$timestamp')";
                mysql_query($strQuery);
        } 

        $strQuery = ("DELETE FROM chatScript WHERE timestamp<$timeout") or die("$useronline $base DELETE Error");
         mysql_query($strQuery);

        $strQuery = "select theText, theNick from chatScript order by pk_Id asc";
        $chats = mysql_query($strQuery);
           echo '<table border="0" width="100%" height="100%" cellpadding="1">
           <tr><td  valign="top" align="left" width="80%" height="100%" class="chattext">';
          
        while($chatline = mysql_fetch_array($chats)) {
           print "<font size=\"2\"><b>" . $chatline["theNick"] . ":</b> " . swapFaces($chatline["theText"]) . "</b></i></font><br>";
        }
        echo '</td></tr></table>';
        ?>
        <script language="JavaScript">
        scroll(10,600)
        </script>
<?
}

function showusers() {
        global $HTTP_SESSION_VARS;
        global $nick;
        global $skin;
        $activedir = "./style/";
        @chdir($activedir);
        print '<meta http-equiv="refresh" content="15;URL=index.php?action=users">';
        echo '<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">';
  if ($skin=="") {
  print '<link rel="stylesheet" href="./style/yellow.css" type="text/css">';}
  else { ?> <link rel="stylesheet" href="<? echo $activedir.$skin; ?>" type="text/css"><?
  }


        echo '<table border="0" width="100%" height="100%" cellpadding="1" >
           <tr>';
          
        echo '<td nowrap valign="top" align="left" width="400px" height="50%" class="online"><b>Usuários Online:</b><br>';
        include ("config.php");
        $svrConn = mysql_connect("$host", "$user", "$pass") or die("<b>Error:</b> Couldnt connect to database");
        $dbConn = mysql_select_db("$base", $svrConn) or die ("<b>Error:</b> Couldnt connect to database");
        $nicks = array();
        $strQuery = "select theNick from chatScript order by theNick asc";
        $chats = mysql_query($strQuery);
        while($chatline = mysql_fetch_array($chats)) {
                        if (!in_array($chatline['theNick'],$nicks)) {
                                $nicks[] = $chatline['theNick'];
                                print "" . $chatline["theNick"] . "<br>";
                        }

        }
      echo '</td></tr></table>';

     }


function swapFaces($chatLine) {

  $chatLine = str_replace(":<img src='http://forum.wmonline.com.br/public/style_emoticons/default/smile.gif' class='bbc_emoticon' alt=':)' />", "<img src='./img/rolleyes.gif'>", $chatLine);
  $chatLine = str_replace("<img src='http://forum.wmonline.com.br/public/style_emoticons/default/smile.gif' class='bbc_emoticon' alt=':)' />", "<img src='./img/smile.gif'>", $chatLine);
  $chatLine = str_replace("<img src='http://forum.wmonline.com.br/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />", "<img src='./img/frown.gif'>", $chatLine);
  $chatLine = str_replace("<img src='http://forum.wmonline.com.br/public/style_emoticons/default/biggrin.gif' class='bbc_emoticon' alt=':D' />", "<img src='./img/bigsmile.gif'>", $chatLine);
  $chatLine = str_replace(">(", "<img src='./img/angry.gif'>", $chatLine);
  $chatLine = str_replace("8)", "<img src='./img/cool.gif'>", $chatLine);
  $chatLine = str_replace("<img src='http://forum.wmonline.com.br/public/style_emoticons/default/tongue.gif' class='bbc_emoticon' alt=':P' />", "<img src='./img/tongue.gif'>", $chatLine);
  $chatLine = str_replace("???", "<img src='./img/huh.gif'>", $chatLine);
  $chatLine = str_replace(":-[", "<img src='./img/embarassed.gif'>", $chatLine);
  $chatLine = str_replace(":-X", "<img src='./img/lipsrsealed.gif'>", $chatLine);
  $chatLine = str_replace(':-\\', '<img src=\'./img/undecided.gif\'>', $chatLine);
  $chatLine = str_replace(":-*", "<img src='./img/kiss.gif'>", $chatLine);
  $chatLine = str_replace(":'(", "<img src='./img/cry.gif'>", $chatLine);
  $chatLine = str_replace("<img src='http://forum.wmonline.com.br/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' />", "<img src='./img/wink.gif'>", $chatLine);
  return $chatLine;
}

?>

Consegui resolver uma parte desse problema, porém agora está ocorrendo o seguinte erro:
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\chat\index.php on line 370

Alguém pode me ajudar? abraço!

#2 André Manoel

André Manoel

    Doutor

  • Usuários
  • 996 posts
  • Sexo:Masculino
  • Localidade:Brasilia

Posted 26/07/2010, 10:55

Olá.

Bem primeiramente quando você for postar algum código.

Poste entre as tags CODE.

é o simbolo <> no editor de posts.

Outra coisa...

Você postou um código muito grande...

Poste somente o local aonde o erro está sendo gerado.

No seu caso é a linha 370.

Utilize algum editor que tenha os números das linhas, para que vc poste somente a linha que está gerando o erro... no caso a linha 370.

Ninguém vai ficar olhando o código tão grande para descobrir aonde está o erro...

(y)

Aguardo a linha 370...
Iniciando na Ajuda On line...

Posted Image Meu post lhe ajudou? Reputar/votar é uma das formas de agradecer.

#3 colombo

colombo

    Novato no fórum

  • Usuários
  • 9 posts
  • Sexo:Masculino
  • Localidade:Taboão da Serra

Posted 27/07/2010, 16:56

Consegui resolver aquele erro, era problema de falta de fecha-chave. Mas agora ele abre a 1º tela, para inserir o nome eo botão entrar, porém quando clico em Entrar, não acontece nada... apenas apaga o nome que digitei e fica em loop.


<?php

switch ($action) {
case "posts": ShowAddPosts(); break;
case "users": showusers(); break;
case "form": GetInput(); break;
case "logo": showlogo(); break;
case "enter": Login(); break;
default: ShowLoginForm(); break;
}


function ShowLoginForm() {
$time = date ("h:i A");

?>

<b> ENTRE COM O SEU NOME COMPLETO </b>
<form name="chat" method="post" action="index.php" target="_top"><br>
<input type="text" name="nick" size="25" MAXLENGTH=25><br><br>
<input type="hidden" name="chat" value="ENTROU NO CHAT AS <?php echo $time; ?>">
<input type="submit" name="enter" value="Entrar">
<input type="submit" name="reset" value="Apagar">
<script language="JavaScript">
document.chat.nick.focus();
</script>
</form>

<?php

function Login() {

global $HTTP_SESSION_VARS;
global $chat;
global $nick;

session_start();
session_register("nick", $nick);
if ($skin=="") {
setCookie ("skin","yellow.css", time()+30240000);}
?>

<frameset rows="*,70" cols="*,115" >

<frame name="posts" src="index.php?action=posts&nick=<?php echo $nick; ?>&chat=<?php echo $chat; ?>" scrolling="auto" noresize frameborder="0" border="0">
<frame name="user" src="index.php?action=users" scrolling="no" noresize" frameborder="0" border="0" >
<frame name="form" src="index.php?action=form&nick=<?php echo $nick; ?>" scrolling="no" noresize" frameborder="0" border="0" >
<frame name="logo" src="index.php?action=logo" scrolling="no" noresize" frameborder="0" border="0" >

</frameset>
<noframes>
<body>

<p>Esta página usa Frames, mas seu navegador não suporta</p>

</body>
</noframes>
</frameset>

<?php

#4 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 21/10/2017, 00:25

Cash On Delivery Bentyl viagra Viagra Canada. Shop
Proscar Without Prescription Generic Propecia Viagra Kaufen Cialis Bestellen Reaction To Amoxicillin viagra Kamagra Efectos Secundarios

#5 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 21/10/2017, 02:31

Comprar Cialis Francia Dulcolax levitra online paypal Dutasteride Benign Prostatic Hyperplasia Where Can I Buy Priligy How Long
Getting Synthroid In Mexico viagra Cialis Afecta El Esperma Viagra A Firenze Propecia Ectopico

#6 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 21/10/2017, 17:21

Cephalexin Dental Infection Amoxicillin 100mg Ct cialis online Viagra Cialis Levitra Cafergot Available In Canada
Cialis 5 Mg Price Kamagra Priceminister overnight delivery buy levitra online Propecia Medication
Clomid Pourquoi Cephalexin Same As Ceftin Kamagra Sachet Pharmacie viagra prescription Clomid Acidose Lactique

#7 RonsisM

RonsisM

    Super Veterano

  • Usuários
  • 15724 posts
  • Sexo:Masculino
  • Localidade:Plovdiv

Posted 22/10/2017, 04:45

Viagra Rezeptfrei Kaufen Deutschland Why Amoxicillin Before Surgery Cialis En La Farmacia viagra Buy Prevacid 24 Hr Buy Cipro Canada
Cialis Generico Serve La Ricetta Amoxicillin Without Rx viagra Dosage For 45 Pounds Amoxicillin Cialis Und Viagra Zusammen Einnehmen
Order Finasteride Online Generic Propecia Levitra 10 Bucodispersable Cialis Potenzmittel Shop viagra vs cialis vs levitra Pharmacycustomercare Saint Generic Propecia Cheap
Keflex Engineering viagra Comprare Viagra In Germania Buy Zithromax By The Pill
Order Nizagara Online 33 Compare Generic Cialis Prices Package Insert Amoxicillin Dosage tadalafil viagra levitra Cialis 10 Mg Prospecto Acheter Cialis 10mg
Buy Tamoxifen Research Chemical levitra 40 mga for sale mexico beach Cialis Gunstigster Preis Levitra Uk Pharmacy
Acheter Dapoxetine 90mg Generique Viagra Buy Oonline Levitra Vendita Farmacia viagra Venta De Cialis Tadalafil Canadianhealth Propecia Generic India Propecia Levitra
Genuine Viagra Online Cialis 5mg Beipackzettel viagra Valore Levitra In Farmacia
Free Shipping Dutasteride Pharmacy Levitra Perdita Vista levitra generico prezzo Cephalexin Liquid For Toddlers Propecia Donde Comprar
Comprar Propecia Online viagra online prescription Keflex And Conjunctivits Vardenafil Canadian Pharmacy Where To Buy Levitra Online
Cod Elocon Mometasona No Rx cheap levitra canada Uk Kamagra Does Alcohol Affect Cephalexin Ciprofloxacin Interaction With Amoxicillin
Buy Celexa From Canada online pharmacy Cialis Ereccion Buy Nolvadex And Hcg Online Propecia Embarazo Este
Cialis Jour generic viagra Cialis Y Paracetamol Viagra From Canida
Lioresal Commander 10mg Propecia Sell Medicament Misoprostol C Est Pours Quoi viagra Buy Now Fedex Shipping Doryx Tablet Medicine Visa Acheter Priligy 30mg Kamagra En Suisse
Buy Celexa Online generic viagra Bentyl 20mg Usa Visa Accepted
Zithromax Warfarin Interaction Cialis No Funciona levitra brand Ativan En Ligne Cialis Ceguera
Buy Now Worldwide Isotretinoin Shop Doxycycline For Cheap viagra Buy Tamoxifen Paypal




2 user(s) are reading this topic

0 membro(s), 2 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq