Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // DELETE THE USER-SPECIFIED FILES
- if(isset($_POST['submit'])) {
- $deletedFile = $_POST['file'];
- if(empty($deletedFile)) {
- echo("<div class='error'>You didn't choose to delete any files.</div>");
- }
- else {
- $query = "SELECT `bandwhitch`, `freeSpace`
- FROM members
- WHERE uname='$_SESSION[user]'";
- $result = mysql_query($query) or die(mysql_error());
- if (mysql_num_rows($result) > 0) {
- $row = mysql_fetch_array($result) or die(mysql_error());
- $deletedFiles = $row['bandwhitch'] - $totalSizeDeletedFiles; // Gets the new bandwhitch total
- mysql_query("UPDATE members SET bandwhitch = '$deletedFiles' WHERE uname='$_SESSION[user]'");
- $freeSpace = $row['freeSpace'] + $totalSizeDeletedFiles; // Update the free space left on their account
- mysql_query("UPDATE members SET freeSpace = '$freeSpace' WHERE uname='$_SESSION[user]'");
- mysql_close($uploader);
- }
- for ($i=0; $i<$count; $i++) {
- if ($i == $count-1) { // if this is the last file that they are deleting... use "and"
- unlink("users/" . $_SESSION['user'] . "/uploads/" . $deletedFile[$i]);
- echo (" and <b>" . $deletedFile[$i] . "</b>.");
- }
- else {
- echo ("<b>" . $deletedFile[$i] . ", </b> ");
- unlink("users/" . $_SESSION['user'] . "/uploads/" . $deletedFile[$i]);
- }
- }
- }
- }
- // THIS SCRIPT SHOWS THE UPLOADED FILES
- if ($handle = opendir('users/' . $_SESSION['user'] . '/uploads/')) {
- print ("<form action='' method='post' id='deleteFiles' name='deleteFiles'> <table border=1 cellpadding='1' cellspacing='1' width='75%'>
- <TR><TH>File Name</TH><th>File Size</th><th>Delete</th><th>Date Last Modified</th><th>Download</th></TR>");
- while (false !== ($file = readdir($handle))) {
- if ($file != "." && $file != ".." && (!(is_dir($file)))) {
- print("<TR><Td>");
- if ((pathinfo($file, PATHINFO_EXTENSION)) == "mp4")
- {
- $_SESSION['videoFile'] = $_SESSION['user']."/uploads/".$file;
- echo "<a href='video/play.php' target='_blank'>$file</a>\n\n";
- }
- else if ((pathinfo($file, PATHINFO_EXTENSION)) == "txt" || (pathinfo($file, PATHINFO_EXTENSION)) == "doc" || (pathinfo($file, PATHINFO_EXTENSION)) == "docx")
- {
- $_SESSION['editDocumentText'] = $_SERVER['DOCUMENT_ROOT'] . "users/" . $_SESSION['user']."/uploads/".$file;
- echo "<a href='wysiwyg/text_editor.php' target='_blank'>$file</a>\n\n";
- }
- else if ((pathinfo($file, PATHINFO_EXTENSION)) == "mp3")
- {
- echo "<a href='music_player/iPlay.php?file=$file' target='_blank'>$file</a>\n\n";
- }
- else
- {
- echo "<a href='users/$_SESSION[user]/uploads/$file' target='_blank'>$file</a>\n";
- }
- print("</td><td>");
- $fileSize = round(((filesize($file)) / 1000),8); // Gets you MB
- echo $fileSize." MB <br>";
- $usedStorage = $fileSize + $usedStroage;
- print("</td>");
- print ("<td align='center'><input name='file' type='checkbox' value='$file' /></td>");
- print ("<td>" . date ('F d Y H:i:s.', filemtime($file)) . "</td>");
- print "<td><a href='download.php?f=". $file . "' target='_blank'><img src='http://www.mysite.com/Images/icn_file_download.png' width='50' height='50' title='Download this file!' style='margin-left:auto; margin-right:auto;' /></a></td>";
- }
- }
- print("</tr></table>");
- closedir($handle);
- }
- echo("<br><input type='submit' name='submit' id='submit' value='Delete Checked Files' />");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement