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

/**
* @package     Prime Social
* @link        http://primesocial.ru
* @copyright   Copyright (C) 2016 Prime Social
* @author      BoB | http://primesocial.ru/about
*/



function icon($msg,$w="16",$h="16",$align="middle") {
global 
$user;
$root_them = !empty($user) ? $user['style'] : 'default';
return 
"<img src='/style/themes/{$root_them}/ico/{$msg}' width='{$w}' height='{$h}' align='{$align}' alt='Prime Social' style='vertical-align:middle;'/>";
}
function 
head($title = 'Prime Social') {
    
    global 
$user;
if (!
file_exists(inc . 'style/themes/' . $user['style'] . '/head.php')) {
$styler = 'default';
} else {
$styler = $user['style'];
}
require_once(
inc.'style/themes/' .$styler. '/head.php');

if (!empty(
$user)) {
        
DB::$dbs->query("UPDATE ".USERS." SET `location` = ? WHERE `user_id` = ? ",array($title, num($_SESSION['user_id'])));
    }
    
    
}

function 
nav ($array) {
    
    if (empty(
$array)) {
        echo 
'<div class="footer"> &raquo; <a href="'.HOME.'/">Bosh sahifa</a>';
        
        
echo 
' <span style="float:right;font-size:12px;"><a href="/menu/style?ver=default">WAP</a>/
<a href="/menu/style?ver=default_web">WEB</a></span></div>'
;  

    } else {
        echo 
'<div class="footer"> &raquo; <a href="'.HOME.'/">Bosh sahifa</a> ';
foreach (
$array AS $value) {
    echo 
' &raquo; '.navURL($value).'';
} 
echo 
' <span style="float:right;font-size:12px;"><a href="/menu/style?ver=default">WAP</a>/
<a href="/menu/style?ver=default_web">WEB</a></span></div>'
;       
    }
    
}

function 
navURL ($value) {
        
$str = str_replace('Shahsiy xona', '<a href="'.HOME.'/menu" />' . $value . '</a>', $value);
        
$str = str_replace('Status', '<a href="'.HOME.'/menu/status" />' . $value . '</a>', $str);
        
$str = str_replace('Avatar', '<a href="'.HOME.'/menu/photo" />' . $value . '</a>', $str);
        
$str = str_replace('Anketani tahrirlash', '<a href="'.HOME.'/menu/anceta" />' . $value . '</a>', $str);
        
$str = str_replace('Tanishuvdagi anketa', '<a href="'.HOME.'/menu/love" />' . $value . '</a>', $str);
        
$str = str_replace('Sozlamalar', '<a href="'.HOME.'/menu/sett" />' . $value . '</a>', $str);
        
$str = str_replace('Shaharni izlash', '<a href="'.HOME.'/menu/city" />' . $value . '</a>', $str);
        
$str = str_replace('Do`stlar', '<a href="'.HOME.'/friends/" />' . $value . '</a>', $str);
        
$str = str_replace('Mening takliflarim', '<a href="'.HOME.'/friends/my_appl/" />' . $value . '</a>', $str);
        
$str = str_replace('Do`stlik takliflari', '<a href="'.HOME.'/friends/user_appl/" />' . $value . '</a>', $str);
        
$str = str_replace('Qora ro`yhat', '<a href="'.HOME.'/blacklist/" />' . $value . '</a>', $str);
        
$str = str_replace('Garem', '<a href="'.HOME.'/harem/" />' . $value . '</a>', $str);
        
$str = str_replace('Mening garemim', '<a href="'.HOME.'/harem/my/" />' . $value . '</a>', $str);
        
$str = str_replace('Garemga sotib olish', '<a href="'.HOME.'/harem/kup/" />' . $value . '</a>', $str);
        
$str = str_replace('Garemdan chiqarish', '<a href="'.HOME.'/harem/otpusk/" />' . $value . '</a>', $str);
        
$str = str_replace('Eng qimmatlar', '<a href="'.HOME.'/harem/dorog/" />' . $value . '</a>', $str);
        
$str = str_replace('Eng boylar', '<a href="'.HOME.'/harem/bogat/" />' . $value . '</a>', $str);
        
$str = str_replace('Ma`lumotlar', '<a href="'.HOME.'/faq/" />' . $value . '</a>', $str);
        
$str = str_replace('Smayllar', '<a href="'.HOME.'/smiles" />' . $value . '</a>', $str);
        
$str = str_replace('BB-kodlar', '<a href="'.HOME.'/bb" />' . $value . '</a>', $str);
        
$str = str_replace('Ballar ishlash', '<a href="'.HOME.'/balls" />' . $value . '</a>', $str);
        
$str = str_replace('Suhbatlar', '<a href="'.HOME.'/mail/" />' . $value . '</a>', $str);
        
$str = str_replace('Lenta', '<a href="'.HOME.'/lenta/" />' . $value . '</a>', $str);
        
$str = str_replace('Yangiliklar', '<a href="'.HOME.'/news/" />' . $value . '</a>', $str);
        
$str = str_replace('Chat', '<a href="'.HOME.'/chat/" />' . $value . '</a>', $str);
        
$str = str_replace('Forum', '<a href="'.HOME.'/forum/" />' . $value . '</a>', $str);
        
$str = str_replace('Blog', '<a href="'.HOME.'/blog/" />' . $value . '</a>', $str);
        
$str = str_replace('Fotoalbom', '<a href="'.HOME.'/album/" />' . $value . '</a>', $str);
        
$str = str_replace('Mini chat', '<a href="'.HOME.'/guestbook/" />' . $value . '</a>', $str);
        
$str = str_replace('Guruhlar', '<a href="'.HOME.'/groups/" />' . $value . '</a>', $str);
        
$str = str_replace('Yuklamalar', '<a href="'.HOME.'/loads/" />' . $value . '</a>', $str);
        
$str = str_replace('Duellar', '<a href="'.HOME.'/duel/" />' . $value . '</a>', $str);
        
$str = str_replace('Do`kon', '<a href="'.HOME.'/shop/" />' . $value . '</a>', $str);
        
$str = str_replace('Tiket', '<a href="'.HOME.'/touch/" />' . $value . '</a>', $str);
        
$str = str_replace('Prime Social', '' . $value . '', $str);
        
$str = str_replace('Kirish', '' . $value . '', $str);
        return 
$str;
    
    
}

