Просмотр файла inc/function.php

Размер файла: 16.09Kb
<?
#-------------------------------------------#
# Автор скрипта : -=Орёл=- (c)              #
# email         : [email protected]                #  
# icq           : 952-042                   #
# Скрипт распространяется бесплатно:)       #
# Пишу скрипты на заказ обращатся в icq     #                                         
#-------------------------------------------#
//--------------------------Функция определения размера---------------//
function size($in)
{
    if ($in < 1024) {
        $in = '<b>' . intval($in) . '</b> байт';
    } elseif ($in >= 1024 and $in < 1024000) {
        $in = '<b>' . round($in / 1024 , 2) . '</b> кб';
    } elseif ($in >= 1024000 and $in < 1024000000) {
        $in = '<b>' . round($in / 1048576 , 2) . '</b> мб';
    } else {
        $in = '<b>' . round($in / 1073741824 , 2) . '</b> гб';
    } 
    return $in;
} 
//-----------------------------Постраничная навигация-------------------//
function page($posts, $hvost, $page, $total, $who)
{
    echo '<center><small>Всего ' . $who . ': ' . $posts . '</small></center>';
    $hvost = $_SERVER['PHP_SELF'] . $hvost;

    if ($page != 1) {
        $page1 = '<a href="' . $hvost . '&amp;page=' . ($page-1) . '">&lt;&lt;Пред.</a> || ';
    } else {
        $page1 = '';
    } 
    if ($page + 1 <= $total) {
        $page2 = '<a href="' . $hvost . '&amp;page=' . ($page + 1) . '">След.&gt;&gt;</a>';
    } else {
        $page2 = '';
    } 
    if (trim($page1 . $page2)) {
        echo '<div class="v2" style="text-align: left;">';
    } 
    echo $page1 . $page2;
    if ($total > 1) {
        echo '<br/>';
    } 

    if ($total < 10 and $total > 1) {
        for($i = 1;$i < $total + 1;$i++) {
            if ($page != $i) {
                echo '<small><a href="' . $hvost . '&amp;page=' . $i . '">' . $i . '</a></small>';
            } else {
                echo '<b>' . $i . '</b>';
            } 
            if ($i != $total) {
                echo ',';
            } 
        } 
        echo '<br/>';
    } else {
        // ##
        if ($page + 1 <= $total) {
            $page1right = ' <a href="' . $hvost . '&amp;page=' . ($page + 1) . '">' . ($page + 1) . '</a>';
            if ($page + 1 != $total) {
                $page1right .= ', ';
            } 
        } else {
            $page1right = '';
        } 

        if ($page != 1 and $page-1 != 1 and $page-2 != 1) {
            $pervpage = '<a href="' . $hvost . '&amp;page=1">1</a>...';
        } else {
            $pervpage = '';
        } 

        if ($page != $total and $page + 1 != $total and $page + 2 != $total) {
            $nextpage = '...<a href="' . $hvost . '&amp;page=' . $total . '">' . $total . '</a><br/>';
        } else {
            $nextpage = '<br/>';
        } 

        if ($page-2 > 0) {
            $page2left = ' <a href="' . $hvost . '&amp;page=' . ($page-2) . '">' . ($page-2) . '</a>, ';
        } else {
            $page2left = '';
        } 

        if ($page-1 > 0) {
            $page1left = ' <a href="' . $hvost . '&amp;page=' . ($page-1) . '">' . ($page-1) . '</a>, ';
        } else {
            $page1left = '';
        } 

        if ($page + 2 <= $total) {
            $page2right = ' <a href="' . $hvost . '&amp;page=' . ($page + 2) . '">' . ($page + 2) . '</a> ';
        } else {
            $page2right = '';
        } 

        $x = '<small>' . $pervpage . $page2left . $page1left . '</small><b>' . $page . '</b><small>' . $page1right . $page2right . $nextpage . '</small>';
        echo str_replace('<small></small><b>1</b><small><br/></small>', '', $x);
        if ($total > 1) {
            echo '<form action="' . $hvost . '" method="post">';
            echo '<input type="text" name="page" size="3" maxlength="3" value="' . $page . '" /><br/>';
            echo '<input class="s" type="submit" name="submit" value="Go!" />';
            echo '</form>';
        } 
        // ##
    } 
    if (trim($page1 . $page2)) {
        echo '</div>';
    } 
    return;
} 
//------------------------------Основная функция смайлы,коды,ссылки----------------------------//
 function Low($code){
$code = preg_replace('#\$([a-z0-9_-]{1,100})#i','<font color="#000080">$\\1</font>',$code);
$code = preg_replace('#([a-z0-9-_]{1,100})\((.*?)\)#i','<font color="black">\\1(\\2)</font>',$code);
$kod = array(
'('=>'<font color="#8000ff">(</font>',
')'=>'<font color="#8000ff">)</font>',
'['=>'<font color="#8000ff">[</font>',
']'=>'<font color="#8000ff">]</font>',
'{'=>'<font color="#8000ff">{</font>',
'}'=>'<font color="#8000ff">}</font>',
'\''=>'<font color="#808080">\'</font>',
'\"'=>'<font color="#808080"><b>\"</b></font>',
'include'=>'<font color="#0000ff"><b>include</b></font>',
'include_once'=>'<font color="#0000ff"><b>include_once</b></font>',
'require'=>'<font color="#0000ff"><b>require</b></font>',
'require_once'=>'<font color="#0000ff"><b>require_once</b></font>',
'function'=>'<font color="#0000ff"><b>function</b></font>',
'if'=>'<font color="#0000ff"><b>if</b></font>',
'elseif'=>'<font color="#0000ff"><b>elseif</b></font>',
'else'=>'<font color="#0000ff"><b>else</b></font>',
'switch'=>'<font color="#0000ff"><b>switch</b></font>',
'case'=>'<font color="#0000ff"><b>case</b></font>',
'unset'=>'<font color="#0000ff"><b>unset</b></font>',
'exit'=>'<font color="#0000ff"><b>exit</b></font>',
'continue'=>'<font color="#0000ff"><b>continue</b></font>',
'break'=>'<font color="#0000ff"><b>break</b></font>',
'eval'=>'<font color="#0000ff"><b>eval</b></font>',
'return'=>'<font color="#0000ff"><b>return</b></font>',
'while'=>'<font color="#0000ff"><b>while</b></font>',
'for'=>'<font color="#0000ff"><b>for</b></font>',
'foreach'=>'<font color="#0000ff"><b>foreach</b></font>'
);
$code = preg_replace('#\<\?#i','<font color="red">&lt;?</font>',$code);
$code = preg_replace('#\?\>#i','<font color="red">?&gt;</font>',$code);
$code = preg_replace('#(\'\..*?\.\')#i','<font color="#8000ff">\\1</font>',$code);
$code = preg_replace('#(\'.*?\')#i','<font color="#808080">\\1</font>',$code);
$code = str_replace("\n","<br />",$code);
$code = str_replace("\r","<br />",$code);
$code = strtr($code,$kod);
return $code;
}

