<?php
define('_IN_JOHNCMS', 1);
require('../incfiles/core.php');
$textl = '&#350;ahsy habarlary okamak';
require('../incfiles/head.php');
echo '<div class="phdr">'.$textl.'</div>';
////// Anbketa funk ///////
function anketa($fid){
$fid = trim($fid);
$kim2 = mysql_query("SELECT `name` FROM `users` WHERE `id`='$fid'");
$kim = mysql_fetch_array($kim2);
$name = '<b> '.$kim['name'].'</b>';
if ($kim2==0) {
return '<b><del>&Ouml;&ccedil;&uuml;rilen</del></b>';
}else{
return '<a href="/users/profile.php?user='.$fid.'"><b>'.$name.'</b></a>';
}}
/////////////////////////



if (core::$user_rights < 8) {
echo '<div class="rmenu">Munu&#328; &yacute;aly sahypa &yacute;ok!</div>';
require('../incfiles/end.php');
exit;
}

if(isset($_GET['virus'])) { $virus = trim($_GET['virus']); }
switch($virus){

default;
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_mail`"),0);
if ($total==0) {
echo '<div class="menu">&#350;ahsy habarlar h&auml;zirlik&ccedil;e &yacute;ok!</div>';
}
$q=mysql_query("SELECT * FROM `cms_mail` ORDER BY id DESC LIMIT $start,$kmess");
while ($post = mysql_fetch_assoc($q)) {
if ($post['user_id']==0) {
} else
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$post['user_id']."'"));
$ank2 = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$post['from_id']."'"));
$text = functions::checkout($post['text'], 1, 1);
if ($set_user['smileys'])
$text = functions::smileys($text, $res['rights'] >= 1 ? 1 : 0);
echo '<div class="menu">';
echo 'Kimden: '.anketa($ank['id']).'';
echo '<div class="fr"><b>'.functions::display_date($post['time']).'</b></div>';
echo '<br>Kime: '.anketa($ank2['id']).'<br />';
echo 'Sene: '.functions::display_date($post['time']).'<br />';
echo 'Habar teksti: '.$text.'<br />';
echo '[<a href="mail.php?virus=tasdiq&amp;id='.$post['id'].'">&Ouml;&ccedil;&uuml;rmek</a>]<br />';
echo '</div>';
}
if ($total > $kmess) echo '<div class="topmenu">' . functions::display_pagination('mail.php?', $start, $total, $kmess) . '</div>';
echo '<div class="phdr">Umumy: '.$total.'</div>';
break;

case del;
if (mysql_query("DELETE FROM `cms_mail` WHERE `id` = '".trim(mysql_real_escape_string($_GET['id']))."'")) header('location:mail.php');
break;

case tasdiq;
$pos = mysql_fetch_array(mysql_query("SELECT * FROM `cms_mail` WHERE `id`='".trim(mysql_real_escape_string($_GET['id']))."'"));
$text = functions::checkout($pos['text'], 1, 1);
if ($set_user['smileys'])
$text = functions::smileys($text, $res['rights'] >= 1 ? 1 : 0);
echo '<div class="gmenu">';
echo '<b>Habar:</b> '.$text;
echo '</div>';
echo '<div class="menu" align ="center"><span class="red">&#350;u habary &ouml;&ccedil;&uuml;rm&auml;ge ynamy&#328;yz barmy?</span><br />
<a href="mail.php?virus=del&amp;id='.$pos['id'].'">Hawa</a> | <a href="mail.php">&Yacute;ok</a></div>';
break;

}
require('../incfiles/end.php');
?>