Просмотр файла manager/functions.php

Размер файла: 27.04Kb
<?
// Файловый Менеджер + Редактор
// Gmanager
//
// Версия: 0.4.1b
// Автор: Gemorroj
// http://wapinet.ru
//
// Номера кошельков. Надеюсь понятно для чего =)
// WMR 167963845445
// WMZ 225757696726



// Расширения файлов, которые будут открываться в редакторе
$edit_format = '.wml|.wmls|.wmlc|.wmlsc|.htm|.html|.xhtm|.xhtml|.shtm|.shtml|.phtm|.phtml|.php|.php2|.php3|.php4|.php5|.php6|.pimg|.inc|.css|.js|.pl|.py|.rb|.tcl|.tpl|.cfg|.sql|.dat|.txt|.inf|.ini|.log|.lng|.cgi|.xml|.jad|.htaccess|.htpasswd';
$time = 14400;                // + Время по гринвичу
$date_format = 'd.m.Y H:i';   // Формат даты
$auth = 0;                    // Авторизация
$user_pass = '1234';          // Пароль
$user_name = 'Gemorroj';      // Логин
$user_mail = '[email protected]';// Ваш E-mail
$string = 1;                  // Поле ввода где можно в ручную набирать путь к папке/файлу
$realname = 2;                // 0 - Относительные пути к файлам/директориям, 1 - Полные пути к файлам/директориям, 2 - Скрывать относительные пути к файлам/директориям
$syntax = 0;                  // 0 - проверка синтаксиса PHP кода у себя на сервере (если работает exec), 1 - проверка синтаксиса через специальный сервис на wapinet.ru
$target = 1;                  // Открывать редактор в отдельном окне
$php = '/usr/local/bin/php';  // Путь к PHP
$pclzip = 'pclzip.php';       // Путь к PEAR классу PclZip

// Верх
$top = '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
<head>
<title>Page</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>';

// Низ
$foot = '<div class="w">Powered by Gemorroj<br/>
<a href="http://wapinet.ru">wapinet.ru</a></div>
</body></html>';