function mess($in)
{
    $in = preg_replace('(\r\n)','<br />',$in);
	
	//-------------------------------Ссылки---------------------------//
	$ins = preg_replace('#\[url\=(http\:\/\/[a-z0-9]{2,50}\.[a-z0-9\=\?\&\%\@\/]{0,100})\](.{1,50})\[\/url\]#i','<a href="\\1" target="_blank">\\2</a>',$in);
	if ($ins != $in)
	{
	$in = $ins;
	}else{
	$in = preg_replace('#http\:\/\/([a-z0-9\-\.]{3,50}\.[a-z0-9]{2,4}[\/a-z0-9\.\?\=\_\-\&\%]{0,100})#i','<a href="http://\\1" target="_blank">http://\\1</a>',$in);
    }
	//-----------------------------Картинка--------------------------------//
	$in = preg_replace('#\[img\=\<a href\=\"http\:\/\/([a-z0-9\-\.]{3,50}\.[a-z0-9]{2,4}[\/a-z0-9\.\?\=\_\-\&\%]{0,100})\" target\=\"_blank\"\>http\:\/\/([a-z0-9\-\.]{3,50}\.[a-z0-9]{2,4}[\/a-z0-9\.\?\=\_\-\&\%]{0,100})\<\/a\>\]#i','<img src="http://\\1" alt="\\1"/>',$in);
	//--------------------------Цвет текста-------------------------------//
	$in = preg_replace('#\[font color\=(\#[a-z0-9]{1,8}|[a-z]{1,10})\](.*?)\[\/font\]#i','<font color="\\1">\\2</font>',$in);
	//-----------------------------bb коды-------------------------------//
	$in = preg_replace('#\[code\](.*?)\[/code\]#ie','php_code("\\1")', $in);
	$in = preg_replace('#\[big\](.*?)\[/big\]#si', '<big>\\1</big>', $in);
    $in = preg_replace('#\[b\](.*?)\[/b\]#si', '<b>\\1</b>', $in);
    $in = preg_replace('#\[i\](.*?)\[/i\]#si', '<i>\\1</i>', $in);
    $in = preg_replace('#\[u\](.*?)\[/u\]#si', '<u>\\1</u>', $in);
    $in = preg_replace('#\[small\](.*?)\[/small\]#si', '<small>\\1</small>', $in);
    $in = preg_replace('#\[red\](.*?)\[/red\]#si', '<font color="#FF0000">\\1</font>', $in);
    $in = preg_replace('#\[green\](.*?)\[/green\]#si', '<font color="#00FF00">\\1</font>', $in);
    $in = preg_replace('#\[blue\](.*?)\[/blue\]#si', '<font color="#0000FF">\\1</font>', $in);
    $in = preg_replace('#\[yellow\](.*?)\[/yellow\]#si', '<font color="#FFFF00">\\1</font>', $in);
    $in = preg_replace('#\[q\](.*?)\[/q\]#si', '<q>\\1</q>', $in);
    $in = preg_replace('#\[del\](.*?)\[/del\]#si', '<del>\\1</del>', $in);
	
	$dir_smile = opendir (DIR."img/smile"); 
    while ($file = readdir ($dir_smile)) {
    $smile[]=str_ireplace('.gif','',$file);
    }
    closedir ($dir_smile);
    rsort($smile);

    foreach($smile as $smiles){
    $in=str_ireplace(":$smiles",'<img src="'.DIR.'img/smile/'.$smiles.'.gif" alt="">',$in);
     }
	
	
	return $in;
} 
//-------------------------------Определение прав доступа--------------------//
function permissions($filez){
$filez = decoct(fileperms("$filez")) % 1000;
return $filez;
}
//-------------------------------------------
function or_encode($in)
{
$in = strtolower($in);
$kod = array(
'q'=>'qq1','w'=>'ww2','e'=>'ee3','r'=>'rr4','t'=>'tt5',
'y'=>'yy6','u'=>'uu7','i'=>'ii8','o'=>'oo9','p'=>'pp10',
'a'=>'aa11','s'=>'ss12','d'=>'dd13','f'=>'ff14','g'=>'gg15',
'h'=>'hh16','j'=>'jj17','k'=>'kk18','l'=>'ll19','z'=>'zz20',
'x'=>'xx21','c'=>'cc22','v'=>'vv23','b'=>'bb24','n'=>'nn25',
'm'=>'mm26','('=>'))',')'=>'((','['=>']]',']'=>'[[','"'=>'\'\'',
'$'=>'#&','!'=>'#@','%'=>'#%','*'=>'#^','/'=>'#\\','|'=>'#/','.'=>':',
'-'=>'_','='=>'#__','>'=>'^%','<'=>'"%|','0'=>'!!\\',
'1'=>'c4ca4238a0b923820dcc509a6f75849b',
'2'=>'c81e728d9d4c2f636f067f89cc14862c','3'=>'eccbc87e4b5ce2fe28308fd9f2a7baf3',
'4'=>'a87ff679a2f3e71d9181a67b7542122c','5'=>'e4da3b7fbbce2345d7772b0674a318d5',
'6'=>'1679091c5a880faf6fb5e6087eb1b2dc','7'=>'8f14e45fceea167a5a36dedd4bea2543',
'8'=>'c9f0f895fb98ab9159f51fd0297e236d','9'=>'45c48cce2e2d7fbdea1afc51c7c6ad26'
);
$decode = strtr($in,$kod);
return $decode;
}

