Просмотр файла waplend/tools.php

Размер файла: 5.41Kb
<?php
/** функция не используется но может пригодится	
	function smiles($array)  
{  
global $smls_templts;  
static $s;  
      
if($s == 3) return $array[0];  
if(!in_array($array[0], $smls_templts)) return $array[0];  

$s++;  

return "<img src='/smiles/" . $array[1] . ".gif' alt='" . $array[0] . "' />";  
}  

$smls_templts = array(":smile:", ":smile2:");  
$string = "1st smile: :smile:, 2nd smile: :smile2:, 2nd smile: :smile2:, 2nd smile: :smile2:, 2nd smile: :smile2:, 2nd smile: :smile2:";  
$string = preg_replace_callback("/:([a-z0-9]+):/", "smiles", $string); */ 
	
	
	
	function count_file_new($dir,$n_time)
{
$livetime=time()-60;
$q2 = mysql_query("SELECT COUNT(*) FROM `load_k_n` WHERE `time` > '$livetime' AND `dir` = '$dir';");

if (mysql_result($q2, 0)>0)
{
$q = mysql_query("SELECT k FROM `load_k_n` WHERE `time` > '$livetime' AND `dir` = '$dir' LIMIT 1;");
$k_files=mysql_fetch_array($q, 1);
return $k_files['k'];
}
else
{
$k_files=0;
$od=opendir($dir);
while ($rd=readdir($od))
{
if (is_dir("$dir/$rd") && $rd!='.' && $rd!='..')
{
$k_files=$k_files+count_file_new("$dir/$rd", $n_time);
}
elseif(!ereg(".name|error.log|.htaccess|.opis|.aut|.jad",$rd) && $rd!='.' && $rd!='..')
{
if (time()<filemtime("$dir/$rd")+$n_time)
{
$k_files++;
}
}
}

$time=time();
mysql_query("INSERT INTO `load_k_n` (dir, time, k) values('$dir', '$time', '$k_files')");
mysql_query("DELETE FROM `load_k_n` WHERE `time` < '$livetime';");
return $k_files;
}
}

function count_file($dir)
{
$livetime=time()-60;
$q2 = mysql_query("SELECT COUNT(*) FROM `load_k` WHERE `time` > '$livetime' AND `dir` = '$dir';");

if (mysql_result($q2, 0)>0)
{
$q = mysql_query("SELECT k FROM `load_k` WHERE `time` > '$livetime' AND `dir` = '$dir' LIMIT 1;");
$k_files=mysql_fetch_array($q, 1);
return $k_files['k'];
}
else
{
$k_files=0;
$od=opendir($dir);
while ($rd=readdir($od))
{
if (is_dir("$dir/$rd") && $rd!='.' && $rd!='..')
{
$k_files=$k_files+count_file("$dir/$rd");
}
elseif(!ereg(".name|error.log|.htaccess|.opis|.aut|.jad",$rd) && $rd!='.' && $rd!='..')
{
$k_files++;
}
}

$time=time();
mysql_query("INSERT INTO `load_k` (dir, time, k) values('$dir', '$time', '$k_files')");
mysql_query("DELETE FROM `load_k` WHERE `time` < '$livetime';");
return $k_files;
}
}

