Просмотр файла system/func.php

Размер файла: 10.4Kb
<?php
//Считаем сколько статей в библе

function podlib_stat($id_kat){
$themrazd=0;
$razds=mysql_query("SELECT * FROM `library_kategory` WHERE `gde`='$id_kat'");
while($srazd=mysql_fetch_array($razds)){
$themrazd=$themrazd+mysql_num_rows(mysql_query("SELECT * FROM `library` WHERE `id_kat`='".$srazd['id']."'"));
$nrazds=mysql_query("SELECT * FROM `library_kategory` WHERE `gde`='".$srazd['id']."' limit 1");
if(mysql_num_rows($nrazds)!=0){$themrazd=$themrazd+podlib_stat($srazd['id']);}
}
return $themrazd;
}

function PodTem($id_forum){
$themrazd=0;
$razds=mysql_query("SELECT * FROM `forum_kategory` WHERE `gde`='$id_forum'");
while($srazd=mysql_fetch_array($razds)){
$themrazd=$themrazd+mysql_num_rows(mysql_query("SELECT * FROM `forum_themes` WHERE `id_kat`='".$srazd['id_forum']."'"));
$nrazds=mysql_query("SELECT * FROM `forum_kategory` WHERE `gde`='".$srazd['id_forum']."' limit 1");
if(mysql_num_rows($nrazds)!=0){$themrazd=$themrazd+PodTem($srazd['id_forum']);}
}
return $themrazd;
}

