Файл: user/anketa/index.php
Строк: 347
<?php
/* Мод "Анкета"
* Версия v0.0.3
* Дата последнего редактирования 24.04.2015
* Двиг DCMS Special
* Модифицировал densnet
* Файл index.php
* Описание: Анкета
*/
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';
if ((!isset($_SESSION['refer']) || $_SESSION['refer'] == NULL) && isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != NULL &&
!preg_match('#info.php#', $_SERVER['HTTP_REFERER'])) {
$_SESSION['refer'] = str_replace('&', '&', preg_replace('#^http://[^/]*/#', '/', $_SERVER['HTTP_REFERER']));
}
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 = 'Отправить сообщение'>" . img('sms.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'>" . img('new_f.png', '') . " Добавить в друзья</a>";
} else {
echo "<a href = '/user/friends/new.php?del=$ank[id]' class = 'add'>" . img('cancel.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 = 'Отправить сообщение'>" . img('sms.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'>" . img('new_f.png', '') . " Добавить в друзья</a>";
} else {
echo "<a href = '/user/friends/new.php?del=$ank[id]' class = 'add'>" . img('cancel.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=''/>";
echo "<button class = 'add' name = 'submited'>";
echo "Войти";
echo "</button></form>";
echo "<a href = '/user/mail/?new_message=$ank[id]' class = 'add' title = 'Отправить сообщение'>" . img('sms.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'>" . img('new_f.png', '') . " Добавить в друзья</a>";
} else {
echo "<a href = '/user/friends/new.php?del=$ank[id]' class = 'add'>" . img('cancel.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: 18px;font-weight: bold;color:#373e4d;' class = 'comm'>";
echo "<span style = 'float:right'>$ank[nick]</span>";
echo "" . img('user24.png', '') . " Информация</div>";
switch ($mod) {
default:
echo "<div class = 'comm'><a href = '/user/anketa/?name=$ank[nick]&mod=information'>Общие сведения</a></div>";
echo "<div class = 'comm'><a href = '/user/anketa/?name=$ank[nick]&mod=work'>Работа и образование</a></div>";
echo "<div class = 'comm'><a href = '/user/anketa/?name=$ank[nick]&mod=locations'>Место проживания</a></div>";
echo "<div class = 'comm'><a href = '/user/anketa/?name=$ank[nick]&mod=contacts'>Контакты и ссылки</a></div>";
echo "<div class = 'comm'><a href = '/user/anketa/?name=$ank[nick]&mod=family'>Семья и отношения</a></div>";
echo "<div class = 'comm'><a href = '/user/anketa/?name=$ank[nick]&mod=events'>События из жизни</a></div>";
echo "<div class = 'comm'><a href = '/user/anketa/?name=$ank[nick]&mod=activity'>Активность</a></div>";
echo "<div class = 'comm'><a href = '/user/anketa/?name=$ank[nick]&mod=character_type'>Типаж</a></div>";
echo "<div class = 'comm'><a href = '/user/anketa/?name=$ank[nick]&mod=hobbies'>Интересы и увлечения</a></div>";
echo "<div class = 'comm'><a href = '/user/anketa/?name=$ank[nick]&mod=position'>Жизненная позиция</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;
}
echo "<div class = 'comm'>";
if (isset($user) && $user['id'] == $ank['id']) {
echo "<a href = '/user/anketa/setting.php'>" . img('setting.png', '') . " <small>Настройки анкеты</small></a><br />";
}
echo "<a href = '/user/anketa/?name=$user[nick]'>" . img('ank.png', '') . " <small>Посмотреть анкету</small></a>";
echo "</div>";
if ($user['level'] > $ank['level']) {
if (user::access('user_prof_edit')) {
echo "<div class = 'comm'><a href = '/adm_panel/user.php?id=$ank[id]'>" . img('rights.png', '') . " Редактировать профиль</a></div>n";
}
if ($user['id'] != $ank['id']) {
if (user::access('user_ban_set') || user::access('user_ban_set_h') || user::access('user_ban_unset')) {
echo "<div class = 'comm'><a href = '/adm_panel/ban.php?id=$ank[id]'>" . img('rights.png', '') . " Нарушения (бан)</a></div>";
}
if (user::access('user_delete')) {
echo "<div class = 'comm'><a href = '/adm_panel/delete_user.php?id=$ank[id]'>" . img('rights.png', '') . " Удалить пользователя</a></div>n";
}
}
}
if (user::access('adm_log_read') && $ank['level'] != 0 && ($ank['id'] == $user['id'] || $ank['level'] < $user['level'])) {
echo "<div class='comm'><a href='/adm_panel/adm_log.php?id=$ank[id]'>" . img('rights.png', '') . " Отчет по администрированию</a></div>n";
}
require_once H . 'sys/inc/tfoot.php';