View file chat.php

File size: 4.51Kb
<?php
/**********************************************/
/* Автор скрипта: Александр Есин              */
/* E-Mail: [email protected] ([email protected]) */
/* ICQ: 6464729                               */
/* Site: http://ticlove.ru                    */
/**********************************************/
?>
<?php define ('SECURED', true); ?>
<?php require (dirname(__FILE__).'/_inc/sql.php'); ?>
<?php require (dirname(__FILE__).'/_inc/config.php'); ?>
<?php require (dirname(__FILE__).'/_inc/function.php'); ?>
<?php $title_page = 'Чат'; ?>
<?php $description_page = 'Чат для общения'; ?>
<?php $keywords_page = 'чат'; ?>
<?php include (dirname(__FILE__).'/include/header.php'); ?>
<div id="block_left">
<?php include (dirname(__FILE__).'/include/lider.php'); ?>
</div>
<div id="content_page">
<div class="tit_zag">Чатик</div>
<div class="clear"></div>
<div class="tit_zag_hr"></div>



<noindex>
<div style="margin-top: 5px;"><a class="addchat" href="javascript:void(0)" onclick="<?php echo (!isset($_SESSION['auth_id']) ? 'javascript:NoAuth()' : 'javascript:add_chat()'); ?>">Написать</a></div>
<div class="hr"></div>
</noindex>
<?php $sql = mysql_query("SELECT * FROM `q_smschat` INNER JOIN `q_users` ON `q_users`.`id_user` = `q_smschat`.`user_id` ORDER BY `q_smschat`.`time` DESC LIMIT 10;"); ?>
<?php while ($array = mysql_fetch_array($sql)) { ?>
<a class="<?php echo ($array['pol'] == 1 ? 'm_color' : 'zh_color'); ?>" href="http://<?php echo $_SERVER['HTTP_HOST']; ?>/id<?php echo $array['id_user']; ?>"><?php echo htmlspecialchars($array['name'], ENT_QUOTES); ?></a>, <span class="vozrast"><?php echo function_vozrast_n($array['god'].'-'.$array['mes'].'-'.$array['day']); ?></span>, <span class="city"><?php echo htmlspecialchars($array['city'], ENT_QUOTES); ?></span><br/>
<div style="padding-bottom: 5px;"><?php echo htmlspecialchars(function_bigword($array['msg'], 25), ENT_QUOTES); ?><br/>
<noindex>
<?php
if ($array['id_user'] != $_SESSION['auth_id']) {
echo '<a '.(!isset($_SESSION['auth_id']) ? 'href="javascript:void(0)" onclick="javascript:NoAuth()"' : 'href="/messages.php?page=chat&amp;user_uid='.$array['id_user'].'"').'>Ответить</a>';
}
?>
</noindex>
</div>
<div style="border-top: 1px dotted #666666; padding-top: 5px; color: #565656;"></div>
<?php } ?>
<noindex>
<div class="hr"></div>
<div><a class="addchat" href="javascript:void(0)" onclick="<?php echo (!isset($_SESSION['auth_id']) ? 'javascript:NoAuth()' : 'javascript:add_chat()'); ?>">Написать</a></div>
</noindex>
</div>
<noindex>
<script type="text/javascript">
function add_chat() {
$(document).ready(function() {
     $.arcticmodal({
     type: 'ajax',
     url: '/moduls/add_chat.php',
     ajax: {
          type: 'POST',
          data: { user_id: <?php echo (isset($_SESSION['auth_id']) ? $_SESSION['auth_id'] : 0); ?> },
          dataType: 'html',
          success: function(data, el, responce) {
               var h = $(responce);
               $('B', h).html(responce.title);
               $('P:last', h).html(responce.text);
               data.body.html(h);
          }
     }
});
});
};

function chat_send_msg() {
      $('#ChatStatusMsg').hide();
      $('#ChatStatusMsg').fadeIn(900);
      var msg = $('#msg').val();
      if (msg == '') { $("#ChatStatusMsg").html('<span style="color: #ff0000;">Введите сообщение</span>'); }
      else if (msg.length > 1000) { $("#ChatStatusMsg").html('<span style="color: #ff0000;">Сообщение слишком длинное</span>'); }
      else
      {
           chat_send_go();
      }
      $('#ChatStatusMsg').fadeOut(1200);
};

function chat_send_go() {
$(document).ready(function() {
$.ajax({
     type: "POST",
     url: "moduls/add_chat.php?page=add",
     data: { user_id: <?php echo (isset($_SESSION['auth_id']) ? $_SESSION['auth_id'] : 0); ?>, msg: $('#msg').val() },
     beforeSend: function()
     {
          $("#ChatStatus").html('<img src="images/ajax.gif" alt="" />');
     },
     success: function(data)
     {
          $("#ChatStatus").html(data);
     },
     error: function()
     {
          $("#ChatStatus").html('<span style="color: #ff0000;">Произошла неизвестная ошибка.' + '<br/>' + 'Возможно, проблемы с подключением к интернету.</span>');
     }
});
});
};
</script>
</noindex>






</div>
<div class="clear"></div>
<?php include (dirname(__FILE__).'/include/footer.php'); ?>