// Язык
$lng = array(
'title_index'=>'Содержимое Папки',
'title_edit'=>'Редактирование Файла',
'title_change'=>'Измнение Параметров',
'n'=>'N',
'name'=>'Имя',
'type'=>'Тип',
'size'=>'Размер',
'change'=>'Изменение',
'del'=>'Удаление',
'chmod'=>'CHMOD',
'date'=>'Дата',
'ch_index'=>'Выбор',
'create'=>'Создать',
'upload'=>'Загрузить Файл',
'up'=>'Загрузить',
'url'=>'URL',
'scan'=>'Сканер',
'scan_false'=>'Не Удалось Соединиться с Сервером',
'pattern'=>'Шаблон',
'enter'=>'Обзор',
'look'=>'Смотреть',
'go'=>'Перейти',
'ch'=>'Изменить',
'dl'=>'Удалить',
'cr'=>'Создать',
'send_mail'=>'Отправить E-mail',
'mail_to'=>'Кому',
'mail_from'=>'От Кого',
'mail_theme'=>'Тема',
'mail_mess'=>'Сообщение',
'sz'=>'Размер',
'mod'=>'Дополнительно',
'phpinfo'=>'PHPINFO',
'eval'=>'EVAL',
'eval_go'=>'Выполнить',
'php_code'=>'PHP Код',
'get'=>'Скачать',
'new_version'=>'Проверка Обновления',
'version_new'=>'Новая Версия',
'version_old'=>'Текущая Версия',
'new_version_true'=>'Доступна Новая Версия',
'new_version_false'=>'У Вас Последняя Версия Менеджера',
'change_name'=>'Имя',
'change_chmod'=>'CHMOD',
'change_del'=>'Удалить Исходный Файл',
'change_func'=>'Переместить/Переименовать',
'only_write'=>'Только для Записи',
'syntax'=>'PHP Валидатор',
'validator'=>'XML Валидатор',
'charset'=>'Кодировка',
'charset_no'=>'Оригинал',
'charset_utf'=>'UTF-8',
'charset_win'=>'Win-1251',
'warning'=>'Такой Файл Уже Существует<br/>Вся Информация в Нем Будет Уничтожена',
'back'=>'Назад',
'file'=>'Файл',
'dir'=>'Каталог',
'dir_empty'=>'Директория Пуста',
'not_found'=>'Файл не Найден',
'copy_file_true'=>'Файл Скопирован',
'copy_file_false'=>'Файл не Скопирован',
'move_file_true'=>'Файл Перемещен',
'move_file_false'=>'Файл не Перемещен',
'del_file_true'=>'Файл Удален',
'del_file_false'=>'Файл не Удален',
'full_del_file_dir_true'=>'Выбранные Файлы/Папки Удалены',
'full_del_file_dir_false'=>'Следующие Файлы/Папки не Удалены',
'full_rechmod'=>'Права Изменены',
'create_file_true'=>'Файл Создан',
'create_file_false'=>'Файл не Создан',
'create_dir_true'=>'Каталог Создан',
'create_dir_false'=>'Каталог не Создан',
'fputs_file_true'=>'Данные Записаны',
'fputs_file_false'=>'Данные не Записаны',
'chmod_true'=>'Права Изменены',
'chmod_false'=>'Права не Изменены',
'copy_files_true'=>'Файлы Скопированы',
'move_files_true'=>'Файлы Перемещены',
'del_dir_true'=>'Каталог Удален',
'del_dir_false'=>'Следующие Файлы/Папки не Удалось Удалить',
'syntax_true'=>'Синтаксических Ошибок не Найдено',
'syntax_not_check'=>'Файл не Проверен',
'syntax_unknown'=>'Unknown',
'validator_true'=>'Синтаксических Ошибок не Найдено',
'validator_not_check'=>'Файл не Проверен',
'zip_size'=>'Размер в Архиве',
'unzip_size'=>'Реальный Размер',
'zip_date'=>'Добавлено в Архив',
'extract_archive'=>'Распаковать Архив',
'extract_file'=>'Распаковать Файлы/Папки',
'extract_file_true'=>'Файлы/Папки Распакованы',
'extract_file_false'=>'Файлы/Папки не Распакованы',
'extract_true'=>'Архив Распакован',
'extract_false'=>'Архив не Распакован',
'zip_error'=>'Невозможно Открыть Архив',
'create_archive'=>'Создать ZIP Архив',
'create_archive_true'=>'ZIP Архив Создан',
'create_archive_false'=>'ZIP Архив не Создан',
'upload_true'=>'Файл Загружен',
'upload_false'=>'Файл не Загружен',
'send_mail_true'=>'Сообщение Отправлено',
'send_mail_false'=>'Сообщение не Отправлено'
);



///////////////////
// Дальше Функции, туда не влезай - убьет =)
//////////////////
$version = '0.4.1';
error_reporting(0);


list($msec,$sec) = explode(' ',microtime());
$HeadTime = $sec+$msec;


if($_SERVER['HTTP_ACCEPT_ENCODING'])
{$compress = strtolower($_SERVER['HTTP_ACCEPT_ENCODING']);}
else
{$compress = strtolower($_SERVER['HTTP_TE']);}

if(substr_count($compress,'deflate'))
{
function compress_output_deflate($output)
{return gzdeflate($output,4);}

header('Content-Encoding: deflate');
ob_start('compress_output_deflate');
ob_implicit_flush(0);
}
elseif(substr_count($compress,'gzip'))
{
function compress_output_gzip($output)
{return gzencode($output,4);}

header('Content-Encoding: gzip');
ob_start('compress_output_gzip');
ob_implicit_flush(0);
}


