Re: [TChat] Module de Tchat Communautaire

Le module devrait fonctionner avec cette modification :

Remplacer le contenu du ficher "modules/tchatche/theme/tchatche.php" par :


Code PHP :
Pour copier le contenu exact du code,
Veuillez citer le message
  1.  
  2. <?php
  3.  
  4. class tpl{
  5.  
  6.     function tchatche_main(){
  7.     
  8.     global $K_user,$K_mod,$K_theme;
  9.         
  10.         $main = null;
  11.         $main .= '<script type="text/javascript">'."\n";
  12.         
  13.         $main .= '
  14.         
  15.         function ajax()
  16.         {
  17.             var http_request;
  18.             
  19.             if (window.XMLHttpRequest)    //  Objet standard
  20.             { 
  21.                 http_request = new XMLHttpRequest();     //  Firefox, Safari, ...
  22.             } 
  23.             else  if (window.ActiveXObject)      //  Internet Explorer
  24.             {
  25.                 http_request = new ActiveXObject("Microsoft.XMLHTTP");
  26.             }
  27.  
  28.             http_request.onreadystatechange = function() { alert_ajax(http_request); };
  29.  
  30.             http_request.open("POST", "modules/tchatche/comments.php?cmd=show", true);
  31.             http_request.send(null);
  32.         }
  33.  
  34.         function alert_ajax(http_request)
  35.         {
  36.         
  37.             if (http_request.readyState == 4)
  38.                     {
  39.                         if (http_request.status == 200)
  40.                         {
  41.                             document.getElementById(\'c_cont\').innerHTML=http_request.responseText;
  42.                             
  43.                         }
  44.                         
  45.                     }
  46.         }
  47.         
  48.         
  49.         setInterval(\'ajax()\', 3000);
  50.         window.onload = ajax();'."\n";
  51.         
  52.         $main .= '</script>'."\n";
  53.                     
  54.         $main .= '<div id="c_cont"></div>'."\n";            
  55.         $main .= '<div id="u_online"></div>'."\n";
  56.         $main .= '<div class="clearer"></div>'."\n";        
  57.                 
  58.         echo $main;
  59.  
  60.         
  61.  
  62.     }//FIN FUNCTION tchatche_MAIN
  63.     
  64.     function tchatche_publish()
  65.     {
  66.     global $K_user,$K_mod,$K_theme;
  67.     
  68.         $main = null;        
  69.         
  70.         $main .= '<script type="text/javascript">'."\n";
  71.         $main .= '        
  72.         function submitComment(text,id)
  73.         { 
  74.         
  75.             if(text == \'\')
  76.             {
  77.         
  78.                 alert("Vous n\'avez pas rempli le champ input");
  79.                 return false;
  80.             }
  81.             else
  82.             {
  83.                 var xhr; 
  84.                 if (window.XMLHttpRequest)    //  Objet standard
  85.                 { 
  86.                     xhr = new XMLHttpRequest();     //  Firefox, Safari, ...
  87.                 } 
  88.                 else  if (window.ActiveXObject)      //  Internet Explorer
  89.                 {
  90.                     xhr = new ActiveXObject("Microsoft.XMLHTTP");
  91.                 }
  92.              
  93.                 xhr.onreadystatechange  = function() 
  94.                 { 
  95.                    if(xhr.readyState  == 4)
  96.                    {
  97.                     if(xhr.status  == 200) 
  98.                     {                    
  99.                     document.getElementById(\'reponse\').innerHTML = \'<img class="tchatche-submit-success" src="'.(file_exists('modules/'.$K_mod.'/theme/ok.png') ? 'modules/'.$K_mod.'/theme/ok.png' : 'themes/'.$K_theme.'/images/ok.png' ).'" alt="" />\';
  100.                         document.getElementById(\'text\').value = \'\';
  101.                     }
  102.                     else 
  103.                     {
  104.                         document.getElementById(\'reponse\').innerHTML = \'<h5 class="tchatche-submit-error">Une erreur est intervenue dans la publication de votre commentaire</h5>\';
  105.                     }
  106.                     }
  107.                 };
  108.                 
  109.                 if(text == \'delete\')
  110.                 {
  111.                 
  112.                 xhr.open( \'POST\', "modules/'.$K_mod.'/comments.php?cmd=remove",  true); 
  113.                 xhr.setRequestHeader(\'Content-Type\', \'application/x-www-form-urlencoded\');
  114.                 
  115.                 xhr.send(\'id=\'+id);
  116.                 
  117.                 }
  118.                 
  119.                 if(text != \'delete\' && text != \'abus\')
  120.                 {
  121.  
  122.                 xhr.open( \'POST\', "modules/'.$K_mod.'/comments.php?cmd=add",  true); 
  123.                 xhr.setRequestHeader(\'Content-Type\', \'application/x-www-form-urlencoded\');                
  124.                 xhr.send(\'text=\'+text,\'\');
  125.  
  126.                 }
  127.                 
  128.                 if(text == \'abus\')
  129.                 {
  130.  
  131.                 xhr.open( \'POST\', "modules/'.$K_mod.'/comments.php?cmd=abus",  true); 
  132.                 xhr.setRequestHeader(\'Content-Type\', \'application/x-www-form-urlencoded\');
  133.                 
  134.                 xhr.send(\'id=\'+id);
  135.  
  136.                 }
  137.                 
  138.                 
  139.             }    
  140.         }
  141.  
  142.         '."\n";
  143.         $main .= '</script>'."\n";
  144.         
  145.         $main .= '<div class="tchatche-comments-box">'."\n";
  146.         
  147.         $main .= '<form action="index.php">'."\n";
  148.         //$main .= '<form action="index.php" onkeypress="if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {submitComment(escape(document.getElementById(\'text\').value));return false;}} else {return true}; ">'."\n";
  149.         $main .= '<img class="tchatche-user-infos" src="'.$K_user->avatar.'"  alt="" />'."\n";
  150.         $main .= '<input type="text" name="text" id="text" />'."\n";
  151.         $main .= '<input type="button" value="Tchater" title="Valider avec la touche entrée" onclick="submitComment(escape(document.getElementById(\'text\').value));" /><span id="reponse"></span>'."\n";
  152.         $main .= '</form>'."\n";
  153.         $main .= '<p class="clearer"></p>'."\n";
  154.         $main .= '</div>'."\n";
  155.                 
  156.         echo $main;
  157.     
  158.     }
  159.     
  160.     function tchatche_comment($data)
  161.     {
  162.     global $K_user,$K_mod,$K_theme;
  163.     
  164.  
  165.         $main  = '<div class="tchatche-comments">'."\n";
  166.         $main .=  '<img src="'.$data->u_avatar.'" alt="" class="tchatche-comments-avatar" title="'.$data->userName.'"/>'."\n";
  167.         $main .= '<div class="tchatche-comments-text"><span class="tchatche-comments-date">'.date('H:i:s',$data->time).' :</span> '. bbcode($data->text,1, 0, 0, 0, 0, 0).'</div>'."\n";
  168.         $main .= '<img src="'.(file_exists('modules/tchatche/theme/abus.png') ? 'modules/tchatche/theme/abus.png' : 'themes/'.$K_theme.'/images/abus.png' ).'" alt="" class="tchatche-abus-img" onclick="submitComment(\'abus\',\''.$data->id.'\');" title="Signaler un abus" />'."\n";
  169.         if(get_grade() >= GRD_MODOF)
  170.         {
  171.         $main .= '<img src="'.(file_exists('modules/tchatche/theme/delete.png') ? 'modules/tchatche/theme/delete.png' : 'themes/'.$K_theme.'/images/delete.png' ).'" alt="" class="tchatche-delete-img" onclick="submitComment(\'delete\',\''.$data->id.'\');" title="Supprimer"/>'."\n";
  172.         }
  173.         $main .=  '<div class="clearer"></div>'."\n";
  174.         $main .=  '</div>'."\n";
  175.         
  176.         echo $main;
  177.     
  178.     }
  179.     
  180.     function tchatche_comment_ADM($data)
  181.     {
  182.     global $K_user,$K_mod,$K_theme;
  183.     
  184.  
  185.         $main  = '<div class="tchatche-comments">'."\n";
  186.         $main .=  '<img src="'.$data->u_avatar.'" alt="" class="tchatche-comments-avatar" title="'.$data->userName.'"/>'."\n";
  187.         $main .= '<div class="tchatche-comments-text"><span class="tchatche-comments-date">'.date('H:i:s',$data->time).' :</span> '. bbcode($data->text,1, 0, 0, 0, 0, 0).'</div>'."\n";
  188.         $main .= '<a href="index.php?mod='.$K_mod.'&amp;ac=gestion&amp;cmd=valid&amp;id='.$data->id.'"><img src="'.(file_exists('modules/tchatche/theme/check.png') ? 'modules/tchatche/theme/check.png' : 'themes/'.$K_theme.'/images/check.png' ).'" alt="" class="tchatche-check-img" /></a>'."\n";
  189.         if(get_grade() >= GRD_MODOF)
  190.         {
  191.         $main .= '<a href="index.php?mod='.$K_mod.'&amp;ac=gestion&amp;cmd=remove&amp;id='.$data->id.'"><img src="'.(file_exists('modules/tchatche/theme/delete.png') ? 'modules/tchatche/theme/delete.png' : 'themes/'.$K_theme.'/images/delete.png' ).'" alt="" class="tchatche-delete-img" /></a>'."\n";
  192.         }
  193.         $main .=  '<div class="clearer"></div>'."\n";
  194.         $main .=  '</div>'."\n";
  195.         
  196.         echo $main;
  197.     
  198.     }
  199.     
  200.     function tchatche_onlineh()
  201.     {
  202.     
  203.     $main = null;
  204.     
  205.     $main .= '<h5 class="tchatche-user-online">Membres connect&eacute;s (sur 60 secondes)</h5>'."\n";
  206.     $main .= "\n".'<ul class="tchatche-online-list">'."\n";
  207.     
  208.     echo $main;
  209.     
  210.     }
  211.     
  212.     function tchatche_online($data)
  213.     {
  214.     global $K_user,$K_mod,$K_theme;
  215.     
  216.     $main = null;
  217.     $main .= '<script type="text/javascript">'."\n";
  218.     $main .= 'function online()
  219.         {
  220.             var user_online;
  221.             
  222.             if (window.XMLHttpRequest)    //  Objet standard
  223.             { 
  224.                 user_online = new XMLHttpRequest();     //  Firefox, Safari, ...
  225.             } 
  226.             else  if (window.ActiveXObject)      //  Internet Explorer
  227.             {
  228.                 user_online = new ActiveXObject("Microsoft.XMLHTTP");
  229.             }
  230.  
  231.             user_online.onreadystatechange = function() { alert_online(user_online); };
  232.             user_online.open("POST", "modules/tchatche/online.php", true);
  233.             user_online.send(null);
  234.         }
  235.  
  236.         function alert_online(user_online)
  237.         {
  238.             if (user_online.readyState == 4)
  239.                     {
  240.                         if (user_online.status == 200)
  241.                         {
  242.                             document.getElementById(\'u_online\').innerHTML=user_online.responseText;
  243.                             
  244.                         }
  245.                     }
  246.         }
  247.         
  248.         
  249.         setInterval(\'online()\', 60000);
  250.         window.onload = online();
  251.         '."\n";
  252.         $main .= '</script>'."\n";
  253.         
  254.         if(!empty($data))
  255.         {
  256.         $main .= '<li><img src="'.(file_exists('modules/tchatche/theme/user.png') ? 'modules/tchatche/theme/user.png' : 'themes/'.$K_theme.'/images/user.png' ).'" alt="" /> <a href="'.url_rw('index.php?mod=espace_membre&amp;ac=profil&amp;id='.$data->user,array($data->userName)).'" title="Dernière connexion : '.date('H:i:s',$data->last_time).'">'.$data->userName.'</a></li>'."\n";
  257.         }
  258.         
  259.         echo $main;    
  260.     }
  261.     
  262.     function tchatche_onlinef()
  263.     {
  264.     
  265.     $main = null;
  266.     $main .= '</ul>'."\n";
  267.     
  268.     echo $main;
  269.     
  270.     }
  271.  
  272. } // FIN CLASS
  273.  
  274. ?>
  275.  
  276.  


Sujet écrit par Gothicae le jeudi 12 janvier 2012 à 00:37

[ Imprimer ] - [ Fermer la fenêtre ]