function 
lenta($text, $id) {
    
    global 
$user;
    
    if (
$user['user_id'] != $id) {
        
DB::$dbs->query("INSERT INTO ".LENTA." (`user_id`, `time`, `text`, `status`) VALUES (?, ?, ?, ?)", array($id, time(), $text, 1));
    } 
}

function 
balls_operation ($balls) {
    
    global 
$user;
    
    
DB::$dbs->query("UPDATE ".USERS." SET `balls` = ? WHERE `user_id` = ? ",array(($user['balls'] + $balls), $user['user_id']));
    
}

function 
num($int) {
    
    return 
intval($int);
}

function 
html($str) {
    
    return 
trim(strtr(htmlspecialchars(stripcslashes($str),ENT_QUOTES,'UTF-8'), array('$'=>'$','%'=>'%','_'=>'_')));

}

function 
color_nick ($id) {
    
    global 
$color, $gradient_1, $gradient_2;
    
    
$ank = DB::$dbs->queryFetch("SELECT `nick`, `color_nick` FROM ".USERS." WHERE `user_id` = ?",array($id));
    
    if (empty(
$ank['color_nick'])) {
        
$nick = $ank['nick'];
    } else {
        
$data = explode(":", $ank['color_nick']);
        
        if (
$data[0] == 'color') {
            
$nick = '<font color="'.$color[$data[1]].'">'.$ank['nick'].'</font>';            
        } else {
            
$nick = GradientLetter($ank['nick'], $gradient_1[$data[1]], $gradient_2[$data[1]]);          
        }
    }
    
    return 
'<font style="font-size: 13px;">' . $nick . '</font>';
}

function 
user_choice($id, $choice) {
    
    if (
$choice == 'name') {
        
$result = DB::$dbs->queryFetch("SELECT `name` FROM ".USERS." WHERE `user_id` = ?",array(num($id)));
        return 
$result['name'];
    }
    
    if (
$choice == 'nick') {
        
$result = DB::$dbs->queryFetch("SELECT `nick` FROM ".USERS." WHERE `user_id` = ?",array(num($id)));
        return 
$result['nick'];
    }
    
    if (
$choice == 'gender') {
        
$result = DB::$dbs->queryFetch("SELECT `gender` FROM ".USERS." WHERE `user_id` = ?",array(num($id)));
        return 
$result['gender'];
    }

    if (
$choice == 'link') {
        
$result = DB::$dbs->queryFetch("SELECT `user_id`, `nick`, `gender` FROM ".USERS." WHERE `user_id` = ?",array(num($id)));
        return 
onlineIcon($result['user_id']) . ' <a href="' . HOME . '/id' . $result['user_id'] . '">' . color_nick($result['user_id']) . '</a>';
    }    
}