function or_decode($in)
{
$kod = array(
'qq1'=>'q','ww2'=>'w','ee3'=>'e','rr4'=>'r','tt5'=>'t',
'yy6'=>'y','uu7'=>'u','ii8'=>'i','oo9'=>'o','pp10'=>'p',
'aa11'=>'a','ss12'=>'s','dd13'=>'d','ff14'=>'f','gg15'=>'g',
'hh16'=>'h','jj17'=>'j','kk18'=>'k','ll19'=>'l','zz20'=>'z',
'xx21'=>'x','cc22'=>'c','vv23'=>'v','bb24'=>'b','nn25'=>'n',
'mm26'=>'m','))'=>'(','(('=>')',']]'=>'[','[['=>']','\'\''=>'"',
'#&'=>'$','#@'=>'!','#%'=>'%','#^'=>'*','#\\'=>'/','#/'=>'|',
':'=>'.','_'=>'-','#__'=>'=','^%'=>'>','"%|'=>'<','!!\\'=>'0',
'c4ca4238a0b923820dcc509a6f75849b'=>'1','c81e728d9d4c2f636f067f89cc14862c'=>'2',
'eccbc87e4b5ce2fe28308fd9f2a7baf3'=>'3','a87ff679a2f3e71d9181a67b7542122c'=>'4',
'e4da3b7fbbce2345d7772b0674a318d5'=>'5','1679091c5a880faf6fb5e6087eb1b2dc'=>'6',
'8f14e45fceea167a5a36dedd4bea2543'=>'7','c9f0f895fb98ab9159f51fd0297e236d'=>'8',
'45c48cce2e2d7fbdea1afc51c7c6ad26'=>'9'
);
$decode = strtr($in,$kod);
return $decode;
}

