Файл: minichat_by_KoT/minichat_by_KoT/config.php
Строк: 82
<?php
##########################################
# ~ Разработка отдельных модулей ~~~~~~~ #
# ~ и написание скриптов на php (c)KoT ~ #
# ~ ICQ: 7675072 ~~~~~~~~~~~~~~~~~~~~~~~ #
# ~ Site: 4atlove.ru ~~~~~~~~~~~~~~~~~~~ #
# ~ E-mail: notefree@bk.ru ~~~~~~~~~~~~~ #
##########################################
define('DBhost','localhost');
define('DBuser','db_test');
define('DBpass','test');
define('DBname','db_test');
$copy = 'Powered by KoT'; // копирайт
$site = './'; // адрес
$block = '<div class="block"></div>'; // блоки
$SQLlink = '';
$HTTP_USER_AGENT = htmlentities(addslashes($_SERVER['HTTP_USER_AGENT']));
$REMOTE_ADDR = htmlentities(addslashes($_SERVER['REMOTE_ADDR']));
function connect_db()
{
$SQLlink = @mysql_connect(DBhost, DBuser, DBpass);
if ($SQLlink)
{
if (mysql_select_db(DBname))
{
mysql_query('SET charset utf8');
mysql_query('SET names utf8');
mysql_query('SET character_set_client="utf8"');
mysql_query('SET character_set_connection="utf8"');
mysql_query('SET character_set_result="utf8"');
return $SQLlink;
} else {
show_error('Database does not exist...');
}
} else {
show_error('Lost connection to SQL database...');
}
exit;
}
function show_error($err)
{
include 'head.php';
echo $err . '<br/>Обратитесь к Администрации!';
include 'foot.php';
}
include 'function.php';
$times = getmicrotime();
function check_login($link)
{
global $rm,$us,$trun,$id,$usid,$ps,$ref,$bad,$div2,$div5,$copy;
$ref = mt_rand(10000, 1000000);
if (isset($_POST['id'])) $id = (int)$_POST['id'];
elseif (isset($_GET['id'])) $id = (int)$_GET['id'];
elseif (isset($_COOKIE['id'])) $id = (int)$_COOKIE['id'];
elseif (isset($_SESSION['id'])) $id = (int)$_SESSION['id'];
if (isset($_POST['us'])) $us = mysql_real_escape_string(check($_POST['us']));
elseif (isset($_GET['us'])) $us = mysql_real_escape_string(check($_GET['us']));
elseif (isset($_COOKIE['us'])) $us = mysql_real_escape_string(check($_COOKIE['us']));
elseif (isset($_SESSION['us'])) $us = mysql_real_escape_string(check($_SESSION['us']));
if (isset($_POST['ps'])) $ps = mysql_real_escape_string(check($_POST['ps']));
elseif (isset($_GET['ps'])) $ps = mysql_real_escape_string(check($_GET['ps']));
elseif (isset($_COOKIE['ps'])) $ps = mysql_real_escape_string(check($_COOKIE['ps']));
elseif (isset($_SESSION['ps'])) $ps = mysql_real_escape_string(check($_SESSION['ps']));
if (isset($us)) {
$us = trim($us);
if ($us == '') {
$noavt = 1;
}
}
if (isset($id)) {
#if (!ctype_digit($id)) { header("Location: index.php?isset=403"); die; }
$result = mysql_query("SELECT * FROM `users` WHERE `id`='".$id."' LIMIT 1;");
} else {
if (!ctype_digit($us)) {
if ($_POST['trun'] == 1) {
$us = trun_to_rus($us);
}
$latuser = strtolower($us);
$ruser = rus_to_k($us);
if ($ruser == $us) {
$result = mysql_query("SELECT * FROM `users` WHERE `latuser`='".$latuser."' LIMIT 1");
} else {
$result = mysql_query("SELECT * FROM `users` WHERE `ruser`='".$ruser."' LIMIT 1");
}
} else {
$result = mysql_query("SELECT * FROM `users` WHERE `id`='".$us."' LIMIT 1");
}
if (mysql_affected_rows() == 0) {
$noavt = 1;
}
}
$row = mysql_fetch_array($result);
if (!isset($id)) {
$id = $row['id'];
}
if ($ps !== $row['pass']) {
$noavt = 1;
}
$_SESSION['us'] = $us;
$_SESSION['id'] = $id;
$_SESSION['ps'] = $ps;
if (!$_SESSION['id']) {
include 'head.php';
echo '<META HTTP-EQUIV="Refresh" CONTENT="1; URL=index.php?'.$ref.'">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body>
' . $bad . 'Время сессии истекло!' . $div5;
include 'foot.php';
unset($_SESSION['id']);
unset($_SESSION['ps']);
$row = false;
exit;
}
if ($noavt == 1)
{
include 'head.php';
echo '<META HTTP-EQUIV="Refresh" CONTENT="1; URL=index.php?'.$ref.'">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body>
' . $bad . 'Ошибка Авторизации!' . $div5;
include 'foot.php';
unset($_SESSION['id']);
unset($_SESSION['ps']);
$row = false;
exit;
}
return array($row, $id, $ps);
}
?>