function 
check_auth() {
    if (empty(
$_SESSION['user_id'])) {
        
header("Location: ".HOME."/auth");
    }
    return 
false;
}

function 
gender ($gender) {
    if (
$gender == 0) {
        return 
'Ayol';
    } else {
        return 
'Erkak';
    }
}

function 
getIP2()
{
   if(
$_ENV["HTTP_VIA"])
   {
      if(
$_ENV["HTTP_X_FORWARDED_FOR"]!="unknown")
      {
      
$ip = $_ENV["HTTP_X_FORWARDED_FOR"];
         if(
$ip=="")
         {
         
$ip=$_SERVER["REMOTE_ADDR"];
         }
      }
      else
      {
      
$ip=$_SERVER["REMOTE_ADDR"];
      }
   }
   else
   {
   
$ip=$_SERVER["REMOTE_ADDR"];
   }
return 
$ip;
}

function 
city ($id) {
    
    
$city = DB::$dbs->queryFetch("SELECT * FROM ".CITY." WHERE `city_id` = ? ",array($id));
    
$region = DB::$dbs->queryFetch("SELECT `name` FROM ".REGION." WHERE `region_id` = ? ",array($city['region_id']));
    
$country = DB::$dbs->queryFetch("SELECT `name` FROM ".COUNTRY." WHERE `country_id` = ? ",array($city['country_id']));
    
    return 
'<b>' . $city['name'] . '</b> (' . $region['name'] . ', ' . $country['name'] . ')';
    
}

function 
gen_timer_start() {
    global 
$timer_start_time;
    
$start_time = microtime();
    
$start_array = explode(" ",$start_time);
    
$timer_start_time = $start_array[1] + $start_array[0];
    return 
$timer_start_time;
}

function 
gen_timer_stop() {
    global 
$timer_start_time;
    
$end_time = microtime();
    
$end_array = explode(" ",$end_time);
    
$timer_stop_time = $end_array[1] + $end_array[0];
    
$time = $timer_stop_time - $timer_start_time;
    
$time = substr($time,0,5);
    return 
"[$time soniya]";
}

function 
vrem ($time = '', $format = 'd.m.y / H:i') {
    
    
define("SITE_TIME", time());
    
    if (!
is_numeric($time)) {
        
$time = SITE_TIME;
    } 
    
$shift     = 0;
    
$date      = date($format, $time + $shift);
    
$today     = date("d.m.y", SITE_TIME + $shift);
    
$yesterday = date("d.m.y", strtotime("-1 day") + $shift);
    
$date      = str_replace($today, 'Bugun', $date);
    
$date      = str_replace($yesterday, 'Kecha', $date);
    
$search    = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
    
$replace   = array('Yanvar', 'Fevral', 'Mart', 'Aprel', 'May', 'Iyun', 'Iyul', 'Avgust', 'Sentabr', 'Oktyabr', 'Noyabr', 'Dekabr');
    
$date      = str_replace($search, $replace, $date);
    return 
$date;

}

function 
level ($id) {
    
    
$pos = DB::$dbs->queryFetch("SELECT * FROM ".POSITIONS." WHERE `id` = ? ",array($id));
    
    if (empty(
$pos['id'])) {
        return 
'Hali yangi';
    } else {
        return 
$pos['position'];
    }
    
}

