View file functions.php

File size: 2.97Kb
<?php
function news_gaga($id) {
$var='0';
$file=file('news.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($id==$ex[0])
{
$var='1';
}
}
return $var;
}
function bb_code($text){
$text=htmlspecialchars($text);
$text=stripslashes($text);
$text=nl2br($text);
$text=str_replace('
','',$text);
$text = preg_replace('#\[big\](.*?)\[/big\]#si', '<big>\1</big>', $text);
$text = preg_replace('#\[b\](.*?)\[/b\]#si', '<b>\1</b>', $text);
$text = preg_replace('#\[i\](.*?)\[/i\]#si', '<i>\1</i>', $text);
$text = preg_replace('#\[u\](.*?)\[/u\]#si', '<u>\1</u>', $text);
$text = preg_replace('#\[small\](.*?)\[/small\]#si', '<small>\1</small>', $text);
$text = preg_replace('#\[red\](.*?)\[/red\]#si', '<span style="color:#FF0000">\1</span>', $text);
$text = preg_replace('#\[green\](.*?)\[/green\]#si', '<span style="color:#00FF00">\1</span>', $text);
$text = preg_replace('#\[blue\](.*?)\[/blue\]#si', '<span style="color:#0000FF">\1</span>', $text);
$text = preg_replace('#\[yellow\](.*?)\[/yellow\]#si', '<span style="color:#FFFF00">\1</span>', $text);
$text = preg_replace('#\[quote\](.*?)\[/quote\]#si', '<q>\1</q>', $text);
$text = preg_replace('#\[del\](.*?)\[/del\]#si', '<del>\1</del>', $text);
$text=preg_replace("!(http://[\S]+)([\s]|$)!i","<a href=\"\\1\">\\1</a> ",$text);
$text=str_replace('">http://','">',$text);
return $text; 
}
function smile($text)
{
if (is_dir("smile") && $handle=opendir("smile"))
{
while (false !==($file=readdir($handle)))
{
if ($file!="." and $file!=".." and $file!="index.php" and $file!="page.php")
{
$mas[]=$file;
}
}
}
sort($mas);
$count=count($mas);
for($i=0;$i<$count;$i++)
{
$file=$mas[$i];
$ex=explode(".",$file);
$smile=$ex[0];
$trans1=array("TS","ts","JO","ZH","CH","SH","SCH","YE","JU","JA","jo","zh","ch","sh","sch","ye","ju","ja","A","B","V","G","D","E","Z","I","J","K","L","M","N","O","P","R","S","T","U","F","H","Y","a","b","v","g","d","e","z","i","j","k","l","m","n","o","p","r","s","t","u","f","h","'","y","X","x","1","2","3","4","5","6","7");
$trans2=array("Ц","ц","Ё","Ж","Ч","Ш","Щ","Э","Ю","Я","ё","ж","ч","ш","щ","э","ю","я","А","Б","В","Г","Д","Е","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ы","а","б","в","г","д","е","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ь","ы","КС","кс",":-)",":-(",":-|",":-0",";-)","8-)",":-D");
$pokaz=str_replace($trans1,$trans2,$smile); 
if ($smile==1 || $smile==2 || $smile==3 || $smile==4 || $smile==5 || $smile==6 || $smile==7)
{
$text=str_replace($pokaz,'<img src="smile/'.$file.'" alt="'.$pokaz.'"/>',$text);
}
else
{
$text=str_replace(':'.$pokaz.':','<img src="smile/'.$file.'" alt=":'.$pokaz.':"/>',$text);
}
}
return $text;
}
function newpost() {
$file=file('news.dat');
if (!empty($file[0])) {
$ex=explode('#/#/#',$file[0]);
return trim($ex[0])+1;
} else {
return '1'; }
}
function news() {
$news='0';
$file=file('news.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$news++;
}
return $news;
}
?>