//Функция подсчёта сообщений в подфорумах
function PodMes($id_forum){
$soobrazd=0;
$razds=mysql_query("select * from forum_kategory where gde='$id_forum'");
while($srazd=mysql_fetch_array($razds)){


$soobrazd=$soobrazd+mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_messages` WHERE `id_kat`='".$srazd['id_forum']."'"),0);
$nrazds=mysql_query("SELECT * FROM `forum_kategory` WHERE `gde`='".$srazd['id_forum']."' LIMIT 1");
if(mysql_num_rows($nrazds)!=0){$soobrazd=$soobrazd+PodMes($srazd['id_forum']);}
}
return $soobrazd;
}

//перекодировка в норм символы

function dec_text($code){$coed = strtr($code,array('&#124;'=>'|','&lt;'=>'<','&gt;'=>'>','&amp;'=>'&','&#36;'=>'$','&quot;'=>'"','&#39;'=>"'",'&#92;'=>'`','&#37;'=>'%','&#94;'=>'^','&#58;'=>':','<br />'=>"\r\n"));
return $coed;}

//Знак зодиака
function v_zodiak($d,$m){ if($m=="1" && $m=="01"){ if(20<=$d){ $z='1.Водолей'; }else{$z='2.Козерог';}} if($m=="2" && $m=="02"){ if(19<=$d){$z='3.Рыба'; }else{$z='1.Водолей';}} if($m=="3" && $m=="03"){ if(21<=$d){ $z='4.Овен'; }else{$z='3.Рыба';
}} if($m=="4" && $m=="04"){ if(21<=$d){ $z='5.Телец'; }else{$z='4.Овен';}} if($m=="5" && $m=="05"){ if(21<=$d){$z='6.Близнецы'; }else{$z='5.Телец';}} if($m=="6" && $m=="06"){ if(22<=$d){$z='7.Рак'; }else{$z='6.Близнецы';}} if($m=="7"
&& $m=="07"){ if(23<=$d){$z='8.Лев'; }else{$z='7.Рак';}} if($m=="8" && $m=="08"){ if(23<=$d){$z='9.Дева'; }else{$z='8.Лев';}} if($m=="9" && $m=="09"){ if(23<=$d){$z='10.Весы'; }else{$z='9.Дева';}} if($m=="10"){ if(23<=$d){$z='11.Скорпион';
}else{$z='10.Весы';}} if($m=="11"){ if(22<=$d){$z='12.Стрелец'; }else{$z='11.Скорпион';}} if($m=="12"){ if(22<=$d){$z='2.Козерог'; }else{$z='12.Стрелец';}} list($im,$za) = split("[.]",$z); return '<img src="../images/zodiak/'.$im.'.gif"
alt="'.$za.'" />'.$za.'<br>';}

function highlight_code($code) {
$code = strtr($code,array('&#124;'=>'|','&lt;'=>'<','&gt;'=>'>','&amp;'=>'&','&#036;'=>'$','&quot;'=>'"','&#039;'=>"'",'&#092;'=>'`','&#037;'=>'%','&#094;'=>'^','&#58;'=>':','<br />'=>"\r\n"));

$code=str_replace('&gt;','>',$code);
$code=str_replace('&lt;','<',$code);

$code = highlight_string($code,true);

$code='<div class="code">'.$code.'</div>'; return $code;}


function dopoln($m){
return '<a href="'.$m[0].'">'.$m[0].'</a>';}
function vizual($stext){
global $vhod; for($v=1;$v<106;$v++){$stext=str_replace('.'.$v.'.','<img src="/images/smiles/'.$v.'.gif" alt=".'.$v.'.">',$stext);}
$stext=str_replace(':)','<img src="/images/smiles/2.gif" alt=".2.">',$stext);
$stext=str_replace(':(','<img src="/images/smiles/3.gif" alt=".3.">',$stext);
$stext=str_replace(':D','<img src="/images/smiles/7.gif" alt=".7.">',$stext);

$stext=str_replace(';)','<img src="/images/smiles/4.gif" alt=".4.">',$stext);



$stext=preg_replace('/\[sub\](.+)\[\/sub\]/isU','<sub>$1</sub>',$stext);
$stext=str_replace('\r\n','[br/]',$stext);

$stext=str_replace('[br/]','<br>',$stext);
$stext=preg_replace('/\[sup\](.+)\[\/sup\]/isU','<sup>$1</sup>',$stext);
$stext = preg_replace('#\[code\](.*?)\[/code\]#ie', 'highlight_code("\1")', $stext);
$stext=preg_replace('/\[size=([0-9]+)\](.+)\[\/size\]/isU','<span style="font-size:$1px;">$2</span>',$stext);

$stext=preg_replace('#\[color=(\#[0-9A-F]{3,6}|[a-z\-]+)\](.*)\[/color\]#isU','<span style="color: \\1">\\2</span>',$stext);

$stext = preg_replace('#\[del\](.*?)\[/del\]#si', '<del>\1</del>', $stext);

$stext = preg_replace('#\[url=(.*?)](.*?)\[/url\]#si', '<a href="\1">\2</a>', $stext);

$stext = preg_replace('#\[q\](.*?)\[/q\]#si', '<div class="quote">\1</div>', $stext);

$stext=ereg_replace("\[b\](.*)\[/b\]","<b>\\1</b>",$stext);
$stext=ereg_replace("\[u\](.*)\[/u\]","<u>\\1</u>",$stext);

$stext=ereg_replace("\[red\](.*)\[/red\]","<font color=\"red\">\\1</font>",$stext);
$stext=ereg_replace("\[green\](.*)\[/green\]","<font color=\"green\">\\1</font>",$stext)
;
$stext=ereg_replace("\[black\](.*)\[/black\]","<font color=\"black\">\\1</font>",$stext);
$stext=ereg_replace("\[white\](.*)\[/u\]","<font color=\"white\">\\1</font>",$stext);
$stext=ereg_replace("\[yellow\](.*)\[/yellow\]","<font color=\"yellow\">\\1</font>",$stext);$stext=ereg_replace("\[orange\](.*)\[/orange\]","<font color=\"orange\">\\1</font>",$stext);
$stext=ereg_replace("\[blue\](.*)\[/blue\]","<font color=\"blue\">\\1</font>",$stext);
$stext=ereg_replace("\[violet\](.*)\[/violet\]","<font color=\"violet\">\\1</font>",$stext);
$spokaz=cifry($vhod);if($spokaz==1){$stext=ereg_replace("\[hidden\](.*)\[/hidden\]","\\1",$stext);}else{$stext=ereg_replace("\[hidden\](.*)\[/hidden\]","[Этот текст могут видеть только авторизованные пользователи]",
$stext);}$stext=preg_replace_callback('~(http://[0-9a-z\.-]+\.[0-9a-z]{2,6}[0-9a-zA-Z/\?\.\~&amp;_=/-:#]*)~', 'dopoln', $stext); return $stext;}
function date_fixed($d){ $d=(int)$d; $mes=date('F',$d); $den=date('d',$d); $clock=date('H:i',$d); $mes = str_replace("January","Янв",$mes); $mes = str_replace("February","Фев",$mes);
$mes = str_replace("March","Март",$mes); $mes = str_replace("April","Апр",$mes); $mes = str_replace("May","Мая",$mes);
$mes = str_replace("June","Июнь",$mes); $mes = str_replace("July","Июль",$mes); $mes = str_replace("August","Авг",$mes); $mes = str_replace("September","Сен",$mes); $mes = str_replace("October","Окт",$mes); $mes = str_replace("November","Ноя",
$mes); $mes = str_replace("December","Дек",$mes); $vivod='<b>'.$den.' '.$mes.' '.$clock.'</b>'; return $vivod;}
function user_online($string){ $inlogsa=mysql_query("SELECT `online` FROM `users` WHERE `id_user`='$string' LIMIT 1"); if(mysql_num_rows($inlogsa)==0){
$vivod='<font color="maroon">[Hid]</font>';}else{ $uzinn=mysql_fetch_array($inlogsa);} if($uzinn['online']>(time()-120)){$vivod='<font color="lime"><img src="/img/on.gif" alt="1" /></font>';}else{$vivod='<font color="red"><img src="/img/off.gif" alt="2" /></font>';} return $vivod; }

function nik_one($id_user){ $id_user=(int)$id_user; $query=mysql_query("SELECT `login`,`colornik`,`avator` FROM `users` WHERE `id_user`='$id_user'");  $qe=mysql_num_rows($query); if($qe==0){echo'error';}  $qy=mysql_fetch_array($query);
if($qy['colornik']!=""){$nik='<font color="'.prov($qy['colornik']).'">'.prov($qy['login']).' </font>';}else{$nik=prov($qy['login']);}   if($qy['avator']==""){$ava='<img src="'.$dirsite.'/images/avators/noavatar.gif" width="30" height="30" alt="">';}else{$ava='<img
src="'.$dirsite.'/images/'.$qy['avator'].'" width="30" height="30" alt="">';}   $ank=$ava.' <a href="'.$dirsite.'/pages/about.php?id='.$id_user.'">'.$nik.'</a> '.user_online($id_user);
return $ank;}
function check($peta){
$ped=htmlspecialchars(stripslashes($peta));
return $ped; }
function nik_two($id_user){ $id_user=(int)$id_user; $query=mysql_query("SELECT `login`,`colornik` FROM `users` WHERE `id_user`='$id_user'");  $qe=mysql_num_rows($query); if($qe==0){echo'error';}  $qy=mysql_fetch_array($query);
if($qy['colornik']!=""){$nik='<font color="'.prov($qy['colornik']).'">'.prov($qy['login']).' </font>';}else{$nik=prov($qy['login']);}   $ank='<a href="'.$dirsite.'/pages/about.php?id='.$id_user.'">'.$nik.'</a> '.user_online($id_user);
return $ank;}
function nik_tri($id_user){ $id_user=(int)$id_user; $query=mysql_query("SELECT `login`,`colornik` FROM `users` WHERE `id_user`='$id_user'");  $qe=mysql_num_rows($query); if($qe==0){echo'error';}  $qy=mysql_fetch_array($query);
if($qy['colornik']!=""){$nik='<font color="'.prov($qy['colornik']).'">'.prov($qy['login']).' </font>';}else{$nik=prov($qy['login']);}   $ank='<a href="'.$dirsite.'/pages/about.php?id='.$id_user.'">'.$nik.'</a>';
return $ank;}



//Постраничная навигация
function strpage($page, $posts, $total, $start, $reqpage=""){



if ($page != 0) echo '<a href="'.$start.'?'.$reqpage.'page='.($page - $posts).'">&lt;-Назад</a> ';
else echo '&lt;-Назад';

echo ' | ';

if ($total > $page + $posts)
echo ' <a href="'.$start.'?'.$reqpage.'page='.($page + $posts).'">Далее-&gt;</a>';
else echo 'Далее-&gt;';
if($total>0){

$ba = ceil($total/$posts);
$ba2 = $ba*$posts-$posts;
echo '<br>Стр:';
$asd = $page-($posts*3);
$asd2 = $page+($posts*4);

if($asd<$total && $asd>0) echo ' <a href="'.$start.'?'.$reqpage.'page=0">1</a> ... ';

for($i=$asd; $i<$asd2;){
if($i<$total && $i>=0){
$ii = floor(1+$i/$posts);
if ($page==$i) echo ' <b>['.$ii.']</b>';
else echo ' <a href="'.$start.'?'.$reqpage.'page='.$i.'">'.$ii.'</a>';
}
$i=$i+$posts;
}
if($asd2<$total) echo ' ... <a href="'.$start.'?'.$reqpage.'page='.$ba2.'">'.$ba.'</a>';
}}

//Пост навигация+мод реврайт
function strmpage($page, $posts, $total, $start){



if ($page != 0) echo '<a href="'.$start.'page='.($page - $posts).'">&lt;-Назад</a> ';
else echo '&lt;-Назад';

echo ' | ';

if ($total > $page + $posts)
echo ' <a href="'.$start.'page='.($page + $posts).'">Далее-&gt;</a>';
else echo 'Далее-&gt;';
if($total>0){
$ba = ceil($total/$posts);
$ba2 = $ba*$posts-$posts;
echo '<br>Стр:';
$asd = $page-($posts*3);
$asd2 = $page+($posts*4);

if($asd<$total && $asd>0) echo ' <a href="'.$start.'page=0">1</a> ... ';

for($i=$asd; $i<$asd2;){
if($i<$total && $i>=0){
$ii = floor(1+$i/$posts);
if ($page==$i) echo ' <b>['.$ii.']</b>';
else echo ' <a href="'.$start.'page='.$i.'">'.$ii.'</a>';
}
$i=$i+$posts;
}
if($asd2<$total) echo ' ... <a href="'.$start.'page='.$ba2.'">'.$ba.'</a>';
}}

?>