if($auth)
{auth($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']);}


function auth($user,$pass)
{
global $user_name, $user_pass;
if(empty($user) || empty($pass))
{
header('WWW-Authenticate: Basic realm="Authentification"');
header('HTTP/1.0 401 Unauthorized');
header('Content-type: text/html; charset=utf-8');
print '<html><head><title>Error</title></head><body><p style="color:red;font-size:24pt;text-align:center">Unauthorized</p></body></html>';
exit;
}
else
{
if(($user != $user_name) || ($pass != $user_pass))
{
header('WWW-Authenticate: Basic realm="Authentification"');
header('HTTP/1.0 401 Unauthorized');
header("Content-type: text/html; charset=utf-8");
print '<html><head><title>Error</title></head><body><p style="color:red;font-size:24pt;text-align:center">Unauthorized</p></body></html>';
exit;
}
}
return;
}


function send_header()
{
if(substr_count($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
{header('Content-type: text/html; charset=UTF-8');}
else
{header('Content-type: application/xhtml+xml; charset=UTF-8');}
header('Cache-control: no-cache');
return;
}


function c($query,$c)
{
if(!$query)
{return '.';}
else
{
if($c)
{
$current = rawurldecode(trim($c));
if(is_dir($current))
{
if(strrchr($current,'/') != '/')
{$current = $current.'/';}
}
}
else
{return rawurldecode(trim($query));}
}
return $current;
}


function this($current)
{
global $lng;
$up = explode_url($current,3);

if(is_dir($current))
{
if($current == '.')
{return '<div class="border">'.$lng['dir'].' <strong><a href="index.php">'.getcwd().'</a></strong> ('.look_chmod(getcwd()).')<br/></div>';}
else
{
return '<div class="border">'.$lng['back'].' <a href="index.php?'.$up.'">'.$up.'</a> ('.look_chmod($up).')<br/></div>
<div class="border">'.$lng['dir'].' <strong><a href="index.php?'.$current.'">'.realpath($current).'</a></strong> ('.look_chmod($current).')<br/></div>';
}
}
elseif((is_file($current)) && (strpos(strtoupper($current),'.ZIP') || strpos(strtoupper($current),'.JAR')))
{
$d = explode_url($current,2);
return '<div class="border">'.$lng['back'].' <a href="index.php?'.$up.'">'.$up.'</a> ('.look_chmod($up).')<br/></div>
<div class="border">'.$lng['dir'].' <strong><a href="index.php?'.$d.'">'.$d.'</a></strong> ('.look_chmod($d).')<br/></div>
<div class="border">'.$lng['file'].' <strong><a href="index.php?'.$current.'">'.realpath($current).'</a></strong> ('.look_chmod($current).')<br/></div>';
}
else
{
$d = explode_url($current,2);
return '<div class="border">'.$lng['back'].' <a href="index.php?'.$up.'">'.$up.'</a> ('.look_chmod($up).')<br/></div>
<div class="border">'.$lng['dir'].' <strong><a href="index.php?'.$d.'">'.$d.'</a></strong> ('.look_chmod($d).')<br/></div>
<div class="border">'.$lng['file'].' <strong><a href="edit.php?'.$current.'">'.realpath($current).'</a></strong> ('.look_chmod($current).')<br/></div>';
}
}


function static_name($current,$dest)
{
$len = strlen($current);
if(substr($dest,0,$len) == $current)
{
$static = substr($dest,$len);

if(strpos($static,'/'))
{$static = strtok($static,'/');}
}
else
{return;}
return $static;
}


function look($current)
{
global $lng,$date_format,$time,$edit_format,$realname,$target;
if($target)
{$target=' target="_blank"';}
else
{$target=null;}

$dir = opendir($current);

$page1 = $page2 = array();
$i = 1;
while($file = readdir($dir))
{
if($file=='.' || $file=='..')
{continue;}

if($current != '.')
{$file = $current.$file;}

if($realname==1)
{$name = realpath($file);}
elseif($realname==2)
{$name = basename($file);}
else
{$name = $file;}

if(is_dir($file))
{$page1[] = '<td><a href="?'.$file.'/">'.$name.'/</a></td><td>DIR</td><td>'.dir_size($file).'</td><td><a href="change.php?'.$file.'/">'.$lng['ch'].'</a></td><td><a href="change.php?go=del&amp;c='.$file.'/">'.$lng['dl'].'</a></td><td><a href="change.php?go=chmod&amp;c='.$file.'">'.look_chmod($file).'</a></td><td>'.gmdate($date_format, filemtime($file) + $time).'</td><td><input name="'.$i++.'" type="checkbox" value="'.$file.'"/></td>';}
else
{
$type = strtoupper(strrchr($name,'.'));

if(eregi("^($edit_format)+$", $type))
{$page2[] = '<td><a href="edit.php?'.$file.'"'.$target.'>'.$name.'</a></td><td>'.$type.'</td><td>'.file_size($file).'</td><td><a href="change.php?'.$file.'">'.$lng['ch'].'</a></td><td><a href="change.php?go=del&amp;c='.$file.'">'.$lng['dl'].'</a></td><td><a href="change.php?go=chmod&amp;c='.$file.'">'.look_chmod($file).'</a></td><td>'.gmdate($date_format, filemtime($file) + $time).'</td><td><input name="'.$i++.'" type="checkbox" value="'.$file.'"/></td>';}
elseif($type=='.ZIP' || $type=='.JAR')
{$page2[] = '<td><a href="?'.$file.'">'.$name.'</a></td><td>'.$type.'</td><td>'.file_size($file).'</td><td><a href="change.php?'.$file.'">'.$lng['ch'].'</a></td><td><a href="change.php?go=del&amp;c='.$file.'">'.$lng['dl'].'</a></td><td><a href="change.php?go=chmod&amp;c='.$file.'">'.look_chmod($file).'</a></td><td>'.gmdate($date_format, filemtime($file) + $time).'</td><td><input name="'.$i++.'" type="checkbox" value="'.$file.'"/></td>';}
else
{$page2[] = '<td><a href="'.$file.'">'.$name.'</a></td><td>'.$type.'</td><td>'.file_size($file).'</td><td><a href="change.php?'.$file.'">'.$lng['ch'].'</a></td><td><a href="change.php?go=del&amp;c='.$file.'">'.$lng['dl'].'</a></td><td><a href="change.php?go=chmod&amp;c='.$file.'">'.look_chmod($file).'</a></td><td>'.gmdate($date_format, filemtime($file) + $time).'</td><td><input name="'.$i++.'" type="checkbox" value="'.$file.'"/></td>';}
}
}
closedir($dir);

natsort($page1);
natsort($page2);
$page = array_merge($page1,$page2);

if($page)
{
$i = 1;
foreach($page as $var)
{print '<tr class="border"><td>'.$i++.'</td>'.$var.'</tr>';}
print '<input type="hidden" name="x" value="'.($i-1).'"/>';
}
else
{print '<tr class="border"><th colspan="8">'.$lng['dir_empty'].'</th></tr>';}

return;
}


function copy_d($dest)
{
$ex = explode('/',$dest);
foreach($ex as $var)
{
$tmp.= $var.'/';
@mkdir($tmp,0777);
}
return;
}


function copy_files($d,$dest,$static,$chmod)
{
global $lng;
$f = opendir($d);
while($file = readdir($f))
{
if($file=='.' || $file=='..' || $file==$static){continue;}
if($d == $dest){break;}
if(is_dir($d.'/'.$file))
{
mkdir($dest.'/'.$file,0777);
copy_files($d.'/'.$file,$dest.'/'.$file,$static,$chmod);
}
else
{copy($d.'/'.$file,$dest.'/'.$file);}
}
closedir($f);
@chmod($dest,octdec(intval($chmod)));
return '<div class="red">'.$lng['copy_files_true'].'<br/></div>';
}


function move_files($d,$dest,$static,$chmod)
{
global $lng;
$f = opendir($d);
while($file = readdir($f))
{
if($file=='.' || $file=='..' || $file==$static){continue;}
if($d == $dest){break;}
if(is_dir($d.'/'.$file))
{
mkdir($dest.'/'.$file,0777);
move_files($d.'/'.$file,$dest.'/'.$file,$static,$chmod);
@rmdir($d.'/'.$file);
}
else
{
if(copy($d.'/'.$file,$dest.'/'.$file))
{unlink($d.'/'.$file);}
}
}
closedir($f);
@chmod($d,0777);
rmdir($d);
@chmod($dest,octdec(intval($chmod)));
return '<div class="red">'.$lng['move_files_true'].'<br/></div>';
}


function copy_file($source,$dest,$chmod)
{
global $lng;
copy_d(dirname($dest));
if(copy($source,$dest))
{
@chmod($dest,octdec(intval($chmod)));
return '<div class="red">'.$lng['copy_file_true'].'<br/></div>';
}
else
{return '<div class="red">'.$lng['copy_file_false'].'<br/></div>';}
}


function move_file($source,$dest,$chmod)
{
global $lng;
copy_d(dirname($dest));
if(copy($source,$dest))
{
del_file($source);
@chmod($dest,octdec(intval($chmod)));
return '<div class="red">'.$lng['move_file_true'].'<br/></div>';
}
else
{return '<div class="red">'.$lng['move_file_false'].'<br/></div>';}
}


function del_file($f)
{
global $lng;
@chmod($f,0777);
if(@unlink($f))
{return '<div class="red">'.$lng['del_file_true'].'<br/></div>';}
else
{return '<div class="red">'.$lng['del_file_false'].'<br/></div>';}
}


function del_dir($d)
{
global $lng;
@chmod($d,0777);
$dir = opendir($d);
while($f = readdir($dir))
{
if(is_file($d.$f))
{
@chmod($d.$f,0777);
if(!@unlink($d.$f)){$err.=realpath($d.$f).'<br/>';}
}
elseif(is_dir($d.$f) && $f!='.' && $f!='..')
{
@chmod($d.$f,0777);
del_dir($d.$f);
}
}
closedir($dir);
if(!@rmdir($d)){$err.=realpath($d).'<br/>';}
if($err){return '<div class="red">'.$lng['del_dir_false'].'<br/>'.$err.'</div>';}
return '<div class="red">'.$lng['del_dir_true'].'<br/></div>';
}


function explode_url($current,$kol)
{
$ex = explode('/',$current);
$count = sizeof($ex)-$kol;

if($count >= 0)
{
$i = 0;
do
{$up.= $ex[$i].'/';}
while(++$i <= $count);
}
else
{return '.';}
return $up;
}


function dir_size($file)
{
if(!is_dir($file) || !is_readable($file))
{return;}
$ds[] = $file;
$sz = 0;
do
{
$d = array_shift($ds);
$h = opendir($d);
while($file = readdir($h))
{
if($file!='.' && $file!='..' && is_readable($d.'/'.$file))
{
if(is_dir($d.'/'.$file))
{$ds[] = $d.'/'.$file;}
$sz += filesize($d.'/'.$file);
}
}
closedir($h);
}
while(sizeof($ds) > 0);
return round($sz/1024,2).' kb';
}


function file_size($file)
{return round(filesize($file)/1024,2).' kb';}


function look_chmod($file)
{return substr(sprintf('%o', fileperms($file)), -4);}


function create_file($file,$mode,$chmod,$text)
{
global $lng;
if($create = fopen($file, $mode))
{
$page.= '<div class="red">'.$lng['create_file_true'].'<br/></div>';
if($text)
{
if(fputs($create,trim($text)))
{$page.= '<div class="red">'.$lng['fputs_file_true'].'<br/></div>';}
else
{$page.= '<div class="red">'.$lng['fputs_file_false'].'<br/></div>';}
}
fclose($create);
$page.= rechmod($file,$chmod);
}
else
{return '<div class="red">'.$lng['create_file_false'].'<br/></div>';}
return $page;
}


function rechmod($current,$chmod)
{
global $lng;
if(chmod(trim($current), octdec(intval($chmod))))
{return '<div class="red">'.$lng['chmod_true'].'<br/></div>';}
else
{return '<div class="red">'.$lng['chmod_false'].'<br/></div>';}
}


function create_dir($dir,$chmod)
{
global $lng;
if(mkdir($dir, octdec(trim($chmod))))
{return '<div class="red">'.$lng['create_dir_true'].'<br/></div>';}
else
{return '<div class="red">'.$lng['create_dir_false'].'<br/></div>';}
}


function syntax($source,$charset)
{
global $lng,$php;
exec($php.' -c -f -l "'.$source.'"',$rt,$v);

if(!sizeof($rt) || !file_exists($source))
{return '<div class="red">'.$lng['syntax_not_check'].'<br/></div>';}

if(($v == 255) || (sizeof($rt) == 3))
{
$st = trim(strip_tags($rt[1]));
if($st!=null)
{
$erl = preg_replace("~.*\s(\d*)$~","\\1",$st,1);
$pg = $st;
}
else
{$pg = $lng['syntax_unknown'].'<br/>';}
}
elseif($v == 0)
{$pg = $lng['syntax_true'].'<br/>';}

$fl = trim(file_get_contents($source));
if($charset == 'windows-1251')
{$fl = @iconv('UTF-8','windows-1251',$fl);}
elseif($charset == 'utf-8')
{$fl = @iconv('windows-1251','UTF-8',$fl);}

if(substr_count($fl,"\r") > 2)
{$arr = split("\r",xhtml_highlight(str_replace("\n",null,$fl)));}
else
{$arr = split('<br />',xhtml_highlight($fl));}

$end = sizeof($arr);
for($i=0; $i<$end; $i++)
{
if($i == ($erl-1))
{$page.= '<span class="fail_code">&#160;'.($i+1).'&#160;</span> '.$arr[$i].'<br/>';}
else
{$page.= '<span class="true_code">'.($i+1).'</span> '.$arr[$i].'<br/>';}
}

return '<div class="red">'.$pg.'</div><div class="code">'.$page.'</div>';
}


function syntax2($current)
{
global $lng;
$fp = @fsockopen('wapinet.ru',80,$er1,$er2,15);
if(!$fp){return '<div class="red">'.$lng['syntax_not_check'].'<br/></div>';}
$f = rawurlencode(trim(@file_get_contents($current)));
fputs($fp,'POST /syntax2/index.php HTTP/1.0'."\r\n".'Host: wapinet.ru'."\r\n".'Content-type: application/x-www-form-urlencoded'."\r\n".'Content-length: '.(strlen($f)+2)."\r\n".'Connection: close'."\r\n\r\n".'f='.$f."\r\n\r\n");

while($r != "\r\n"){$r = fgets($fp);}
$r=null;

while(!feof($fp))
{$r.=fread($fp,1024);}
fclose($fp);
return trim($r);
}


function validator($current,$charset)
{
global $lng;
$data = @fopen($current,'r');
if(!$data)
{return '<div class="red">'.$lng['validator_not_check'].'<br/></div>';}
$fl = file_get_contents($current);
if($charset == 'windows-1251')
{$fl = @iconv('UTF-8','windows-1251',$fl);}
elseif($charset == 'utf-8')
{$fl = @iconv('windows-1251','UTF-8',$fl);}
$xml_parser = xml_parser_create();
if(!xml_parse($xml_parser, $fl, feof($data)))
{
$err = xml_error_string(xml_get_error_code($xml_parser));
$line = xml_get_current_line_number($xml_parser);
$column = xml_get_current_column_number($xml_parser);
xml_parser_free($xml_parser);
fclose($data);
return '<div class="red">Error [Line '.$line.', Column '.$column.']: '.$err.'<br/></div>'.code($fl,$line);
}
else
{
xml_parser_free($xml_parser);
return '<div class="red">'.$lng['validator_true'].'<br/></div>'.code($fl,0);
}
}


function xhtml_highlight($fl)
{return preg_replace('#color="(.*?)"#', 'style="color: \\1"', str_replace(array('<font ', '</font>'), array('<span ', '</span>'), highlight_string($fl,true)));}


function url_highlight($fl)
{return '<code>'.nl2br(preg_replace("~(&quot;|&#039;)[^<>]*(&quot;|&#039;)~iU",'<span style="color:#DD0000">\\0</span>',preg_replace("~&lt;!--.*--&gt;~iU",'<span style="color:#FF8000">\\0</span>',preg_replace("~(&lt;[^\s!]*\s)([^<>]*)([/?]?&gt;)~iU",'\\1<span style="color:#007700">\\2</span>\\3',preg_replace("~&lt;[^<>]*&gt;~iU",'<span style="color:#0000BB">\\0</span>',htmlspecialchars($fl,ENT_QUOTES)))))).'</code>';}


function code($fl,$line)
{
if(substr_count($fl,"\r") > 2)
{$arr = split("\r",url_highlight(str_replace("\n",null,$fl)));}
else
{$arr = split("\n",url_highlight($fl));}

$end = sizeof($arr);
for($i=0; $i<$end; $i++)
{
if($i == ($line-1))
{$page.= '<span class="fail_code">&#160;'.($i+1).'&#160;</span> '.$arr[$i];}
else
{$page.= '<span class="true_code">'.($i+1).'</span> '.$arr[$i];}
}
return '<div class="code">'.$page.'</div>';
}


function list_archive($current)
{
global $lng,$pclzip,$date_format,$time;
require_once $pclzip;

$zip = new PclZip($current);

if(($list = $zip->listContent())==0)
{return '<div class="red">'.$lng['zip_error'].'<br/></div>';}
else
{
$s = sizeof($list);

for($i=0; $i<$s; $i++)
{
if($list[$i]['folder'])
{
$type = 'DIR';
$name = $list[$i]['filename'];
$size = ' ';
}
else
{
$type = strtoupper(strrchr($list[$i]['filename'],'.'));
$name = '<a href="?c='.$current.'&amp;f='.$list[$i]['filename'].'">'.$list[$i]['filename'].'</a>';
$size = round($list[$i]['size']/1024,2).' kb';
}
$link.= '<tr class="border"><td>'.($i+1).'</td><td>'.$name.'</td><td>'.$type.'</td><td>'.$size.'</td><td> </td><td><a href="change.php?go=del_archive&amp;c='.$current.'&amp;f='.$list[$i]['filename'].'">'.$lng['dl'].'</a></td><td> </td><td>'.gmdate($date_format,($list[$i]['mtime']+$time)).'</td><td><input name="'.($i+1).'" type="checkbox" value="'.$list[$i]['filename'].'"/></td></tr>';
}

return $link.'<input type="hidden" name="x" value="'.$i.'"/>';
}
}


function create_archive($name,$chmod,$ext)
{
global $lng,$pclzip;
require_once $pclzip;

$zip = new PclZip($name);
function cb($p_event, &$p_header)
{$p_header['stored_filename'] = basename($p_header['filename']);return 1;}
$zip->create($ext, PCLZIP_CB_PRE_ADD, 'cb');

if(file_exists($name))
{
chmod($name,octdec(intval($chmod)));
return '<div class="red">'.$lng['create_archive_true'].'<br/></div>';
}
else
{return '<div class="red">'.$lng['create_archive_false'].'<br/></div>';}
}

function extract_archive($current,$name,$chmod)
{
global $lng,$pclzip;
require_once $pclzip;

$zip = new PclZip($current);
$zip->extract(PCLZIP_OPT_PATH, $name);

if(is_dir($name))
{
chmod($name,octdec(intval($chmod)));
return '<div class="red">'.$lng['extract_true'].'<br/></div>';
}
else
{return '<div class="red">'.$lng['extract_false'].'<br/></div>';}
}


function extract_file($current,$name,$chmod,$ext)
{
global $lng,$pclzip;
require_once $pclzip;

$zip = new PclZip($current);
$zip->extract(PCLZIP_OPT_PATH, $name, PCLZIP_OPT_BY_NAME, $ext);

if(is_dir($name))
{
chmod($name,octdec(intval($chmod)));
return '<div class="red">'.$lng['extract_file_true'].'<br/></div>';
}
else
{return '<div class="red">'.$lng['extract_file_false'].'<br/></div>';}
}


function del_archive($current,$f)
{
global $lng,$pclzip;
require_once $pclzip;

$zip = new PclZip($current);
$list = $zip->delete(PCLZIP_OPT_BY_NAME, $f);

if(!$list)
{return '<div class="red">'.$lng['del_file_false'].'<br/></div>';}
else
{return '<div class="red">'.$lng['del_file_true'].'<br/></div>';}
}


function look_file($current,$f)
{
global $lng,$pclzip,$date_format,$time;
require_once $pclzip;

$zip = new PclZip($current);
$ext = $zip->extract(PCLZIP_OPT_BY_NAME, $f, PCLZIP_OPT_EXTRACT_AS_STRING);

if(!$ext)
{return '<div class="red">'.$lng['zip_error'].'<br/></div>';}
else
{return '<div class="red">'.$lng['zip_size'].': '.round($ext['0']['compressed_size']/1024,2).' kb<br/>'.$lng['unzip_size'].': '.round($ext['0']['size']/1024,2).' kb<br/>'.$lng['zip_date'].': '.gmdate($date_format,($ext['0']['mtime']+$time)).'<br/></div>'.zip_fl(trim($ext['0']['content']));}
}


function zip_fl($fl)
{
if(substr_count($fl,"\r"))
{$arr = split("\r",xhtml_highlight(str_replace("\n",NULL,$fl)));}
else
{$arr = split('<br />',xhtml_highlight($fl));}

foreach($arr as $i => $val)
{$page.= '<span class="true_code">'.($i+1).'</span> '.$val.'<br/>';}

return '<div class="code">'.$page.'</div>';
}


function upload_opera($f,$name,$chmod)
{
global $lng;

$file = explode('file=',$f);
$file['1'] = base64_decode($file['1']);

$dir = explode_url($name,2);
if(substr($name,-1)=='/'){$name=$file['0'];}else{$name=basename($name);}

$f = fopen($dir.$name,'wb');
fputs($f,$file['1']);
fclose($f);
chmod($dir.$name,octdec(intval($chmod)));

if(file_exists($dir.$name))
{return '<div class="red">'.$lng['upload_true'].'</div>';}
else
{return '<div class="red">'.$lng['upload_false'].'</div>';}
}


function upload_files($tmp,$name,$dir,$chmod)
{
global $lng;
if(substr($dir,-1)!='/'){$name=basename($dir);}
$dir = explode_url($dir,2);
if(move_uploaded_file($tmp,$dir.$name))
{
chmod($dir.$name,octdec(intval($chmod)));
return '<div class="red">'.$lng['upload_true'].'</div>';
}
else
{return '<div class="red">'.$lng['upload_false'].'</div>';}
}


function upload_url($url,$name,$chmod)
{
global $lng;
$dir = explode_url($name,2);
if(substr($name,-1)=='/'){$name=basename($url);}else{$name=basename($name);}

if(copy($url,$dir.$name))
{
chmod($dir.$name,octdec(intval($chmod)));
return '<div class="red">'.$lng['upload_true'].'</div>';
}
else
{return '<div class="red">'.$lng['upload_false'].'</div>';}
}


function send_mail($theme,$mess,$to,$from)
{
global $lng;
if(@mail($to, '=?utf-8?B?'.base64_encode($theme).'?=', $mess, "From: $from\r\nContent-type: text/plain; charset=utf-8;\r\nX-Mailer: GemorMail;\r\nX-Priority: 3"))
{return '<div class="red">'.$lng['send_mail_true'].'<br/></div>';}
else
{return '<div class="red">'.$lng['send_mail_false'].'<br/></div>';}
}


function show_eval($eval)
{
$tmp = ob_get_contents();
if($tmp)
{
ob_clean();
eval($eval);
$ret = ob_get_contents();
ob_clean();

$rows = sizeof(explode("\n",$ret))+1;
if($rows < 12){$rows = 12;}
return $tmp.'<div class="input"><textarea cols="48" rows="'.$rows.'">'.htmlspecialchars($ret).'</textarea></div>';
}
else
{
print '<div class="red"><pre>';
eval($eval);
print '</pre></div>';
return;
}
}


if($_SERVER['QUERY_STRING'] == 'phpinfo'){phpinfo();}
?>