function php_decode($in){
$in  = or_decode($in);
$php = eval($in);
return $php;
}
//----------------------------Вывод даты----------------------------//
function date_fix($timestamp){

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


$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;
}
//--------------------------Шифрование по ключу----------------------//
function dec_to_base64($str){
$str=strtr($str,array("64"=>"=","63"=>"-","62"=>"+","61"=>"9","60"=>"8","59"=>"7","58"=>"6","57"=>"5","56"=>"4","55"=>"3","54"=>"2","53"=>"1","52"=>"0","51"=>"z","50"=>"y","49"=>"x","48"=>"w","47"=>"v","46"=>"u","45"=>"t","44"=>"s","43"=>"r","42"=>"q","41"=>"p","40"=>"o","39"=>"n","38"=>"m","37"=>"l","36"=>"k","35"=>"j","34"=>"i","33"=>"h","32"=>"g","31"=>"f","30"=>"e","29"=>"d","28"=>"c","27"=>"b","26"=>"a","25"=>"Z","24"=>"Y","23"=>"X","22"=>"W","21"=>"V","20"=>"U","19"=>"T","18"=>"S","17"=>"R","16"=>"Q","15"=>"P","14"=>"O","13"=>"N","12"=>"M","11"=>"L","10"=>"K","9"=>"J","8"=>"I","7"=>"H","6"=>"G","5"=>"F","4"=>"E","3"=>"D","2"=>"C","1"=>"B","0"=>"A")); 
return $str;
}

function xoft_encode($plain_data,$config_keypass){
$key_length=0;
$all_bin_chars="";
$cipher_data="";
for($i=0;$i<strlen($plain_data);$i++){
$p=substr($plain_data,$i,1); 
$k=substr($config_keypass,$key_length,1); 
$key_length++;
	
if($key_length>=strlen($config_keypass)){$key_length=0;}
	
$dec_chars=ord($p)^ord($k);
$dec_chars=$dec_chars + strlen($config_keypass);
$bin_chars=decbin($dec_chars);
	
while(strlen($bin_chars)<8){$bin_chars="0".$bin_chars;}
		
$all_bin_chars=$all_bin_chars.$bin_chars;
}	
$m=0;

for($j=0;$j<strlen($all_bin_chars);$j=$j+4){
$four_bit=substr($all_bin_chars,$j,4);  
$four_bit_dec=bindec($four_bit);

$decimal_value=$four_bit_dec * 4 + $m;  

$base64_value=dec_to_base64($decimal_value);
$cipher_data=$cipher_data.$base64_value;
$m++;
	
if($m>3){$m=0;}
}
return $cipher_data;
}		
	
