Файл: user/anketa/index.php
Строк: 388
<?php
/* DCMS S (Special)
 * Версия файла 0.0.1
 * Дата последнего редактирования 22.11.2015
 * Модифицировал densnet
 */
require_once '../../sys/inc/start.php';
require_once H . 'sys/inc/compress.php';
require_once H . 'sys/inc/sess.php';
require_once H . 'sys/inc/settings.php';
require_once H . 'sys/inc/db_connect.php';
require_once H . 'sys/inc/ipua.php';
require_once H . 'sys/inc/fnc.php';
require_once H . 'sys/inc/user.php';
if (isset($user)) {
    $ank['id'] = $user['id'];
}
if (isset($_GET['id'])) {
    $ank['id'] = intval($_GET['id']);
} elseif (isset($_GET['name'])) {
    $arr['nick'] = $_GET['name'];
    $nick = mysql_real_escape_string($arr['nick']);
    $res = mysql_query("SELECT `id` FROM `user` WHERE `nick`='$nick';");
    if (mysql_num_rows($res) > 0) {
        $row = mysql_fetch_assoc($res);
        $ank['id'] = $row['id'];
    } else {
        $ank['id'] = 0;
    }
}
if ($ank['id'] == 0) {
    exit;
}
$ank = user::get_user($ank['id']);
if (!$ank) {
    header("Location: /index.php?" . SID);
    exit;
}
$set['title'] = $ank['nick'] . ' - анкета '; // заголовок страницы
require_once H . 'sys/inc/thead.php';
title();
aut();
$user_voice = mysql_result(mysql_query("SELECT COUNT(*) FROM `user_voice2` WHERE `id_user` = '$ank[id]' OR `id_kont` = '$ank[id]'"), 0);
if ($ank['id'] != $user['id']) {
    mysql_query("UPDATE `user` SET `viewing` = '" . ($ank['viewing'] + 1) . "' WHERE `id` = '$ank[id]' LIMIT 1");
}
if (isset($_POST['password'])) {
    $set_cook = $_POST['password'];
    setcookie("passprofile$ank[id]", $set_cook);
    if (isset($_POST['password']) && $_POST['password'] == $ank['anketa_password']) {
        header("Location: ?id=$ank[id]");
    }
}
if ($ank['anketa_access'] == 'only_me') {
    if ($ank['id'] == $user['id'] && isset($user) || $user['level'] >= 3) {
        
    } else {
        echo "<table class='errs'><tr><td class = 'icon14'>";
        avatar($ank['id'], '48');
        echo "</td><td class = 'null'>";
        echo "Доступ к анкете <b>$ank[nick]</b> закрыт.<br /><br />";
        echo "<a href = '/user/mail/?new_message=$ank[id]' class = 'add' title = 'Отправить сообщение' style = 'color:#88C057;'><img src = '/style/icons/mail.png' /> Сообщение</a> ";
        if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE `user` = '$user[id]' AND `friends` = '$ank[id]'"), 0) == 0) {
            echo "<a href = '/user/friends/add.php?id=$ank[id]' class = 'add' style = 'color:#88C057;'><img src = '/style/icons/plus.png' /> Добавить в друзья</a>";
        } else {
            echo "<a href = '/user/friends/new.php?del=$ank[id]' class = 'add' style = 'color:#ED7161;'><img src = '/style/icons/Minus.png' /> Удалить из друзей</a>";
        }
        echo "</td></tr></table>";
        require_once H . 'sys/inc/tfoot.php';
        exit();
    }
} elseif ($ank['anketa_access'] == 'friends') {
    if ($ank['id'] == $user['id'] && isset($user) || $user['level'] >= 3 || $ank['id'] == $user['id'] && isset($user) || isset($umodd) || mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE (`user` = '$user[id]' AND `friends` = '$ank[id]') OR (`user` = '$ank[id]' AND `friends` = '$user[id]')"), 0) != 0) {
        
    } else {
        echo "<table class = 'errs'><tr><td class = 'icon14'>";
        avatar($ank['id'], '48');
        echo "</td><td class = 'null'>";
        echo "Доступ к профилю <b>$ank[nick]</b> открыт только для друзей пользователя.<br /><br />";
        echo "<a href = '/user/mail/?new_message=$ank[id]' class = 'add' title = 'Отправить сообщение' style = 'color:#88C057;'><img src = '/style/icons/mail.png' /> Сообщение</a> ";
        if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE `user` = '$user[id]' AND `friends` = '$ank[id]'"), 0) == 0) {
            echo "<a href = '/user/friends/add.php?id=$ank[id]' class = 'add' style = 'color:#88C057;'><img src = '/style/icons/plus.png' /> Добавить в друзья</a>";
        } else {
            echo "<a href = '/user/friends/new.php?del=$ank[id]' class = 'add' style = 'color:#ED7161;'><img src = '/style/icons/Minus.png' /> Удалить из друзей</a>";
        }
        echo "</td></tr></table>";
        require_once H . 'sys/inc/tfoot.php';
        exit();
    }
} elseif ($ank['anketa_access'] == 'pass') {
    if (isset($_COOKIE["passprofile$ank[id]"]) && $_COOKIE["passprofile$ank[id]"] == $ank['profile_password'] || $ank['id'] == $user['id'] && isset($user) || $user['level'] >= 3) {
        
    } else {
        if (isset($_POST['password']) && $_POST['password'] != $ank['profile_password']) {
            $err[] = "Пароль неправильный.";
        }
        err();
        echo "<table class = 'errs'><tr><td class = 'icon14'>";
        avatar($ank['id'], '48');
        echo "</td><td class = 'null'>";
        echo "<form action='' method='post'>";
        echo "Доступ к профилю <b>$ank[nick]</b> доступен только по паролю:<br/>";
        echo "<input name='password' aria-required = 'true' aria-invalid = 'false' required = 'required' type = 'password' value=''/><br />";
        echo "<button class = 'button-green' name = 'submited'>Войти</button>";
        echo "</form><br />";
        echo "<a href = '/user/mail/?new_message=$ank[id]' class = 'add' title = 'Отправить сообщение' style = 'color:#88C057;'><img src = '/style/icons/mail.png' /> Сообщение</a> ";
        if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE `user` = '$user[id]' AND `friends` = '$ank[id]'"), 0) == 0) {
            echo "<a href = '/user/friends/add.php?id=$ank[id]' class = 'add' style = 'color:#88C057;'><img src = '/style/icons/plus.png' /> Добавить в друзья</a>";
        } else {
            echo "<a href = '/user/friends/new.php?del=$ank[id]' class = 'add' style = 'color:#ED7161;'><img src = '/style/icons/Minus.png' /> Удалить из друзей</a>";
        }
        echo "</td></tr></table>";
        require_once H . 'sys/inc/tfoot.php';
        exit();
    }
}
$timediff = mysql_result(mysql_query("SELECT `time` FROM `user` WHERE `id` = '$ank[id]' LIMIT 1", $db), 0);
$oneMinute = 60;
$oneHour = 60 * 60;
$oneDay = 60 * 60 * 24;
$dayfield = floor($timediff / $oneDay);
$hourfield = floor(($timediff - $dayfield * $oneDay) / $oneHour);
$minutefield = floor(($timediff - $dayfield * $oneDay - $hourfield * $oneHour) / $oneMinute);
$secondfield = floor(($timediff - $dayfield * $oneDay - $hourfield * $oneHour - $minutefield * $oneMinute));
$sDaysLeft = $dayfield;
$sDaysText = "дней";
$nDaysLeftLength = strlen($sDaysLeft);
$d_1 = substr($sDaysLeft, -1, 1);
if (substr($sDaysLeft, -2, 1) != 1 && $nDaysLeftLength > 1) {
    if ($d_1 == 2 || $d_1 == 3 || $d_1 == 4) {
        $sDaysText = "дня";
    } elseif ($d_1 == 1) {
        $sDaysText = "день";
    }
}
if ($nDaysLeftLength == 1) {
    if ($d_1 == 2 || $d_1 == 3 || $d_1 == 4) {
        $sDaysText = "дня";
    } elseif ($d_1 == 1) {
        $sDaysText = "день";
    }
}
$sHoursLeft = $hourfield;
$sHoursText = "часов";
$nHoursLeftLength = strlen($sHoursLeft);
$h_1 = substr($sHoursLeft, -1, 1);
if (substr($sHoursLeft, -2, 1) != 1 && $nHoursLeftLength > 1) {
    if ($h_1 == 2 || $h_1 == 3 || $h_1 == 4) {
        $sHoursText = "часа";
    } elseif ($h_1 == 1) {
        $sHoursText = "час";
    }
}
if ($nHoursLeftLength == 1) {
    if ($h_1 == 2 || $h_1 == 3 || $h_1 == 4) {
        $sHoursText = "часа";
    } elseif ($h_1 == 1) {
        $sHoursText = "час";
    }
}
$sMinsLeft = $minutefield;
$sMinsText = "минут";
$nMinsLeftLength = strlen($sMinsLeft);
$m_1 = substr($sMinsLeft, -1, 1);
if ($nMinsLeftLength > 1 && substr($sMinsLeft, -2, 1) != 1) {
    if ($m_1 == 2 || $m_1 == 3 || $m_1 == 4) {
        $sMinsText = "минуты";
    } else if ($m_1 == 1) {
        $sMinsText = "минута";
    }
}
if ($nMinsLeftLength == 1) {
    if ($m_1 == 2 || $m_1 == 3 || $m_1 == 4) {
        $sMinsText = "минуты";
    } elseif ($m_1 == "1") {
        $sMinsText = "минута";
    }
}
$sSecsLeft = $secondfield;
$sSecsText = "секунд";
$s_1 = substr($sSecsLeft, -1, 1);
$nSecsLeftLength = strlen($sSecsLeft);
if (substr($sSecsLeft, -2, 1) != 1 && $nSecsLeftLength > 1) {
    if ($s_1 == 2 || $s_1 == 3 || $s_1 == 4) {
        $sSecsText = "секунды";
    } elseif ($s_1 == 1) {
        $sSecsText = "секунда";
    }
}
if ($nSecsLeftLength == 1) {
    if ($s_1 == 2 || $s_1 == 3 || $s_1 == 4) {
        $sSecsText = "секунды";
    } elseif ($sSecsLeft == "1") {
        $sSecsText = "секунда";
    }
}
$displaystring = "" .
        $sDaysLeft . " " .
        $sDaysText . " " .
        $sHoursLeft . " " .
        $sHoursText . " " .
        $sMinsLeft . " " .
        $sMinsText . " " .
        $sSecsLeft . " " .
        $sSecsText;