function 
privilegy ($privilegy, $id = NULL) {
    
    global 
$user;
    
    
$sql = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".PRIVILEGE." WHERE `pos` = ? && `privil` = ?", array($user['level'], $privilegy));

    if (!empty(
$id)) {
        
$ank = DB::$dbs->queryFetch("SELECT `level` FROM ".USERS." WHERE `user_id` = ? ",array($id));
        
$pos = DB::$dbs->queryFetch("SELECT `prioritet` FROM ".POSITIONS." WHERE `id` = ? ",array($ank['level']));
        
        
$mypos = DB::$dbs->queryFetch("SELECT `prioritet` FROM ".POSITIONS." WHERE `id` = ? ",array($user['level']));
        if (
$sql == TRUE) {
            if (
$pos['prioritet'] >= $mypos['prioritet']) {
                return 
FALSE;
            } else {
                return 
TRUE;
            }
        } else {
            return 
FALSE;
        }
    } else {
        return 
DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".PRIVILEGE." WHERE `pos` = ? && `privil` = ?", array($user['level'], $privilegy));
    }
}
function 
img_resize($src, $dest, $width, $height, $rgb=0xFFFFFF, $quality=85)
{
  if (!
file_exists($src)) return false;

  
$size = getimagesize($src);

  if (
$size === false) return false;


  
$format = strtolower(substr($size['mime'], strpos($size['mime'], '/')+1));
  
$icfunc = "imagecreatefrom" . $format;
  if (!
function_exists($icfunc)) return false;

  
$x_ratio = $width / $size[0];
  
$y_ratio = $height / $size[1];

  
$ratio       = min($x_ratio, $y_ratio);
  
$use_x_ratio = ($x_ratio == $ratio);

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

  
$isrc = $icfunc($src);
  
$idest = imagecreatetruecolor($width, $height);

  
imagefill($idest, 0, 0, $rgb);
  
imagecopyresampled($idest, $isrc, $new_left, $new_top, 0, 0, 
    
$new_width, $new_height, $size[0], $size[1]);

  
imagejpeg($idest, $dest, $quality);

  
imagedestroy($isrc);
  
imagedestroy($idest);

  return 
true;

}

function 
calc_age($data)
{
    
$ex_age = explode('/', $data);
    
$age = date('Y') - $ex_age[2];
    if (
date('m') < $ex_age[1] || (date('m') == $ex_age[1] && date('d') < $ex_age[0])) {
    
$age--;
    }
    
$age = (int)$age;
    
    if (
$age == date('Y')) $age = 0;
    return 
$age; 
}

function 
text ($str) {
    
    
$str = smiles($str);

    
$str = BBcode($str);
    
    
$str = nl2br($str);
    
    return 
$str;
}

function 
bbsmile() {
    echo 
DIV_LI . '<a href="'.HOME.'/smiles">Smayllar</a> | <a href="'.HOME.'/bb">BB-kodlar</a>' . CLOSE_DIV;
}


function 
userLink($id, $link = NULL) {
    
    
$user = DB::$dbs->queryFetch("SELECT `user_id`, `nick` FROM ".USERS." WHERE `user_id` = ?",array($id));

    
$url = (empty($link) || $link == 'page' ? onlineIcon($user['user_id']) . ' ' : NULL) . '<a href="'.HOME.'/id'.$id.'">'.(empty($link) ? color_nick($user['user_id']) : $link).'</a>';
    return 
$url;
    
}

function 
smiles($str) {
    
$sql = DB::$dbs->query("SELECT `url`, `name` FROM ".SMILES."");
    while(
$smile = $sql -> fetch()) {
        
$str = str_replace($smile['name'], '<img src="'.HOME.'/files/smiles/' . $smile['url'] . '" alt="'.$smile['name'].'" width="20px;"/>', $str);
    }  
    return 
$str;
}

function 
BBcode($msg)
{

$bbcode=array();
$bbcode['/[i](.+)[/i]/isU']='<em>$1</em>';
$bbcode['/[b](.+)[/b]/isU']='<strong>$1</strong>';
$bbcode['/[u](.+)[/u]/isU']='<span style="text-decoration:underline;">$1</span>';
$bbcode['/[big](.+)[/big]/isU']='<span style="font-size:large;">$1</span>';
$bbcode['/[small](.+)[/small]/isU']='<span style="font-size:small;">$1</span>';
$bbcode['/[red](.+)[/red]/isU']='<span style="color:#ff0000;">$1</span>';
$bbcode['/[yellow](.+)[/yellow]/isU']='<span style="color:#ffff22;">$1</span>';
$bbcode['/[green](.+)[/green]/isU']='<span style="color:#00bb00;">$1</span>';
$bbcode['/[blue](.+)[/blue]/isU']='<span style="color:#0000bb;">$1</span>';
$bbcode['/[white](.+)[/white]/isU']='<span style="color:#ffffff;">$1</span>';
$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);

