Файл: gb/functions.php
Строк: 214
<?php
#-----------------------------------------------------#
# ********* WAP-MOTORS ********* #
# Made by : VANTUZ #
# E-mail : visavi.net@mail.ru #
# Site : http://pizdec.ru #
# WAP-Site : http://visavi.net #
# ICQ : 36-44-66 #
# Вы не имеете право вносить изменения в код скрипта #
# для его дальнейшего распространения #
#-----------------------------------------------------#
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('html_errors', true);
ini_set('error_reporting', E_ALL);
/* @error_reporting(E_ALL ^ E_NOTICE);
@ini_set('display_errors', true);
@ini_set('html_errors', false);
@ini_set('error_reporting', E_ALL ^ E_NOTICE); */
@ini_set('url_rewriter.tags','');
@ini_set('session.use_trans_sid', 1);
@set_magic_quotes_runtime(0);
define('TIMESTART', microtime(1));
define('BOOKVERSION', '1.4');
define('VANTUZBOOK', TRUE);
session_name('SID');
session_start();
ob_start();
//-------------------------------- ФУНКЦИИ -------------------------------------//
function page_navigation($link, $posts, $start, $total, $koll = 4) {
if($total>0){
echo '<hr>Страницы: ';
$ba=ceil($total/$posts);
$ba2=$ba*$posts-$posts;
$min = $start - $posts * ($koll - 1);
$max = $start + $posts * $koll;
if($min<$total && $min>0){
if($min-$posts>0){
echo ' <span class="pagelink"><a href="'.$link.'start=0">1</a></span> ... ';
} else {
echo ' <span class="pagelink"><a href="'.$link.'start=0">1</a></span> ';
}}
for($i=$min; $i<$max;){
if($i<$total && $i>=0){
$ii=floor(1+$i/$posts);
if ($start==$i) {
echo ' <span class="pagecurrent">'.$ii.'</span> ';
} else {
echo ' <span class="pagelink"><a href="'.$link.'start='.$i.'">'.$ii.'</a></span> ';
}}
$i=$i+$posts;}
if($max<$total){
if($max+$posts<$total){
echo ' ... <span class="pagelink"><a href="'.$link.'start='.$ba2.'">'.$ba.'</a></span> ';
} else {
echo ' <span class="pagelink"><a href="'.$link.'start='.$ba2.'">'.$ba.'</a></span> ';
}}
}}
//----------------------- Функция экранирования основных знаков --------------------------//
function check($message){
$message = htmlspecialchars($message);
$message = str_replace("'","'",$message);
$message = str_replace(""",""",$message);
$message = str_replace("$","$",$message);
$message = str_replace("$","$",$message);
$message = str_replace("\","\", $message);
$message = str_replace("^","^", $message);
$message = str_replace("%","%", $message);
$message = str_replace("`","", $message);
$message = stripslashes(trim($message));
$message = sqlite_escape_string($message);
return $message;
}
//---------------------- Аналог функции strlen для UTF-8 -----------------------//
function utf_strlen($str){
if (function_exists('mb_strlen')) return mb_strlen($str, 'utf-8');
if (function_exists('iconv_strlen')) return iconv_strlen($str, 'utf-8');
return strlen(utf8_decode($str));
}
//------------------ Функция определения реального IP --------------------//
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && preg_match('|^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$|', $_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];}
elseif(isset($_SERVER['HTTP_CLIENT_IP']) && preg_match('|^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$|', $_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];}
else {$ip = preg_replace('|[^0-9.]|', '', $_SERVER['REMOTE_ADDR']);}
$ip = check($ip);
//------------------ Функция определения реального браузера --------------------//
if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])) {$browsus = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];}
elseif(isset($_SERVER['HTTP_USER_AGENT'])) {$browsus = $_SERVER['HTTP_USER_AGENT'];}
else {$browsus = 'Not_detected';}
$brow = preg_replace('|http://|i','', $browsus);
$brow = strtok($brow,'( ');
$brow = substr($brow,0,22);
$brow = check($brow);
//------------------------- Вспомогательная функция быстрой вставки ------------------------//
function quickpaste($form){
echo '<script language="JavaScript" type="text/javascript">
function tag(text1, text2) {
if ((document.selection)) {
document.form.'.$form.'.focus();
document.form.document.selection.createRange().text = text1+document.form.document.selection.createRange().text+text2;
} else if(document.forms['form'].elements[''.$form.''].selectionStart!=undefined) {
var element = document.forms['form'].elements[''.$form.''];
var str = element.value;
var start = element.selectionStart;
var length = element.selectionEnd - element.selectionStart;
element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
} else document.form.'.$form.'.value += text1+text2;
}
function code(text){
document.form.'.$form.'.focus();
document.selection.createRange().text = text;
document.form.'.$form.'.focus();
}
</script>';
}
//------------------------- Функция вывода быстрых смайлов ------------------------//
function quicksmiles(){
echo 'Смайлы<br>';
echo '<a href="#sm" onClick="javascript:code(' :) ');"><img src="files/smiles/).gif" alt=""></a> ';
echo '<a href="#sm" onClick="javascript:code(' :( ');"><img src="files/smiles/(.gif" alt=""></a> ';
echo '<a href="#sm" onClick="javascript:code(' :D ');"><img src="files/smiles/D.gif" alt=""></a> ';
echo '<a href="#sm" onClick="javascript:code(' :E ');"><img src="files/smiles/E.gif" alt=""></a> ';
echo '<a href="#sm" onClick="javascript:code(' :hello ');"><img src="files/smiles/hello.gif" alt=""></a> ';
echo '<a href="#sm" onClick="javascript:code(' :cry ');"><img src="files/smiles/cry.gif" alt=""></a> ';
echo '<a href="#sm" onClick="javascript:code(' :obana ');"><img src="files/smiles/obana.gif" alt=""></a> ';
echo '<a href="#sm" onClick="javascript:code(' :infat ');"><img src="files/smiles/infat.gif" alt=""></a> ';
echo '<a href="#sm" onClick="javascript:code(' :krut ');"><img src="files/smiles/krut.gif" alt=""></a> ';
echo '<a href="#sm" onClick="javascript:code(' :vtopku ');"><img src="files/smiles/vtopku.gif" alt=""></a> ';
echo '<br>';
}
function quickcode(){
echo 'BB-код<br>';
echo '<a href="#sm" onClick="javascript:tag('[url=]', '[/url]');"><img src="files/editor/a.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[b]', '[/b]');"><img src="files/editor/b.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[big]', '[/big]');"><img src="files/editor/big.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[small]', '[/small]');"><img src="files/editor/small.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[i]', '[/i]');"><img src="files/editor/i.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[u]', '[/u]');"><img src="files/editor/u.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[q]', '[/q]');"><img src="files/editor/q.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[del]', '[/del]');"><img src="files/editor/del.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[code]', '[/code]');"><img src="files/editor/code.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[red]', '[/red]');"><img src="files/editor/red.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[green]', '[/green]');"><img src="files/editor/green.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[blue]', '[/blue]');"><img src="files/editor/blue.gif" alt=""></a>';
echo '<a href="#sm" onClick="javascript:tag('[yellow]', '[/yellow]');"><img src="files/editor/yellow.gif" alt=""></a>';
echo '<br>';
}
//------------------ Вспомогательная функция для bb-кода --------------------//
function url_replace($m) {
if( !isset($m[3]) ) {
return '<a href="' . $m[1] . '">' . $m[2] . '</a>';
} else {
return '<a href="' . $m[3] . '">' . $m[3] . '</a>';
}}
//------------------ Функция вставки BB-кода --------------------//
function bb_code($message){
$message = preg_replace('#[code](.*?)[/code]#ie', 'highlight_code("1")', $message);
$message = preg_replace('#[big](.*?)[/big]#si', '<big>1</big>', $message);
$message = preg_replace('#[b](.*?)[/b]#si', '<b>1</b>', $message);
$message = preg_replace('#[i](.*?)[/i]#si', '<i>1</i>', $message);
$message = preg_replace('#[u](.*?)[/u]#si', '<u>1</u>', $message);
$message = preg_replace('#[small](.*?)[/small]#si', '<small>1</small>', $message);
$message = preg_replace('#[red](.*?)[/red]#si', '<font color="#FF0000">1</font>', $message);
$message = preg_replace('#[green](.*?)[/green]#si', '<font color="#00FF00">1</font>', $message);
$message = preg_replace('#[blue](.*?)[/blue]#si', '<font color="#0000FF">1</font>', $message);
$message = preg_replace('#[yellow](.*?)[/yellow]#si', '<font color="#FFFF00">1</font>', $message);
$message = preg_replace('#[q](.*?)[/q]#si', '<q>1</q>', $message);
$message = preg_replace('#[del](.*?)[/del]#si', '<del>1</del>', $message);
$message = preg_replace_callback('~\[url=(http://.+?)\](.+?)\[/url\]|(http://(www.)?[0-9a-z.-]+.[0-9a-z]{2,6}[0-9a-zA-Z/?.~&_=/%-:#]*)~', 'url_replace', $message);
$message = str_replace('[br]', '<br>',$message);
$message = str_replace(':)', '<img src="files/smiles/).gif" alt="">',$message);
$message = str_replace(':(', '<img src="files/smiles/(.gif" alt="">',$message);
$message = str_replace(':D', '<img src="files/smiles/D.gif" alt="">',$message);
$message = str_replace(':E', '<img src="files/smiles/E.gif" alt="">',$message);
$message = str_replace(':hello', '<img src="files/smiles/hello.gif" alt="">',$message);
$message = str_replace(':cry', '<img src="files/smiles/cry.gif" alt="">',$message);
$message = str_replace(':obana', '<img src="files/smiles/obana.gif" alt="">',$message);
$message = str_replace(':infat', '<img src="files/smiles/infat.gif" alt="">',$message);
$message = str_replace(':krut', '<img src="files/smiles/krut.gif" alt="">',$message);
$message = str_replace(':vtopku', '<img src="files/smiles/vtopku.gif" alt="">',$message);
return $message;
}
//----------------------- Функция вырезания переноса строки --------------------------//
function no_br($message,$replace = ""){
$message = preg_replace ("|[rn]+|si",$replace,$message);
return $message;
}
//--------------------- Функция шифровки Email-адреса ------------------------//
function crypt_mail($mail) {
$output = "";
$strlen = strlen($mail);
for ($i = 0; $i < $strlen; $i++) {
$output .= '&#'.ord($mail[$i]).';';
}
return $output;
}
//--------------------- Функция определения админа ------------------------//
function is_admin($log, $par) {
if (isset($_SESSION['adminlogin']) && isset($_SESSION['adminpass'])){
if ($_SESSION['adminlogin']==$log && md5(md5($_SESSION['adminpass']))==$par){
return true;
}}
if (isset($_COOKIE['adminlogin']) && isset($_COOKIE['adminpass'])){
if ($_COOKIE['adminlogin']==$log && md5(md5($_COOKIE['adminpass']))==$par){
return true;
}}
return false;
}
//------------------ Функция подсветки кода -------------------------//
function highlight_code($code) {
$code = strtr($code,array('<'=>'<','>'=>'>','&'=>'&','$'=>'$','"'=>'"','''=>"'",'\'=>'`','%'=>'%','[br]'=>"rn",'^'=>'^',':'=>':'));
if(!strpos($code,'<?') && substr($code,0,2)!='<?') {$code="<?phprn".trim($code);}
$code = highlight_string($code,true);
$code = strtr($code,array("rn"=>'<br>','<br />'=>'<br>','$'=>'$',"'"=>''','`'=>'\','%'=>'%','^'=>'^',':'=>':'));
$code = '<div class=d>'.$code.'</div>';
return $code;
}
?>