Файл: config.php
Строк: 1294
<?
ob_start();
/*
define('DB_host','localhost');
define('DB_user','db1363599167');
define('DB_pass','53f4gh5f4gjhf5g4khj3f54gjh3f54j');
define('DB_db','db1363599167');
*/
define('DB_host','localhost');
define('DB_user','mysql');
define('DB_pass','mysql');
define('DB_db','bak_raduga');
class Tgen
{
public function startTimer()
{
global $starttime;
$mtime = microtime ();
$mtime = explode (' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
}
public function endTimer()
{
global $starttime;
$mtime = microtime ();
$mtime = explode (' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$endtime = round ((($endtime - $starttime)/10), 4);
return $endtime;
}
}
$debag = new Tgen;
$debag->startTimer();
if (function_exists('mb_internal_encoding')) mb_internal_encoding('UTF-8');
@error_reporting(E_ALL ^ E_NOTICE);
@ini_set('display_errors', true);
@ini_set('html_errors', true);
@ini_set('error_reporting', E_ALL ^ E_NOTICE);
@ini_set('url_rewriter.tags', '');
@ini_set('session.use_trans_sid', 1);
session_name('SID');
@session_start();
$SID = session_id();
$SID=md5(rand(09009,999999));
$flevel = NULL;
$flevelk=0;
while (!is_file($flevel.'config.php') && $flevelk<20)
{
$flevel.='../';
$flevelk++;
}
define('H', $flevel);
define('F', 'http://'.$_SERVER['HTTP_HOST'].'/forum/');
define('H2', 'http://'.$_SERVER['HTTP_HOST'].'/');
class sql_db
{
var $db_connect_id;
var $query_result;
var $row = array();
var $rowset = array();
var $num_queries = 0;
var $in_transaction = 0;
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->password = $sqlpassword;
$this->server = $sqlserver;
$this->dbname = $database;
$this->db_connect_id = ($this->persistency) ? mysql_pconnect($this->server, $this->user, $this->password) : mysql_connect($this->server, $this->user, $this->password);
if( $this->db_connect_id )
{
if( $database != "" )
{
$this->dbname = $database;
$dbselect = mysql_select_db($this->dbname);
if( !$dbselect )
{
mysql_close($this->db_connect_id);
$this->db_connect_id = $dbselect;
}
}
return $this->db_connect_id;
}
else
{
return false;
}
}
function sql_close()
{
if( $this->db_connect_id )
{
if( $this->in_transaction )
{
mysql_query("COMMIT", $this->db_connect_id);
}
return mysql_close($this->db_connect_id);
}
else
{
return false;
}
}
function sql_query($query = "", $transaction = FALSE)
{
unset($this->query_result);
if( $query != "" )
{
$this->num_queries++;
if( $transaction == "BEGIN_TRANSACTION" && !$this->in_transaction )
{
$result = mysql_query("BEGIN", $this->db_connect_id);
if(!$result)
{
return false;
}
$this->in_transaction = TRUE;
}
$this->query_result = mysql_query($query, $this->db_connect_id);
}
else
{
if( $transaction == "END_TRANSACTION" && $this->in_transaction )
{
$result = mysql_query("COMMIT", $this->db_connect_id);
}
}
if( $this->query_result )
{
unset($this->row[$this->query_result]);
unset($this->rowset[$this->query_result]);
if( $transaction == "END_TRANSACTION" && $this->in_transaction )
{
$this->in_transaction = FALSE;
if ( !mysql_query("COMMIT", $this->db_connect_id) )
{
mysql_query("ROLLBACK", $this->db_connect_id);
return false;
}
}
return $this->query_result;
}
else
{
if( $this->in_transaction )
{
mysql_query("ROLLBACK", $this->db_connect_id);
$this->in_transaction = FALSE;
}
return false;
}
}
function sql_numrows($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
return ( $query_id ) ? mysql_num_rows($query_id) : false;
}
function sql_affectedrows()
{
return ( $this->db_connect_id ) ? mysql_affected_rows($this->db_connect_id) : false;
}
function sql_numfields($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
return ( $query_id ) ? mysql_num_fields($query_id) : false;
}
function sql_fieldname($offset, $query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
return ( $query_id ) ? mysql_field_name($query_id, $offset) : false;
}
function sql_fieldtype($offset, $query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
return ( $query_id ) ? mysql_field_type($query_id, $offset) : false;
}
function sql_fetchrow($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
if( $query_id )
{
$this->row[$query_id] = mysql_fetch_array($query_id, MYSQL_ASSOC);
return $this->row[$query_id];
}
else
{
return false;
}
}
function sql_fetchrowset($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
if( $query_id )
{
unset($this->rowset[$query_id]);
unset($this->row[$query_id]);
while($this->rowset[$query_id] = mysql_fetch_array($query_id, MYSQL_ASSOC))
{
$result[] = $this->rowset[$query_id];
}
return $result;
}
else
{
return false;
}
}
function sql_fetchfield($field, $rownum = -1)
{
if( $rownum > -1 )
{
$result = mysql_result($field, $rownum);
}
else
{
if( empty($this->row[$query_id]) && empty($this->rowset[$query_id]) )
{
if( $this->sql_fetchrow() )
{
$result = $this->row[$query_id][$field];
}
}
else
{
if( $this->rowset[$query_id] )
{
$result = $this->rowset[$query_id][0][$field];
}
else if( $this->row[$query_id] )
{
$result = $this->row[$query_id][$field];
}
}
}
return $result;
}
function sql_rowseek($rownum, $query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
return ( $query_id ) ? mysql_data_seek($query_id, $rownum) : false;
}
function sql_nextid()
{
return ( $this->db_connect_id ) ? mysql_insert_id($this->db_connect_id) : false;
}
function sql_freeresult($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
if ( $query_id )
{
unset($this->row[$query_id]);
unset($this->rowset[$query_id]);
mysql_free_result($query_id);
return true;
}
else
{
return false;
}
}
function sql_error()
{
$result['message'] = mysql_error($this->db_connect_id);
$result['code'] = mysql_errno($this->db_connect_id);
return $result;
}
}
$db = new sql_db(DB_host, DB_user, DB_pass, DB_db, false);
if(!$db->db_connect_id)
{
echo '
<div align="center">
Сайт недоступен по техническим причинам!
Приносим свои извинения!
<br />
Проверьте настройки соединения с БД!
<br />
</div>
';
exit;
}
if($db_charset_utf) $db->sql_query("SET NAMES utf8");
mysql_query('SET charset utf8');
mysql_query('SET character_set_client="utf8"');
mysql_query('SET character_set_connection="utf8"');
mysql_query('SET character_set_result="utf8"');
$id = isset ($_REQUEST['id']) ? trim($_REQUEST['id']) : false;
$m = isset ($_REQUEST['m']) ? abs(intval($_REQUEST['m'])) : false;
$page = isset ($_REQUEST['page']) && $_REQUEST['page'] > 0 ? abs(intval($_REQUEST['page'])) : 1;
$start = isset ($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0;
$act = isset ($_REQUEST['act']) ? trim($_REQUEST['act']) : '';
$mod = isset ($_REQUEST['mod']) ? trim($_REQUEST['mod']) : '';
$do = isset ($_REQUEST['go']) ? trim($_REQUEST['go']) : '';
class ipinit
{
public $ip; // IP адрес в LONG формате
public $flood_chk = 1; // Включение - выключение функции IP антифлуда
public $flood_interval = '120'; // Интервал времени в секундах
public $flood_limit = '50'; // Число разрешенных запросов за интервал (50)
public $flood_file = 'shaxty_antiflood.dat'; // Рабочий файл функции
private $requests; // Число запросов с IP адреса за период времени
function __construct()
{
$this->ip = ip2long($this->getip());
if ($this->flood_chk)
{
$this->requests = $this->reqcount();
if ($this->requests > $this->flood_limit)
die('Куда спешишь?! Не Флуди!!!');
}
}
private function getip()
{
if (isset ($_SERVER['HTTP_X_FORWARDED_FOR']) && $this->ip_valid($_SERVER['HTTP_X_FORWARDED_FOR']))
{
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
elseif ($_SERVER['REMOTE_ADDR'])
{
return $_SERVER['REMOTE_ADDR'];
}
else
{
die('Unknown IP');
}
}
private function reqcount()
{
global $db, $rootpath;
$sys = array();
$requests = 1;
if (!file_exists(H.'files/' . $this->flood_file))
$in = fopen(H.'files/' . $this->flood_file, "w+");
else
$in = fopen(H.'files/' . $this->flood_file, "r+");
flock($in, LOCK_EX) or die("Cannot flock ANTIFLOOD file.");
$now = time();
while ($block = fread($in, 8))
{
$arr = unpack("Lip/Ltime", $block);
if (($now - $arr['time']) > $this->flood_interval)
{
continue;
}
if ($arr['ip'] == $this->ip)
{
$requests++;
}
$sys[] = $arr;
}
fseek($in, 0);
ftruncate($in, 0);
for ($i = 0; $i < count($sys); $i++)
{
fwrite($in, pack('LL', $sys[$i]['ip'], $sys[$i]['time']));
}
fwrite($in, pack('LL', $this->ip, $now));
fclose($in);
return $requests;
}
function ip_valid($ip = '')
{
$d = explode('.', $ip);
for ($x = 0; $x < 4; $x++)
if (!is_numeric($d[$x]) || ($d[$x] < 0) || ($d[$x] > 255))
return false;
return $ip;
}
}
$ipinit = new ipinit();
$ipl = $ipinit->ip;
$ip = long2ip($ipl);
unset ($ipinit);
if ( isset($_SERVER['HTTP_USER_AGENT']) )
{
$soft=$_SERVER['HTTP_USER_AGENT'];
$soft = strtok($soft, '(');
$soft = preg_replace('~[^a-z_./ 0-9]~i', null, $soft);
if ( isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) && strstr($soft, 'Opera') )
{
$soft_om = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
$soft_om = strtok($soft_om, '/');
$soft_om = strtok($soft_om, '(');
$soft_om = preg_replace('~[^a-z_. 0-9]~i', null, $soft_om);
$soft = 'Opera Mini ('.$soft_om.')';
}
}
else $soft='Нет данных';
$soft=mysql_escape_string(stripslashes(htmlspecialchars($soft)));
$ref=rand(10000,1000000);
$set = $db->sql_fetchrow($db->sql_query ("Select * from setting where ids='1'"));
if (!isset($user))$time = ($starttime+$set['timesdvig']*60*60);
else if ($user['poias']!='') $time = (($starttime-3*60*60)+$user['poias']*60);
////////////////// Боты ///////////////////////
$user_um = '<b>'.$set['umnik'].'</b>'; //
$user_prod = '<b>'.$set['baryga'].'</b>'; //
$user_shut = '<b>'.$set['shut'].'</b>'; //
$user_anek = '<b>'.$set['anek'].'</b>'; //
$user_tupica = '<b>'.$set['tupica'].'</b>'; //
$user_svaisch = '<b>'.$set['svaisch'].'</b>'; //
$user_system = '<b>'.$set['system'].'</b>'; //
$user_znatok = '<b>'.$set['znatok'].'</b>'; //
$user_flyder = '<b>'.$set['flyder'].'</b>'; //
$mafiozi = ''.$set['mafiozi'].''; //
/////////////////////////////////////////////////
function check($str)
{
$str = htmlentities(trim($str), ENT_QUOTES, 'UTF-8');
$str = nl2br($str);
$str = strtr($str, array (chr(0)=> '',chr(1)=> '',chr(2)=> '',chr(3)=> '',chr(4)=> '',chr(5)=> '',chr(6)=> '',chr(7)=> '',chr(8)=> '',chr(9)=> '',chr(10)=> '',chr(11)=> '',chr(12)=> '',chr(13)=> '',chr(14)=> '',chr(15)=> '',chr(16)=> '',chr(17)=> '',chr(18)=> '',chr(19)=> '',chr(20)=> '',chr(21)=> '',chr(22)=> '',chr(23)=> '',chr(24)=> '',chr(25)=> '',chr(26)=> '',chr(27)=> '',chr(28)=> '',chr(29)=> '',chr(30)=> '',chr(31)=> ''));
$str = str_replace("'", "'", $str);
$str = str_replace('\', "\", $str);
$str = str_replace("|", "I", $str);
$str = str_replace("||", "I", $str);
$str = str_replace("/\$/", "$", $str);
$str = mysql_real_escape_string($str);
$str = iconv('utf-8', 'windows-1251', $str);
$str = iconv('windows-1251', 'utf-8', $str);
return $str;
}
function my_int($var)
{
$var = abs((int)$var);
return $var;
}
function esc2($msg)
{
for ($i=0;$i<10;$i++)$msg=str_replace(chr($i), NULL, $msg);
for ($i=11;$i<20;$i++)$msg=str_replace(chr($i), NULL, $msg);
for ($i=21;$i<=31;$i++)$msg=str_replace(chr($i), NULL, $msg);
return $msg;
}
if (get_magic_quotes_gpc())
{
$in = array(&$_GET, &$_POST, &$_COOKIE);
while (list($k, $v) = each($in))
{
foreach ($v as $key => $val)
{
if (!is_array($val))
{
$in[$k][$key] = stripslashes($val);
continue;
}
$in[] = &$in[$k][$key];
}
}
unset ($in);
if (!empty ($_FILES))
{
foreach ($_FILES as $k => $v)
{
$_FILES[$k]['name'] = stripslashes((string) $v['name']);
}
}
}
foreach ($_GET as $check_url)
{
if (is_string($check_url) && !preg_match('#^(?:[a-z0-9_-/]+|.+(?!/))*$#i', $check_url))
{
header ('Location: '.H.'?err=403&'.SID);exit;
}
}
unset($check_url);
function maketime($string)
{
if($string < 3600)
{
$string = sprintf("%02d:%02d", (int)($string / 60) % 60, $string % 60);
}
else
{
$string = sprintf("%02d:%02d:%02d", (int)($string / 3600) % 24, (int)($string / 60) % 60, $string % 60);
}
return $string;
}
function makestime($string)
{
$day=floor($string/86400);
$hours=floor(($string/3600)-$day*24);
$min=floor(($string-$hours*3600-$day*86400)/60);
$sec=$string-($min*60+$hours*3600+$day*86400);
$sec=intval($sec);
return $day.' дн. '.$hours.'час. '.$min.'мин. '.$sec.'сек. ';
}
function calc_age($d, $m, $y)
{
$age = date('Y') - $y;
$_m = date('m');
if($_m < $m || ($_m == $m && date('d') < $d))
$age--;
return $age;
}
function win_to_utf($str)
{
$str=strtr($str,array(''=>'а',''=>'б',''=>'в',''=>'г',''=>'д',''=>'е',''=>'ё',''=>'ж',''=>'з',''=>'и',''=>'й',''=>'к',''=>'л',''=>'м',''=>'н',''=>'о',''=>'п',''=>'р',''=>'с',''=>'т',''=>'у',''=>'ф',''=>'х',''=>'ц',''=>'ч',''=>'ш',''=>'щ',''=>'ъ',''=>'ы',''=>'ь',''=>'э',''=>'ю',''=>'я',''=>'А',''=>'Б',''=>'В',''=>'Г',''=>'Д',''=>'Е',''=>'Ё',''=>'Ж',''=>'З',''=>'?',''=>'Й',''=>'К',''=>'Л',''=>'М',''=>'Н',''=>'О',''=>'П',''=>'Р',''=>'С',''=>'Т',''=>'У',''=>'Ф',''=>'Х',''=>'Ц',''=>'Ч',''=>'Ш',''=>'Щ',''=>'Ъ',''=>'Ы',''=>'Ь',''=>'Э',''=>'Ю',''=>'Я'));
return $str;
}
function utf_to_win($str)
{
$str=strtr($str,array('а'=>'','б'=>'','в'=>'','г'=>'','д'=>'','е'=>'','ё'=>'','ж'=>'','з'=>'','и'=>'','й'=>'','к'=>'','л'=>'','м'=>'','н'=>'','о'=>'','п'=>'','р'=>'','с'=>'','т'=>'','у'=>'','ф'=>'','х'=>'','ц'=>'','ч'=>'','ш'=>'','щ'=>'','ъ'=>'','ы'=>'','ь'=>'','э'=>'','ю'=>'','я'=>'','А'=>'','Б'=>'','В'=>'','Г'=>'','Д'=>'','Е'=>'','Ё'=>'','Ж'=>'','З'=>'','И'=>'','Й'=>'','К'=>'','Л'=>'','М'=>'','Н'=>'','О'=>'','П'=>'','Р'=>'','С'=>'','Т'=>'','У'=>'','Ф'=>'','Х'=>'','Ц'=>'','Ч'=>'','Ш'=>'','Щ'=>'','Ъ'=>'','Ы'=>'','Ь'=>'','Э'=>'','Ю'=>'','Я'=>''));
return $str;
}
function getmicrotime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
function rus_to_k($str)
{
$str = strtr($str, array ('а' => 'a','б' => 'b','в' => 'v','г' => 'g','д' => 'd','е' => 'e','ё' => 'e','ж' => 'j','з' => 'z','и' => 'i','й' => 'y','к' => 'k','л' => 'l','м' => 'm','н' => 'n','о' => 'o','п' => 'p','р' => 'r','с' => 's','т' => 't','у' => 'u','ф' => 'f','х' => 'h','ч' => 'c','ц' => 'q','ш' => 'w','щ' => '>','ь' => '<','ы' => 'x','ъ' => '.','э' => ':','ю' => ';','я' => '}','А' => 'a','Б' => 'b','В' => 'v','Г' => 'g','Д' => 'd','Е' => 'e','Ё' => 'e','Ж' => 'j','З' => 'z','И' => 'i','Й' => 'y','К' => 'k','Л' => 'l','М' => 'm','Н' => 'n','О' => 'o','П' => 'p','Р' => 'r','С' => 's','Т' => 't','У' => 'u','Ф' => 'f','Х' => 'h','Ч' => 'c','Ц' => 'q','Ш' => 'w','Щ' => '>','Ь' => '<','Ы' => 'x','Ъ' => '.','Э' => ':','Ю' => ';','Я' => '}'));
return $str;
}
function rus_to_lat($str)
{
$str = strtr($str, array ('а' => 'a','б' => 'b','в' => 'v','г' => 'g','д' => 'd','е' => 'e','ё' => 'e','ж' => 'j','з' => 'z','и' => 'i','й' => 'i','к' => 'k','л' => 'l','м' => 'm','н' => 'n','о' => 'o','п' => 'p','р' => 'r','с' => 's','т' => 't','у' => 'u','ф' => 'f','х' => 'h','ц' => 'c','ч' => 'ch','ш' => 'sh','щ' => 'sch','ъ' => "",'ы' => 'y','ь' => "",'э' => 'ye','ю' => 'yu','я' => 'ya'));
return $str;
}
function tolower($str)
{
if (function_exists('mb_strtolower')) return mb_strtolower($str, 'utf-8');
$arraytolower = array('А' => 'а', 'Б' => 'б', 'В' => 'в', 'Г' => 'г', 'Д' => 'д', 'Е' => 'е', 'Ё' => 'ё', 'Ж' => 'ж', 'З' => 'з', 'И' => 'и', 'Й' => 'й', 'К' => 'к', 'Л' => 'л', 'М' => 'м', 'Н' => 'н', 'О' => 'о', 'П' => 'п', 'Р' => 'р', 'С' => 'с', 'Т' => 'т', 'У' => 'у', 'Ф' => 'ф', 'Х' => 'х', 'Ц' => 'ц', 'Ч' => 'ч', 'Ш' => 'ш', 'Щ' => 'щ', 'Ь' => 'ь', 'Ъ' => 'ъ', 'Ы' => 'ы', 'Э' => 'э', 'Ю' => 'ю', 'Я' => 'я','A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd', 'E' => 'e', 'I' => 'i', 'F' => 'f', 'G' => 'g', 'H' => 'h', 'J' => 'j', 'K' => 'k', 'L' => 'l', 'M' => 'm', 'N' => 'n', 'O' => 'o', 'P' => 'p', 'Q' => 'q', 'R' => 'r', 'S' => 's', 'T' => 't', 'U' => 'u', 'V' => 'v', 'W' => 'w', 'X' => 'x', 'Y' => 'y', 'Z' => 'z');
return strtr($str, $arraytolower);
}
function translit($str)
{
$str = strtr($str, array ('a' => 'а','b' => 'б','v' => 'в','g' => 'г','d' => 'д','e' => 'е','yo' => 'ё','zh' => 'ж','z' => 'з','i' => 'и','j' => 'й','k' => 'к','l' => 'л','m' => 'м','n' => 'н','o' => 'о','p' => 'п','r' => 'р','s' => 'с','t' => 'т','u' => 'у','f' => 'ф','h' => 'х','c' => 'ц','ch' => 'ч','w' => 'ш','sh' => 'щ','q' => 'ъ','y' => 'ы','x' => 'э','yu' => 'ю','ya' => 'я','A' => 'А','B' => 'Б','V' => 'В','G' => 'Г','D' => 'Д','E' => 'Е','YO' => 'Ё','ZH' => 'Ж','Z' => 'З','I' => 'И','J' => 'Й','K' => 'К','L' => 'Л','M' => 'М','N' => 'Н','O' => 'О','P' => 'П','R' => 'Р','S' => 'С','T' => 'Т','U' => 'У','F' => 'Ф','H' => 'Х','C' => 'Ц','CH' => 'Ч','W' => 'Ш','SH' => 'Щ','Q' => 'Ъ','Y' => 'Ы','X' => 'Э','YU' => 'Ю','YA' => 'Я'));
return $str;
}
function strlen2($str)
{
if (function_exists('mb_strlen')) return mb_strlen($str, 'utf-8');
if (function_exists('iconv_strlen')) return iconv_strlen($str, 'utf-8');
if (function_exists('utf8_decode')) return strlen(utf8_decode($str));
return strlen(utf_to_win($str));
}
function substr2($str)
{
global $db, $user,$set;
$str=substr($str, 0, $set['size_lich']);
$str=preg_replace('#^(?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,0}'.'((?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,500}).*#s','$1',$str);
return $str;
}
function slv($str,$msg1,$msg2,$msg3)
{
$str = (int)$str;
$str1 = abs($str) % 100;
$str2 = $str % 10;
if ($str1 > 10 && $str1 < 20)return $str .' '. $msg3;
if ($str2 > 1 && $str2 < 5)return $str .' '. $msg2;
if ($str2 == 1)return $str .' '. $msg1;
return $str .' '. $msg3;
}
function times($times=NULL)
{
//global $time;
$time = time();
if(($time-$times)<=60)
{
$timesp = slv((($time-$times)),'секунду','секунды','секунд').' назад';
return $timesp;
}
elseif(($time-$times)<=3600)
{
$timesp = slv((($time-$times)/60),'минуту','минуты','минут').' назад';
return $timesp;
}
else
{
$today = date("j M Y", $time);
$today = date("j M Y", $time);
$yesterday = date("j M Y", strtotime("-1 day"));
$timesp=date("j M Y в H:i", $times);
$timesp = str_replace($today, 'Сегодня', $timesp);
$timesp = str_replace($yesterday, 'Вчера', $timesp);
$timesp = strtr($timesp, array ('Jan' => 'Янв','Feb' => 'Фев','Mar' => 'Марта',
'May' => 'Мая','Apr' => 'Апр','Jun' => 'Июня',
'Jul' => 'Июля','Aug' => 'Авг',
'Sep' => 'Сент','Oct' => 'Окт',
'Nov' => 'Ноября','Dec' => 'Дек',));
return $timesp;
}
}
function times2($times=NULL)
{
global $db, $_GET;
$timesp=date("j M в H:i", $times);
$timesp = strtr($timesp, array ("Jan" => "Янв","Feb" => "Фев",
"Mar" => "Марта","May" => "Мая","Apr" => "Апр","Jun" => "Июня",
"Jul" => "Июля","Aug" => "Авг","Sep" => "Сент","Oct" => "Окт",
"Nov" => "Ноября","Dec" => "Дек",));
if (isset($_GET['timesp']))$timesp='12';
return $timesp;
}
function opsos($ips=NULL)
{
global $db, $ip;
if ($ips==NULL)$ips=$ip;
$ipl=ip2long($ips);
if ($db->sql_fetchfield($db->sql_query("SELECT COUNT(*) FROM `opsos` WHERE `min` <= '$ipl' AND `max` >= '$ipl'"), 0)!=0)
{
$opsos=$db->sql_fetchrow($db->sql_query("SELECT opsos FROM `opsos` WHERE `min` <= '$ipl' AND `max` >= '$ipl' LIMIT 1"));
return check($opsos['opsos']);
}
else return false;
}
function page($k_page=1)
{
$page=1;
$page=check($page);
$k_page=check($k_page);
if (isset($_GET['page']))
{
if ($_GET['page']=='end')
$page=check(intval($k_page));
elseif(is_numeric($_GET['page']))
$page=check(intval($_GET['page']));
}
if ($page<1)$page=1;
if ($page>$k_page)$page=$k_page;
return $page;
}
function k_page($k_post=0,$k_p_str=10)
{
if ($k_post!=0)
{
$v_pages=ceil($k_post/$k_p_str);
return $v_pages;
}
else
return 1;
}
$HOSTik = md5($_SERVER['HTTP_HOST']);
function str($link='?',$k_page=1,$page=1)
{
if ($page<1)$page=1;
$page=check($page);
$k_page=check($k_page);
if ($page!=1)
echo '<a href="'.$link.'page=1"><<</a> ';
if ($page>1)
echo '<a href="'.$link.'page='.($page-1).'"><</a> ';
echo " ";
if ($page<$k_page)
echo ' <a href="'.$link.'page='.($page+1).'" >></a>';
if ($page!=$k_page)
echo ' <a href="'.$link.'page=end">>></a>';
echo "<br />";
if ($page!=1)
echo '<a href="'.$link.'page=1" >1</a>';
else
echo '<b>1</b>';
for ($ot=-3; $ot<=3; $ot++)
{
if ($page+$ot>1 && $page+$ot<$k_page)
{
if ($ot==-3 && $page+$ot>2)
echo " ..";
if ($ot!=0)echo '|<a href="'.$link.'page='.($page+$ot).'" >'.($page+$ot).'</a>';
else
echo '|<b>'.($page+$ot).'</b>';
if ($ot==3 && $page+$ot<$k_page-1)
echo "|..";
}
}
if ($page!=$k_page)
echo '|<a href="'.$link.'page=end" >'.$k_page.'</a>';
else
if ($k_page>1)
echo '|<b>'.$k_page.'</b>';
}
function str2($link='?',$k_page=1,$page=1)
{
if ($page<1)$page=1;
$page=check($page);
$k_page=check($k_page);
if ($page!=1)
echo "<a href="".$link."_1"><<</a> ";
if ($page>1)
echo "<a href="".$link."_".($page-1).""><</a> ";
echo " ";
if ($page<$k_page)
echo " <a href="".$link."_".($page+1)."" >></a>";
if ($page!=$k_page)
echo " <a href="".$link."_end">>></a>";
echo "<br />";
if ($page!=1)
echo "<a href="".$link."_1" >1</a>";
else
echo "<b>1</b>";
for ($ot=-3; $ot<=3; $ot++)
{
if ($page+$ot>1 && $page+$ot<$k_page)
{
if ($ot==-3 && $page+$ot>2)
echo " ..";
if ($ot!=0)
echo "|<a href="".$link."_".($page+$ot)."" >".($page+$ot)."</a>";
else
echo "|<b>".($page+$ot)."</b>";
if ($ot==3 && $page+$ot<$k_page-1)
echo "|..";
}
}
if ($page!=$k_page)
echo "|<a href="".$link."_end" >$k_page</a>";
elseif ($k_page>1)
echo "|<b>$k_page</b>";
}
function passgen($k_simb=8)
{
$password="";
$small="abcdefghijklmnopqrstuvwxyz";
$large="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$numbers="1234567890";
mt_srand((double)microtime()*1000000);
for ($i=0; $i<$k_simb; $i++)
{
$type=mt_rand(1,3);
switch ($type)
{
case 1:
$password.=$large[mt_rand(0,25)];
break;
case 2:
$password.=$small[mt_rand(0,25)];
break;
case 3:
$password.=$numbers[mt_rand(0,9)];
break;
}
}
return $password;
}
function kikt($t)
{
global $db, $time;
$t2 = $t-$time;
if($t2>(60*60*24*30)) $t3 = round($t2/(60*60*24*30)).' месяцев';
else if($t2>(60*60*24)) $t3 = round($t2/(60*60*24)).' дней';
else if($t2>(60*60)) $t3 = round($t2/(60*60)).' часов';
else if($t2>60) $t3 = round($t2/60).' минут';
else $t3 = $t2.' секунд';
return $t3;
}
function lev_neme($lv)
{
global $db, $time;
$ln = @$db->sql_fetchrow($db->sql_query ("Select * from levels where level='".intval($lv)."'"));
return $ln['name'];
}
function addmail($usermail, $subject, $msg)
{
global $db, $set;
$mail = 'admin@'.$_SERVER['HTTP_HOST'];
$name = $set['name'];
function utf_to_win2($str)
{
if (function_exists('mb_convert_encoding')) return mb_convert_encoding($str, 'windows-1251', 'utf-8');
if (function_exists('iconv')) return iconv('utf-8', 'windows-1251', $str);
$utf8win1251 = array("А"=>"xC0","Б"=>"xC1","В"=>"xC2","Г"=>"xC3","Д"=>"xC4","Е"=>"xC5","Ё"=>"xA8","Ж"=>"xC6","З"=>"xC7","И"=>"xC8","Й"=>"xC9","К"=>"xCA","Л"=>"xCB","М"=>"xCC","Н"=>"xCD","О"=>"xCE","П"=>"xCF","Р"=>"xD0","С"=>"xD1","Т"=>"xD2","У"=>"xD3","Ф"=>"xD4","Х"=>"xD5","Ц"=>"xD6","Ч"=>"xD7","Ш"=>"xD8","Щ"=>"xD9","Ъ"=>"xDA",
"Ы"=>"xDB","Ь"=>"xDC","Э"=>"xDD","Ю"=>"xDE","Я"=>"xDF","а"=>"xE0","б"=>"xE1","в"=>"xE2","г"=>"xE3","д"=>"xE4","е"=>"xE5","ё"=>"xB8","ж"=>"xE6","з"=>"xE7",
"и"=>"xE8","й"=>"xE9","к"=>"xEA","л"=>"xEB","м"=>"xEC","н"=>"xED","о"=>"xEE","п"=>"xEF","р"=>"xF0","с"=>"xF1","т"=>"xF2","у"=>"xF3","ф"=>"xF4","х"=>"xF5",
"ц"=>"xF6","ч"=>"xF7","ш"=>"xF8","щ"=>"xF9","ъ"=>"xFA","ы"=>"xFB","ь"=>"xFC","э"=>"xFD","ю"=>"xFE","я"=>"xFF");
return strtr($str, $utf8win1251);
}
$subject = utf_to_win2($subject);
$msg = utf_to_win2($msg);
$name = utf_to_win2($name);
$subject = convert_cyr_string($subject, 'w','k');
$msg = convert_cyr_string($msg, 'w','k');
$name = convert_cyr_string($name, 'w','k');
$subject = '=?KOI8-R?B?'.base64_encode($subject).'?=';
$adds = "From: ".$name." <".$mail.">n";
$adds .= "X-sender: ".$name." <".$mail.">n";
$adds .= "Content-Type: text/plain; charset=koi8-rn";
$adds .= "MIME-Version: 1.0n";
$adds .= "Content-Transfer-Encoding: 8bitn";
$adds .= "X-Mailer: PHP v.".phpversion();
return mail($usermail,$subject,$msg,$adds);
}
function smiles($msg)
{
$sql = mysql_query("SELECT * FROM `smile`");
while ($smile = mysql_fetch_assoc($sql))
{
$msg=str_replace($smile['name'],'<img src="/upload/smiles/'.$smile['smile'].'" alt="'.$smile['name'].'"/>',$msg);
$msg=str_replace($smile['name1'],'<img src="/upload/smiles/'.$smile['smile'].'" alt="'.$smile['name1'].'"/>',$msg);
$msg=str_replace($smile['name2'],'<img src="/upload/smiles/'.$smile['smile'].'" alt="'.$smile['name2'].'"/>',$msg);
$msg=str_replace($smile["name3"],'<img src="/upload/smiles/'.$smile['smile'].'" alt="'.$smile['name3'].'"/>',$msg);
}
return $msg;
}
function links_preg1($arr)
{
return '<a href="'.$arr[1].'">'.$arr[2].'</a>';
}
function links_preg2($arr)
{
return $arr[1].'<a href="'.$arr[2].'">'.$arr[2].'</a>'.$arr[4];
}
function links($msg)
{
$msg=preg_replace_callback('~[url=([^ rnt`'"]+)](.*?)[/url]~iu', 'links_preg1', $msg);
$msg=preg_replace_callback('~(^|s)([a-z]+://([^ rnt`'"]+))(s|$)~iu', 'links_preg2', $msg);
return $msg;
}
if (ini_get('register_globals'))
{
$allowed = array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1);
foreach ($GLOBALS as $key => $value)
{
if (!isset($allowed[$key]))
{
unset($GLOBALS[$key]);
}
}
}
function highlight($code)
{
$code = strtr($code, array('<br />' => "rn", '<br/>' => "rn", '<' => '<', '>' => '>', '&' => '&', '$' => '$', '"' => '"', ''' => "'", '\' => '\', '`' => '`', '%' => '%', '^' => '^'));
if (!strpos($code, '<?') && mb_substr($code, 0, 2, 'UTF-8') != '<?')
{
$code = "<?phprn" . trim($code) . "rn?>";
}
$code = highlight_string($code, true);
$code = strtr($code, array('<br />' => "rn", '<br/>' => "rn"));
$code = preg_replace('|( {2,})|', "rn1", $code);
$codeline = explode("rn", $code);
foreach($codeline as $line => $string)
{
if ($string != '')
{
$ret .= '<li> ' . trim($string) . '</li>';
}
}#<span style="color:#666">' . ($line + 1) . '</span><br/>
$code = strtr($ret, array('$' => '$', "'" => ''', '\' => '\', '`' => '`', '%' => '%', '^' => '^'));
return '<div class="code"><ol>' . $code . '</ol></div>';
}
#############################################
function BBcode($msg)
{
$msg=preg_replace('#[b](.*?)[/b]#si', '<span style="font-weight: bold;">1</span>', $msg);
$msg=preg_replace('#[i](.*?)[/i]#si', '<span style="font-style: italic;">1</span>', $msg);
$msg=preg_replace('#[u](.*?)[/u]#si', '<span style="text-decoration: underline;">1</span>', $msg);
$msg=preg_replace('#[b](.*?)[/b]#si', '<span style="font-weight: bold;">1</span>', $msg);
$msg=preg_replace('#[i](.*?)[/i]#si', '<span style="font-style: italic;">1</span>', $msg);
$msg=preg_replace('#[q](.*?)[/q]#si', '<span style="text-decoration: underline;">1</span>', $msg);
$msg=preg_replace('#[del](.*?)[/del]#si', '<del>1</del>', $msg);
$msg=preg_replace('#[small](.*?)[/small]#si', '<span style="font-size: small;">1</span>', $msg);
$msg=preg_replace('#[big](.*?)[/big]#si', '<span style="font-size: large;">1</span>', $msg);
$msg=preg_replace('#[blink](.*?)[/blink]#si', '<blink>1</blink>', $msg);
$msg=preg_replace('#[red](.*?)[/red]#si', '<span style="color:#FF0000;">1</span>', $msg);
$msg=preg_replace('#[green](.*?)[/green]#si', '<span style="color:#00FF00;">1</span>', $msg);
$msg=preg_replace('#[blue](.*?)[/blue]#si', '<span style="color:#0000FF;">1</span>', $msg);
$msg=preg_replace('#[yellow](.*?)[/yellow]#si', '<span style="color:#ffff22;">1</span>', $msg);
$msg=preg_replace('#[fea](.*?)[/fea]#si', '<span style="color:#FF00FF;">1</span>', $msg);
$msg = preg_replace('#[code](.*?)[/code]#ie', "highlight('$1')", $msg);
$msg=preg_replace('#[img](.*?)[/img]#si', '<img src="1"/>', $msg);
return $msg;
}define('vb12', true);
function br($msg,$br='<br />')
{
$msg=eregi_replace("((<br( ?/?)>)|n|r)+",$br, $msg);
return $msg;
}
function esc($text,$br=NULL)
{
if ($br!=NULL)
for ($i=0;$i<=31;$i++)$text=str_replace(chr($i), NULL, $text);
else
{
for ($i=0;$i<10;$i++)$text=str_replace(chr($i), NULL, $text);
for ($i=11;$i<20;$i++)$text=str_replace(chr($i), NULL, $text);
for ($i=21;$i<=31;$i++)$text=str_replace(chr($i), NULL, $text);
}
return $text;
}
function text($str,$br=true,$html=true,$smiles=true,$links=true,$bbcode=true)
{
if ($html==true)
if ($smiles==true)
$str=smiles($str);
if ($links==true)
$str=links($str);
if ($bbcode==true)
$str=bbcode($str);
if ($br==true)
{
$str=br($str);
$str=esc($str);
}
else
{
$str=esc($str);
}
return $str;
}
function color_msg($text)
{
global $db, $set,$user, $msg;
if ($msg['color']==1)$text = '[red]'.$msg['msg'].'[/red]';
elseif ($msg['color']==2)$text = '[blue]'.$msg['msg'].'[/blue]';
elseif ($msg['color']==3)$text = '[fea]'.$msg['msg'].'[/fea]';
elseif ($msg['color']==4)$text = '[green]'.$msg['msg'].'[/green]';
return $text;
}
function bb_msg($text)
{
global $db, $set,$user, $msg;
if ($msg['bb']==1)$text = '[i]'.$text.'[/i]';
elseif ($msg['bb']==2)$text = '[u]'.$text.'[/u]';
elseif ($msg['bb']==3)$text = '[i][u]'.$text.'[/u][/i]';
elseif ($msg['bb']==4)$text = '[b]'.$text.'[/b]';
elseif ($msg['bb']==5)$text = '[i][b]'.$text.'[/b][/i]';
elseif ($msg['bb']==6)$text = '[big]'.$text.'[/big]';
return $text;
}
function emo_msg($text)
{
global $db, $set,$user, $msg;
if ($msg['emo']==1) $text = '[Радостно] '.$text;
elseif ($msg['emo']==2) $text = '[Печально] '.$text;
elseif ($msg['emo']==3) $text = '[Удивленно] '.$text;
elseif ($msg['emo']==4) $text = '[Ласково] '.$text;
elseif ($msg['emo']==5) $text = '[Смущенно] '.$text;
elseif ($msg['emo']==6) $text = '[Кокетливо] '.$text;
elseif ($msg['emo']==7) $text = '[Обиженно] '.$text;
elseif ($msg['emo']==8) $text = '[Настойчиво] '.$text;
elseif ($msg['emo']==9) $text = '[Шепотом] '.$text;
elseif ($msg['emo']==10) $text = '[Задумчиво] '.$text;
elseif ($msg['emo']==11) $text = '[Злобно] '.$text;
return $text;
}
function antir($msg)
{
global $db, $set,$user;
$msg = str_replace("((http://))((([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z;]{2,3}))|(([0-9]{1,3}.){3}([0-9]{1,3})))((/|?)[a-z0-9~#%&'_+=:;?.-]*)*)", "".$set['antir']."", $msg);
$msg=str_replace(".wab.","".$set['antir']."",$msg);
$msg=str_replace(".com","".$set['antir']."",$msg);
$msg=str_replace(".net","".$set['antir']."",$msg);
$msg=str_replace(".org","".$set['antir']."",$msg);
$msg=str_replace(".kz","".$set['antir']."",$msg);
$msg=str_replace(".ua","".$set['antir']."",$msg);
$msg=str_replace(".ru","".$set['antir']."",$msg);
$msg=str_replace(",ru","".$set['antir']."",$msg);
$msg=str_replace("-ru","".$set['antir']."",$msg);
$msg=str_replace("-ru","".$set['antir']."",$msg);
$msg=str_replace("_ru","".$set['antir']."",$msg);
$msg=str_replace("-net","".$set['antir']."",$msg);
$msg=str_replace(",net","".$set['antir']."",$msg);
$msg=str_replace("-su","".$set['antir']."",$msg);
$msg=str_replace("_su","".$set['antir']."",$msg);
$msg=str_replace(".su","".$set['antir']."",$msg);
$msg=str_replace(",su","".$set['antir']."",$msg);
$msg=str_replace("-mobi","".$set['antir']."",$msg);
$msg=str_replace("_mobi","".$set['antir']."",$msg);
$msg=str_replace(".mobi","".$set['antir']."",$msg);
$msg=str_replace(",mobi","".$set['antir']."",$msg);
$msg=str_replace("-info","".$set['antir']."",$msg);
$msg=str_replace("_info","".$set['antir']."",$msg);
$msg=str_replace(".info","".$set['antir']."",$msg);
$msg=str_replace(",info","".$set['antir']."",$msg);
$msg=str_replace("-com","".$set['antir']."",$msg);
$msg=str_replace("_com","".$set['antir']."",$msg);
$msg=str_replace(".com","".$set['antir']."",$msg);
$msg=str_replace(",com","".$set['antir']."",$msg);
$msg=str_replace("-msk","".$set['antir']."",$msg);
$msg=str_replace("_msk","".$set['antir']."",$msg);
$msg=str_replace(".msk","".$set['antir']."",$msg);
$msg=str_replace(",msk","".$set['antir']."",$msg);
$msg=str_replace("-tk","".$set['antir']."",$msg);
$msg=str_replace("_tk","".$set['antir']."",$msg);
$msg=str_replace(".tk","".$set['antir']."",$msg);
$msg=str_replace(",tk","".$set['antir']."",$msg);
$msg=str_replace(".in","".$set['antir']."",$msg);
$msg=str_replace("-cn","".$set['antir']."",$msg);
$msg=str_replace("_cn","".$set['antir']."",$msg);
$msg=str_replace(".cn","".$set['antir']."",$msg);
$msg=str_replace(",cn","".$set['antir']."",$msg);
$msg=str_replace("-biz","".$set['antir']."",$msg);
$msg=str_replace("_biz","".$set['antir']."",$msg);
$msg=str_replace(".biz","".$set['antir']."",$msg);
$msg=str_replace(",biz","".$set['antir']."",$msg);
$msg=str_replace("-h2m","".$set['antir']."",$msg);
$msg=str_replace("_h2m","".$set['antir']."",$msg);
$msg=str_replace(".h2m","".$set['antir']."",$msg);
$msg=str_replace(",h2m","".$set['antir']."",$msg);
$msg=str_replace("-wen","".$set['antir']."",$msg);
$msg=str_replace("_wen","".$set['antir']."",$msg);
$msg=str_replace(".wen","".$set['antir']."",$msg);
$msg=str_replace(",wen","".$set['antir']."",$msg);
$msg=str_replace("-ua","".$set['antir']."",$msg);
$msg=str_replace("_ua","".$set['antir']."",$msg);
$msg=str_replace(".ua","".$set['antir']."",$msg);
$msg=str_replace(",ua","".$set['antir']."",$msg);
return $msg;
}
function antim($text)
{
$text=strtr($text,array('сука'=>'***','блядь'=>'***','блядь'=>'***','хуй'=>'***','пизда'=>'***','сучка'=>'***',
'пидор'=>'***','пидар'=>'***','пидор'=>'***','пидрила'=>'***','чмо'=>'***','ебать'=>'***'
,'бля'=>'***'));
return $text;
}
function url_replace($m)
{
if( !isset($m[3]) )
{
return '<a href="' . $m[1] . '">' . $m[2] . '</a>';
}
else
{
return '<a href="' . $m[3] . '">' . $m[3] . '</a>';
}
}
function img_replace($m)
{
if( !isset($m[3]) )
{
return '<img src="' . $m[1] . '" alt="' . $m[2] . '">';
}
else
{
return '<img src="' . $m[3] . '" alt="' . $m[3] . '">';
}
}
function bb2($text)
{
$text = preg_replace_callback('~\[link=(http://.+?)\](.+?)\[/link\]|(http://(www.)?[0-9a-z.-]+.[0-9a-z]{2,6}[0-9a-zA-Z/?.~&_=/%-:#]*)~', 'url_replace', $text);
$text = preg_replace_callback('~\[imgs=(.+?)\](.+?)\[/imgs\]|((www.)?[0-9a-z.-]+.[0-9a-z]{2,6}[0-9a-zA-Z/?.~&_=/%-:#]*)~', 'img_replace', $text);
return $text;
}
if (isset ($_SESSION['id']) && isset ($_SESSION['ps']))
{
$us = $_SESSION['id'];
$pass = $_SESSION['ps'];
}
elseif (isset ($_COOKIE['id']) && isset ($_COOKIE['ps']))
{
$us = $_COOKIE['id'];
$_SESSION['id'] = $us;
$pass = $_COOKIE['ps'];
$_SESSION['ps'] = $pass;
}
if ($us && $pass)
{
$req = $db->sql_query("SELECT * FROM `users` WHERE `id` = '".check(intval($us))."' LIMIT 1");
if ($db->sql_numrows($req))
{
$user = $db->sql_fetchrow($req);
if (md5($pass) === $user['pass'])
{
}
else
{
unset ($_SESSION['id']);
unset ($_SESSION['ps']);
setcookie('id', '');
setcookie('ps', '');
$user = false;
}
}
else
{
unset ($_SESSION['id']);
unset ($_SESSION['ps']);
setcookie('id', '');
setcookie('ps', '');
$user = false;
}
}
//@header('Cache-Control: no-store, no-cache, must-revalidate');
if (isset($_GET['ver']))$_SESSION['ver'] = check($_GET['ver']);
if (isset($user))$ver = check($user['ver']);
else if (isset($_SESSION['ver']))
$ver = check($_SESSION['ver']);
else $ver = check($_GET['ver']);
if (empty($ver)) $ver = 'xhtml';
if($user['fsize'] == 'small')
{
$fs1 = '<small>';
$fs2 = '</small>';
}
else if($user['fsize'] == 'big')
{
$fs1 = '<big>';
$fs2 = '</big>';
}
else
{
$fs1 = '';
$fs2 = '';
}
if (isset($user['style']))
$them = $user['style'];
else
if (isset($set['style']))
$them = $set['style'];
else
$them = 'go-wap';
if ($ver!='wml')
{
define('hdrs','<div class="hdrs">');
define('umnik','<div class="umnik">');
define('men','<div class="men">');
define('gb','<div class="gb">');
define('gbinroom','<div class="gbinroom">');
define('links','<div class="links">');
define('menu','<div class="menu">');
define('footer','<div class="footer">');
define('citata','<div class="citata">');
define('copyr','<div class="copy">');
define('div','</div>');
}
else
{
define('copyr','');
define('citata','');
define('footer','');
define('hdrs','');
define('gb','');
define('men','');
define('umnik','');
define('gbinroom','');
define('links','');
define('menu','');
define('div','<br />');
}
function GradientLetter($text, $from='', $to='', $mode = 'hex')
{
$text = iconv("UTF-8", "windows-1251", $text);
if ($mode == 'hex')
{
$to = hexdec($to['0'].$to['1']).','.hexdec($to['2'].$to['3']).','.hexdec($to['4'].$to['5']);
$from = hexdec($from['0'].$from['1']).",".hexdec($from['2'].$from['3']).",".hexdec($from['4'].$from['5']);
}
if (empty($text)) return null;
else $levels = strlen($text);
if (empty($from)) $from = array(0, 0, 255);
else $from = explode(',', $from);
if (empty($to)) $to = array(255, 0, 0);
else $to = explode(',', $to); $output = null;
for ($i = 1; $i <= $levels; $i++)
{
for ($ii = 0; $ii < 3; $ii++)
{
$tmp[$ii] = $from[$ii] - $to[$ii];
$tmp[$ii] = floor($tmp[$ii] / $levels);
$rgb[$ii] = $from[$ii] - ($tmp[$ii] * $i);
if ($rgb[$ii] > 255)
$rgb[$ii] = 255;
$rgb[$ii] = dechex($rgb[$ii]);
$rgb[$ii] = strtoupper($rgb[$ii]);
if (strlen($rgb[$ii]) < 2)
$rgb[$ii] = '0'.$rgb[$ii];
}
$output .= '<span style="color: #'.$rgb['0'].$rgb['1'].$rgb['2'].'">'.$text[$i-1].'</span>';
}
return iconv("windows-1251", "UTF-8", $output);
}
function nik($ref=NULL,$link=NULL)
{
global $db, $user, $wap, $rm, $usid, $name, $set, $sid, $nk, $user_system, $time, $rmmaf, $mafiozi;
if(isset($ref)&&($ref!=$user_system)) $ref=check($ref);
if ($ref!=$mafiozi)
{
if (!ctype_digit($ref))
{
$ruser = rus_to_k($ref);
$result = $db->sql_query ("Select * from users where ruser = '".$ruser."' LIMIT 1;");
}
else
{
$result = $db->sql_query ("Select * from users where id = '".$ref."' LIMIT 1;");
}
$nik = $db->sql_fetchrow ($result);
if (!isset($user))$time = (time()+$set['timesdvig']*60*60);
else if ($user['poias']!='') $time = ((time()-3*60*60)+$user['poias']*60);
if ($nik['onl'] >= ($time - $set['time_aut']))
{
if ($nik['xstatus']==1) $on_off='<img src="/img/online/gotov_boltat.png" alt="" />';
else if ($nik['xstatus']==2) $on_off='<img src="/img/online/zaniat.png" alt="" />';
else if ($nik['xstatus']==3) $on_off='<img src="/img/online/boleu.png" alt="" />';
else if ($nik['xstatus']==4) $on_off='<img src="/img/online/depressia.png" alt="" />';
else if ($nik['xstatus']==5) $on_off='<img src="/img/online/dumau.png" alt="" />';
else if ($nik['xstatus']==6) $on_off='<img src="/img/online/kuru.png" alt="" />';
else if ($nik['xstatus']==7) $on_off='<img src="/img/online/kushau.png" alt="" />';
else if ($nik['xstatus']==8) $on_off='<img src="/img/online/love.png" alt="" />';
else if ($nik['xstatus']==9) $on_off='<img src="/img/online/tv.png" alt="" />';
else if ($nik['xstatus']==10) $on_off='<img src="/img/online/music.png" alt="" />';
else if ($nik['xstatus']==11) $on_off='<img src="/img/online/vanna.png" alt="" />';
else if ($nik['xstatus']==12) $on_off='<img src="/img/online/tualet.png" alt="" />';
else if ($nik['xstatus']==13) $on_off='<img src="/img/online/sex.png" alt="" />';
else if ($nik['xstatus']==14) $on_off='<img src="/img/online/igrau.png" alt="" />';
else if ($nik['xstatus']==15) $on_off='<img src="/img/online/pivo.png" alt="" />';
else if ($nik['xstatus']==16) $on_off='<img src="/img/online/sonni.png" alt="" />';
else if ($nik['xstatus']==0)
{
if ($nik['sex']==1) $on_off='<img src="/img/online/man_on.gif" alt=""/>';
else if ($nik['sex']==0) $on_off='<img src="/img/online/woman_on.gif" alt="" />';
else $on_off='<img src="/img/online/on.gif" alt="" />';
}
}
else
{
if ($nik['sex']==1) $on_off='<img src="/img/online/man_off.gif" alt="" />';
else if ($nik['sex']==0) $on_off='<img src="/img/online/woman_off.gif" alt="" />';
else $on_off='<img src="/img/online/off.gif" alt="" />';
}
$color_nik = $nik['color_nik'];
$name = $nik['user'];
if ($user['ver']!='wml')
{
if ($nik['effnik']==1) $name = '<blink>'.$name.'</blink>';
if ($nik['color_nik'] == 1) $name = GradientLetter($name, 'F90000', '00FF00');
elseif ($nik['color_nik'] == 2) $name = GradientLetter($name, 'FF0000', '000000');
elseif ($nik['color_nik'] == 3) $name = GradientLetter($name, 'EEE467', '384267');
elseif ($nik['color_nik'] == 4) $name = GradientLetter($name, 'F7FF0D', '1E49E6');
elseif ($nik['color_nik'] == 5) $name = GradientLetter($name, '000000', '00FF00');
elseif ($nik['color_nik'] == 6) $name = GradientLetter($name, 'EF33ED', 'EFCAF1');
elseif ($nik['color_nik'] == 7) $name = GradientLetter($name, '030303', '96A0A4');
elseif ($nik['color_nik'] == 8) $name = GradientLetter($name, '1C1C1C', 'FFB90F');
elseif ($nik['color_nik'] == 9) $name = GradientLetter($name, 'FF0000', '00F5FF');
elseif ($nik['color_nik'] == 10) $name = GradientLetter($name, '7D26CD', 'FF7F24');
elseif ($nik['color_nik'] == 11) $name = GradientLetter($name, '000000', 'E8E8E8');
elseif ($nik['color_nik'] == 12) $name = GradientLetter($name, 'FF0000', '00F5FF');
elseif ($nik['color_nik'] == 13) $name = GradientLetter($name, '912CEE', '90EE90');
#if ($nik['color_nik']=='') $name = ''.$name.'';
else $name = '<font color="#'.$nik['color_nik'].'">'.$name.'</font>';
}
if ($link==NULL)$link=''.H.$nik['id'].'';
if ($ref!=$user_system)
{
if (isset($nik['id']))
{
if ($user['pic_stat']==0)
{
if(!isset($rm) || isset($nk))
{
return '<a href="/'.$link.'">'.$name.'</a>';
}
else
{
return '<a href="/'.$link.'">'.$name.'</a> ';
}
}
else if ($user['pic_stat']==1)
{
if(!isset($rm) || isset($nk))
{
return '<a href="/'.$link.'">'.$name.'</a> <a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> ';
}
else
{
return '<a href="/'.$link.'">'.$name.'</a> <a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> ';
}
}
else if ($user['pic_stat']==2)
{
if ($user['ver']!='wml')
{
if(!isset($rm) || isset($nk))
{
return '<a href="/'.$link.'">'.$name.'</a> <a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> ';
}
else
{
return '<a href="/'.$link.'">'.$name.'</a> <a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> ';
}
}
else
{
if(!isset($rm) || isset($nk))
{
return '<a href="/'.$link.'">'.$name.'</a>';
}
else
{
return '<a href="/'.$link.'">'.$name.'</a> ';
}
}
}
else if ($user['pic_stat']==3)
{
if ($user['ver']=='wml')
{
if(!isset($rm) || isset($nk))
{
return '<a href="/'.$link.'">'.$name.'</a> <a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> ';
}
else
{
return '<a href="/'.$link.'">'.$name.'</a> <a href="/xstatus?nk='.$nik['id'].'">'.$on_off.'</a> ';
}
}
else
{
if(!isset($rm) || isset($nk))
{
return '<a href="/'.$link.'">'.$name.'</a>';
}
else
{
return '<a href="/'.$link.'">'.$name.'</a> ';
}
}
}
}
else
{
return 'Гость';
}
}
else
{
return $ref;
}
}
else return '<img src="'.H.'img/bot.gif" alt="" /> <a href="inside?rmmaf='.$rmmaf.'&nk=0"><b>'.$ref.'</b></a> ';
}
function user($ref=NULL,$link=NULL)
{
global $db, $user, $ver, $rm, $usid, $name, $set, $sid,$time;
if(isset($ref)) $ref=check($ref);
if (!ctype_digit($ref))
{
$ruser = rus_to_k($ref);
$result = $db->sql_query ("Select * from users where ruser = '".$ruser."' LIMIT 1;");
}
else
{
$result = $db->sql_query ("Select * from users where id = '".$ref."' LIMIT 1;");
}
$nik = $db->sql_fetchrow ($result);
if ($link==NULL)return $nik['user'];
else if ($link==1) return '<a href="'.H.$nik['id'].'">'.$nik['user'].'</a>';
}
function user_inf($ref=NULL,$w=NULL)
{
global $db, $user, $ver, $rm, $usid, $name, $set, $sid,$time;
if(isset($ref)) $ref=check($ref);
if (!ctype_digit($ref))
{
$ruser = rus_to_k($ref);
$result = $db->sql_query ("Select * from users where ruser = '".$ruser."' LIMIT 1;");
}
else
{
$result = $db->sql_query ("Select * from users where id = '".$ref."' LIMIT 1;");
}
$nik = $db->sql_fetchrow ($result);
if ($w==NULL)return esc2($nik['id']);
else return esc2($nik[$w]);
}
function friends($f1=NULL,$f2=NULL,$w=NULL)
{
global $db, $user, $ver, $rm, $usid, $name, $set, $sid,$time;
if(isset($f1)) $f1=check($f1);
if(isset($f2)) $f2=check($f2);
if(isset($w)) $w=check($w);
$f = $db->sql_fetchrow($db->sql_query("Select * from friends WHERE `user_id` = '$f2' and `fr_id` = '$f1' and yes = '1'"));
if ($w==NULL)
{
if ($f1!=$f2)
{
if (isset($f['id']))return '1';
else return '0';
}
else
{
return '1';
}
}
else
{
if (isset($f['id']))return $f[$w];
}
}
if (!defined('vb12')) die("");
function ignor($f1=NULL,$f2=NULL,$w=NULL)
{
global $db, $user, $ver, $rm, $usid, $name, $set, $sid,$time;
if(isset($f1)) $f1=check($f1);
if(isset($f2)) $f2=check($f2);
if(isset($w)) $w=check($w);
$f = $db->sql_fetchrow($db->sql_query("Select * from ignor WHERE `user_id` = '$f1' and `ig_id` = '$f2'"));
if ($w==NULL)
{
if ($f1!=$f2)
{
if (isset($f['id']))return '1';
else return '0';
}
else
{
return '0';
}
}
else
{
if (isset($f['id']))return $f[$w];
}
}
function aut($link = NULL) // только для зарегистрированиых
{
global $db, $user;
if (!isset($user['id']))
{
if ($link==NULL)$link=H.'aut?';
header("Location: $link".SID);exit;
}
}
function unaut($link = NULL) // только для незарегистрированых
{
global $db, $user;
if (isset($user['id']))
{
if ($link==NULL)$link=H.'index?';
header("Location: $link".SID);exit;
}
}
function levels($level=0,$link = NULL) // только для тех, у кого уровень доступа больше или равен $level
{
global $db, $user;
if (!isset($user['id']) || $user['level']<$level)
{
if ($link==NULL)$link='/index?';
header("Location: $link&".SID);exit;
}
}
function posts_add()
{
global $db, $user;
if (isset($user['id']))
{
$user['posts']++;
$user['dayp']++;
$db->sql_query("UPDATE `users` SET `posts` = '$user[posts]', dayp = '$user[dayp]' WHERE `id` = '$user[id]';");
}
}
function postsf_add()
{
global $db, $user;
if (isset($user['id']))
{
$user['postsf']++;
//$user['posts']++;
$user['dayp']++;
$db->sql_query("UPDATE `users` SET `postsf` = '$user[postsf]', dayp = '$user[dayp]' WHERE `id` = '$user[id]';");
}
}
function cred_add()
{
global $db, $user;
if (isset($user['id']))
{
$user['credits']++;
$user['daya']++;
$db->sql_query("UPDATE `users` SET `credits` = '$user[credits]', `daya` = '$user[daya]' WHERE `id` = '$user[id]';");
}
}
function who_add($rm=0,$room = NULL)
{
global $db, $user, $time, $set,$ip,$soft;
if (isset($user['id']))
{
$db->sql_query("DELETE FROM `who` WHERE `user` = '".$user['id']."'");
$db->sql_query("DELETE FROM `who` WHERE `time` < '".($time-$set['time_aut'])."'");
$db->sql_query("INSERT INTO `who` (user,time,room,rm) values('$user[id]', '$time', '$room', '$rm')");
$db->sql_query('UPDATE `users` SET `onl` = "'.$time.'", `user_ip` = "'.$ip.'", `user_soft` = "'.$soft.'" WHERE `id` = "'.$user['id'].'";');
if($user['viz']!=date("d"))$db->sql_query('UPDATE `users` SET `viz` = "'.date("d").'", `daya` = "0", `dayp` = "0" WHERE `id` = "'.$user['id'].'";');
}
}
function quickpaste($form)
{
echo '
<script language="JavaScript" type="text/javascript">
function tag(text1, text2)
{
if ((document.selection))
{
document.form.' . $form . '.focus();
document.form.document.selection.createRange().text = text1+document.form.document.selection.createRange().text+text2;
}
else if(document.forms['form'].elements['' . $form . ''].selectionStart!=undefined)
{
var element = document.forms['form'].elements['' . $form . ''];
var str = element.value;
var start = element.selectionStart;
var length = element.selectionEnd - element.selectionStart;
element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
}
else document.form.' . $form . '.value += text1+text2;
}
</script>';
}
function medal($user=NULL)
{
global $db, $set;
$user = check($user);
$adm = $db->sql_fetchrow($db->sql_query("SELECT * from `users` where `id`='$user' limit 1;"));
if ($adm['postsf']>=1000 )
{
echo "<img src='/img/medal_bronze.gif' alt=''/>";
}
else
if ($adm['postsf']>=5000)
{
echo "<img src='/img/medal_silver.gif' alt=''/>";
}
else
{
if ($adm['postsf']>=10000)
echo "<img src='/img/medal_gold.gif' alt=''/>";
}
}
$db->sql_query("DELETE FROM `who` WHERE `time` < '".($time-$set['time_aut'])."'");
if (filemtime(H."files/statwho.dat") < $time-150)
{
$stat = $db->sql_fetchfield($db->sql_query('SELECT COUNT(*) FROM `who`'),0);
file_put_contents(H."files/statwho.dat", (int)$stat, LOCK_EX);
}
$set['vip']= 1; //ид папки для элиты
$set['scripts_size']= 1024;
$set['p_add_gr'] = 500; // Посты для создания группы
$set['s_gr_logo'] = 50; // Вес лого
$set['w_logo_gr'] = 80;// Высота лого (отображение)
$set['h_logo_gr'] = 80;// Ширина лого (отображение)
$set['path'] = 'files';// папка с файлами
$set['fo_size'] = 10; // макс размер в мб
$set['fo_day_new'] = 2; // сколько файл считается новым
$set['prev_size'] = '80*80'; // размер превьюшек
$set['marker'] = 1;// включен - 1, нет - 0
$set['upload_level'] = 1; //Уровень с которого можно выгружать файлы в обменник
$set['rur_1mb'] = 1; // + рублей за 1мб загружаемых файлов
$set['top_num'] = 20; // Топ ... Юзеров и файлов
$set['eval_change'] = 1; // не меняем
if($db->sql_numrows($db->sql_query('SHOW TABLES FROM '.DB_db.'')) != 0)
{
if ($user['level']<7)
{
$banl = $db->sql_fetchrow($db->sql_query ("Select * from bannlist WHERE ip = '".$ip."' and soft = '".$soft."' LIMIT 1;"));
if (mysql_affected_rows()>=1)
{
$align="center";
$title='Баня';
include 'style/head.php';
echo '
<b>'.user($banl['who_id']).'</b>
забанил вас по IP и SOFT!<br />
Причина: <b>'.$banl[why].'</b>
<br /><br />';
include 'style/foot.php';
}
$b_ip = $db->sql_fetchrow($db->sql_query ("Select * from bannip;"));
if ($ip == $b_ip['ip'])
{
$align="center";
$title='Баня';
include 'style/head.php';
echo 'Ваш IP забаннен!<br /><br />';
include 'style/foot.php';
}
}
if (isset($user['id']))
{
if ($user['level']<7)
{
if ($user['bann']>$time)
{
$align='center';
$title='Баня';
include 'style/head.php';
echo '
<b>'.user($user['whobann']).'</b>
забаннил вас на <b>'.kikt($user['bann']).'</b><br />
Причина: <b>'.$user['whybann'].'</b>
<br /><br />';
include 'style/foot.php';
}
if ($user['odobr']!=0)
{
$align='left';
$title='Стоп!';
include 'style/head.php';
if (isset($_GET['exit']))
{
setcookie('id');
setcookie('user');
setcookie('ps');
unset($_SESSION['user']);
unset($_SESSION['id']);
unset($_SESSION['ps']);
header('Location: /?'.SID);
}
if ($user['odobr']==1)
{
echo '
<b>Вы получите доступ к сайту только после одобрения администрацией!</b><br />
<b>Не регистрируйтесь повторно, за регу нескольких ников вы будете забаннены!</b><br />
Сделайте закладку и зайдите позже: <br />
<i>http://'.$_SERVER['HTTP_HOST'].'/in?id='.$id.'&ps='.$pass.'&cookie=1</i> <br />
Скопировать ссылку:<br />
<input name="" type="text" value="http://'.$_SERVER['HTTP_HOST'].'/in?id='.$id.'&ps='.$pass.'&cookie=1"/><br /><br />
<a href="in?id='.$id.'&ps='.$pass.'&cookie=1">Перейти на сайт</a><br />';
}
else if ($user['odobr']==2)
{
echo "<b>Извините, вам отказано в доступе!</b><br />";
}
echo '<br /><a href="?exit">Выход (убить сессию)</a><br/>';
echo '<br />';
include 'style/foot.php';
}
}
}
}
$div9="</div>";
$div11="<div class="hdrs">";
$div0="<div class="gb">";
$div1="<div class="gbinroom">";
$div2="<div class="gbinroom">";
$div3="<div class="menu">";
$div4="<div class="menu">";
$div00="<div class="citata">";
$div5="---<br/>";
$div6="</div>";
$div7="";
$div8="</div>";
//////Чистка объявлений
mysql_query("DELETE FROM `objavs` WHERE `srok` < '".time()."'");
///////////////////////////// Присвоение статуса /////////////////////////
if(isset($user['id']) AND $user['level'] <= 3 )
{
if($user['postsf']==0) { $level12=0; $postsfor=1; }
elseif($user['postsf']==999) { $level12=1; $postsfor=1000; }
elseif($user['postsf']==4999) { $level12=2; $postsfor=5000; }
elseif($user['postsf']==9999) { $level12=3; $postsfor=10000; }
/* получаем название статусов */
$levelselect = $db->sql_query ("Select * from levels where level='".$level12."'");
$levels = $db->sql_fetchrow($levelselect);
$levname = $levels['name'];
/* присваеваем пользователю уровень и статус */
$db->sql_query ("UPDATE `users` SET
`level`='".$level12."',
`status`='".$levname."',
`postsf`='".$postsfor."'
WHERE `id`='".$user['id']."'");
$msg='Вам присвоен статус '.$levname.''; // Пишем послание юзеру =)
/* Отсылаем послание юзеру =) */
$db->sql_query ("INSERT INTO privat (user,user_id,to_user,to_id,time,msg)
VALUES ('".$user_system."','0','".user($user['user'])."','".user_inf($user['id'])."','$time','$msg')");
/* Призрак http://masteram.us/222 icq 144-332-6 */
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>