Вход Регистрация
Файл: core/sys.php
Строк: 163
<?php
require_once ('other.php');
require_once (
'openssl.class.php');
require_once (
'mail.class.php');


$iv '05978abff10e52b19d32bc3d7d8b7f50';
$key '322b6748909f1465375b264956807320';

$crypt = new OpenSSLCrypt($key,$iv);

ini_set('date.timezone''Europe/Moscow');

$db_host 'localhost';
$db_user 'kassa';
$db_pass 'Y7b3D2w8';
$db_name 'kassa';
try{
$db = new PDO("mysql:host=$db_host;dbname=$db_name",$db_user,$db_pass);
}
catch(
PDOException $e){
die(
'Обслуживание временно приостановлено');  
}
$db->exec("set names utf8");
session_start();
ob_start();
$max 10;
///Cookie
if(isset($_COOKIE['id']) and isset($_COOKIE['password'])){
$user $db->prepare('SELECT * FROM `users` WHERE `id` = ? and `password` = ?');
$user -> execute([$crypt->decrypt($_COOKIE['id']),$crypt->decrypt($_COOKIE['password'])]);
$user $user -> fetch(PDO :: FETCH_ASSOC);
if(!isset(
$user['id'])){
$_SESSION['message'] = 'Ошибка авторизации по cookie.';
setcookie('id''');
setcookie('password','');
setcookie('token','');
header('Location: /auth.aspx');
exit;
}

if(isset(
$user['id'])){

$online $db->prepare('UPDATE `users` SET `online` = ? WHERE `id` = ?');
$online -> execute([time(),$user['id']]);

if(empty(
$_COOKIE['token'])){
$_SESSION['message'] = 'Ваш Token был уничтожен вашим браузером , авторизуйтесь заново.';
setcookie('id''');
setcookie('password','');
setcookie('token','');
header('Location: /auth.aspx');
exit;
}
$help $crypt->decrypt($_COOKIE['token']);
$help explode(':',$help);
$ip_us $help[0];
$ip_us explode('.',$ip_us);
$ip_us_on htmlspecialchars($_SERVER['REMOTE_ADDR']);
$ip_us_on explode('.',$ip_us_on);
if(
$ip_us[0].'.'.$ip_us[1].'.'.$ip_us[2] != $ip_us_on[0].'.'.$ip_us_on[1].'.'.$ip_us_on[2]){
$_SESSION['message'] = 'Ваш IP адрес изменился после последнего посещения , в целях безопасности авторизуйтесь заново.';

$mail_to = new mailer($user['email']);
$mail_to->add('Ваш IP адрес изменился после последнего посещения , в целях безопасности авторизуйтесь заново.
<b>Новый</b> : '
.htmlspecialchars($_SERVER['REMOTE_ADDR']).'
'
);

setcookie('id''');
setcookie('password','');
setcookie('token','');
header('Location: /auth.aspx');
exit;
}

}

}
///time function

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 && $str2 5) return $str .' '$msg2;
if (
$str2 == 1) return $str .' '$msg1;
return 
$str .' '$msg3;
}
function 
vremja($times=NULL){
$time time();
if ((
$time-$times)<=60) {
$timesp slv((($time-$times)),'секунду','секунды','секунд').' назад';
return 
$timesp;
} else if((
$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 
vremja_str($time NULL){
global 
$db;
if(!isset(
$time)) $time time();
$data date('j.n.y'$time);
$mouth = array('Неизвестно','Янв','Фев','Мар' ,'Апр' ,'Май','Июн','Июл','Авг','Сен','Окт','Ноя','Дек');
$var date('j '$mouth[date('n',$time)].' Y в G:i' $time);
$var str_replace(date'Y' ), ''$var);
return 
$var;
}
///pagination
function page($k_page=1){
$page=1;
if (isset(
$_GET['page'])){
if (
$_GET['page']=='end'$page intval($k_page);elseif(is_numeric($_GET['page'])) $page 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;
}

function 
str($link='?',$k_page=1,$page=1){
if (
$page<1)$page=1;
echo 
'<div class="col-md-16 mt-4" style="text-align:center;">
<div class="card">
<div class="card-body">'
;
$str_div 'btn btn-success my-2 my-sm-0';

if (
$page!=1)
echo 
'<a href=''.$link.'?page=1' title="Страница в 1"><span class="'.$str_div.'">1</span></a>';
else echo 
'<span class="btn btn-outline-success my-2 my-sm-0"><b>1</b></span>';
for (
$ot=-3$ot<=3$ot++){
if (
$page+$ot>&& $page+$ot<$k_page)
{
if (
$ot==-&& $page+$ot>2) echo ' <span class="btn btn-outline-success my-2 my-sm-0"> ...</span>';
if (
$ot!=0) echo ' <a href="'.$link.'?page='.($page+$ot).'" title="Страница в'.($page+$ot).'"><span class="'.$str_div.'">'.($page+$ot).'</span></a> ';
else
echo 
' <span class="btn btn-outline-success my-2 my-sm-0" style="color:#fff"> <b>'.($page+$ot).'</b> </span>';
if (
$ot==&& $page+$ot<$k_page-1)echo '<span class="btn btn-outline-success my-2 my-sm-0"> ...</span>';
}
}
if (
$page!=$k_page) echo ' <a href="'.$link.'?page=end" title="Страница в'.$k_page.'"><span class="'.$str_div.'">'.$k_page.'</span></a>';
elseif (
$k_page>1)echo '<span class="btn btn-outline-success my-2 my-sm-0"> <b>'.$k_page.'</b></span>';
echo 
'</div></div></div>';
}


function 
rez($msg$maxwords 100$maxchar 100){
$sep=' ';
$sep2='…';
$words explode($sep,$msg);
$char iconv_strlen($msg,'utf-8');
if (
count($words) > $maxwords){        $msg join($separray_slice($words0$maxwords));
}
if(
$char $maxchar){
$msg iconv_substr($msg0$maxchar'utf-8' );
}
return 
$msg.$sep2;
}

function 
nick($id){
global 
$db$user;
$us $db->prepare('SELECT * FROM `users` WHERE `id` = ?');
$us -> execute([$id]);
$us $us -> fetch(PDO :: FETCH_ASSOC);
return 
'<strong><i style="color: #7867a7;width: 18px;height: 18px;" class="fa fa-user-plus"></i> '.$us['name'].'</strong>';
}

function 
highlightText($text$fileExt="")
{
    if (
$fileExt == "php")
    {
        
ini_set("highlight.comment""#008000");
        
ini_set("highlight.default""#000000");
        
ini_set("highlight.html""#808080");
        
ini_set("highlight.keyword""#0000BB; font-weight: bold");
        
ini_set("highlight.string""#DD0000");
    }
    else if (
$fileExt == "html")
    {
        
ini_set("highlight.comment""green");
        
ini_set("highlight.default""#CC0000");
        
ini_set("highlight.html""#000000");
        
ini_set("highlight.keyword""black; font-weight: bold");
        
ini_set("highlight.string""#0000FF");
    }
    
// ...

    
$text trim($text);
    
$text highlight_string("<?php " $texttrue);  // highlight_string() requires opening PHP tag or otherwise it will not colorize the text
    
$text trim($text);
    
$text preg_replace("|^\<code\>\<span style\="color\: #[a-fA-F0-9]{0,6}"\>|", "", $text, 1);  // remove prefix
    
$text preg_replace("|\</code\>$|"""$text1);  // remove suffix 1
    
$text trim($text);  // remove line breaks
    
$text preg_replace("|\</span\>$|"""$text1);  // remove suffix 2
    
$text trim($text);  // remove line breaks
    
$text preg_replace("|^(\<span style\="color\: #[a-fA-F0-9]{0,6}"\>)(&lt;\?php&nbsp;)(.*?)(\</span\>)|", "$1$3$4", $text);  // remove custom added "<?php "

    
return $text;
}
?>
Онлайн: 0
Реклама