Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $serverpath = dirname($_SERVER['SCRIPT_FILENAME']).'/';
- $serverpath_url = '';
- $max = 1024*1024*1024;
- $passwd = 'yourpasshere';
- function ShowSize ($filesize) {
- if ($filesize < 1024) {
- echo $filesize."B";
- } elseif ($filesize < pow(1024,2)) {
- echo number_format($filesize/1024, 2)."KB";
- } elseif ($filesize < pow(1024,3)) {
- echo number_format($filesize/pow(1024,2),2)."MB";
- } else {
- echo number_format($filesize/pow(1024,3),2)."GB";
- }
- }
- session_start();
- if (isset($_REQUEST['passwd'])) {
- if ($_REQUEST['passwd'] == $passwd) {
- $_SESSION['logado'] = true;
- }
- }
- if (empty($_SESSION['logado'])) {
- ?>
- <html>
- <head><title>Emperror Upload Bin</title></head>
- <body>
- <form action="index.php" method="POST">
- Password: <input name="passwd" type="password">
- <input type="submit" value="Send">
- </form>
- </body>
- </html>
- <?php } else { ?>
- <html>
- <head><title>Emperror Upload Bin</title></head>
- <body>
- <?php
- if (isset($_REQUEST['kill'])) {
- if ($_REQUEST['kill'] == basename($_SERVER['SCRIPT_FILENAME'])) { ?>
- Invalid file!<br>
- <?php } elseif (unlink($serverpath.$_REQUEST['kill'])) { ?>
- File deleted!<br>
- <?php } else { ?>
- Error deleting file!<br>
- <?php }
- }
- if (isset($_REQUEST['killfiles'])) {
- foreach ($_REQUEST['killfiles'] as $file) {
- if ($file == basename($_SERVER['SCRIPT_FILENAME'])) { ?>
- Invalid file!<br>
- <?php } elseif (unlink($serverpath.$file)) { ?>
- File deleted!(<?php echo $file; ?>)<br>
- <?php } else { ?>
- Error deleting file!(<?php echo $file; ?>)<br>
- <?php }
- }
- }
- if (isset($_REQUEST['url'])) {
- $urls = explode("\r\n", $_REQUEST['url']);
- if (count($urls) == 1) $urls = explode("\n", $_REQUEST['url']);
- foreach ($urls as $u) {
- $p = explode(' ', $u);
- if (count($p) == 2) {
- $bn = basename($p[1]);
- $u = $p[0];
- } else {
- $bn = basename($p[0]);
- $u = $p[0];
- }
- if ($bn == basename($_SERVER['SCRIPT_FILENAME'])) { ?>
- Invalid file name!<br>
- <?php
- } else {
- $f = fopen($serverpath.$bn, 'w');
- $c = curl_init($u);
- curl_setopt($c, CURLOPT_HEADER, false);
- curl_setopt($c, CURLOPT_FILE, $f);
- if (curl_exec($c)) {
- chmod($serverpath.$bn,0664); ?>
- File transfered! (<?php echo $u; ?> -> <?php echo $bn; ?>)<br>
- <?php } else { ?>
- Error transfering file! (<?php echo $u; ?>)<br>
- <?php }
- curl_close($c);
- fclose($f);
- }
- }
- }
- if (isset($_FILES['upfile'])) {
- if ($_FILES['upfile']['name'] == basename($_SERVER['SCRIPT_FILENAME'])) { ?>
- Invalid file!<br>
- <?php } elseif (move_uploaded_file($_FILES['upfile']['tmp_name'], $serverpath.$_FILES['upfile']['name'])) {
- chmod($serverpath.$_FILES['upfile']['name'],0664); ?>
- File sent!<br>
- <?php } else { ?>
- Error sending file!<br>
- <?php }
- } ?>
- Uploaded files:
- <table width="100%" border="1">
- <tr>
- <td>Sel</td>
- <td>Name</td>
- <td width="20%">Size</td>
- <td width="20%">Date/Time</td>
- <td width="10%"> </td>
- </tr>
- <form action="index.php" method="post">
- <?php
- $dir = opendir($serverpath);
- $f_total = 0;
- $files = array();
- while (false !== ($file = readdir($dir))) {
- $files[] = $file;
- }
- sort($files);
- foreach ($files as $file) if (($file != ".") and ($file != "..") and ($file != basename($_SERVER['SCRIPT_FILENAME']))) { ?>
- <tr>
- <td><input type="checkbox" name="killfiles[]" value="<?php echo $file; ?>"></td>
- <td><a href="<?php echo $serverpath_url.$file; ?>"><?php echo $file; ?></a></td>
- <td align="right"><?php echo ShowSize(filesize($serverpath.$file)); ?> </td>
- <?php $f_total += (filesize($serverpath.$file)); ?>
- <td align="right"><?php echo date ("Y-m-d H:i:s", filemtime($serverpath.$file)); ?> </td>
- <td align="right"><a href="<?php echo basename($_SERVER['SCRIPT_FILENAME']); ?>?kill=<?php echo $file; ?>">Delete</a>
- </tr>
- <?php
- }
- ?>
- <tr>
- <td><br>Disk space used:</td>
- <td align="right"><?php echo ShowSize($f_total); ?> </td>
- <td colspan="3"> </td>
- </tr>
- <tr>
- <td colspan="5"><input type="submit" value="Delete Selected"></td>
- </tr>
- </form>
- </table>
- <?php if ($f_total <= $max) { ?>
- <form enctype="multipart/form-data" action="index.php" method="POST">
- Send this file: <input name="upfile" type="file">
- <input type="submit" value="Send">
- </form>
- <form enctype="multipart/form-data" action="index.php" method="POST">
- Get this URL(s):
- <textarea name="url" cols="80" rows="5"></textarea>
- <input type="submit" value="Get">
- </form>
- <?php } else { ?>
- <br><span><?php echo "Exceeded maximum disk space quota! ({$max})"; ?></span><br>
- <?php } ?>
- </body>
- </html>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment