[Openfirst-cvscommit] members workspace.php,1.4,1.5
Brought to you by:
xtimg
From: <xt...@us...> - 2003-08-12 04:33:55
|
Update of /cvsroot/openfirst/members In directory sc8-pr-cvs1:/tmp/cvs-serv26851 Modified Files: workspace.php Log Message: Implement subdirectory functionality. Complete with customisable sub directory icons, and adding/removing sub directories, as well as support sub directories within sub directories, etc. Index: workspace.php =================================================================== RCS file: /cvsroot/openfirst/members/workspace.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** workspace.php 12 Aug 2003 02:33:41 -0000 1.4 --- workspace.php 12 Aug 2003 04:27:00 -0000 1.5 *************** *** 28,31 **** --- 28,35 ---- include("../config/globals.php"); + + if($_GET["filepath"] == "") { $filepath = "/"; } else {$filepath = $_GET["filepath"]; } + if($_POST["filepath"] != "") { $filepath = $_POST["filepath"]; } + // Get important data used throughout this. $wsu = mysql_query("SELECT * FROM ofirst_workspace_users WHERE user='$user->user';"); *************** *** 78,81 **** --- 82,92 ---- die(include($footer)); } + if($_POST["action"] == "makedirectory") { + mkdir(getcwd() . "/virtfs/$user->user/$filepath/" . $_POST["directory"]); + $uf = mysql_query("INSERT INTO ofirst_workspace_files (size, location, owner, permissions, date, description, filetype, name) VALUES('0', '$filepath', '$user->user', 'drw-------', '" . date('D M d Y h:m:s') . "', 'Sub Directory', 'dir-" . $_POST["directorytype"] . "', '" . $_POST["directory"] . "');"); + echo("Sub directory Created [<a href='workspace.php?filepath=$filepath'>Return to Workspace</a> ]"); + + die(include($footer)); + } if(isset($_GET["action"])) { *************** *** 93,100 **** die(include($footer)); } // Handle file modification if($_GET["action"] == "modify") { ! $fi = mysql_fetch_object(mysql_query("SELECT * FROM ofirst_workspace_files WHERE name='" . $_GET["file"] . "' AND location='" . $_GET["filepath"] . "' ! AND owner='" . $_GET["owner"] . "';")); echo("<h1>Modify " . $_GET["file"] . "</h1> <table style='width: 500px;'> --- 104,144 ---- die(include($footer)); } + // Handle directory deletion + if($_GET["action"] == "removedirectory" && isset($_GET["confirmed"]) == true) { + $del = mysql_query("DELETE FROM ofirst_workspace_files WHERE name='" . $_GET["directory"] . "' AND owner='$user->user' AND location='" . $_GET["filepath"] ."';"); + + // deldir() based on code originally written by: fl...@cu... + + function deldir($dir){ + $current_dir = opendir($dir); + while($entryname = readdir($current_dir)){ + if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){ + deldir("${dir}/${entryname}"); + } elseif($entryname != "." and $entryname!="..") { + unlink("${dir}/${entryname}"); + } + } + closedir($current_dir); + rmdir(${dir}); + } + + if($filepath =="/") { + deldir($ws->virtfspath . $_GET["directory"]); + } else { + deldir($ws->virtfspath . $filepath . $_GET["directory"]); + } + echo("The sub directory <strong>"" . $_GET["directory"] . ""</strong> has been deleted. [ <a href='workspace.php'>Workspace</a> ]"); + die(include($footer)); + } elseif($_GET["action"] == "removedirectory" && isset($_GET["confirmed"]) == false) { + echo("Are you sure you want to delete "" . $_GET["directory"] . "" in the " . $_GET["filepath"] . " directory? This <strong>will also remove all + sub directories and files underneath the sub directory.</strong> + <br><a href='workspace.php?confirmed=true&directory=" . $_GET["directory"] . "&action=removedirectory&filepath=" . $_GET["filepath"] . + "'>Yes, I'm sure</a> <a href='workspace.php'>No, I've changed my mind</a>"); + die(include($footer)); + + } // Handle file modification if($_GET["action"] == "modify") { ! $fi = mysql_fetch_object(mysql_query("SELECT * FROM ofirst_workspace_files WHERE name='" . $_GET["file"] . "' AND location='" . $_GET["filepath"] . "' AND owner='" . $_GET["owner"] . "';")); echo("<h1>Modify " . $_GET["file"] . "</h1> <table style='width: 500px;'> *************** *** 124,133 **** <br>User: <select name="userperm"> ! <option value="-r--" <?php if(substr($fi->permissions, 0,4) == "-r--") { echo ! "selected='selected'"; } ?>>View</option> ! <option value="--w-" <?php if(substr($fi->permissions, 0,4) == "--w-") { echo ! "selected='selected'"; } ?>>Modify</option> ! <option value="-rw-" <?php if(substr($fi->permissions, 0,4) == "-rw-") { echo ! "selected='selected'"; } ?>>View and Modify</option> </select> <br>Group: --- 168,174 ---- <br>User: <select name="userperm"> ! <option value="-r--" <?php if(substr($fi->permissions, 0,4) == "-r--") { echo "selected='selected'"; } ?>>View</option> ! <option value="--w-" <?php if(substr($fi->permissions, 0,4) == "--w-") { echo "selected='selected'"; } ?>>Modify</option> ! <option value="-rw-" <?php if(substr($fi->permissions, 0,4) == "-rw-") { echo "selected='selected'"; } ?>>View and Modify</option> </select> <br>Group: *************** *** 136,142 **** <option value="r--" <?php if(substr($fi->permissions, 4,3) == "r--") { echo "selected='selected'"; } ?>>View</option> <option value="-w-" <?php if(substr($fi->permissions, 4,3) == "-w-") { echo "selected='selected'"; } ?>>Modify</option> ! <option value="rw-" <?php if(substr($fi->permissions, 4,3) == "rw-") { echo "selected='selected'"; } ?> ! ! >View and Modify</option> </select> <br>Other: --- 177,181 ---- <option value="r--" <?php if(substr($fi->permissions, 4,3) == "r--") { echo "selected='selected'"; } ?>>View</option> <option value="-w-" <?php if(substr($fi->permissions, 4,3) == "-w-") { echo "selected='selected'"; } ?>>Modify</option> ! <option value="rw-" <?php if(substr($fi->permissions, 4,3) == "rw-") { echo "selected='selected'"; } ?>>View and Modify</option> </select> <br>Other: *************** *** 223,228 **** <p><?php if($_GET["filepath"] == "") { $filepath = "/"; } else {$filepath = $_GET["filepath"]; } ! $files = mysql_fetch_object(mysql_query("SELECT SUM(size) as used FROM ofirst_workspace_files ! WHERE owner='$user->user';")); if(mysql_num_rows($wsu) == 1) { ?> --- 262,266 ---- <p><?php if($_GET["filepath"] == "") { $filepath = "/"; } else {$filepath = $_GET["filepath"]; } ! $files = mysql_fetch_object(mysql_query("SELECT SUM(size) as used FROM ofirst_workspace_files WHERE owner='$user->user';")); if(mysql_num_rows($wsu) == 1) { ?> *************** *** 231,234 **** --- 269,273 ---- <table style="width: 155px;"> <tr><th style="width: 50px;">User</th><td><?php echo $ws->user; ?></td></tr> + <tr><th style="width: 50px;">Home</th><td><a href='workspace.php?filepath=/'>Home</a></td></tr> <tr><th style="width: 50px;">Usage</th><td style="width: 105px;"> *************** *** 238,248 **** <br><?php echo(round($files->used / 1024, 2) . " of $ws->quota"); ?> Megabytes</td></tr> </table></td><td> <p><strong>Your Files (<?php echo($filepath); ?>)</strong></p> <table> <?php ! $files = mysql_query("SELECT * FROM ofirst_workspace_files WHERE owner='$user->user' AND location='$filepath';"); ! echo("<tr><th>File ! Type</th><th>Name</th><th>Division</th><th>Permissions</th><th>Date</th><th>Description</th> ! <th>Actions</th></tr>"); while($file = mysql_fetch_object($files)) { $file->name = str_replace("\"", """, $file->name); --- 277,301 ---- <br><?php echo(round($files->used / 1024, 2) . " of $ws->quota"); ?> Megabytes</td></tr> </table></td><td> + <?php + $dirs = mysql_query("SELECT * FROM ofirst_workspace_files WHERE permissions like 'd%' AND owner='$user->user' AND location='$filepath';"); + if(mysql_num_rows($dirs) > 0) { + ?> + <p><strong>Your Sub Directories (<?php echo($filepath); ?>)</strong></p> + <table> + <?php + echo("<tr><th>Icon</th><th>Name</th><th>Date Created</th><th>Actions</th></tr>"); + while($d = mysql_fetch_object($dirs)) { + echo("<tr><td>" . fileicon($d->filetype) . "</td><td><a href='workspace.php?filepath=$d->location$d->name'>$d->name</a></td><td>$d->date</td><td><a href='workspace.php?action=removedirectory&directory=$d->name&filepath=$filepath'>Remove Directory</a></td></tr>"); + } + ?> + </table> + <?php + } + ?> <p><strong>Your Files (<?php echo($filepath); ?>)</strong></p> <table> <?php ! $files = mysql_query("SELECT * FROM ofirst_workspace_files WHERE permissions not like 'd%' AND owner='$user->user' AND location='$filepath';"); ! echo("<tr><th>File Type</th><th>Name</th><th>Division</th><th>Permissions</th><th>Date</th><th>Description</th> <th>Actions</th></tr>"); while($file = mysql_fetch_object($files)) { $file->name = str_replace("\"", """, $file->name); *************** *** 256,259 **** --- 309,350 ---- ?> </table> + Make a directory: + <form action="workspace.php" method="post"> + <input type="hidden" name="action" value="makedirectory"> + <input type="hidden" name="filepath" value="<?php echo $filepath; ?>"> + <table> + <tr><th>Directory Name</th><td><input type="text" name="directory"></td></tr> + <tr><th>Directory Type</th><td> + <select name="directorytype"> + <option value="folder.png" selected="selected">Standard (Blue)</option> + <option value="folder_green.png">Green</option> + <option value="folder_orange.png">Orange</option> + <option value="folder_red.png">Red</option> + <option value="folder_yellow.png">Yellow</option> + <option value="folder_grey.png">Grey</option> + <option value="folder_violet.png">Violet</option> + <option value="trashcan_full.png">Junk</option> + <option value="favorites.png">Favourites (Star)</option> + <option value="folder_cool.png">Smiley</option> + <option value="folder_penguin.png">Penguin</option> + <option value="folder_cd.png">CD-ROM</option> + <option value="folder_home.png">Home</option> + <option value="folder_html.png">Web</option> + <option value="folder_image.png">Images</option> + <option value="folder_important.png">Important</option> + <option value="folder_man.png">Documentation</option> + <option value="folder_midi.png">Midi</option> + <option value="folder_sound.png">Sound</option> + <option value="folder_tar.png">Archive</option> + <option value="folder_video.png">Video</option> + <option value="network_local.png">Network</option> + <option value="folder_txt.png">Text Documents</option> + <option value="folder_wordprocessing.png">Wordprocessing</option> + </select> + </td></tr> + <tr><th>Make</th><td><input type="submit" value="Make Directory"></td></tr> + </table> + </form> + Add a file: <?php *************** *** 308,314 **** <?php $files = mysql_query("SELECT * FROM ofirst_workspace_files WHERE permissions like '____r%';"); ! echo("<tr><th>File ! Type</th><th>Name</th><th>Owner</th><th>Division</th><th>Permissions</th><th>Date</th><th>Description</th> ! <th>Actions</th></tr>"); while($file = mysql_fetch_object($files)) { echo("<tr><td>" . fileicon($file->filetype) . --- 399,404 ---- <?php $files = mysql_query("SELECT * FROM ofirst_workspace_files WHERE permissions like '____r%';"); ! echo("<tr><th>File Type</th><th>Name</th><th>Owner</th><th>Division</th><th>Permissions</th><th>Date</th><th>Description</th> ! <th>Actions</th></tr>"); while($file = mysql_fetch_object($files)) { echo("<tr><td>" . fileicon($file->filetype) . *************** *** 326,339 **** <?php $files = mysql_query("SELECT * FROM ofirst_workspace_files WHERE permissions like '%r__';"); ! echo("<tr><th>File ! Type</th><th>Name</th><th>Owner</th><th>Division</th><th>Permissions</th><th>Date</th><th>Description</th> ! <th>Actions</th></tr>"); while($file = mysql_fetch_object($files)) { echo("<tr><td>" . fileicon($file->filetype) . ! "</td><td>$file->name</td><td>$file->owner</td><td>$file->division</td> ! <td>$file->permissions</td><td>$file->date</td><td>$file->description</td><td> ! <a href='workspace.php?file=$file->name&owner=$file->owner&action=view&filepath=$filepath'>View</a> ! <br><a href='workspace.php?file=$file->name&owner=$file->owner&action=modify&filepath=$filepath'>Modify</a> ! </td></tr>"); } ?> --- 416,428 ---- <?php $files = mysql_query("SELECT * FROM ofirst_workspace_files WHERE permissions like '%r__';"); ! echo("<tr><th>File Type</th><th>Name</th><th>Owner</th><th>Division</th><th>Permissions</th><th>Date</th><th>Description</th> ! <th>Actions</th></tr>"); while($file = mysql_fetch_object($files)) { echo("<tr><td>" . fileicon($file->filetype) . ! "</td><td>$file->name</td><td>$file->owner</td><td>$file->division</td> ! <td>$file->permissions</td><td>$file->date</td><td>$file->description</td><td> ! <a href='workspace.php?file=$file->name&owner=$file->owner&action=view&filepath=$filepath'>View</a> ! <br><a href='workspace.php?file=$file->name&owner=$file->owner&action=modify&filepath=$filepath'>Modify</a> ! </td></tr>"); } ?> |