Вход Регистрация
Файл: system/core.php
Строк: 174
<?php 

/**
 * @author Moroz Taras (-= MTV =-)
 */
 
namespace functions;

function 
viewStatus($sex null$status null)
{
    if (
time() > $status 300) {
        
$icon = ($sex == 'm' 'm_n' 'j_n');
    } else {
        
$icon = ($sex == 'm' 'm_o' 'j_o');
    }

    return 
'<img src="/public/img/sex_' $icon '.gif">';
}

function 
a_filter_url($string) {
    if(
is_string($string)) {
        
$string stripslashes(trim($string));
        return 
filter_var($stringFILTER_SANITIZE_URL);
    }
}

function 
a_filter_str($string) {
    if(
is_string($string)) {
        
$string stripslashes(trim($string));
        return 
filter_var($stringFILTER_SANITIZE_FULL_SPECIAL_CHARS);
    }
}


function 
a_filter_int($number) {
    return (int) 
filter_var($numberFILTER_SANITIZE_NUMBER_INT);
}

try {
    
$db = new PDO('mysql:host=localhost;dbname=admin_sad''admin_sad''amstoramstor111', array(
        
PDO::ATTR_DEFAULT_FETCH_MODEPDO::FETCH_ASSOC
        
PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION
        
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' 
    
));
    
} catch(
PDOException $e) {
    exit(
$e->getMessage());
}

if(isset(
$_COOKIE['id']) and isset($_COOKIE['ps'])) {
    global 
$db;
    
$stmt $db->prepare('UPDATE `db_users` SET `online` = :online WHERE `id` = :id');
    
$stmt->bindValue(':online'time());
    
$stmt->bindValue(':id'a_isUser('id'));
    
$stmt->execute();
}

function 
a_isUser($query null) {
    global 
$db;
    if(isset(
$_COOKIE['id']) and isset($_COOKIE['ps'])) {
        
$stmt $db->prepare('SELECT ' . (is_null($query) ? 'id' $query) . ' FROM `db_users` WHERE `id` = :id AND `ps` = :ps LIMIT 1');
        
$stmt->execute(array(
            
':id' => a_filter_int($_COOKIE['id']),
            
':ps' => a_filter_str($_COOKIE['ps'])
        ));
        
$fetch $stmt->fetch();
        
        if(!empty(
$fetch)) {
            if(
is_null($query)) {
                return 
true;
            } else {
                return 
$fetch[$query];
            }
        } else {
            
setcookie('id'''time() - 86400*7'/');
            
setcookie('ps'''time() - 86400*7'/');
        }
    } else {
        return 
false;
    }
}

//профайл юзера
function a_isUsers($query null) {
    global 
$db;
    if(isset(
$_GET['id'])) {
        
$stmt $db->prepare('SELECT ' . (is_null($query) ? 'id' $query) . ' FROM `db_users` WHERE `id` = :id LIMIT 1');
        
$stmt->execute(array(
            
':id' => a_filter_int($_GET['id'])
        ));
        
$fetch $stmt->fetch();
        
        if(!empty(
$fetch)) {
            if(
is_null($query)) {
                return 
true;
            } else {
                return 
$fetch[$query];
            }
    } else {
        return 
false;
    }
}
}
//профайл юзера

function getUserById($query,$id) {
    global 
$db;
    
$stmt $db->prepare('SELECT `'.$query.'` FROM `db_users` WHERE `id` = :id LIMIT 1');
    
$stmt->bindValue(':id'$id);
    
$stmt->execute();
    
$fetch $stmt->fetch();
    if(!empty(
$fetch)) {
        return 
$fetch[$query];
    } else {
        return 
false;
    }
}

function 
getFruitById($query,$id) {
    global 
$db;
    
$stmt $db->prepare('SELECT `'.$query.'` FROM `db_fruit` WHERE `id` = :id LIMIT 1');
    
$stmt->bindValue(':id'$id);
    
$stmt->execute();
    
$fetch $stmt->fetch();
    if(!empty(
$fetch)) {
        return 
$fetch[$query];
    } else {
        return 
false;
    }
}

