View file moduls/mess_chat.php

File size: 3.9Kb
<?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
	 if (!empty($_SESSION['auth_id']) && (intval($_POST['user_id']) == $_SESSION['auth_id']))
	 {
	      $mode = isset($_GET['mode']) ? $_GET['mode'] : NULL;
	      switch ($mode)
	      {
	      case 'userinfo':
	      $user_id = intval($_POST['user_uid']);
	      $q = mysql_query("SELECT * FROM `q_users` WHERE `id_user` = '".$user_id."' LIMIT 1;");
	      $array = mysql_fetch_array($q);
	      echo '<table cellspacing="0" cellpadding="0" width="100%">';
	      echo '<tr>';
	      echo '<td width="65" valign="top">';
	      echo '<a href="/user.php?id='.$array['id_user'].'">';
	      if (!empty($array['avatar'])) {
	      echo '<img class="'.($array['vip_status'] == 1 ? 'photo_bor_vip' : 'photo_bor').'" src="'.DIR_PHOTOS.'/'.$array['id_user'].'/'.$array['avatar'].'" alt="" />';
	      }
	      else echo '<img class="'.($array['vip_status'] == 1 ? 'photo_bor_vip' : 'photo_bor').'" src="/images/no_photo_small.png" alt="" />';
	      echo '</a>';
	      echo '</td>';
	      echo '<td valign="top">';
	      echo '<a class="'.($array['pol'] == 1 ? 'm_color' : 'zh_color').'" href="/user.php?id='.$array['id_user'].'">'.htmlspecialchars($array['name'], ENT_QUOTES).'</a>, <span class="vozrast">'.function_vozrast_n($array['god'].'-'.$array['mes'].'-'.$array['day']).'</span>';
	      echo '<span id="online">';
	      if (function_online($array['online']) == TRUE) echo ' <img src="/images/on.gif" alt="" />';
	      echo '</span>';
	      echo '<br/>';
	      echo '<span class="city">'.htmlspecialchars($array['city'], ENT_QUOTES).', '.htmlspecialchars($array['country'], ENT_QUOTES).'</span>';
	      echo '</td>';
	      echo '</tr>';
	      echo '</table>';
	      break;
	      
	      case 'online':
	      $user_id = intval($_POST['user_uid']);
	      $q = mysql_query("SELECT * FROM `q_users` WHERE `id_user` = '".$user_id."' LIMIT 1;");
	      $array = mysql_fetch_array($q);
	      if (function_online($array['online']) == TRUE) echo ' <img src="/images/on.gif" alt="" />';
	      break;
	      
	      default:
	      $user_uid = intval($_POST['user_uid']);
	      $sql = mysql_query("SELECT * FROM `q_messages` WHERE (`user_uid` = '".$user_uid."' AND `user_id` = '".$_SESSION['auth_id']."' && `n` = '1') OR (`user_uid` = '".$_SESSION['auth_id']."' && `user_id` = '".$user_uid."' && `n` = '1') ORDER BY `id` DESC LIMIT 25;");
	      while ($array = mysql_fetch_array($sql))
	      {
	           mysql_query("UPDATE `q_messages` SET `new` = '1' WHERE `user_uid` = '".$_SESSION['auth_id']."' AND `user_id` = '".$user_uid."';");
		   
		   $s = mysql_query("SELECT * FROM `q_users` WHERE `id_user` = '".$user_uid."' LIMIT 1;");
		   $arr = mysql_fetch_array($s);
		   
		   echo '<div class="msgcolor" style="padding: 2px 0;">';
		   
		   if ($array['user_uid'] == $_SESSION['auth_id']) echo '<strong>Я</strong> &gt; <strong>'.htmlspecialchars($arr['name'], ENT_QUOTES).'</strong> <span style="color: #098035; font-size: 11px;">['.function_vizit($array['time']).']</span>: ';
		   else echo '<strong>'.htmlspecialchars($arr['name'], ENT_QUOTES).'</strong> <span style="color: #098035; font-size: 11px;">['.function_vizit($array['time']).']</span>: ';
		   
		   $msg = function_bigword($array['msg'], 45);
		   $msg = htmlspecialchars($msg, ENT_QUOTES);
		   echo function_smile($msg);
		   
		   echo '</div>';
	      }
	      break;
	      }
	 }
?>