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

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



require 'functions.php';

$current = c($_SERVER['QUERY_STRING'],$_GET['c']);

send_header();

print $top.'
<div class="w2">
'.$lng['title_change'].'<br/>
</div>
'.this($current);

switch($_GET['go'])
{
default:

if(!file_exists($current))
{
print '<div class="red">'.$lng['not_found'].'<br/></div>';
break;
}

if(is_dir($current))
{$size = dir_size($current);}
elseif(is_file($current))
{$size = file_size($current);}

print '<div>
'.$lng['sz'].' '.$size.'<br/>
</div>
<div class="input">
<form action="?go=rename&amp;c='.$current.'" method="post">
<div>
'.$lng['change_func'].'<br/>
<input type="text" name="name" value="'.$current.'"/><br/>
'.$lng['change_del'].'<br/>
<input type="checkbox" name="del" value="1"/><br/>
'.$lng['change_chmod'].'<br/>
<input type="text" size="4" maxlength="4" name="chmod" value="'.look_chmod($current).'"/><br/>
<input type="submit" value="'.$lng['ch'].'"/>
</div>
</form>
</div>
<div class="border"><a href="?go=del&amp;c='.$current.'">'.$lng['dl'].'</a><br/></div>';
break;

case 1:
$i = 0;
$x = intval($_POST['x']);

if($_POST['full_del'])
{
while(++$i <= $x)
{
if(is_dir($_POST[$i]))
{
del_dir($_POST[$i].'/');
if(file_exists($_POST[$i])){$err.=realpath($_POST[$i]).'<br/>';}
}
else
{
del_file($_POST[$i]);
if(file_exists($_POST[$i])){$err.=realpath($_POST[$i]).'<br/>';}
}
}

if($err)
{print '<div class="red">'.$lng['full_del_file_dir_false'].'<br/>'.$err.'</div>';}
else
{print '<div class="red">'.$lng['full_del_file_dir_true'].'<br/></div>';}
}
elseif($_POST['full_chmod'])
{
if(!$_GET['go2'])
{
print '<div class="input">
<form action="?go=1&amp;go2=1&amp;c='.$current.'" method="post">
<div>
'.$lng['change_chmod'].'<br/>
<input type="text" size="4" maxlength="4" name="chmod" value="0644"/><br/>
<input name="x" type="hidden" value="'.$x.'"/>
<input name="full_chmod" type="hidden" value="1"/>';
while(++$i <= $x)
{
if($_POST[$i])
{print '<input name="'.$i.'" type="hidden" value="'.$_POST[$i].'"/>';}
}
print '<input type="submit" value="'.$lng['ch'].'"/>
</div>
</form>
</div>';
}
else
{
while(++$i <= $x)
{if($_POST[$i]){rechmod($_POST[$i],$_POST['chmod']);}}
print '<div class="red">'.$lng['full_rechmod'].'<br/></div>';
}
}
elseif($_POST['mega_full_extract'])
{
if(!$_POST['name'] || !$_POST['chmod'])
{
print '<div class="input">
<form action="?go=1&amp;c='.$current.'" method="post">
<div>
'.$lng['change_name'].'<br/>
<input type="text" name="name" value="'.dirname($current).'/"/><br/>
'.$lng['change_chmod'].'<br/>
<input type="text" name="chmod" size="4" maxlength="4" value="0755"/><br/>
<input name="mega_full_extract" type="hidden" value="1"/>
<input type="submit" value="'.$lng['extract_archive'].'"/>
</div>
</form>
</div>';
}
else
{print extract_archive($current,$_POST['name'],$_POST['chmod']);}
}
elseif($_POST['full_extract'])
{
if(!$_POST['name'] || !$_POST['chmod'])
{
print '<div class="input">
<form action="?go=1&amp;c='.$current.'" method="post">
<div>
'.$lng['change_name'].'<br/>
<input type="text" name="name" value="'.dirname($current).'/"/><br/>
'.$lng['change_chmod'].'<br/>
<input type="text" name="chmod" size="4" maxlength="4" value="0755"/><br/>
<input name="full_extract" type="hidden" value="1"/>
<input name="x" type="hidden" value="'.$x.'"/>';
while(++$i <= $x)
{if($_POST[$i]){print '<input name="'.$i.'" type="hidden" value="'.$_POST[$i].'"/>';}}
print '<input type="submit" value="'.$lng['extract_archive'].'"/>
</div>
</form>
</div>';
}
else
{
while(++$i <= $x)
{if($_POST[$i]){$ext[].= $_POST[$i];}}
print extract_file($current,$_POST['name'],$_POST['chmod'],$ext);
}
}
elseif($_POST['create_archive'])
{
if(!$_POST['name'] || !$_POST['chmod'])
{
print '<div class="input">
<form action="?go=1&amp;c='.$current.'" method="post">
<div>
'.$lng['change_name'].'<br/>
<input type="text" name="name" value="'.$current.'archive.zip"/><br/>
'.$lng['change_chmod'].'<br/>
<input type="text" name="chmod" size="4" maxlength="4" value="0644"/><br/>
<input name="create_archive" type="hidden" value="1"/>
<input name="x" type="hidden" value="'.$x.'"/>';
while(++$i <= $x)
{
if($_POST[$i])
{print '<input name="'.$i.'" type="hidden" value="'.$_POST[$i].'"/>';}
}
print '<input type="submit" value="'.$lng['create_archive'].'"/>
</div>
</form>
</div>';
}
else
{
while(++$i <= $x)
{if($_POST[$i]){$ext[].= $_POST[$i];}}
print create_archive($_POST['name'],$_POST['chmod'],$ext);
}
}
break;

case 'del':
if(is_dir($current))
{print del_dir($current);}
else
{print del_file($current);}
break;

case 'chmod':
if(!$_POST['chmod'])
{
print '<div class="input">
<form action="?go=chmod&amp;c='.$current.'" method="post">
<div>
'.$lng['change_chmod'].'<br/>
<input type="text" size="4" maxlength="4" name="chmod" value="'.look_chmod($current).'"/><br/>
<input type="submit" value="'.$lng['ch'].'"/>
</div>
</form>
</div>';
}
else
{print rechmod($current,$_POST['chmod']);}
break;

case 'create_dir':
if(!$_POST['name'] || !$_POST['chmod'])
{
print '<div class="input">
<form action="?go=create_dir&amp;c='.$current.'" method="post">
<div>
'.$lng['change_name'].'<br/>
<input type="text" name="name" value="dir"/><br/>
'.$lng['change_chmod'].'<br/>
<input type="text" name="chmod" size="4" maxlength="4" value="0755"/><br/>
<input type="submit" value="'.$lng['cr'].'"/>
</div>
</form>
</div>';
}
else
{print create_dir(trim($current).trim($_POST['name']),$_POST['chmod']);}
break;

case 'create_file':
require 'pattern.dat';
if(!$_POST['name'] || !$_POST['chmod'])
{
print '<div class="input">
<form action="?go=create_file&amp;c='.$current.'" method="post">
<div>
'.$lng['change_name'].'<br/>
<input type="text" name="name" value="file.php"/><br/>
'.$lng['pattern'].'<br/>
<select name="ptn">';
$all = sizeof($pattern)-1;
$i=0;
do
{print '<option value="'.$i.'">'.$pattern[$i]['0'].'</option>';}
while(++$i <= $all);

print '</select><br/>
'.$lng['change_chmod'].'<br/>
<input type="text" name="chmod" size="4" maxlength="4" value="0644"/><br/>
'.$lng['only_write'].'<br/>
<input type="checkbox" name="w"/><br/>
<input type="submit" value="'.$lng['cr'].'"/>
</div>
</form>
</div>';
}
else
{
if(file_exists($current.$_POST['name']) && !$_POST['a'])
{
print '<div class="red">'.$lng['warning'].'<br/></div>
<form action="?go=create_file&amp;c='.$current.'" method="post">
<div>
<input type="hidden" name="name" value="'.$_POST['name'].'"/>
<input type="hidden" name="ptn" value="'.$_POST['ptn'].'"/>
<input type="hidden" name="chmod" value="'.$_POST['chmod'].'"/>';
if($_POST['w'])
{print '<input type="hidden" name="w" value="1"/>';}
print '<input type="hidden" name="a" value="1"/>
<input type="submit" value="'.$lng['ch'].'"/>
</div>
</form>';
}
else
{
if($_POST['w'])
{$mode = 'w';}
else
{$mode = 'w+';}

if($realname)
{$realpath = realpath($current).$_POST['name'];}
else
{$realpath = $current.$_POST['name'];}

print '<div class="border">'.$lng['file'].' <strong><a href="edit.php?'.$current.$_POST['name'].'">'.$realpath.'</a></strong> ('.$_POST['chmod'].')<br/></div>'.create_file(trim($current).trim($_POST['name']),$mode,$_POST['chmod'],$pattern[intval($_POST['ptn'])]['1']);
}
}
break;

case 'rename':
if(is_dir($current))
{
copy_d($_POST['name']);

if($_POST['del'])
{print move_files($current,$_POST['name'],static_name($current,$_POST['name']),$_POST['chmod']);}
else
{print copy_files($current,$_POST['name'],static_name($current,$_POST['name']),$_POST['chmod']);}
}
else
{
if($_POST['del'])
{print move_file($current,$_POST['name'],$_POST['chmod']);}
else
{print copy_file($current,$_POST['name'],$_POST['chmod']);}
}
break;

case 'del_archive':
print del_archive($_GET['c'],$_GET['f']);
break;

case 'upload':
if((((!$_POST['url'] || $_POST['url']=='http://') && ($_FILES['f']['error'] || !$_FILES)) && !$_POST['f']) || !$_POST['name'] || !$_POST['chmod'])
{
print '<div class="input">
<form action="?go=upload&amp;c='.$current.'" method="post" enctype="multipart/form-data">
<div>
'.$lng['url'].'<br/><input name="url" type="text" value="http://"/><br/>';
if(substr_count($_SERVER['HTTP_USER_AGENT'],'Opera Mini'))
{print $lng['file'].'<br/><input name="f" type="text"/>
<a href="op:fileselect">'.$lng['enter'].'</a><br/>';}
else
{print $lng['file'].'<br/><input type="file" name="f"/><br/>';}
print $lng['name'].'<br/><input type="text" name="name" value="'.$current.'"/><br/>
'.$lng['change_chmod'].'<br/><input type="text" name="chmod" value="0644" size="4" maxlength="4"/><br/>
<input type="submit" value="'.$lng['upload'].'"/>
</div>
</form>
</div>';
}
else
{
if($_POST['f'])
{print upload_opera($_POST['f'],$_POST['name'],$_POST['chmod']);}
elseif(!$_FILES['f']['error'])
{print upload_files($_FILES['f']['tmp_name'],$_FILES['f']['name'],$_POST['name'],$_POST['chmod']);}
else
{print upload_url($_POST['url'],$_POST['name'],$_POST['chmod']);}
}
break;

case 'mod':
print '<div class="red">'.$_SERVER['SERVER_SOFTWARE'].'<br/>
<a href="?go=scan&amp;c='.$current.'">'.$lng['scan'].'</a><br/>
<a href="?go=eval&amp;c='.$current.'">'.$lng['eval'].'</a><br/>
<a href="?go=send_mail&amp;c='.$current.'">'.$lng['send_mail'].'</a><br/>
<a href="functions.php?phpinfo">'.$lng['phpinfo'].'</a> ('.PHP_VERSION.')<br/>
<a href="?go=new_version&amp;c='.$current.'">'.$lng['new_version'].'</a><br/>
</div>';
break;

case 'new_version':
$new = @file_get_contents('http://wapinet.ru/script/manager.txt');
print '<div class="red">'.$lng['version_new'].': '.$new.'<br/>
'.$lng['version_old'].': '.$version.'<br/>';
if($new == $version)
{print $lng['new_version_false'].'<br/></div>';}
else
{print $lng['new_version_true'].'<br/><a href="http://wapinet.ru/script/manager.zip">'.$lng['get'].'</a><br/></div>';}
break;

case 'scan':
if(!$_POST['url'] || $_POST['url']=='http://')
{
print '<div class="input">
<form action="?go=scan&amp;c='.$current.'" method="post">
<div>
'.$lng['url'].'<br/>
<input type="text" name="url" value="http://"/><br/>
<input type="submit" value="'.$lng['look'].'"/>
</div>
</form>
</div>';
}
else
{
@ini_set('user_agent',$_SERVER['HTTP_USER_AGENT']);
$url = @file_get_contents($_POST['url']);
if($url)
{print code($url,0);}
else
{print '<div class="red">'.$lng['scan_false'].'<br/></div>';}
}
break;

case 'send_mail':
if(!$_POST['theme'] || !$_POST['mess'] || !$_POST['to'] || !$_POST['from'])
{
print '<div class="input">
<form action="?go=send_mail&amp;c='.$current.'" method="post">
<div>
'.$lng['mail_to'].'<br/>
<input type="text" name="to" value="@"/><br/>
'.$lng['mail_from'].'<br/>
<input type="text" name="from" value="'.$user_mail.'"/><br/>
'.$lng['mail_theme'].'<br/>
<input type="text" name="theme" value="Hello"/><br/>
'.$lng['mail_mess'].'<br/>
<textarea name="mess" rows="12" cols="48"></textarea><br/>
<input type="submit" value="'.$lng['send_mail'].'"/>
</div>
</form>
</div>';
}
else
{print send_mail($_POST['theme'],$_POST['mess'],$_POST['to'],$_POST['from']);}
break;

case 'eval':
if($_POST['eval'])
{print show_eval($_POST['eval']);}
print '<div class="input">
<form action="?go=eval&amp;c='.$current.'" method="post">
<div>
'.$lng['php_code'].'<br/>
<textarea name="eval" rows="12" cols="48">'.$_POST['eval'].'</textarea><br/>
<input type="submit" value="'.$lng['eval_go'].'"/>
</div>
</form>
</div>';
break;
}

list($msec,$sec) = explode(' ',microtime());
print '<div class="border">'.round(($sec+$msec)-$HeadTime,4).'<br/></div>'.$foot;
?>