if ($timediff < 0) {
    $displaystring = 'дата уже наступила';
}
$time_online = $displaystring;
$mod = (isset($_GET['mod'])) ? htmlspecialchars($_GET['mod']) : null;
echo "<div style = 'font-size: 16px;font-weight: bold;color:#9197a3;-webkit-font-smoothing: antialiased;text-transform: uppercase;' class = 'list-group-item'>";
echo "<span style = 'float:right'>$ank[nick]</span>";
echo "Информация</div>";
switch ($mod) {
    default:
        echo "<div class = 'list-group-item'><a href = '/user/anketa/?name=$ank[nick]&mod=information'><span class='fa fa-sticky-note-o fa-fw'></span> Общие сведения</a></div>";
        echo "<div class = 'list-group-item'><a href = '/user/anketa/?name=$ank[nick]&mod=work'><span class='fa fa-briefcase fa-fw'></span> Работа и образование</a></div>";
        echo "<div class = 'list-group-item'><a href = '/user/anketa/?name=$ank[nick]&mod=locations'><span class='fa fa-building fa-fw'></span> Место проживания</a></div>";
        echo "<div class = 'list-group-item'><a href = '/user/anketa/?name=$ank[nick]&mod=contacts'><span class='fa fa-phone-square fa-fw'></span> Контакты и ссылки</a></div>";
        echo "<div class = 'list-group-item'><a href = '/user/anketa/?name=$ank[nick]&mod=family'><span class='fa fa-female fa-fw'></span> Семья и отношения</a></div>";
        echo "<div class = 'list-group-item'><a href = '/user/anketa/?name=$ank[nick]&mod=events'><span class='fa fa-calendar-check-o fa-fw'></span> События из жизни</a></div>";
        echo "<div class = 'list-group-item'><a href = '/user/anketa/?name=$ank[nick]&mod=activity'><span class='fa fa-commenting-o fa-fw'></span> Активность</a></div>";
        echo "<div class = 'list-group-item'><a href = '/user/anketa/?name=$ank[nick]&mod=character_type'><span class='fa fa-user-secret fa-fw'></span> Типаж</a></div>";
        echo "<div class = 'list-group-item'><a href = '/user/anketa/?name=$ank[nick]&mod=hobbies'><span class='fa fa-futbol-o fa-fw'></span> Интересы и увлечения</a></div>";
        echo "<div class = 'list-group-item'><a href = '/user/anketa/?name=$ank[nick]&mod=position'><span class='fa fa-child fa-fw'></span> Жизненная позиция</a></div>";
        break;
    case 'information':
        #редактирование здесь
        include 'edit.php';
        include 'information.php';
        break;
    case 'work':
        #редактирование здесь
        include 'edit.php';
        include 'work.php';
        break;
    case 'locations':
        #редактирование здесь
        include 'edit.php';
        include 'locations.php';
        break;
    case 'contacts':
        #редактирование здесь
        include 'edit.php';
        include 'contacts.php';
        break;
    case 'family':
        #редактирование здесь
        include 'edit.php';
        include 'family.php';
        break;
    case 'events':
        #редактирование здесь
        include 'edit.php';
        include 'events.php';
        break;
    case 'activity':
        #редактирование здесь
        include 'edit.php';
        include 'activity.php';
        break;
    case 'character_type':
        #редактирование здесь
        include 'edit.php';
        include 'character_type.php';
        break;
    case 'hobbies':
        #редактирование здесь
        include 'edit.php';
        include 'hobbies.php';
        break;
    case 'position':
        #редактирование здесь
        include 'edit.php';
        include 'position.php';
        break;
}
if (isset($user) && $user['id'] == $ank['id']) {
    echo "<a href = '/user/settings.php?act=private&set=anketa' class='list-group-item'><span class='fa fa-cog'></span> Приватность анкеты</a>";
}
echo "<a href='/user/anketa/?name=$user[nick]' class='list-group-item'><span class='fa fa-pencil-square-o'></span> Анкета</a>";
if ($user['level'] > $ank['level']) {
    if (user::access('user_prof_edit')) {
        echo "<a href='/panel/user.php?id=$ank[id]' class='list-group-item'><span class='fa fa-pencil-square-o'></span> Редактировать профиль</a>n";
    }
    if ($user['id'] != $ank['id']) {
        if (user::access('user_ban_set') || user::access('user_ban_set_h') || user::access('user_ban_unset')) {
            echo "<a href = '/panel/ban.php?id=$ank[id]' class='list-group-item'><span class='fa fa-gavel'></span> Нарушения (бан)</a>";
        }
        if (user::access('user_delete')) {
            echo "<a href = '/panel/delete_user.php?id=$ank[id]' class='list-group-item'><span class='fa fa-user-times'></span> Удалить пользователя</a>n";
        }
    }
}
if (user::access('adm_log_read') && $ank['level'] != 0 && ($ank['id'] == $user['id'] || $ank['level'] < $user['level'])) {
    echo "<a href = '/panel/adm_log.php?id=$ank[id]' class='list-group-item'><span class='fa fa-list-alt'></span> Отчет по администрированию</a>n";
}
require_once H . 'sys/inc/tfoot.php';