battles/data/contact.php

74 lines
3.3 KiB
PHP

<?php
session_start();
if(!isset($_SESSION['uid'])) { die(); }
include("../config.php");
include("../functions.php");
if(!isset($user['id']) || ($user['align'] <= 1.7 && $user['align'] > 2 && $user['align'] != '2.99')) {
exit();
}
function nics($id) {
$user = mysql_fetch_array(mysql_query("SELECT `id`, `align`, `level`, `login`, `klan` FROM `users` WHERE `id` = '{$id}' LIMIT 1"));
if(isset($user['id'])) {
$mm .= '<img src=\'i/align_'.($user['align'] > 0 ? $user['align']:0).'.gif\' />';
if($user['klan'] > 0) {
$mm .= '<img title=\''.ClanImage($user['klan']).'\' src=\'i/klan/'.ClanImage($user['klan']).'.gif\' />';
}
$mm .= '<b>'.$user['login'].'</b> ['.$user['level'].']<a href=inf.php?'.$user['id'].' target=_blank><img src=i/inf.gif width=12 height=11 /></a>';
}
return $mm;
}
$action = isset($_GET["act"]) ? $_GET["act"] : "";
$fid = isset($_GET["fid"]) ? $_GET["fid"] : "";
$page = isset($_GET["page"]) ? $_GET["page"] : 0;
if(!empty($fid)) {
$txt = mysql_fetch_array(mysql_query('SELECT `id`, `text` FROM `forum` WHERE `id` = "'.$fid.'" LIMIT 1'));
}
if($action == "edit" && !empty($fid)) {
$output = "<div style='display: none;'><div class='contact-top'></div><div class='contact-content'>
<h1 class='contact-title'>Редактирование сообщения :</h1>
<div class='contact-loading' style='display: none;'></div>
<div class='contact-message' style='display: none;'></div>
<form action='#' style='display: none;'>";
$output .= "<textarea id='contact-message' class='contact-input' name='message' cols='40' rows='4' tabindex='1004' style=\"margin: 4px; height: 409px; width: 944px; max-height: 409px; max-width: 944px;\">".$txt['text']."</textarea><br />";
$output .= "<label>&nbsp;</label><span style=\"float: left;\">
<input type=\"hidden\" name=\"fids\" value=\"$fid\" />
<input type=\"hidden\" name=\"page\" value=\"$page\" />
<button type='submit' class='contact-send contact-button' tabindex='1006'>Сохранить</button>
<button type='submit' class='contact-cancel contact-button simplemodal-close' tabindex='1007'>Отмена</button>
</span>
<br />
</form>
</div>
<div class='contact-bottom'></div></div>";
echo $output;
} elseif($action == "send") {
$txt = iconv('UTF-8', 'utf-8', $_GET['message']);
$us = nics($user['id']);
$txt .= '<br /><b style=\'color: Red;\'>Откредактировал :</b> '.$us;
$forum = mysql_fetch_array(mysql_query('SELECT `id`, `parent` FROM `forum` WHERE `id` = "'.$_GET['fids'].'" LIMIT 1'));
if($forum['parent'] <= 100) {
$forum['parent'] = $_GET['fids'];
} else {
$forum['parent'] = $forum['parent'];
}
$top = mysql_fetch_array(mysql_query('SELECT `id`, `parent` FROM `forum` WHERE `id` = "'.$forum['parent'].'" LIMIT 1'));
$loc = mysql_fetch_array(mysql_query('SELECT `id` FROM `forum` WHERE `id` = "'.$top['parent'].'" AND `type` = 1 LIMIT 1'));
mysql_query('UPDATE `forum` SET `text` = "'.$txt.'" WHERE `id` = "'.$_GET['fids'].'" LIMIT 1');
echo 'Изменения вступили в силу. Обновляю.';
echo '<script>location.href="forum.php?topic='.$forum['parent'].'&konftop='.$loc['id'].'&page='.$_GET['page'].'";</script>';
} else {
exit();
}
exit;
?>