Файл: vk.com_vhllam/sys/core/system.func.php
Строк: 242
<?
//////Автор OPPS (Kasell)////
/////Скрипт бесплатный //////
////Плтную версию можно купить vk.com/vhllam///
function user_collision($massive, $im=0)
{
global $user;
$new=false;
for ($i=0;$i<count($massive);$i++)
{
$collision_q=mysql_query("SELECT * FROM `user_collision` WHERE `id_user` = '".$massive[$i]."' OR `id_user2` = '".$massive[$i]."'");
while ($collision = mysql_fetch_assoc($collision_q))
{
if ($collision['id_user']==$massive[$i])$coll=$collision['id_user2'];else $coll=$collision['id_user'];
$ank_coll2=get_user($coll);
if (!in_array ($coll, $massive) && ($user['level']>$ank_coll2['level']) && ($im==0 || $user['id']!=$ank_coll2['id'])) {
$massive[]=$coll;
$new=true;
}
}
}
if($new)$massive=user_collision($massive);
return $massive;
}
if(isset($_GET)){
foreach($_GET as $key=>$value){$_GET[$key]=fiera($value);}
}
///Права доступа
function user_access($access,$u_id=null,$exit=false)
{
if ($u_id==null)global $user;
else $user=get_user($u_id);
if (!isset($user['group_access']) || $user['group_access']==null)
{
if ($exit!==false){header("Location: $exit");exit;}
else return false;
}
if ($exit!==false)
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_group_access` WHERE `id_group` = '$user[group_access]' AND `id_access` = '".my_esc($access)."'"),0)==0)
{
header("Location: $exit");exit;
}
}
else
return (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_group_access` WHERE `id_group` = '$user[group_access]' AND `id_access` = '".my_esc($access)."'"),0)==1?true:false);
}
///ББ КОДЫ
function bbcodehightlight($arr)
{
$arr[0]=html_entity_decode($arr[0], ENT_QUOTES, 'UTF-8');
return '<div class="cit" style="overflow:scroll;clip:auto;max-width:480px;">'.preg_replace('#<code>(.*?)</code>#si', '\1' ,highlight_string($arr[0],1)).'</div>'."n";
}
function BBcode($msg)
{
global $set;
$bbcode=array();$bbcode['/[br]/isU']='<br />'; // новая строка
if ($set['bb_i'])$bbcode['/[i](.+)[/i]/isU']='<em>$1</em>';
if ($set['bb_b'])$bbcode['/[b](.+)[/b]/isU']='<strong>$1</strong>';
if ($set['bb_u'])$bbcode['/[u](.+)[/u]/isU']='<span style="text-decoration:underline;">$1</span>';
if ($set['bb_big'])$bbcode['/[big](.+)[/big]/isU']='<span style="font-size:large;">$1</span>';
if ($set['bb_small'])$bbcode['/[small](.+)[/small]/isU']='<span style="font-size:small;">$1</span>';
if ($set['bb_red'])$bbcode['/[red](.+)[/red]/isU']='<span style="color:#ff0000;">$1</span>';
if ($set['bb_yellow'])$bbcode['/[yellow](.+)[/yellow]/isU']='<span style="color:#ffff22;">$1</span>';
if ($set['bb_green'])$bbcode['/[green](.+)[/green]/isU']='<span style="color:#00bb00;">$1</span>';
if ($set['bb_blue'])$bbcode['/[blue](.+)[/blue]/isU']='<span style="color:#0000bb;">$1</span>';
if ($set['bb_white'])$bbcode['/[white](.+)[/white]/isU']='<span style="color:#ffffff;">$1</span>';
if ($set['bb_size'])$bbcode['/[size=([0-9]+)](.+)[/size]/isU']='<span style="font-size:$1px;">$2</span>';
if (count($bbcode))$msg= preg_replace(array_keys($bbcode), array_values($bbcode), $msg);
if ($set['bb_code']){
$msg=preg_replace_callback('#<?(.*?)?>#sui', 'bbcodehightlight', $msg);$msg=preg_replace('#[code](.*?)[/code]#si', '1', $msg);
}
return $msg;
}
////Где пользователь находится
if (isset($_SESSION['refer']) && $_SESSION['refer']!=NULL && !preg_match('#(rules)|(smiles)|(secure)|(aut)|(reg)|(umenu)|(zakl)|(mail)|(anketa)|(settings)|(avatar)|(info).php#',$_SERVER['SCRIPT_NAME']))
$_SESSION['refer']=NULL;
function otkuda($ref)
{
if (preg_match('#^/forum/#',$ref))
$mesto='Форум';
elseif (preg_match('#^/chat/#',$ref))
$mesto='Чат';
elseif (preg_match('#^/lib/#',$ref))
$mesto='Библиотека';
elseif (preg_match('#^/news/#',$ref))
$mesto='Новости';
elseif (preg_match('#^/adm_panel/#',$ref))
$mesto='Админка';
elseif (preg_match('#^/votes/#',$ref))
$mesto='Голосования';
elseif (preg_match('#^/guest/#',$ref))
$mesto='Гостевая';
elseif (preg_match('#^/loads/#',$ref))
$mesto='Загрузки';
elseif (preg_match('#^/users.php#',$ref))
$mesto='Пользователи';
elseif (preg_match('#^/online.php#',$ref))
$mesto='Сейчас на сайте';
elseif (preg_match('#^/online_g.php#',$ref))
$mesto='Гости';
elseif (preg_match('#^/reg.php#',$ref))
$mesto='Регистрация';
elseif (preg_match('#^/obmen/#',$ref))
$mesto='Обменник';
elseif (preg_match('#^/aut.php#',$ref))
$mesto='Авторизация';
elseif (preg_match('#^/index.php#',$ref))
$mesto='Главная';
elseif (preg_match('#^/??$#',$ref))
$mesto='Главная';
else
$mesto=false;
return $mesto;
}
//Смайлы
function smiles($msg)
{
global $user;
$q=mysql_query("SELECT * FROM `smile`");
while($post = mysql_fetch_array($q))
{
$sm=explode("|",$post['smile']);
for ($i=0;$i<count($sm) ;$i++ )
{
$msg = str_replace($sm[$i], '<img src="/style/smiles/'.$post['name'].'" alt=""/>', $msg);
}
}
return $msg;
}
///Замещение ссылки в бб коде by Opps
function img_preg($arr)
{
return '<img src="http://'.$_SERVER['HTTP_HOST'].'/go.php?go='.base64_encode(html_entity_decode($arr[1])).'" alt="img" />';
}
function links_preg1($arr)
{
global $set;
if (preg_match('#^http://'.preg_quote($_SERVER['HTTP_HOST']).'#',$arr[1]) || !preg_match('#://#',$arr[1]))
return '<a href="'.$arr[1].'">'.$arr[2].'</a>';
else
return '<a'.($set['web']?' target="_blank"':null).' href="http://'.$_SERVER['HTTP_HOST'].'/go.php?go='.base64_encode(html_entity_decode($arr[1])).'">'.$arr[2].'</a>';
}
function links_preg2($arr)
{
global $set;
if (preg_match('#^http://'.preg_quote($_SERVER['HTTP_HOST']).'#',$arr[2]))
return $arr[1].'<a href="'.$arr[2].'">'.$arr[2].'</a>'.$arr[4];
else
return $arr[1].'<a'.($set['web']?' target="_blank"':null).' href="http://'.$_SERVER['HTTP_HOST'].'/go.php?go='.base64_encode(html_entity_decode($arr[2])).'">Ссылка</a>'.$arr[4];
}
function links($msg)
{
global $set;
if ($set['bb_img'])$msg=preg_replace_callback('/[img](.+)[/img]/isU', 'img_preg', $msg);
if ($set['bb_url'])$msg=preg_replace_callback('/[url=(.+)](.+)[/url]/isU', 'links_preg1', $msg);
if ($set['bb_http'])$msg=preg_replace_callback('~(^|s)([a-z]+://([^ rnt`'"]+))(s|$)~iu', 'links_preg2', $msg);
return $msg;
}
///Бэкап БД автоматом
if (!isset($hard_process)){
$q=mysql_query("SELECT * FROM `cron` WHERE `id` = 'backup_mysql'");
if (mysql_num_rows($q)==0)mysql_query("INSERT INTO `cron` (`id`, `time`) VALUES ('backup_mysql', '".time()."')");
$backup = mysql_fetch_assoc($q);
if (preg_match('#^[^@]*@[^@]*.[^@]*$#iu',$set['mail_backup']) && ($backup['time']==NULL || $backup['time']<time()-60*60*24)){
mysql_query("UPDATE `cron` SET `time` = '".time()."' WHERE `id` = 'backup_mysql'");
$hard_process=true;
if (function_exists('set_time_limit'))@set_time_limit(600); // Ставим ограничение на 10 минут
@unlink(H."sys/tmp/MySQL.sql.gz");
$list_tables=NULL;
$tab=mysql_list_tables($set['mysql_db_name']);
for($i=0;$i<mysql_num_rows($tab);$i++)
{
$sql=NULL;
$table=mysql_tablename($tab,$i);
$sql.="DROP TABLE IF EXISTS `$table`;rn";
$res=@mysql_query("SHOW CREATE TABLE `$table`");
$row=@mysql_fetch_row($res);
$sql.=$row[1].";rnrn";
$res = @mysql_query("SELECT * FROM `$table`");
if (@mysql_num_rows($res) > 0) {
while (($row = @mysql_fetch_assoc($res))) {
$keys = @implode("`, `", @array_keys($row));
$values = @array_values($row);
foreach($values as $k=>$v) {
$values[$k] = my_esc($v);
$values[$k]=ereg_replace("(n|r){1,}", 'n', $values[$k]);
}
$values2 = @implode("', '", $values);
$values2 = "'".$values2."'";
$values2= str_replace("''", "null", $values2);
$sql .= "INSERT INTO `$table` (`$keys`) VALUES ($values2);rn";
}
$sql .= "rnrn";
}
$fopen_mysql=fopen(H."sys/tmp/MySQL.sql.gz",'a');
if (strlen($sql)<5*1024*1024)
fwrite($fopen_mysql, gzencode($sql,9));
fclose($fopen_mysql);
}
$EOL="rn";
$subj='Beckup xHaTa';
$bound = "--".md5(uniqid(time()));
$headers="From: "xhata@$_SERVER[HTTP_HOST]" <xhata@$_SERVER[HTTP_HOST]>$EOL";
$headers.="To: $set[mail_backup]$EOL";
$headers.="Subject: $subj$EOL";
$headers.="Mime-Version: 1.0$EOL";
$headers.="Content-Type: multipart/mixed; boundary="$bound"$EOL";
$body="--$bound$EOL";
$body.="Content-Type: text/plain; charset="utf-8"$EOL";
$body.="Content-Transfer-Encoding: 8bit$EOL";
$body.=$EOL;
$body.="Автоматическая отправка BackUp базы данных";
$body.="$EOL--$bound$EOL";
$body.="Content-Type: application/x-gzip; name="MySQL.sql.gz"$EOL";
$body.="Content-Disposition: attachment; filename="MySQL.sql.gz"$EOL";
$body.="Content-Transfer-Encoding: Base64$EOL";
$body.=$EOL;
$body.=chunk_split(base64_encode(file_get_contents(H."sys/tmp/MySQL.sql.gz")));
$body.="$EOL--$bound$EOL";
$body.="Content-Type: text/plain; name="settings_6.2.dat"$EOL";
$body.="Content-Disposition: attachment; filename="settings_6.2.dat"$EOL";
$body.="Content-Transfer-Encoding: Base64$EOL";
$body.=$EOL;
$body.=chunk_split(base64_encode(file_get_contents(H."sys/dat/settings_6.2.dat")));
$body.="$EOL--$bound--$EOL";
mail("$set[mail_backup]", '=?utf-8?B?'.base64_encode($subj).'?=', $body, $headers);
unlink(H."sys/tmp/MySQL.sql.gz");
}
}
///МД5 , зашифровка паролей
function passgen($k_simb=8, $types=3) {
$password="";
$small="abcdefghijklmnopqrstuvwxyz";
$large="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$numbers="1234567890";
mt_srand((double)microtime()*1000000);
for ($i=0; $i<$k_simb; $i++) {
$type=mt_rand(1,min($types,3));
switch ($type) {
case 3:
$password.=$large[mt_rand(0,25)];
break;
case 2:
$password.=$small[mt_rand(0,25)];
break;
case 1:
$password.=$numbers[mt_rand(0,9)];
break;
}
}
return $password;
}
$passgen=&passgen();
//УРЛ
function url($url)
{
$url2=preg_split('#&(amp;)?#', $url);
$url3=NULL;
for ($i=0;$i<count($url2);$i++)
{
$url4=explode('=', $url2[$i]);
if (isset($url4[1]))
$url3.=$url4[0].'='.urlencode($url4[1]);
else $url3.=$url4[0];
if ($i<count($url2)-1)$url3.='&';
}
return $url3;
}
function url2($url)
{
$url2=explode('/', $url);
for ($i=0;$i<sizeof($url2);$i++)
{
$url2[$i]=urlencode($url2[$i]);
}
return implode('/',$url2);
}
//Фиера
function cmp2 ($a, $b) {
if ($a['2'] == $b['2']) return 0;
return ($a['2'] > $b['2']) ? -1 : 1;
}
if(isset($_POST)){foreach($_POST as $key=>$value){$_POST[$key]=fiera($value);}}
////Какае то еботень
function strlen2($str)
{
$rus=array('й','ц','у','к','е','н','г','ш','щ','з','х','ъ','ф','ы','в','а','п','р','о','л','д','ж','э','я','ч','с','м','и','т','ь','б','ю','Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П','Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь','Б','Ю');
return strlen(str_replace($rus, '0', $str));
}
?>