<?php
/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//
// Sitchi CMS - Mobile Content Management System //
// The author: Nikoloz Sitchinava [sitchi] //
// Link: http://sitchicms.num.ge //
// Skype: SitchiCMS //
// License: LICENSE.txt (see attached file) //
// Version: VERSION.txt (see attached file) //
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
defined('_SITCHICMS') or die ('Restricted access');
//
function mres($str) // ფუნქციის ფსევდონიმი
{
return mysql_real_escape_string($str);
}
//
function timef($time=NULL)
{
global $user, $lng;
if ($time==NULL)$time=$time;
$timep="".date("j M Y H:i", $time + $user['timing'] * 3600)."";
$time_p[0]=date("j n Y", $time);
$time_p[1]=date("H:i", $time);
if ($time_p[0]==date("j n Y"))$timep=date("H:i:s", $time);
$timep=str_replace("Jan","".$lng['1_20']."",$timep);
$timep=str_replace("Feb","".$lng['1_21']."",$timep);
$timep=str_replace("Mar","".$lng['1_22']."",$timep);
$timep=str_replace("May","".$lng['1_23']."",$timep);
$timep=str_replace("Apr","".$lng['1_24']."",$timep);
$timep=str_replace("Jun","".$lng['1_25']."",$timep);
$timep=str_replace("Jul","".$lng['1_26']."",$timep);
$timep=str_replace("Aug","".$lng['1_27']."",$timep);
$timep=str_replace("Sep","".$lng['1_28']."",$timep);
$timep=str_replace("Oct","".$lng['1_29']."",$timep);
$timep=str_replace("Nov","".$lng['1_30']."",$timep);
$timep=str_replace("Dec","".$lng['1_31']."",$timep);
return $timep;
}
/*
ფუნქცია დღეების გადამთვლელი
*/
function timecount($var){
global $lng;
$str = '';
if ($var < 0)
$var = 0;
$day = ceil($var / 86400);
if ($var > 345600){
$str = $day . ' '.$lng['1_74'].'';
}else
if ($var >= 172800){
$str = $day . ' '.$lng['1_74'].'';
}else
if ($var >= 86400){
$str = '1 '.$lng['1_5'].'';
}else{
$str = gmdate('G:i:s', $var);
}
return $str;
}
// მომხმარებლების სტატუსი
function user_status($level)
{
global $lng;
if($level==0)$user_status=$lng['1_55'];
else
if($level==2)$user_status=$lng['1_56'];
else
if($level==4)$user_status=$lng['1_57'];
else
if($level==6)$user_status=$lng['1_58'];
else
if($level==8)$user_status=$lng['1_59'];
else
if($level==10)$user_status=$lng['1_60'];
echo'<b>'.$user_status.'</b>';
}
// ავატარი
function avatars($id)
{
global $root_path,$set;
if (is_file($root_path.'files/avatars/'.$id.'.gif'))
echo'<img src="'.$root_path.'files/avatars/'.$id.'.gif" alt="" /><br/>';
else
if (is_file($root_path.'files/avatars/'.$id.'.jpg'))
echo'<img src="'.$root_path.'files/avatars/'.$id.'.jpg" alt="" /><br/>';
else
if (is_file($root_path.'files/avatars/'.$id.'.png'))
echo'<img src="'.$root_path.'files/avatars/'.$id.'.png" alt="" /><br/>';
else
echo'<img src="/themes/'.$set['set_them'].'/images/user.gif" alt="" /><br/>';
}
// ნებართვის დახურვა სტუმრებისთვის
function aut_off()
{
global $user, $lng, $root_path, $set;
if (!isset($user))
{
echo'<div class="errmenu">'.$lng['1_34'].'<br/></div>';
require $root_path.'includes/end.php'; // დასასრული
}}
// ნებართვის დახურვა მომხმარებლებისთვის
function aut_on_off()
{
global $user, $lng, $root_path, $set;
if (isset($user))
{
echo'<div class="errmenu">'.$lng['1_35'].'<br/></div>';
require $root_path.'includes/end.php'; // დასასრული
}}
// შეცდომის გამოტანა
function err()
{
global $err;
if (isset($err)){
if (is_array($err)){
foreach ($err as $key=>$value){
echo'<div class="err">'.$value.'</div>';}}else
echo'<div class="err">'.$err.'</div>';}
}
//
function msg($msg)
{
echo''.$msg.'';
}
// ბალანსის დათვლა
function moneys($balans){
$balans = round($balans / 100 * 100) / 100 . ' GEL ';
return $balans;
}
// რეკლამა
function ads($selection)
{
global $time;
$q=mysql_query("SELECT * FROM `ads` WHERE `selection` = '$selection' AND `lasttime` > '".$time."' ORDER BY id ASC");
$q2=mysql_fetch_assoc(mysql_query("SELECT * FROM `ads` WHERE `selection` = '$selection' AND `lasttime` > '".$time."' LIMIT 1"));
if ($selection==1) // ზედა
{
if("".$time."" < $q2['lasttime'] ){
echo'<div class="tmn">';}
}else
if ($selection==2) // ქვედა
{
if("".$time."" < $q2['lasttime'] ){
echo'<div class="tmn">';}
}
while ($post = mysql_fetch_assoc($q))
{
if ($post['img']==NULL)
{
$link='<a href="http://'.$post['link'].'"><span style="color:'.$post['link_color'].';font-style:'.$post['font_style'].';font-weight:'.$post['font_weight'].'">'.$post['name'].'</span></a>';
}else{
$link='<a href="http://'.$post['link'].'"><img src="http://'.$post['img'].'" alt="'.$post['name'].'" /></a>';
}
echo $link.'<br/>';
}
echo'</div>';
}
//
function page($k_page=1)
{
$page=1;
if (isset($_GET['page']))
{
if ($_GET['page']=='end')$page=intval($k_page);else
if(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_count=10)
{
if ($k_post!=0)
{
$v_pages=ceil($k_post/$k_p_count);
return $v_pages;
}else return 1;
}
//
function str($link='?',$k_page=1,$page=1){
if ($page<1)$page=1;
echo'<div class="egmenu">';
if ($page!=1)
echo'<a href="'.$link.'page=1" title="front page"><<</a> ';
if ($page>1)
echo'<a href="'.$link.'page='.($page-1).'" title="Previous page (№'.($page-1).')"><</a> ';
if ($page!=1)
echo'<a href="'.$link.'page=1 title="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!=0)
{
echo'<a href="'.$link.'page='.($page+$ot).'" title="page №'.($page+$ot).'">'.($page+$ot).'</a>';
}else{
echo'<b>'.($page+$ot).'</b>';
}}}
if ($page!=$k_page)
echo'<a href="'.$link.'page=end" title="page №'.$k_page.'">'.$k_page.'</a>';else
if ($k_page>1)
echo'<b>['.$k_page.']</b>';
if ($page<$k_page)
echo'<a href="'.$link.'page='.($page+1).'" title="Next page (№'.($page+1).')">></a>';
if ($page!=$k_page)
echo'<a href="'.$link.'page=end" title="Last page">>></a>';
echo'</div>';
}
// სმაილები
function smiles($msg)
{
$q=mysql_query("SELECT * FROM `smiles_list`");
while($post = mysql_fetch_array($q))
{
$msg = str_replace($post['sim'], '<img src="/files/smiles/'.$post['name'].'.gif" alt="'.$post['name'].'"/>', $msg);
}
return $msg;
}
//
function links_preg($arr)
{
global $set;
if (@preg_match('#^http://#i'.$_SERVER['HTTP_HOST'],$arr[1]) || !preg_match('#^://#i',$arr[1]))
return '<a href="'.$arr[1].'">'.$arr[2].'</a>';
}
//
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>';
}
// bbcode
function bbcode($msg)
{
$bbcode = array(
'/\[i\](.+)\[\/i\]/isU' => '<em>$1</em>',
'/\[b\](.+)\[\/b\]/isU' => '<strong>$1</strong>',
'/\[u\](.+)\[\/u\]/isU' => '<span style="text-decoration:underline;">$1</span>',
'/\[big\](.+)\[\/big\]/isU' => '<span style="font-size:large;">$1</span>',
'/\[small\](.+)\[\/small\]/isU' => '<span style="font-size:small;">$1</span>',
'/\[code\](.+)\[\/code\]/isU' => '<code>$1</code>',
'/\[red\](.+)\[\/red\]/isU' => '<span style="color:#ff0000;">$1</span>',
'/\[yellow\](.+)\[\/yellow\]/isU' => '<span style="color:#ffff22;">$1</span>',
'/\[green\](.+)\[\/green\]/isU' => '<span style="color:#00bb00;">$1</span>',
'/\[blue\](.+)\[\/blue\]/isU' => '<span style="color:#0000bb;">$1</span>',
'/\[size=([0-9]+)\](.+)\[\/size\]/isU' => '<span style="font-size:$1px;">$2</span>',
'/\[img\](.+)\[\/img\]/isU' => '<img src="$1" alt="" />'
);
$msg= preg_replace(array_keys($bbcode), array_values($bbcode), $msg);
$msg=preg_replace_callback('/\[url=(.+)\](.+)\[\/url\]/isU', 'links_preg', $msg);
$msg=preg_replace_callback('#<\?(.*?)\?>#sui', 'bbcodehightlight', $msg);
$msg=preg_replace('#\[code\](.*?)\[/code\]#si', '\1', $msg);
return $msg;
}
//
function post($text, $html=true, $nl2br = true, $smiles = true, $bbcode = true)
{
if($smiles)
{
$text = smiles($text);
}
if($bbcode)
{
$text = bbcode($text);
}
if($nl2br)
{
$text = nl2br($text);
}
return $text;
}
// online
function online($id=false)
{
if($id)
{
global $time;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `id` = '$id' AND `lastvisit` > '".($time-600)."' LIMIT 1"),0)==1)
{
$status='<span class="on">[On]</span>';
}else{
$status='<span class="off">[Off]</span>';
}}else{
$status='';
}
return $status;
}
?>