$msg = preg_replace('#[google](.*?)[/google]#si', '<a href="http://www.google.ru/search?q=$1">Izlash <span style="color:#0000ff">G</span><span style="color:#ff0000">o</span><span style="color:#FFD700">o</span><span style="color:#0000ff">g</span><span style="color:#008000">l</span><span style="color:#ff0000">e</span>: <i>$1</i></a> ', $msg);
$msg = preg_replace('#[googleimg](.*?)[/googleimg]#si', '<a href="http://www.google.com.ua/images?q=$1">Rasm izlash <span style="color:#0000ff">G</span><span style="color:#ff0000">o</span><span style="color:#FFD700">o</span><span style="color:#0000ff">g</span><span style="color:#008000">l</span><span style="color:#ff0000">e</span>: <i>$1</i></a> ', $msg);

return 
$msg;
}

function 
get_size($size)
{

    if (
$size < 1024) $size = $size . 'Bt';
    if (
$size > 1024 and $size < 1048576) $size = round($size / 1024, 1) . 'Kb';
    if (
$size >= 1048576) $size = round(($size / 1024) / 1024, 1) . 'Mb';

    return 
$size;
}

function 
SubstrMaus($text, $len, $start = 0, $mn = ' (...)') {
        
$text = trim($text);
        if (
function_exists('mb_substr')) {
            return 
mb_substr($text, $start, $len) . (mb_strlen($text) > $len - $start ? $mn : null);
        }
        if (
function_exists('iconv')) {
            return 
iconv_substr($text, $start, $len) . (iconv_strlen($text) > $len - $start ? $mn : null);
        }

        return 
$text;
    }
    
# Anketa 
function smok($id) {
    
$user = DB::$dbs->queryFetch("SELECT `gender`, `smok` FROM ".USERS." WHERE `user_id` = ?",array($id));
    
    if (
$user['gender'] == 0) {
        
$array = array(1 => 'Chekmaganman', 2 => 'Tashaganman', 3 => 'Tashayapman', 4 => 'Faqat ichgan paytda', 5 => 'Paravozdak tutaman',
        
6 => 'Chekaman');
    } else {
        
$array = array(1 => 'Chekmaganman', 2 => 'Tashaganman', 3 => 'Tashayapman', 4 => 'Faqat ichgan paytda', 5 => 'Paravozdak tutaman',
        
6 => 'Chekaman');  
    }
    return 
$array[$user[smok]]; 
}

function 
alco($id) {
    
$user = DB::$dbs->queryFetch("SELECT `gender`, `alco` FROM ".USERS." WHERE `user_id` = ?",array($id));
    
    if (
$user['gender'] == 0) {
        
$array = array(1 => 'Qarshiman', 2 => 'Tashaganman', 3 => 'Mumkun', 4 => 'Tez tashlayman', 5 => 'Ichaman');
    } else {
        
$array = array(1 => 'Qarshiman', 2 => 'Tashaganman', 3 => 'Mumkun', 4 => 'Tez tashlayman', 5 => 'Ichaman');  
    }
    return 
$array[$user[alco]]; 
}

function 
narco($id) {
    
$user = DB::$dbs->queryFetch("SELECT `gender`, `narco` FROM ".USERS." WHERE `user_id` = ?",array($id));
    
    if (
$user['gender'] == 0) {
        
$array = array(1 => 'Aql va ijod', 2 => 'Rahmdillik va rostgo`ylik', 3 => 'Boylik va kuchlilik', 4 => 'Jasurlik va qat`iyat', 5 => 'Hazilkashlik va hayotni sevish',
        
6 => 'Manga farqi yo`q ;)');
    } else {
        
$array = array(1 => 'Aql va ijod', 2 => 'Rahmdillik va rostgo`ylik', 3 => 'Boylik va kuchlilik', 4 => 'Jasurlik va qat`iyat', 5 => 'Hazilkashlik va hayotni sevish',
        
6 => 'Manga farqi yo`q ;)');
    }
    return 
$array[$user[narco]]; 
}

function 
poznakom($id) {
    
$user = DB::$dbs->queryFetch("SELECT `poznakom`, `age1`, `age2` FROM ".USERS." WHERE `user_id` = ?",array($id));

    
$array = array(1 => 'Qiz bola bilan', 2 => 'O`g`il bola bilan');
    
    return 
$array[$user[poznakom]] . (!empty($user['age1']) && !empty($user['age2']) ? '  ' . $user['age1'] . ' yoshdan ' . $user['age2'] . ' yoshgacha': NULL); 
}

