View file guestbook/incfiles/functions.php

File size: 9.66Kb
<?php

#####################################################################################
////////////////Функция антивирусной защиты (для вида)//////////////////////
function kasper() {
if($kasper=="1") {
echo '<img src="../img/kaspersky.png"> <b>Kaspersky Internet Security 2010</b><br>';
echo'<!--Внимание! Включена защита антивирусной системой Kaspersky Lab 2010-->';
}
}
#####################################################################################
////////////////Функция антимата////////////////////////////////////////////
function antimat2($str)
{
$anti=array(
"ХУЙ","ПИЗДА","ХРЕН","ПИЗДА","ЕБАТЬ","ЕБУТСЯ","ЛОХ","ПИЗДАБОЛ",
"хуй","пизда","хрен","пизда","ебать","ебутся","лох","пиздабол",
"Хуй","Пизда","Хрен","Пизда","Ебать","Ебутся","Лох","Пиздабол");

$text=str_replace('anti[0]','[censure]',$str);
$text=str_replace('anti[1]','[censure]',$str);
$text=str_replace('anti[2]','[censure]',$str);
$text=str_replace('anti[3]','[censure]',$str);
$text=str_replace('anti[4]','[censure]',$str);
$text=str_replace('anti[5]','[censure]',$str);
$text=str_replace('anti[6]','[censure]',$str);
$text=str_replace('anti[7]','[censure]',$str);
$text=str_replace('anti[8]','[censure]',$str);
$text=str_replace('anti[9]','[censure]',$str);
$text=str_replace('anti[10]','[censure]',$str);
$text=str_replace('anti[11]','[censure]',$str);
$text=str_replace('anti[12]','[censure]',$str);
$text=str_replace('anti[13]','[censure]',$str);
$text=str_replace('anti[14]','[censure]',$str);
$text=str_replace('anti[15]','[censure]',$str);
$text=str_replace('anti[16]','[censure]',$str);
$text=str_replace('anti[17]','[censure]',$str);
$text=str_replace('anti[18]','[censure]',$str);
$text=str_replace('anti[19]','[censure]',$str);
$text=str_replace('anti[20]','[censure]',$str);
$text=str_replace('anti[21]','[censure]',$str);
$text=str_replace('anti[22]','[censure]',$str);
$text=str_replace('anti[23]','[censure]',$str);
  return $str;
}
#####################################################################################
/////////////////////Функция шифрования по ключу/////////////////////////////////////
function xoft_encode($str, $key){   
$result = "";   
for($i = 1; $i<=strlen($string); $i++){   
$char = substr($string, $i-1,1);   
$keychar = substr($key, ($i % strlen($key)) - 1, 1);   
$char = chr(ord($char)+ord($keychar));   
$result .= $char;   
}   
return safe_encode($result);   
}   
######################################################################################
/////////////////////Функция расшифровки по ключу/////////////////////////////////////	
function xoft_decode($str, $key){  
$string = safe_decode($string); 
$result = "";   
for($i = 1; $i<=strlen($string); $i++){   
$char = substr( $string, $i - 1, 1 );   
$keychar = substr($key, ($i % strlen($key)) - 1, 1);   
$char = chr(ord($char) - ord($keychar));   
$result .= $char;   
}   
return $result;   
}   
#######################################################################################
/////////////////////Функция генерирования паролей/////////////////////////////////////
function generate_password($length=""){

if (empty($length)){$length = mt_rand(10,12);}	
$salt = str_split('aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789');

$makepass = "";
for ($i = 0; $i < $length; $i++){
$makepass .= $salt[array_rand($salt)];
}
return $makepass;
}
#######################################################################################
///////////////////////Функция подсчета строк в файле//////////////////////////////////
function counter_string($files){

$count_lines=0;
if (file_exists($files)){
$lines = file($files);
$count_lines = count($lines);
}
return $count_lines;
}
########################################################################################
////////////////////////Функция обработки строк данных и ссылок/////////////////////////
function check_string($string) {
$string = strtolower($string);
$string = str_replace(array('http://www.','http://wap.','http://','https://'), '',$string);
$string = strtok($string,'/?');
return $string;
}
##########################################################################################
//////////////////////////Функция отправки письма по e-mail///////////////////////////////
function addmail($usermail, $subject, $msg, $mail="", $name="") {


$subject = utf_to_win($subject);
$msg = utf_to_win($msg);
$name = utf_to_win($name);

$subject = convert_cyr_string($subject, 'w','k');
$msg = convert_cyr_string($msg, 'w','k');
$name = convert_cyr_string($name, 'w','k');

$subject = '=?KOI8-R?B?'.base64_encode($subject).'?=';

$adds = "From: ".$name." <".$mail.">\n"; 
$adds .= "X-sender: ".$name." <".$mail.">\n";
$adds .= "Content-Type: text/plain; charset=koi8-r\n";   
$adds .= "MIME-Version: 1.0\n";
$adds .= "Content-Transfer-Encoding: 8bit\n";
$adds .= "X-Mailer: PHP v.".phpversion();

return mail($usermail,$subject,$msg,$adds);
}
###########################################################################################
//////////////////////Функция чтения строки в файле////////////////////////////////////////
function read_string($file, $line="") {   

if (file_exists($file)){
$files = file($file);

if ($line===""){
return explode("|",end($files));
}

if (isset($files[$line])){
return explode("|",$files[$line]);
}
}
return false;
}
###########################################################################################
///////////////////////////Функция записи в файл///////////////////////////////////////////
function write_files($filename, $text, $clear=0, $chmod=""){
$fp = fopen($filename, "a+");
flock ($fp,LOCK_EX);
if ($clear==1) {ftruncate($fp,0);}  
fputs ($fp,$text);
fflush($fp);
flock ($fp,LOCK_UN);
fclose($fp);
if ($chmod!="") {chmod($filename, $chmod);}
}
###########################################################################################
/////////////////////////////Функция чтения из профиля/////////////////////////////////////
function reading_profil($login){

$arrdata = array();

if (file_exists(BASEDIR."local/users/$login.prof")){

$file = file_get_contents(BASEDIR."local/users/$login.prof");
if ($file!=""){ 
$arrdata = explode(':||:', $file);
}}

return $arrdata;
}
###########################################################################################
//////////////////////////Функция экранирования основных знаков////////////////////////////
function check($msg){ 

if (is_array($msg)) {

foreach($msg as $key=>$val) {
$msg[$key] = check($val);
}

} else {
$msg = htmlspecialchars($msg); 
$search = array('|','\'','$','\\','^','%','`',"\0","\x00","\x1A");
$replace = array('&#124;','&#39;','&#36;','&#92;','&#94;','&#37;','&#96;','','','');

$msg = str_replace($search, $replace, $msg);
$msg = stripslashes(trim($msg));
}

return $msg;
}
############################################################################################
//////////////////////////////Функция обработки даты и времени//////////////////////////////
function data_rus($data) {
str_replace('Jan','Январь',$data);
str_replace('Feb','Февраль',$data);
str_replace('Mar','Март',$data);
str_replace('Apr','Апрель',$data);
str_replace('May','Май',$data);
str_replace('Jun','Июнь',$data);
str_replace('Jul','Июль',$data);
str_replace('Aug','Август',$data);
str_replace('Sep','Сентябрь',$data);
str_replace('Oct','Октябрь',$data);
str_replace('Nov','Ноябрь',$data);
str_replace('Dec','Декабрь',$data);

str_replace('Mon','Понедельник',$data);
str_replace('Tue','Вторник',$data);
str_replace('Wed','Среда',$data);
str_replace('Thu','Четверг',$data);
str_replace('Fri','Пятница',$data);
str_replace('Sat','Суббота',$data);
str_replace('Sun','Воскресенье',$data);
//str_replace('','',$data);
//str_replace('','',$data);
str_replace('','',$data);




}
############################################################################################
//----------------------------Вывод даты----------------------------//
function date_fix(){

$datestamp = date("d F Y / H:i");


$datestamp = str_replace("January","Января",$datestamp);
$datestamp = str_replace("February","Февраля",$datestamp);
$datestamp = str_replace("March","Марта",$datestamp);
$datestamp = str_replace("April","Апреля",$datestamp);
$datestamp = str_replace("May","Мая",$datestamp);
$datestamp = str_replace("June","Июня",$datestamp);
$datestamp = str_replace("July","Июля",$datestamp);
$datestamp = str_replace("August","Августа",$datestamp);
$datestamp = str_replace("September","Сентября",$datestamp);
$datestamp = str_replace("October","Октября",$datestamp);
$datestamp = str_replace("November","Ноября",$datestamp);
$datestamp = str_replace("December","Декабря",$datestamp);

return $datestamp;
}
###############################################################################################
//////////////////////////Декодирование из md5/////////////////////////////////////////////////
function de_md5($str) {
$str = md5(trim($str));
return $str;
}


?>