Файл: modules/friends/add.php
Строк: 28
<?php
define('R', $_SERVER['DOCUMENT_ROOT']);
define('S', R.'/system');
#
require_once(R.'/system/kernel.php');
$tmp->header('friends');
$tmp->title('title', Language::config('friends'));
User::panel();
if(User::aut()) {
    if(isset($_GET['id'])){
        $id = my_int($_GET['id']);
    }
    if (User::ID() == $id) {
        exit();
    }
    $p = $db->fass("SELECT * FROM `users` WHERE `id` = '".$id."' ");
    
    if (!$p) $error .= Language::config('error');
    
    $pr = $db->fass_c("SELECT COUNT(*) as count FROM `friends` WHERE `kto` = '".User::ID()."' and `komy` = '".$id."'");
    $pr2 = $db->fass_c("SELECT COUNT(*) as count FROM `friends` WHERE `kto` = '".$id."' and `komy` = '".User::ID()."'");
    
    if ($pr2 != 0) {
        header('location: /friends/bid');
        exit();
    }
    
    if ($pr != 0) $error .= Language::config('error');
    if(!isset($error)){
        $db->query("INSERT INTO `friends` set `kto` = '".User::ID()."', `komy` = '".$id."', `status` = '0'  ");
        header('location: /friends/bid');
        //header('location: /us'.$id.'');
    }
    error($error);
} else {
    header('location: /');
}
$tmp->footer();
?>