function 
goal($id) {
    
$user = DB::$dbs->queryFetch("SELECT `goal` FROM ".USERS." WHERE `user_id` = ?",array($id));

    
$array = array(1 => 'Do`stlik', 2 => 'Suhbat', 3 => 'Flirt', 4 => 'Sevgi', 5 => 'Uchrashuv', 6 => 'Jiddiy a`loqa uchun');
    
    return 
$array[$user[goal]]; 
}

function 
family_status($id) {
    
$user = DB::$dbs->queryFetch("SELECT `gender`, `family_status` FROM ".USERS." WHERE `user_id` = ?",array($id));

    if (
$user['gender'] == 0) {
        
$array = array(1 => 'Bo`sh', 2 => 'Erga chiqqanman', 3 => 'Sevganim bor', 4 => 'Faol izlashdaman', 5 => 'Hammasi qiyin',
        
6 => 'Hamma vaqt tayyorman');
    } else {
        
$array = array(1 => 'Bo`sh', 2 => 'Uylanganman', 3 => 'Sevganim bor', 4 => 'Faol izlashdaman', 5 => 'Hammasi qiyin',
        
6 => 'Hamma vaqt tayyorman');
    }
    
    return 
$array[$user[family_status]]; 
}

function 
children($id) {
    
$user = DB::$dbs->queryFetch("SELECT `children` FROM ".USERS." WHERE `user_id` = ?",array($id));

    
$array = array(1 => 'Hali yo`q', 2 => 'Yo`q, bo`lmaydi', 3 => 'Bor', 4 => 'Yo`q, ammo istayman', 5 => 'Ular katta');
    
    return 
$array[$user[children]]; 
}

function 
orientation($id) {
    
$user = DB::$dbs->queryFetch("SELECT `orientation` FROM ".USERS." WHERE `user_id` = ?",array($id));

    
$array = array(1 => 'Getero', 2 => 'Gomo', 3 => 'Bi');
    
    return 
$array[$user[orientation]]; 
}

function 
birthday($day = NULL, $month = NULL, $year = NULL) {
    
$array = array(1 => 'yanvar', 2 => 'fevral', 3 => 'mart', 4 => 'aprel', 5 => 'may', 6 => 'iyun', 7 => 'iyul', 8 => 'avgust',
    
9 => 'sentyabr', 10 => 'oktyabr', 11 => 'noyabr', 12 => 'dekabr');
    
    return 
$day . ' ' . $array[$month] . ' ' . $year . 'yil.';
}

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);
}

/* Online statusni kursatish */
function onlineIcon ($id) {
    
$ank = DB::$dbs->queryFetch("SELECT `user_id`, `last_time`, `gender`, `vip`, `icon` FROM ".USERS." WHERE `user_id` = ?",array($id));
    
    if (
$ank['last_time'] > (time() - 2000)) {
        if (empty(
$ank['gender'])) {
            
/* Ayol */
            
$online = '<img src="'.HOME.'/style/img/user/woman_on.png" />';
        } else {
            
/* Erkak */
            
$online = '<img src="'.HOME.'/style/img/user/man_on.png" />';
        }
    } else {
        if (empty(
$ank['gender'])) {
            
/* Ayol */
            
$online = '<img src="'.HOME.'/style/img/user/woman_off.png" />';
        } else {
            
/* Erkak */
            
$online = '<img src="'.HOME.'/style/img/user/man_off.png" />';
        }        
    }
    
                
/* Vip Status */
    
if ($ank['vip'] > time()) {
    if (
$ank['last_time'] > (time() - 2000)) {
        if (empty(
$ank['gender'])) {
            
/* Ayol */
        
$vip = '<img src="'.HOME.'/style/img/user/vip.gif" />';
        } else {
            
/* Erkak */
        
$vip = '<img src="'.HOME.'/style/img/user/vip.gif" />';
        }
    } else {
        if (empty(
$ank['gender'])) {
            
/* Ayol */
            
$vip = '<img src="'.HOME.'/style/img/user/woman_off.png" />';
        } else {
            
/* Erkak */
            
$vip = '<img src="'.HOME.'/style/img/user/man_off.png" />';
        }        
    }
        return 
$vip;
    }
    
    
/* Shahsiy ikonka */
    
if ($ank['icon']) {
    if (
$ank['last_time'] > (time() - 2000)) {
        if (empty(
$ank['gender'])) {
            
/* Ayol */
            
$icon = '<img src="'.HOME.'/files/icons_user/'.$ank['icon'].'" />';
        } else {
            
/* Erkak */
            
$icon = '<img src="'.HOME.'/files/icons_user/'.$ank['icon'].'" />';
        }
    } else {
        if (empty(
$ank['gender'])) {
            
/* Ayol */
            
$icon = '<img src="'.HOME.'/style/img/user/woman_off.png" />';
        } else {
            
/* Erkak */
            
$icon = '<img src="'.HOME.'/style/img/user/man_off.png" />';
        }        
    }
        return 
$icon;
    }
    
    return 
$online;
}

