Файл: _modules/friends/del/index.php
Строк: 23
<?php
# mark core v1.0
# author Drk in
# date 24.10.19
# core
require_once ( $_SERVER['DOCUMENT_ROOT']."/_core/system.php" );
# user
system::access(true);
# get
$id = isset( $_GET['id'] ) ? system::abs($_GET['id']): 0;
# check
if ($id == 0)system::header('/map');
if (cache_user::ch($id) == false)system::header('/map');
$data = cache_user::get($id);
if ($id == $user['id'])system::header('/id/'.$id,'Сталкер нельзя удалить себя');
$friends = DB :: $dbh -> querySingle("SELECT count(id) FROM friends WHERE user = ? AND data = ?;", array($user['id'],$id));
if (empty($friends))system::header('/id/'.$id,'Сталкер у вас нет в друзях');
# delete user
$fr_us = DB :: $dbh -> queryFetch("SELECT id FROM friends WHERE user = ? AND data = ? LIMIT 1;", array($user['id'],$id));
if (!empty($fr_us)):
DB :: $dbh -> query("DELETE FROM friends WHERE id = ? LIMIT 1;", array($fr_us['id']));
@unlink(cache."_friends/".$fr_us['id'].".data");
endif;
# delete data
$fr_dt = DB :: $dbh -> queryFetch("SELECT id FROM friends WHERE user = ? AND data = ? LIMIT 1;", array($id,$user['id']));
if (!empty($fr_dt)):
DB :: $dbh -> query("DELETE FROM friends WHERE id = ? LIMIT 1;", array($fr_dt['id']));
@unlink(cache."_friends/".$fr_dt['id'].".data");
endif;
# send mail
send::mail($id,system::check($user['login']).', удалил вас из друзей!');
# header
system::header('/id/'.$id,'Сталкер успешно удален из друзей');
?>