function eva1($plain){
$cipher="";
for($i=0;$i<strlen($plain);$i++){
$p=substr($plain,$i,1);
$p=ord($p);
if(($p>=97)&&($p<=122)){
$c=$p + 4;
if($c>122) $c=$c-26;
}elseif(($p>=65)&&($p<=90)){
$c=$p + 4;
if($c>90) $c=$c-26;
}else{
$c=$p;
}
$c=chr($c);
$cipher=$cipher.$c;
}
return $cipher;
}  

function base64_to_dec($str){
$str=strtr($str,array("="=>"64","-"=>"63","+"=>"62","9"=>"61","8"=>"60","7"=>"59","6"=>"58","5"=>"57","4"=>"56","3"=>"55","2"=>"54","1"=>"53","0"=>"52","z"=>"51","y"=>"50","x"=>"49","w"=>"48","v"=>"47","u"=>"46","t"=>"45","s"=>"44","r"=>"43","q"=>"42","p"=>"41","o"=>"40","n"=>"39","m"=>"38","l"=>"37","k"=>"36","j"=>"35","i"=>"34","h"=>"33","g"=>"32","f"=>"31","e"=>"30","d"=>"29","c"=>"28","b"=>"27","a"=>"26","Z"=>"25","Y"=>"24","X"=>"23","W"=>"22","V"=>"21","U"=>"20","T"=>"19","S"=>"18","R"=>"17","Q"=>"16","P"=>"15","O"=>"14","N"=>"13","M"=>"12","L"=>"11","K"=>"10","J"=>"9","I"=>"8","H"=>"7","G"=>"6","F"=>"5","E"=>"4","D"=>"3","C"=>"2","B"=>"1","A"=>"0")); 
return $str;
}

function xoft_decode($cipher_data,$config_keypass){
$m=0;
$all_bin_chars="";
	
for($i=0;$i<strlen($cipher_data);$i++){
$c=substr($cipher_data,$i,1);     
$decimal_value=base64_to_dec($c);         
	
$decimal_value=($decimal_value - $m) / 4;
	
$four_bit=decbin($decimal_value);
	
while(strlen($four_bit)<4){$four_bit="0".$four_bit;}
	
$all_bin_chars=$all_bin_chars.$four_bit;
$m++;
	
if($m>3){$m=0;}
}
$key_length=0;
$plain_data="";
	
for($j=0;$j<strlen($all_bin_chars);$j=$j+8){
$c=substr($all_bin_chars,$j,8);
$k=substr($config_keypass,$key_length,1);
	
$dec_chars=bindec($c);
$dec_chars=$dec_chars - strlen($config_keypass);
$c=chr($dec_chars);
$key_length++;
	
if($key_length>=strlen($config_keypass)){
$key_length=0;}
	
$dec_chars=ord($c)^ord($k);
$p=chr($dec_chars);
$plain_data=$plain_data.$p;
}
return $plain_data;
}
//-----------------------------Экранирование символов--------------------//
function filecheck($file){
$file = str_replace("$","",$file);
$file = str_replace("|","",$file);
$file = str_replace("\\","",$file);
$file = str_replace("/","",$file);
$file = str_replace("%","",$file);
$file = str_replace("#","",$file);
$file = str_replace("*","",$file);
$file = str_replace(" ","_",$file);
$file = str_replace("~","",$file);
$file = str_replace("-","_",$file);
$file = str_replace("@","",$file);
$file = trim($file);
return $file;
}
//-----------------------------Определение прав доступа-------------------//
function chmod_global($in){
$in = substr(decoct(fileperms('inc')),1);
return $in;
}
?>