View file xmyx.ru/club/act/edit_status.php

File size: 2.66Kb
<?

/*
 * Author - Tw1nGo
 * VK - https://vk.com/tw1ngo93
*/

if (isset($_GET['id'])){
    $group = mysql_fetch_assoc(mysql_query("SELECT * FROM `groups` WHERE `id` = '".abs(intval($_GET['id']))."' LIMIT 1"));
}
if (!isset($_GET['id']) || !isset($group) || $group['id'] <= 0){
    header("Location: /groups");
    exit;
}

if ($group['typic'] == 0){
$text_privat = 'Группа';
}else if ($group['typic'] == 1){
$text_privat = 'Закрытая группа';
}else if ($group['typic'] == 2){
$text_privat = 'Частная группа';
}

$set['title'] = ''.text($group['title']).'';
include_once H.'sys/inc/thead.php';

// Конфигурационный файл
require 'config.php';

shapka_VK(true, '/group'.$group['id'].'', ''.$text_privat.'');

if (isset($user) && ($user['id'] == $group['id_user'] || $user['level'] >= 4)){

# Само изменение
if (isset($user) && isset($_POST['message']))
{

$msg = $_POST['message'];
$mat = antimat($msg);
if ($mat)$err[] = 'В тексте статуса обнаружен мат: '.$mat;

if (strlen2($msg) > 250){
	$err='Статус слишком длинный, max. 250 символов!';
}
elseif(!isset($err)){

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `groups` WHERE `id` = '$group[id]' AND `status` = '".my_esc($msg)."' LIMIT 1"),0)!=0)
{
	mysql_query("UPDATE `groups` SET `status` = '".my_esc($msg)."' WHERE `id` = '".$group['id']."' LIMIT 1");
}
else{
	mysql_query("UPDATE `groups` SET `status` = '".my_esc($msg)."' WHERE `id` = '".$group['id']."' LIMIT 1");
}

header("Location: /group".$group['id']."");
exit;
} 
}
# Удаляем статус
if (isset($user) && isset($_GET['to']) && $_GET['to'] == 'dell_status')
{
	mysql_query("UPDATE `groups` SET `status` = '' WHERE `id` = '".$group['id']."' LIMIT 1");
	header("Location: /group".$group['id']."");
	exit;
}

?>
<div class="pcont fit_box bl_cont">
<div class="owner_panel profile_panel">
<img src="<?= Tw1nGo::Ava($group['id'])?>" class="op_fimg">
<div class="op_fcont">
<h2 class="op_header"><?= text($group['title'])?></h2>
</div>
<div class="pp_edit_status">
<div class="pointer"><i class="i_pointer"></i></div>
<form action="?act=edit_status" method="post">
<div class="iwrap"><input name="message" class="textfield" value="<?= ($group['status'] != NULL ? ''.text($group['status']).'' : '')?>" autofocus="autofocus" type="text"></div>
<div class="pp_buttons_block">
<input class="button" value="Сохранить" type="submit">
<?
if ($group['status'] != NULL){
?>
<div class="near_btn"><a href="?act=edit_status&to=dell_status">Удалить статус</a></div>
<?
}
?>
</div>
</form>
</div>
</div>
</div>
<?
}
else{
	header("Location: /group".$group['id']."");
	exit;
}
?>