function count_dir_size($dir)
{
$livetime=time()-60;
$q2 = mysql_query("SELECT COUNT(*) FROM `load_s` WHERE `time` > '$livetime' AND `dir` = '$dir';");

if (mysql_result($q2, 0)>0)
{
$q = mysql_query("SELECT s FROM `load_s` WHERE `time` > '$livetime' AND `dir` = '$dir' LIMIT 1;");
$size=mysql_fetch_array($q, 1);
return $size['s'];
}
else
{
$size=0;
$od=opendir($dir);
while ($rd=readdir($od))
{
if (is_dir("$dir/$rd") && $rd!='.' && $rd!='..')
{
$size=$size+count_dir_size("$dir/$rd");
}
elseif(!ereg(".name|error.log|.htaccess|.opis|.aut|.jad",$rd) && $rd!='.' && $rd!='..')
{
$size=$size+filesize("$dir/$rd");
}
}

$time=time();
mysql_query("INSERT INTO `load_s` (dir, time, s) values('$dir', '$time', '$size')");
mysql_query("DELETE FROM `load_s` WHERE `time` < '$livetime';");
return $size;
}
}
	
	
	
	
	//////////по bbcode
	function bbcode($msg) 
 { 
 	$msg = str_replace("[u]", "<u>", $msg); //замера bbCode на теги HTML 
 	$msg = str_replace("[U]", "<u>", $msg); 
 	$msg = str_replace("[i]", "<i>", $msg); 
 	$msg = str_replace("[I]", "<i>", $msg); 
 	$msg = str_replace("[b]", "<b>", $msg); 
 	$msg = str_replace("[B]", "<b>", $msg); 
 	$msg = str_replace("[/u]", "</u>", $msg); 
 	$msg = str_replace("[/U]", "</u>", $msg); 
 	$msg = str_replace("[/i]", "</i>", $msg); 
 	$msg = str_replace("[/I]", "</i>", $msg); 
 	$msg = str_replace("[/b]", "</b>", $msg); 
 	$msg = str_replace("[/B]", "</b>", $msg); 
 	$msg = str_replace("[br/]", "<br/>", $msg); 
 	$msg = str_replace("[BR/]", "<br/>", $msg); 
 	$msg = str_replace("\n", "<br/>", $msg); 
 $msg=preg_replace('!\[img\](.*)\[/img\]!Us', '<img src="\\1" border=\'0\' align=\'left\'/>', $msg);
 	 $msg=preg_replace('!\[url=(.*)\](.*)\[/url\]!Us', '<a href="\\1">\\2</a>', $msg);

 	return $msg;
 } 
	////////////
$s1 = "<img src='../smiles/as.gif' alt=':)' />";
$s2 = "<img src='../smiles/ab.gif' alt=':(' />"; 
$s3 = "<img src='../smiles/a1.gif' alt=';)' />";
$s4 = "<img src='../smiles/af.gif' alt='8)' />";
$s5 = "<img src='../smiles/ag.gif' alt=':D' />";
$s6 = "<img src='../smiles/ah.gif' alt='-)' />";
$s7 = "<img src='../smiles/ai.gif' alt=':0' />";
$s8 = "<img src='../smiles/aj.gif' alt=':+' />";
$s9 = "<img src='../smiles/ak.gif' alt=':*(' />";
$s10 = "<img src='../smiles/aq.gif' alt=':devil:' />";
$s11 = "<img src='../smiles/at.gif' alt=':ploho:' />";
$s12 = "<img src='../smiles/aw.gif' alt=':kiss:' />";
$sm1=array(':)',':(',';)','8)',':D','-)',':0',':+',':*(',':devil:',':ploho:',':kiss:');
$sm2=array("$s1","$s2","$s3","$s4","$s5","$s6","$s7","$s8","$s9","$s10","$s11","$s12");
function smilereplase($msg)
{	
$msg=strtr($sm1,$sm2,$msg);
return $msg;
}

function hacker($str)
{
$str=strtr($str,array("`"=>" ","="=>" ","'"=>" ","#"=>" ","\""=>" ","$"=>" "));
 return $str;
}

//$_GET['kateg']=trim(strtr($_GET['kateg'],array("/"=>" ","."=>" ","-"=>" ")));

$ip = $_SERVER['REMOTE_ADDR']; 
$kmess=10;

$ext = array(".doc", ".txt", ".zip", ".sis", ".3gp", ".sisx", ".avi", ".gif", ".jpg", ".mp3", ".mp4", ".mid", ".jad", ".jar");


$max_file_size = "50000000";



?>