View file functions.php

File size: 6.49Kb
<?php
/*
Proton wapforum v5
Запрещается убирать копирайты для дальнейшего распростанения скрипта!
В случае обнаружения ошибок обращайтесь к автору!
Приходите за новыми скриптами: http://svoboda.v1p.su/script удачи! :)
*/
function user_status($user) {
$status='';
$file=file('users.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($ex[0]==$user) {
$status=$ex[4]; }
}
return $status;
}
function bb_code($mes){
$mes=nl2br($mes);
$mes=str_replace('
','<br/>',$mes);
$mes=htmlspecialchars($mes);
$mes=stripslashes($mes);
$mes = preg_replace('#\[big\](.*?)\[/big\]#si', '<big>\1</big>', $mes);
$mes = preg_replace('#\[b\](.*?)\[/b\]#si', '<b>\1</b>', $mes);
$mes = preg_replace('#\[i\](.*?)\[/i\]#si', '<i>\1</i>', $mes);
$mes = preg_replace('#\[u\](.*?)\[/u\]#si', '<u>\1</u>', $mes);
$mes = preg_replace('#\[small\](.*?)\[/small\]#si', '<small>\1</small>', $mes);
$mes = preg_replace('#\[red\](.*?)\[/red\]#si', '<span style="color:#FF0000">\1</span>', $mes);
$mes = preg_replace('#\[green\](.*?)\[/green\]#si', '<span style="color:#00FF00">\1</span>', $mes);
$mes = preg_replace('#\[blue\](.*?)\[/blue\]#si', '<span style="color:#0000FF">\1</span>', $mes);
$mes = preg_replace('#\[yellow\](.*?)\[/yellow\]#si', '<span style="color:#FFFF00">\1</span>', $mes);
$mes = preg_replace('#\[quote\](.*?)\[/quote\]#si', '<q>\1</q>', $mes);
$mes = preg_replace('#\[del\](.*?)\[/del\]#si', '<del>\1</del>', $mes);
$mes=preg_replace("!(http://[\S]+)([\s]|$)!i","<a href=\"\\1\">\\1</a> ",$mes);
$mes=str_replace('">http://','">',$mes);
return $mes; 
}
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 repeatuser($user) {
$var='0';
if (file_exists('users.dat')) {
$file=file('users.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($ex[1]==$user)
{
$var='1';
}
}
}
return $var;
}
function newuser() {
$file=file('users.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
$mas[]=trim($ex[3]).'/'.trim($ex[0]);
}
sort($mas);
rsort($mas);
$ex=explode('/',$mas[0]);
return $ex[1]+1;
}
function time_mes($razdel,$tema) {
$var='None';
$file=file('msg.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($razdel==$ex[0] and $tema==$ex[1])
{
$mas[]=trim($ex[4]);
}
}
sort($mas);
rsort($mas);
return $mas[0];
}
function search_topic($razdel,$tema) {
$var='None';
$file=file('topic.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($razdel==$ex[0] and $tema==$ex[1])
{
$var=trim($ex[2]);
}
}
return $var;
}
function search_part($razdel) {
$var='None';
$file=file('razdely.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($razdel==$ex[0])
{
$var=trim($ex[1]);
}
}
return $var;
}
function search_user($user) {
$var='None';
$file=file('users.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($user==$ex[0])
{
$var=trim($ex[1]);
}
}
return $var;
}
function mes_gaga($id) {
$var='0';
$file=file('msg.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($id==$ex[2])
{
$var='1';
}
}
return $var;
}
function topic_gaga($id) {
$var='0';
$file=file('topic.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($id==$ex[1])
{
$var='1';
}
}
return $var;
}
function part_gaga($id) {
$var='0';
$file=file('razdely.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($id==$ex[0])
{
$var='1';
}
}
return $var;
}
function newtopic() {
$file=file('topic.dat');
if (!empty($file[0])) {
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
$mas[]=trim($ex[4]).'/'.trim($ex[1]);
}
sort($mas);
rsort($mas);
$ex=explode('/',$mas[0]);
return $ex[1]+1;
} else {
return '1'; }
}
function newmes() {
$file=file('msg.dat');
if (!empty($file[0])) {
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
$mas[]=trim($ex[4]).'/'.trim($ex[2]);
}
sort($mas);
rsort($mas);
$ex=explode('/',$mas[0]);
return $ex[1]+1;
} else {
return '1'; }
}
function newpart() {
$file=file('razdely.dat');
if (!empty($file[0])) {
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
$mas[]=trim($ex[2]).'/'.trim($ex[0]);
}
sort($mas);
rsort($mas);
$ex=explode('/',$mas[0]);
return $ex[1]+1;
} else {
return '1'; }
}
function topic_all($id) {
$topic='0';
$file=file('topic.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($ex[0]==$id)
{
$topic++;
}
}
return $topic;
}
function messages($id) {
$messages='0';
$file=file('msg.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($ex[0]==$id)
{
$messages++;
}
}
return $messages;
}
function msg($razdel,$tema) {
$messages='0';
$file=file('msg.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$ex=explode('#/#/#',$file[$i]);
if ($ex[0]==$razdel and $ex[1]==$tema)
{
$messages++;
}
}
return $messages;
}
function user_count() {
$user='0';
$file=file('users.dat');
$count=count($file);
for($i=0;$i<$count;$i++)
{
$user++;
}
return $user;
}
?>