function 
mobile_detect() {
    global 
$user;
        
$user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
        
$accept = strtolower($_SERVER['HTTP_ACCEPT']);
        if ((
strpos($accept, 'text/vnd.wap.wml') !== false) || (strpos($accept, 'application/vnd.wap.xhtml+xml') !== false)) {
            
DB::$dbs->query("UPDATE ".USERS." SET `is_mobile` = ? WHERE `user_id` = ?", array(1, $user['user_id']));
            return 
true;
        }
        if (isset(
$_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])) {
            
DB::$dbs->query("UPDATE ".USERS." SET `is_mobile` = ? WHERE `user_id` = ?", array(1, $user['user_id']));
            return 
true;
        }
        if (
preg_match('/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $user_agent)
            || 
preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|e-|e/|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(-|2|g)|yas-|your|zeto|zte-/i', substr($user_agent, 0, 4))) {
            
DB::$dbs->query("UPDATE ".USERS." SET `is_mobile` = ? WHERE `user_id` = ?", array(1, $user['user_id']));
            return 
true;
        }
        
        
DB::$dbs->query("UPDATE ".USERS." SET `is_mobile` = ? WHERE `user_id` = ?", array(2, $user['user_id']));
        
        return 
false;
}

/* Antispam */
function antiSpam($str) {
    
    
$str = mb_convert_case($str, MB_CASE_LOWER, "UTF-8");
    
# Shahsiy habarlardagi shubxali suzlar
    
$mailSpam = array('kiring', 'taklif qilaman', 'sizni kutamiz', 'wap', 'Ijtimoiy tarmoq', 'moderlar', 'zaibal', 'kut', 'уебан');
    
    foreach (
$mailSpam AS $value) {
        if(
preg_match("/".$value."/i",$str)) {
            return 
true;
            exit();
        }
    }
    
    return 
false;
    
}


function 
antilink($str) {
    
    
$str = mb_convert_case($str, MB_CASE_LOWER, "UTF-8");
    
    if(
preg_match("/primesocial.ru/i",$str)) {
        return 
false;
    }
    
    
$domains = array('.com', '.net', '.ru', '.su', '.in', '.biz', '.name', '.mobi', '.wen',
                     
'. com', '. net', '. ru', '. su', '. in', '. biz', '. name', '. mobi', '. wen',
                     
'http://', 'www.', 'www .'
    
);
    
    foreach (
$domains AS $value) {
        if(
preg_match("/".$value."/i",$str)) {
            return 
true;
            exit();
        }
    }
    
    return 
false;
        
}

function 
copyright() {            /// Tegilmasin
    
echo '<span style="font-size:11px;padding-left:10px;">&copy; <a href="http://primesocial.ru/">Prime Social</a></span>';
}

/* Avatar */
function avatar ($id,$w="48",$h="48") {
    
$ank = DB::$dbs->queryFetch("SELECT `user_id`, `photo` FROM ".USERS." WHERE `user_id` = ?",array($id));

    if (
$ank['photo']) {
        echo 
'<a href="'.HOME.'/files/photo/'.$ank['photo'].'"> <img src="'.HOME.'/files/photo/'.$ank['photo'].'" width="'.$w.'" height="'.$h.'" class="avatar"/></a>';
    }else{
        echo 
'<img src="'.HOME.'/style/img/noava.png" width="'.$w.'" height="'.$h.'" class="avatar"/>';  
    }
}

?>
Онлайн: 0
Реклама