Файл: moduls/functions.php
Строк: 615
<?php
// mod Gemorroj
require_once DIR . '/language.php';
function nam($name){
$ex=explode('|',$name);
$cou=count($ex);
$ok=$ex[$cou-2];
return preg_replace('/<a(.*?)">(.*?)</a> /si','$2',$ok);
}
function int($var){
$var=abs((int)$var);
return $var;
}
function trans($t)
{
$a = array('_', 'YA', 'Ya', 'ya', 'yee', 'YO', 'yo', 'Yo', 'ZH', 'zh', 'Zh', 'Z',
'z', 'CH', 'ch', 'Ch', 'SH', 'sh', 'Sh', 'YE', 'ye', 'Ye', 'YU', 'yu', 'Yu',
'JA', 'ja', 'Ja', 'A', 'a', 'B', 'b', 'V', 'v', 'G', 'g', 'D', 'd', 'E', 'e',
'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p',
'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'F', 'f', 'H', 'h', 'W', 'w', 'x', 'q',
'Y', 'y', 'C', 'c');
$b = array(' ', 'Я', 'Я', 'я', 'ые', 'Ё', 'ё', 'Ё', 'Ж', 'ж', 'Ж', 'З', 'з', 'Ч',
'ч', 'Ch', 'Ш', 'ш', 'Ш', 'Э', 'э', 'Э', 'Ю', 'ю', 'Ю', 'Я', 'я', 'Я', 'А', 'а',
'Б', 'б', 'В', 'в', 'Г', 'г', 'Д', 'д', 'Е', 'е', 'И', 'и', 'Й', 'й', 'К', 'к',
'Л', 'л', 'М', 'м', 'Н', 'н', 'О', 'о', 'П', 'п', 'Р', 'р', 'С', 'с', 'Т', 'т',
'У', 'у', 'Ф', 'ф', 'Х', 'х', 'Щ', 'щ', 'ъ', 'ь', 'Ы', 'ы', 'Ц', 'ц', '');
return str_replace($a, $b, $t);
}
function retrans($t)
{
$a = array('_', 'YA', 'Ya', 'ya', 'yee', 'YO', 'yo', 'Yo', 'ZH', 'zh', 'Zh', 'Z',
'z', 'CH', 'ch', 'Ch', 'SH', 'sh', 'Sh', 'YE', 'ye', 'Ye', 'YU', 'yu', 'Yu',
'JA', 'ja', 'Ja', 'A', 'a', 'B', 'b', 'V', 'v', 'G', 'g', 'D', 'd', 'E', 'e',
'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p',
'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'F', 'f', 'H', 'h', 'W', 'w', 'x', 'q',
'Y', 'y', 'C', 'c');
$b = array(' ', 'Я', 'Я', 'я', 'ые', 'Ё', 'ё', 'Ё', 'Ж', 'ж', 'Ж', 'З', 'з', 'Ч',
'ч', 'Ch', 'Ш', 'ш', 'Ш', 'Э', 'э', 'Э', 'Ю', 'ю', 'Ю', 'Я', 'я', 'Я', 'А', 'а',
'Б', 'б', 'В', 'в', 'Г', 'г', 'Д', 'д', 'Е', 'е', 'И', 'и', 'Й', 'й', 'К', 'к',
'Л', 'л', 'М', 'м', 'Н', 'н', 'О', 'о', 'П', 'п', 'Р', 'р', 'С', 'с', 'Т', 'т',
'У', 'у', 'Ф', 'ф', 'Х', 'х', 'Щ', 'щ', 'ъ', 'ь', 'Ы', 'ы', 'Ц', 'ц');
return str_replace($b, $a, $t);
}
function alfavit($lang,$type){
if($lang == 'rus'){
if($type == 'small'){
$arr=array('а','б','в','г','д','е','ё','ж','з','и',
'й','к','л','м','н','о','п','р','с','т',
'у','ф','х','ц','ч','ш','щ',
'э','ю','я');
}elseif($type == 'big'){
$arr=array('А','Б','В','Г','Д','Е','Ё','Ж','З','И',
'Й','К','Л','М','Н','О','П','Р','С','Т',
'У','Ф','Х','Ц','Ч','Ш','Щ',
'Э','Ю','Я');
}
}elseif($lang == 'eng'){
if($type == 'big'){
$arr=array('A','B','C','D','E','F','G','H','I',
'K','L','M','N','O','P','Q','R','S',
'T','V','W','X','Y','Z');
}elseif($type == 'small'){
$arr=array('a','b','c','d','e','f','g','h','i',
'k','l','m','n','o','p','q','r','s',
't','v','w','x','y','z');
}
}
return $arr;
}
function bbcode($text = '')
{
//конвертация кодов в теги регулярными выражениями
// ББ коды
$bbcode = array(
'/[url](.+)[/url]/isU' => '<a href="$1">$1</a>',
'/[url=(.+)](.+)[/url]/isU' => '<a href="$1">$2</a>',
'/[i](.+)[/i]/isU' => '<em>$1</em>',
'/[b](.+)[/b]/isU' => '<strong>$1</strong>',
'/[u](.+)[/u]/isU' => '<span style="text-decoration:underline;">$1</span>',
'/[big](.+)[/big]/isU' => '<span style="font-size:large;">$1</span>',
'/[small](.+)[/small]/isU' => '<span style="font-size:small;">$1</span>',
'/[code](.+)[/code]/isU' => '<code>$1</code>',
'/[red](.+)[/red]/isU' => '<span style="color:#ff0000;">$1</span>',
'/[yellow](.+)[/yellow]/isU' => '<span style="color:#ffff22;">$1</span>',
'/[green](.+)[/green]/isU' => '<span style="color:#00bb00;">$1</span>',
'/[blue](.+)[/blue]/isU' => '<span style="color:#0000bb;">$1</span>',
'/[white](.+)[/white]/isU' => '<span style="color:#ffffff;">$1</span>',
'/[color=(.+)](.+)[/color]/isU' => '<span style="color:$1;">$2</span>',
'/[size=([0-9]+)](.+)[/size]/isU' => '<span style="font-size:$1px;">$2</span>',
'/[img](.+)[/img]/isU' => '<img src="$1" alt=""/>'
);
return preg_replace(array_keys($bbcode), array_values($bbcode), $text);
}
function antibb($text = ''){
// обратное преобразование ббкодов
$bbcode = array(
'/<a href="(.+)">(.+)</a>/isU' => '[url=$1]$2[/url]',
'/<em>(.+)</em>/isU' => '[i]$1[/i]',
'/<strong>(.+)</strong>/isU' => '[b]$1[/b]',
'/<span style="text-decoration:underline;">(.+)</span>/isU' => '[u]$1[/u]',
'/<span style="font-size:large;">(.+)</span>/isU' => '[big]$1[/big]',
'/<span style="font-size:small;">(.+)</span>/isU' => '[small]$1[/small]',
'/<code>(.+)</code>/isU' => '[code]$1[/code]',
'/<span style="color:#ff0000;">(.+)</span>/isU' => '[red]$1[/red]',
'/<span style="color:#ffff22;">(.+)</span>/isU' => '[yellow]$1[/yellow]',
'/<span style="color:#00bb00;">(.+)</span>/isU' => '[green]$1[/green]',
'/<span style="color:#0000bb;">(.+)</span>/isU' => '[blue]$1[/blue]',
'/<span style="color:#ffffff;">(.+)</span>/isU' => '[white]$1[/white]',
'/<span style="color:(.+);">(.+)</span>/isU' => '[color=$1]$2[/color]',
'/<span style="font-size:([0-9]+)px;">(.+)</span>/isU' => '[size=$1]$2[/size]',
'/<img src="(.+)" alt=""/>/isU' => '[img]$1[/img]',
'/<br />/isU' => ''
);
return preg_replace(array_keys($bbcode), array_values($bbcode), $text);
}
function is_num($txt, $name)
{
if (isset($_POST[$name])) {
$txt = $_POST[$name];
} else if (isset($_GET[$name])) {
$txt = $_GET[$name];
} else if (isset($_SESSION[$name])) {
$txt = $_SESSION[$name];
}
$txt = intval($txt);
if ($txt < 0) {
error($GLOBALS['setup']['hackmess']);
}
return;
}
function check($value)
{
if (!$value) {
return;
} else {
return 'checked="checked"';
}
}
function sel($value, $real)
{
if ($value != $real) {
return;
} else {
return 'selected="selected"';
}
}
function get2ses($name)
{
if (!isset($_SESSION[$name])) {
$_SESSION[$name] = $GLOBALS['setup'][$name];
}
if (isset($_GET[$name])) {
$_SESSION[$name] = $_GET[$name];
}
return $name = $_SESSION[$name];
}
class Reklames{
function Top(){
global $mysql;
$out='';
$ree=mysql_query("SELECT DISTINCT `mesto` FROM `reklames` WHERE `timeoff`>'".$_SERVER['REQUEST_TIME']."' AND `pozition`=0 AND `stat`='0' ORDER BY `mesto`",$mysql);
if(mysql_num_rows($ree) > 0){
$out.='<div class="rek2">';
while($wx=mysql_fetch_row($ree)){
if(mysql_result(mysql_query("SELECT COUNT(`id`) FROM `reklames` WHERE `timeoff`>'".$_SERVER['REQUEST_TIME']."' AND `mesto`='".$wx[0]."' AND `pozition`=0 AND `stat`='0'",$mysql),0) > 1){
$reek=mysql_query("SELECT `id`,`name` FROM `reklames` WHERE `timeoff`>'".$_SERVER['REQUEST_TIME']."' AND `mesto`='".$wx[0]."' AND `pozition`=0 AND `stat`='0' ORDER BY RAND() LIMIT 1",$mysql);
while($wxr=mysql_fetch_row($reek)){
$out.='<a href="'.DIRECTORY.'go.php?id='.$wxr[0].'">'.bbcode($wxr[1]).'</a><br>';
}
}else{
$wxr=mysql_fetch_row(mysql_query("SELECT `id`,`name` FROM `reklames` WHERE `timeoff`>'".$_SERVER['REQUEST_TIME']."' AND `mesto`='".$wx[0]."' AND `pozition`=0 AND `stat`='0'",$mysql));
$out.='<a href="'.DIRECTORY.'go.php?id='.$wxr[0].'">'.bbcode($wxr[1]).'</a><br>';
}
}
$out.='</div>';
}
return $out;
}
function Bottom(){
global $mysql;
$banner='';
$ree=mysql_query("SELECT DISTINCT `mesto` FROM `reklames` WHERE `timeoff`>'".$_SERVER['REQUEST_TIME']."' AND `pozition`=1 AND `stat`='0' ORDER BY `mesto`",$mysql);
if(mysql_num_rows($ree) > 0){
$banner.='<div class="rek2">';
while($wx=mysql_fetch_row($ree)){
if(mysql_result(mysql_query("SELECT COUNT(`id`) FROM `reklames` WHERE `timeoff`>'".$_SERVER['REQUEST_TIME']."' AND `mesto`='".$wx[0]."' AND `pozition`=1 AND `stat`='0'",$mysql),0) > 1){
$reek=mysql_query("SELECT `id`,`name` FROM `reklames` WHERE `timeoff`>'".$_SERVER['REQUEST_TIME']."' AND `mesto`='".$wx[0]."' AND `pozition`=1 AND `stat`='0' ORDER BY RAND() LIMIT 1",$mysql);
while($wxr=mysql_fetch_row($reek)){
$banner.='<a href="'.DIRECTORY.'go.php?id='.$wxr[0].'">'.bbcode($wxr[1]).'</a><br>';
}
}else{
$wxr=mysql_fetch_row(mysql_query("SELECT `id`,`name` FROM `reklames` WHERE `timeoff`>'".$_SERVER['REQUEST_TIME']."' AND `mesto`='".$wx[0]."' AND `pozition`=1 AND `stat`='0'",$mysql));
$banner.='<a href="'.DIRECTORY.'go.php?id='.$wxr[0].'">'.bbcode($wxr[1]).'</a><br>';
}
}
$banner.='</div>';
}
return $banner;
}
function Banner($var = ''){
global $mysql;
global $setup;
$baner='';
$baner = '<div class="foots" align="center">';
if($var == '') $baner.= '<a href="' . $setup['site_url'] . '">' . $_SESSION['language']['home'] . '</a><br/>';
$ree=mysql_query("SELECT `name`,`img`,`http`,`br` FROM `reklames` WHERE `stat`='1' ORDER BY `id`",$mysql);
if(mysql_num_rows($ree) > 0){
while($wxr=mysql_fetch_row($ree)){
$baner.= $wxr[3] == '1' ? '<a href="'.$wxr[2].'"><img src="'.$wxr[1].'" alt="'.$wxr[0].'"/></a><br/>' : '<a href="'.$wxr[2].'"><img src="'.$wxr[1].'" alt="'.$wxr[0].'"/></a> ';
}
}
return $baner.'</div>';
}
}
//
function marker($image = '', $watermark = '')
{
if (!is_resource($image) || !is_resource($watermark)) {
return;
}
$imageWidth = imagesx($image);
$imageHeight = imagesy($image);
$tmpW = $watermarkWidth = imagesx($watermark);
$tmpH = $watermarkHeight = imagesy($watermark);
if ($imageWidth < $watermarkWidth || $imageHeight < $watermarkHeight) {
if ($imageWidth < $watermarkWidth) {
$watermarkWidth = $imageWidth;
$watermarkHeight *= $watermarkWidth / $tmpW;
} else {
$watermarkHeight = $imageHeight / 2;
$watermarkWidth *= $watermarkHeight / $tmpH;
}
$f = imagecreatetruecolor($watermarkWidth, $watermarkHeight);
$transparencyIndex = imagecolortransparent($watermark);
$transparencyColor = array('red' => 255, 'green' => 255, 'blue' => 255);
if ($transparencyIndex >= 0) {
$transparencyColor = imagecolorsforindex($watermark, $transparencyIndex);
}
$transparencyIndex = imagecolorallocate($f, $transparencyColor['red'], $transparencyColor['green'], $transparencyColor['blue']);
imagefill($f, 0, 0, $transparencyIndex);
imagecolortransparent($f, $transparencyIndex);
imagecopyresampled($f, $watermark, 0, 0, 0, 0, $watermarkWidth, $watermarkHeight, $tmpW, $tmpH);
$watermark = & $f;
}
$new = imagecreatetruecolor($imageWidth, $imageHeight);
$footH = $imageHeight - $watermarkHeight;
for ($j = 0; $j < $imageHeight; ++$j) {
for ($i = 0; $i < $imageWidth; ++$i) {
$rgb = imagecolorsforindex($image, imagecolorat($image, $i, $j));
if ($GLOBALS['setup']['marker_where'] == 'top' && $j < $watermarkHeight && $i < $watermarkWidth) {
$rgb2 = imagecolorsforindex($watermark, @imagecolorat($watermark, $i, $j));
if ($rgb2['alpha'] != 127) {
$rgb['red'] = intval(($rgb['red'] + $rgb2['red']) / 2);
$rgb['green'] = intval(($rgb['green'] + $rgb2['green']) / 2);
$rgb['blue'] = intval(($rgb['blue'] + $rgb2['blue']) / 2);
}
} else if ($GLOBALS['setup']['marker_where'] == 'foot' && $j >= $footH && $i < $watermarkWidth) {
$rgb2 = imagecolorsforindex($watermark, @imagecolorat($watermark, $i, $j - $footH));
if ($rgb2['alpha'] != 127) {
$rgb['red'] = intval(($rgb['red'] + $rgb2['red']) / 2);
$rgb['green'] = intval(($rgb['green'] + $rgb2['green']) / 2);
$rgb['blue'] = intval(($rgb['blue'] + $rgb2['blue']) / 2);
}
}
$ind = imagecolorexact($new, $rgb['red'], $rgb['green'], $rgb['blue']);
if ($ind < 1) {
$ind = imagecolorallocate($new, $rgb['red'], $rgb['green'], $rgb['blue']);
if ($ind < 1) {
$ind = imagecolorclosest($new, $rgb['red'], $rgb['green'], $rgb['blue']);
}
}
imagesetpixel($new, $i, $j, $ind);
}
}
return $new;
}
function scaner($path = '', $cont = 'folder.png')
{
static $folders = 0;
static $files = 0;
static $errors = array();
// заглушка
echo 'scan ' . htmlspecialchars($path, ENT_NOQUOTES) . '...' . str_repeat(' ', 56) . '<br/>';
ob_flush();
if (!is_readable($path)) {
echo 'Error<br/>';
return array();
}
chmod($path, 0777);
$tmp = 0;
foreach (array_diff(scandir($path, 0), array('.', '..')) as $file) {
$f = str_replace('//', '/', $path . '/' . $file);
$tmp++;
if ($tmp > 500) {
$tmp = 0;
// такая вот хуита... =( забиваем буфер
echo 'scan ' . htmlspecialchars($f, ENT_NOQUOTES) . '...' . str_repeat(' ', 512/*4096*/) . '<br/>';
ob_flush();
}
$pathinfo = pathinfo($f);
$rus_name = $name = $pathinfo['filename'];
// транслит
if ($name[0] == '!') {
$name = $rus_name = substr($name, 1);
$rus_name = trans($rus_name);
}
if (is_dir($f)) {
// скриншоты
$screen = $GLOBALS['setup']['spath'] . iconv_substr($f . '/', iconv_strlen($GLOBALS['setup']['path']));
if (!file_exists($screen)) {
mkdir($screen, 0777);
}
chmod($screen, 0777);
// описания
$desc = $GLOBALS['setup']['opath'] . iconv_substr($f . '/', iconv_strlen($GLOBALS['setup']['path']));
if (!file_exists($desc)) {
mkdir($desc, 0777);
}
chmod($desc, 0777);
sleep(0.01); // =///
if (!mysql_query('
INSERT IGNORE INTO `files`
(`dir`, `path`, `name`, `rus_name`, `infolder`, `size` ,`timeupload`)
VALUES(
"1",
"' . mysql_real_escape_string($f . '/', $GLOBALS['mysql']) . '",
"' . mysql_real_escape_string($name, $GLOBALS['mysql']) . '",
"' . mysql_real_escape_string($rus_name, $GLOBALS['mysql']) . '",
"' . mysql_real_escape_string($pathinfo['dirname'] . '/', $GLOBALS['mysql']) . '",
0,
"' . filectime($f) . '"
)
', $GLOBALS['mysql'])) {
$errors[] = mysql_error($GLOBALS['mysql']);
}
$folders++;
scaner($f);
} else if (is_file($f)) {
$files++;
if ($pathinfo['basename'] == $cont) {
continue;
} else {
sleep(0.01); // =///
if (!mysql_query('
INSERT IGNORE INTO `files`
(`dir`, `path`, `name`, `rus_name`, `infolder`, `size` ,`timeupload`)
VALUES(
"0",
"' . mysql_real_escape_string($f, $GLOBALS['mysql']) . '",
"' . mysql_real_escape_string($name, $GLOBALS['mysql']) . '",
"' . mysql_real_escape_string($rus_name, $GLOBALS['mysql']) . '",
"' . mysql_real_escape_string($pathinfo['dirname'] . '/', $GLOBALS['mysql']) . '",
"' . filesize($f) . '",
"' . filectime($f) . '"
)
', $GLOBALS['mysql'])) {
$errors[] = mysql_error($GLOBALS['mysql']);
}
}
}
}
return array('folders' => $folders, 'files' => $files, 'errors' => $errors);
}
/**
* изменение количества файлов в директориях
*
* @param string директория
* @param bool инкремент или декремент
*/
function dir_count($path = '', $increment = true)
{
$in = array();
$arr = explode('/', $path);
for ($i = 0, $all = sizeof($arr); $i < $all; ++$i) {
if ($i > 0) {
$in[$i] = $in[$i-1] . mysql_real_escape_string($arr[$i], $GLOBALS['mysql']) . '/';
} else {
$in[$i] = mysql_real_escape_string($arr[$i], $GLOBALS['mysql']) . '/';
}
}
return mysql_query('UPDATE `files` SET `dir_count` = `dir_count` ' . ($increment ? '+' : '-') . ' 1 WHERE `path` IN ("' . implode('","', $in) . '")', $GLOBALS['mysql']);
}
function size($int = 0)
{
if ($int < 1024) {
return $int . ' b';
} else if ($int < 1048576) {
return round($int/1024, 2) . ' Kb';
} else if ($int < 1073741824) {
return round($int/1048576, 2) . ' Mb';
} else {
return round($int/1073741824, 2) . ' Gb';
}
}
/**
* Создает файл
* Последний элемент в path считается файлом. Директория согласно функции pathinfo
*
* @path string
* @return bool
*/
function chmods($path = '', $chmod_dir = 0777, $chmod_file = 0666)
{
@mkdir(pathinfo($path, PATHINFO_DIRNAME), $chmod_dir, true);
return touch($path);
}
function tm($t)
{
if (date('Y.m.d', $t) == date('Y.m.d', @$GLOBALS['time'])) {
return $_SESSION['language']['today'] . ' ' . date('H:i', $t);
} else if (date('Y.m.d', $t) == date('Y.m.d', @$GLOBALS['time'] - 86400)) {
return $_SESSION['language']['yesterday'] . ' ' . date('H:i', $t);
} else {
return date('Y.m.d H:i', $t);
}
}
function thm($path = '')
{
$ver_thm = array(
1 => 'T68, T230, T290, T300, T310',
'1.0' => 'T68, T230, T290, T300, T310',
'1.1' => 'T68, T230, T290, T300, T310',
'1.2' => 'T68, T230, T290, T300, T310',
'1.3' => 'T68, T230, T290, T300, T310',
'1.4' => 'T68, T230, T290, T300, T310',
'1.5' => 'T68, T230, T290, T300, T310',
'1.6' => 'T68, T230, T290, T300, T310',
'1.7' => 'T68, T230, T290, T300, T310',
'1.8' => 'T68, T230, T290, T300, T310',
'1.9' => 'T68, T230, T290, T300, T310',
2 => 'J210, J220, J230, T610, T630, Z600, Z300',
'2.0' => 'J210, J220, J230, T610, T630, Z600, Z300',
'2.1' => 'J210, J220, J230, T610, T630, Z600, Z300',
'2.2' => 'J210, J220, J230, T610, T630, Z600, Z300',
'2.3' => 'J210, J220, J230, T610, T630, Z600, Z300',
'2.4' => 'J210, J220, J230, T610, T630, Z600, Z300',
'2.5' => 'J210, J220, J230, T610, T630, Z600, Z300',
'2.6' => 'J210, J220, J230, T610, T630, Z600, Z300',
'2.7' => 'J210, J220, J230, T610, T630, Z600, Z300',
'2.8' => 'J210, J220, J230, T610, T630, Z600, Z300',
'2.9' => 'J210, J220, J230, T610, T630, Z600, Z300',
3 => 'J300, K300, K500, K700, S700, Z1010',
'3.0' => 'J300, K300, K500, K700, S700, Z1010',
'3.1' => 'V800, Z800',
'3.2' => 'V800, Z800',
4 => 'K600, K750, W700, W800, Z520, Z525',
'4.0' => 'K600, K750, W700, W800, Z520, Z525',
'4.1' => 'K310, K320, K510,W200, W300, Z530, W550, W600, W810, Z550, Z558, W900',
'4.5' => 'Z250, Z310, Z320, K550, K610, Z610, Z710, W610, W660, W710, K790, K800, K810, S500, W580, W830, W850, T650, K770, W880',
'4.6' => 'K630, K660, K850, R300, R306, V640, W760, W890, W910, Z750',
'4.7' => 'C702, C902, W760, W980, Z780',
'UIQ3' => 'M600, P1, W950, W960, P990',
);
require_once DIR . '/PEAR/Tar.php';
$thm = new Archive_Tar($path);
if(!$file = $thm->extractInString(pathinfo($path, PATHINFO_FILENAME).'.xml')){
$file = $thm->extractInString('Theme.xml');
}
if (!$file) {
$list = $thm->listContent();
$all = sizeof($list);
for ($i = 0; $i < $all; ++$i) {
if (pathinfo($list[$i]['filename'], PATHINFO_EXTENSION) == 'xml') {
$file = $thm->extractInString($list[$i]['filename']);
break;
}
}
}
// fix bug in tar.php
if (!$file) {
preg_match('/<?s*xmls*versions*=s*"1.0"s*?>(.*)</.+>/isU', file_get_contents($theme), $arr);
$file = trim($arr[0]);
}
$load = simplexml_load_string($file);
if ($load->Author_organization['Value']) {
$str .= $_SESSION['language']['author'] . ': ' . htmlspecialchars($load->Author_organization['Value'], ENT_NOQUOTES) . '<br/>';
}
if ($load['version']) {
$str .= $_SESSION['language']['version'] . ': ' . htmlspecialchars($load['version'], ENT_NOQUOTES) . '<br/>';
if (in_array($load['version'], array_keys($ver_thm))) {
$str .= $_SESSION['language']['models'] . ': ' . $ver_thm[(string)$load['version']] . '<br/>';
}
}
return $str;
}
function img_resize($in = '', $out = '', $w = '', $h = '', $marker = false)
{
if (!is_writable(dirname($out))) {
return false;
}
//$out = pathinfo($out);
//$out = realpath($out['dirname']) . '/' . $out['basename'];
if (!$w || !$h) {
list($w, $h) = explode('*', $GLOBALS['setup']['prev_size']);
}
list($wn, $hn, $type) = getimagesize($in);
$sxy = round($wn / $hn, 3);
if ($sxy < 1) {
$w = intval($h * $sxy);
} else {
$h = intval($w / $sxy);
}
switch ($type) {
case 1:
if ($GLOBALS['setup']['anim_change']) {
ini_set('memory_limit', '256M');
// GIF Поддержка анимации
require_once DIR . '/class/GIFDecoder.class.php';
require_once DIR . '/class/GIFEncoder.class.php';
$gif = new GIFDecoder(file_get_contents($in));
$arr = $gif->GIFGetFrames();
$dly = $gif->GIFGetDelays();
$frames = $framed = array();
$a = sizeof($arr);
for ($i=0; $i<$a; ++$i) {
$tmp1 = DIR . '/cache/' . mt_rand() . '.gif';
$tmp2 = DIR . '/cache/' . mt_rand() . '.gif';
file_put_contents($tmp1, $arr[$i]);
$resize = imagecreatefromgif($tmp1);
$image_p = imagecreatetruecolor($w, $h);
imagecopyresampled($image_p, $resize, 0, 0, 0, 0, $w, $h, $wn, $hn);
if ($marker) {
$image_p = marker($image_p, imagecreatefrompng(DIR . '/class/marker.png'));
}
imagegif($image_p, $tmp2);
imagedestroy($image_p);
imagedestroy($resize);
$frames[] = file_get_contents($tmp2);
$framed[] = $dly[$i];
unlink($tmp1);
unlink($tmp2);
}
unset($gif, $arr, $dly);
$gif = new GIFEncoder(
$frames,
$framed,
0,
2,
0, 0, 0,
0,
'bin'
);
unset($frames, $framed);
return file_put_contents($out, $gif->GetAnimation());
break;
} else {
// GIF
$old = imagecreatefromgif($in);
}
break;
case 2:
// JPEG
$old = imagecreatefromjpeg($in);
break;
case 3:
// PNG
$old = imagecreatefrompng($in);
break;
case 4:
case 13:
// SWF
rename($in, $out);
return;
break;
case 6:
// BMP
require_once DIR . '/class/bmp.php';
$old = imagecreatefrombmp($in, DIR . '/cache/');
break;
default:
return;
break;
}
$new = imagecreatetruecolor($w, $h);
imagecopyresampled($new, $old, 0, 0, 0, 0, $w, $h, $wn, $hn);
if ($marker) {
$new = marker($new, imagecreatefrompng(DIR . '/class/marker.png'));
}
$f = imagegif($new, $out);
imagedestroy($old);
imagedestroy($new);
return $f;
}
function jar_ico($jar, $f)
{
require_once DIR . '/PEAR/pclzip.lib.php';
$archive = new PclZip($jar);
$list = $archive->extract(PCLZIP_OPT_BY_NAME, 'META-INF/MANIFEST.MF', PCLZIP_OPT_EXTRACT_AS_STRING);
preg_match('/MIDlet-Icon:[s*](.*)/iux', $list[0]['content'], $arr);
if (@$arr[1]) {
$arr[1] = trim(trim($arr[1], '/'));
$icon = $archive->extract(PCLZIP_OPT_BY_NAME, $arr[1], PCLZIP_OPT_EXTRACT_AS_STRING);
} else {
preg_match('/MIDlet-1:[s*](.*),(.*),/iux', $list[0]['content'], $arr);
if ($arr[2]) {
$arr[2] = trim(trim($arr[2], '/'));
$icon = $archive->extract(PCLZIP_OPT_BY_NAME, $arr[2], PCLZIP_OPT_EXTRACT_AS_STRING);
}
}
if (@$icon[0]['content'] && file_put_contents($f, $icon[0]['content'])) {
return true;
} else {
return false;
}
}
function apk_ico($apk,$f){
require_once DIR.'/PEAR/pclzip.lib.php';
$archive = new PclZip($apk);
$list = $archive->extract(PCLZIP_OPT_BY_NAME, 'META-INF/MANIFEST.MF', PCLZIP_OPT_EXTRACT_AS_STRING);
preg_match('/Name:[s*](.*)icon.png/iux', $list[0]['content'], $arr);
if(@$arr){
$icon = $archive->extract(PCLZIP_OPT_BY_NAME, trim($arr[1].'icon.png'), PCLZIP_OPT_EXTRACT_AS_STRING);
}else{
preg_match('/Name:[s*](.*)icon(.*).png/iux', $list[0]['content'], $arr);
$icon = $archive->extract(PCLZIP_OPT_BY_NAME, trim($arr[1].'icon'.$arr[2].'.png'), PCLZIP_OPT_EXTRACT_AS_STRING);
}
if (@$icon[0]['content'] && file_put_contents($f, $icon[0]['content'])) {
return true;
} else {
return false;
}
}
function error($str = '',$banner = '')
{
global $setup;
require_once DIR . '/header.php';
echo '<div class="mainzag">'.$setup['hackmess'].'</div><div class="error">' . $str . '</div><div class="foot"><a href="javascript:history.back();">' . $_SESSION['language']['back'] . '</a> | <a href="' . DIRECTORY . '">' . $_SESSION['language']['downloads'] . '</a> |</div>'.$banner;
require_once DIR . '/foot.php';
exit;
}
/**
* Возвращает случайный пароль
* @return string random password 6-8 symbols
*/
function pass($min = 6, $max = 8)
{
return substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYZ0123456789'), 0, mt_rand($min, $max));
}
function str_to_utf8($str){
$charset = strtolower(mb_detect_encoding($str, 'UTF-8, Windows-1251'));
if($charset != 'utf-8'){
$str = iconv('windows-1251','utf-8',$str);
}
return $str;
}
/*
function str_to_utf8($str)
{
if (@iconv('UTF-8', 'UTF-8//IGNORE', $str) != $str) {
$str = iconv('Windows-1251', 'UTF-8//TRANSLIT', $str);
}
return $str;
}
*/
/**
* Постраничная навигация
* @param int текущая страница
* @param int всего страниц
* @param string url страницы, к нему прибавится /номер
* @return string html с навигацией
*/
function go($pg = 0, $all = 0, $str)
{
if($all == 1) $all=2;
$go = '';
$page1 = $pg - 2;
$page2 = $pg - 1;
$page3 = $pg + 1;
$page4 = $pg + 2;
if ($page1 > 0) {
$go .= '<a href="' . $str . '/' . $page1 . '">' . $page1 . '</a> ';
}
if ($page2 > 0) {
$go .= '<a href="' . $str . '/' . $page2 . '">' . $page2 . '</a> ';
}
$go .= $pg . ' ';
if ($page3 <= $all) {
$go .= '<a href="' . $str . '/' . $page3 . '">' . $page3 . '</a> ';
}
if ($page4 <= $all) {
$go .= '<a href="' . $str . '/' . $page4 . '">' . $page4 . '</a> ';
}
if ($all > 3 && $all > $page4) {
$go .= '... <a href="' . $str . '/' . $all . '">' . $all . '</a>';
}
if ($page1 > 1) {
$go = '<a href="' . $str . '/1">1</a> ... ' . $go;
}
if ($go == $pg . ' ') {
return;
} else {
return '<div class="row">' . $_SESSION['language']['pages'] . ': ' . $go . '</div>';
}
}
/**
* Возвращает MIME файла по его расширению
* @param string расширение
* @return string MIME тип
*/
function ext_to_mime($ext = '')
{
switch (strtolower($ext)) {
default:
return 'application/octet-stream';
break;
case 'jar':
return 'application/java-archive';
break;
case 'jad':
return 'text/vnd.sun.j2me.app-descriptor';
break;
case 'cab':
return 'application/vnd.ms-cab-compressed';
break;
case 'sis':
return 'application/vnd.symbian.install';
break;
case 'zip':
return 'application/x-zip';
break;
case 'rar':
return 'application/x-rar-compressed';
break;
case '7z':
return 'application/x-7z-compressed';
break;
case 'gz':
case 'tgz':
return 'application/x-gzip';
break;
case 'bz':
case 'bz2':
return 'application/x-bzip';
break;
case 'jpg':
case 'jpe':
case 'jpeg':
return 'image/jpeg';
break;
case 'gif':
return 'image/gif';
break;
case 'png':
return 'image/png';
break;
case 'bmp':
return 'image/bmp';
break;
case 'txt':
case 'dat':
case 'php':
case 'php4':
case 'php5':
case 'phtml':
case 'htm':
case 'html':
case 'shtm':
case 'shtml':
case 'wml':
case 'css':
case 'js':
case 'xml':
case 'sql':
return 'text/plain';
break;
case 'mmf':
return 'application/x-smaf';
break;
case 'mid':
return 'audio/mid';
break;
case 'mp3':
return 'audio/mpeg';
break;
case 'amr':
return 'audio/amr';
break;
case 'wav':
return 'audio/x-wav';
break;
case 'mp4':
return 'video/mp4';
break;
case 'wmv':
return 'video/x-ms-wmv';
break;
case '3gp':
return 'video/3gpp';
break;
case 'avi':
return 'video/x-msvideo';
break;
case 'mpg':
case 'mpe':
case 'mpeg':
return 'video/mpeg';
break;
case 'pdf':
return 'application/pdf';
break;
case 'doc':
case 'docx':
return 'application/msword';
break;
case 'swf':
return 'application/x-shockwave-flash';
break;
}
}
?>