+ Rispondi
Risultati da 1 a 1 di 1

Discussione: Chat php

  1. #1
    Nuovo della community
    reputazione complessiva: 1 1

    Messaggi
    7

    Unhappy Chat php

    Allora un aiutino dato che ho il motore della chat già inserito del cms , solo che alcune funzioni non sono ancora implementate o non funzionano come dovrebbe dunque la porzione di codice che interessa le funzioni e la seguente

    Codice PHP:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <?php
    include('../include/db_conn.php');
    include(
    '../include/license.php');
    include(
    '../include/session.php');
    if(
    $user!="")
    {
    $dati=mysql_fetch_array(mysql_query("SELECT * FROM user WHERE nome='$user'"));
    if(
    $dati[ban]=="0"){
    $chat_query=mysql_query("select * from chat_ext");
    while(
    $chat_ext=mysql_fetch_array($chat_query)){
    $chat_ctr[]=$chat_ext[chat];
    }
    if(
    in_array($id,$chat_ctr)){
    $err=FALSE;
    $row2=mysql_fetch_array(mysql_query("select * from chat_ext where chat='$id'"));
    if((
    $row2[block]!="1") || ($gestore==$user)){
    $err=FALSE;
    }
    else{
    $sede=mysql_fetch_array(mysql_query("select * from sede where chat='$row2[chat]'"));
    $pmx_sede=mysql_num_rows(mysql_query("select * from pmx_sede where idsede='$sede[id]' and user='$user'"));
    if(
    $pmx_sede!="0"){
    $err=FALSE;
    }else{
    $err=TRUE;
    }}}
    else{
    $err=TRUE;
    }
    ?>
    <html>
    <head>
    <title><?php echo $gioco_ct?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="../styles/table01.css" type="text/css">
    <link rel="stylesheet" href="../styles/chat.css" type="text/css">
    <script>
    function scroller()
    {
    scroll(0,20000000);
    }
    </script>
    <meta http-equiv='refresh' content='20, chat_engine.php?id=<?php echo $id?>'>
    </head>
    <?php
    if($err==FALSE){
    ?>
        <body leftmargin="2" topmargin="5" bottommargin="5" rightmargin="2" onload="scroller()">
        <table width="99%"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td>
            <?php
            $user_select
    =mysql_fetch_array(mysql_query("SELECT * FROM user WHERE nome='$user'")) or die (mysql_error());    
            
    //Inizializating Chat
            
    $chat_execute='user_ok';
            
    $all_users='all';
            
    $chat_message="";
            
    $chat_message=$_POST['chat_message']; 
            if(
    $chat_message!="")
            {
            
    $transmessaggio = array("+" => " ");
            
    $messaggiotradotto strtr($chat_message$transmessaggio);
            if(
    $chat_message!="$messaggiotradotto"
            {
            
    $messa explode ("+" $chat_message);
            
    $parte1=$messa[0];
            
    $messaggi=$messa[1];
            
    $chat_message=$messaggi;
            if(
    $messaggi)
            {
            
    $chat_execute="user_go";
            }
            }
            }
            if(
    $chat_message!="")
            {
            
    $transmessaggio = array("@" => " ");
            
    $messaggiotradotto strtr($chat_message$transmessaggio);
            if(
    $chat_message!="$messaggiotradotto"
            {
            
    $messa explode ("@" $chat_message);
            
    $parte1=$messa[0];
            
    $destinatario=$messa[1];
            
    $messaggi=$messa[2];
            
    $chat_message=$messaggi;
            
    $all_users=$destinatario;
            if(
    $messaggi)
            {
            
    $chat_execute="user_sussurro";
            }
            }
            }
            if(
    $chat_message!="")
            {
            
    $transmessaggio = array("§" => " ");
            
    $messaggiotradotto strtr($chat_message$transmessaggio);
            if(
    $chat_message!="$messaggiotradotto"
            {
            
    $messa explode ("§" $chat_message);
            
    $parte1=$messa[0];
            
    $messaggi=$messa[1];
            
    $chat_message=$messaggi;
            if(
    $messaggi)
            {
            if(
    ereg("[^0-9]",$chat_message) == FALSE)
            {
            
    $tiro=rand(1,$messaggi);
            
    $chat_execute="user_dado";
            }
            }
            }
            }
            
    //Master Key
            
    if(($dati['fato']=='1') || ($dati[mestiere]=='Nobili'))
            {
            if(
    $chat_message!="")
            {
            
    $transmessaggio = array("#" => " ");
            
    $messaggiotradotto strtr($chat_message$transmessaggio);
            if(
    $chat_message!="$messaggiotradotto"
            {
            
    $messa explode ("#" $chat_message);
            
    $parte1=$messa[0];
            
    $messaggi=$messa[1];
            
    $chat_message=$messaggi;
            if(
    $messaggi)
            {
            
    $chat_execute="user_master";
            }
            }
            }
            }
            if((
    $dati['fato']=='1') || ($dati[mestiere]=='Nobili'))
            {
            if(
    $chat_message!="")
            {
            
    $transmessaggio = array("!" => " ");
            
    $messaggiotradotto strtr($chat_message$transmessaggio);
            if(
    $chat_message!="$messaggiotradotto"
            {
            
    $messa explode ("#" $chat_message);
            
    $parte1=$messa[0];
            
    $messaggi=$messa[1];
            
    $chat_message=$messaggi;
            if(
    $messaggi)
            {
            
    $chat_execute="user_img";
            }
            }
            }
            }
            if((
    $chat_message!=''))
            {
            
    $get_time=time();
            
    //User Select    
            
    $sesso=$user_select['img_sesso'];
            
    $tempo=$user_select['chat'];
            
    //Insert INTO chat SQL table
            
    $azione=mysql_query("INSERT INTO chat (user, messaggio, timeout, sesso, now, luogo, to_chat, do_chat, tiro) VALUES ('$user', '$chat_message', '$get_time', '$sesso', NOW(), '$id', '$all_users', '$chat_execute','$tiro')") or die (mysql_error());
            }
            
    $tempo=$user_select['chat'];
            
    $azione2=mysql_query("SELECT * FROM chat WHERE luogo='$id' AND timeout>='$tempo' ORDER by id") or die (mysql_error());
            
    $risultati"";
            while(
    $row=mysql_fetch_array($azione2))
            {
            
    $chat_date=date("H:i ",$row['timeout']);
            
    $pg_name=$row['user'];
            
    $chat_message=$row['messaggio'];
            
    $chat_img_sex=$row['sesso'];
            
    $chat_message=eregi_replace("<","&lt;",$chat_message);
            
    $chat_message=eregi_replace(">","&gt;",$chat_message);
            
    $chat_message=eregi_replace("\n","<br>",$chat_message);
            
    $chat_message=str_replace("[","[",$chat_message);
            
    $chat_message=str_replace("]","]",$chat_message);
            
    $chat_message=str_replace("/","\",$chat_message);
            $rowpg=mysql_fetch_array(mysql_query("
    select from user where nome='$pg_name'"));
            $countmaster=mysql_num_rows(mysql_query("
    select from gilda where master='$pg_name'"));
            if(($row['do_chat']=='user_ok'))
            {
            if($countmaster!='0')
            {
            $risultati.="
    <p align="left\">$chat_date &nbsp;<img src=\"$rowpg[img_sesso]\">&nbsp;&nbsp;<img src=\"$rowpg[img_razza]\">&nbsp;&nbsp;<span class=\"master\">$pg_name</span>&nbsp;&nbsp;$chat_message</p>";
            }                
            else
            {
            
    $risultati.="$chat_date &nbsp;<img src=\"$rowpg[img_sesso]\">&nbsp;&nbsp;<img src=\"$rowpg[img_razza]\">&nbsp;&nbsp;<span class=\"cittadino\">$pg_name</span>&nbsp;&nbsp;$chat_message</p>";
            }
            }
            if((
    $row['do_chat']=='user_go'))
            {        
            if(
    $countmaster!='0')
            {
            
    $risultati.="<p align=\"left\"><span class=\"master\">$pg_name &nbsp;&nbsp;$chat_message</span></p>";
            }                
            else
            {
            
    $risultati.="<p align=\"left\"><span class=\"cittadino\">$pg_name &nbsp;&nbsp;$chat_message</span></p>";
            }
            }
            if((
    $row['do_chat']=='user_dado'))
            {        
            if(
    ereg("[^0-9]",$chat_message) == FALSE)
            
    $risultati.="<p class=\"dadi\" align=\"left\">$pg_name tiro $row[tiro] su base $chat_message</p>";
            }
            if((
    $row['do_chat']=='user_master'))
            {
            
    $risultati.="<p align=\"center\" class=\"fato\">$chat_message</p>";
            }
            if((
    $row['do_chat']=='user_img'))
            {
            
    $risultati.="<p align=\"center\" class=\"fato\"><img src=\"$chat_message\"></p>";
            }
            if((
    $row['do_chat']=='user_sussurro') && ($row[to_chat] == $user))
            {
            
    $risultati.="<table id=\"table4\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tbody><tr><td class=\"table1\"><p align=\"center\"><font size=\"1\"><b>$pg_name</b> Vi ha sussurrato:</b> e sussurrate: </font></p></td></tr><tr><td class=\"table3\" height=\"22\"><font size=\"1\">$chat_message</font></td></tr></tbody></table>";
            }
            if((
    $row['do_chat']=='user_sussurro') && ($row[user] == $user))
            {
            
    $risultati.="<table id=\"table4\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tbody><tr><td class=\"table1\"><p align=\"center\"><font size=\"1\">Vi avvicinate a <b>$row[to_chat]</b> e sussurrate: </font></p></td></tr><tr><td class=\"table3\" height=\"22\"><font size=\"1\">$chat_message</font></td></tr></tbody></table>";
            }
            }
            echo 
    $risultati;
    ?>
            </td>
          </tr>
        </table><?php
    }
    else{
    echo
    "<p align=\"center\" class=\"tablehead\"><font face=\"Verdana\" size=\"2\">Accesso Negato</font></b></p>";
    }
    ?>
        </body>
    </html>
    <?php
    }
    }
    else
    {
    echo
    "Errore nella Connessione, riprova a fare il Login";
    }
    ?>
    Dunque il codice e regolare ma dato che sono un neofita del php ci sono cose che non riesco a formulare nella funzione , allora la prima dovrei implementare una stringa dove la moderazione può scrivere una striscia con sfondo colorato ( vedi fato ) colorata ovviamente in altro modo , ho provato a scopiazzare la funzione fato cambiandola con moderazione ma mi da errore poi non riconosce più il codice , oltre che (dovrebbe ) tra le funzioni ereg_ e str_replace cambiare il formato dei font utilizzati nella chat quando una scritta e racchiusa tra i due tag , ho detto dovrebbe perché in definitiva non è così...se qualcuno potrebbe darmi un aiutino , non chiedetemi di spulciare il manuale di php che ho letto anche la funzione ma non riesco a comprenderne l'uso su una chat
    Ultima modifica di TheTruster; 10-05-2010 alle 07:12

+ Rispondi

Permessi di Scrittura

  • Tu non puoi inviare nuove discussioni
  • Tu non puoi inviare risposte
  • Tu non puoi inviare allegati
  • Tu non puoi modificare i tuoi messaggi