function 
a_time($time NULL) {
    if(!
$time$time time();
    
$data date('j.n.y'$time);
    if(
$data == date('j.n.y')) $res 'Сегодня в 'date('G:i'$time);
    elseif(
$data == date('j.n.y'time() - 86400)) $res 'Вчера в 'date('G:i'$time);

    else {
        
    
$m = array(
        
'0',
        
'Янв''Фев'
        
'Мар''Апр''Май'
        
'Июн''Июл''Авг'
        
'Сен''Окт''Ноя'
        
'Дек'
    
);
    
    
$res date('j '$m[date('n'$time)] .' Y в G:i'$time);
    }
    
    return 
$res;
}

function 
a_img($images) {
    return 
'http://' $_SERVER['SERVER_NAME'] . '/public/img/' $images;
}


function 
a_header($title) {
    global 
$db;
    
    echo 
'<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=yes" />
<title>' 
$title '</title>
<link rel="stylesheet" href="http://' 
$_SERVER['SERVER_NAME'] . '/public/styles/style.css" type="text/css"/>
<meta name="keywords" content="Инвестиции,Заработок,Пирамида,Мой сад,Игра" />
<meta name="description" content="Заработок на инвестициях в игру" />
<body onselectstart="return false" oncopy="return false"> <body bgcolor="#FFFFFF" text="#000000" onmousedown="javascript:if(event.button==2) alert("Копирование материала запрещено! ");" onkeydown="alert("Копирование запрещенно!")"; >
</head><body>'
;
/*
#$stmt = $db->prepare('SELECT * FROM `db_ads` WHERE `time` >  :time ORDER BY RAND()');
        $stmt->bindValue(':time', time());
        $stmt->execute();
        $fetch_ads = $stmt->fetchAll();
        if($fetch_ads == true){
        echo '<div class="about">';
        foreach($fetch_ads as $val){
            echo '<a href="http://'.$val['adres'].'" style="'.($val['bold'] == '1'? 'font-weight:bold;':null).''.($val['italic'] == '1'? 'font-style:italic;':null).'color:'.$val['color'].'"> '.$val['name'].' </a><br/>';
        }
        echo '</div>';
    }
    */    
}


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(00255); else $from explode(','$from);
if (empty(
$to)) $to = array(25500); else $to explode(','$to);#_9#$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 
get_User_tj($id 0
{    
    global 
$db;
                
$stmt $db->prepare('SELECT * FROM `db_users` WHERE `id` = :id LIMIT 1');
                
$stmt->bindValue(':id'$id);
                
$stmt->execute();
                
$user $stmt->fetch();    
                            
                if(empty(
$user['icon'])) $icon null;
                if(!empty(
$user['icon'])) $icon '<img src="'.$user['icon'].'">';                
                                
$name ''.$user['im'].' '.$user['fam'].'';

    return (empty(
$user) ? '[неизвестно]'$iconGradientLetter($name$user['one_gradient'], $user['two_gradient']));
}

function 
img_resize($src$out$width$height$color 0xFFFFFF$quality 100) {
    if (!
file_exists($src)) return false;

    
$size getimagesize($src);

    
$format strtolower(substr($size['mime'], strpos($size['mime'], '/') + 1));
    
$picfunc 'imagecreatefrom'.$format;

    
$gor $width  $size[0];
    
$ver $height $size[1];

    if (
$height == 0) {
        
$ver $gor;
        
$height  $ver $size[1];
    }
    elseif (
$width == 0) {
        
$gor $ver;
        
$width $gor $size[0];
    }

    
$ratio min($gor$ver);
    if (
$gor == $ratio$use_gor true;
    else 
$use_gor false;

    
$new_width $use_gor  $width  floor($size[0] * $ratio);
    
$new_height  = !$use_gor $height floor($size[1] * $ratio);
    
$new_left$use_gor  floor(($width $new_width) / 2);
    
$new_top = !$use_gor floor(($height $new_height) / 2);

    
$picsrc  $picfunc($src);
    
$picout imagecreatetruecolor($width$height);

    
imagefill($picout00$color);
    
imagecopyresampled($picout$picsrc$new_left$new_top00$new_width$new_height$size[0], $size[1]);
    
imagejpeg($picout$out$quality);
    
imagedestroy($picsrc);
    
imagedestroy($picout);

    return 
true;
}


function 
a_footer() {
    echo 
'</body></html>';
}
Онлайн: 0
Реклама