diff --git a/filemanager/admin.php b/filemanager/admin.php new file mode 100755 index 0000000000..bf95896276 --- /dev/null +++ b/filemanager/admin.php @@ -0,0 +1,136 @@ + + +$phpgw_info["flags"] = array("currentapp" => "phpwebhosting"); +include("../header.inc.php"); +error_reporting (4); + +if ($update == 1) +{ + if ($commit) + { + $query = sql_query ("SELECT shortcut FROM settings"); + while ($array = mysql_fetch_array ($query)) + { + $shortcutvar = addslashes ($$array["shortcut"]); + $query2 = sql_query ("UPDATE settings SET info = '$shortcutvar' WHERE shortcut = '$array[shortcut]'"); + header ("Location: $hostname/admin.php"); + } + } + + elseif ($set) + { + $query = sql_query ("SELECT shortcut FROM settings"); + while ($array = mysql_fetch_array ($query)) + { + $shortcut = $array["shortcut"]; + $shortcutvar = addslashes ($$shortcut); + $query2 = sql_query ("UPDATE settings SET original = '$shortcutvar' WHERE shortcut = '$shortcut'"); + $query3 = sql_query ("UPDATE settings SET info = original"); + header ("Location: $hostname/admin.php"); + } + } + + elseif ($reset) + { + $query = sql_query ("UPDATE settings SET info = original"); + header ("Location: $hostname/admin.php"); + } +} + +html_page_begin ("Administration"); +html_page_body_begin (); +html_text_italic ("This is the administration section. Here you can change most everything. Be careful, because your changes affect the entire site, including this page."); +html_break (1); +html_text_italic (htmlspecialchars ('"Strings" are arbitrary text included inside of the HTML tags. For example, "Body String" would be in the
tag. An example would be "text=blue".')); +html_break (1); +html_text_italic ('"Shortcuts" are used mostly by developers'); +html_break (2); +html_form_begin ("$hostname/users.php?op=logout"); +html_form_input ("submit", NULL, "Log Out"); +html_form_end (); +html_form_begin ("$hostname/admin.php?update=1"); +html_table_begin (); + +$query = sql_query ("SELECT DISTINCT category FROM settings"); +while ($cat = mysql_fetch_array ($query)) +{ + $cat = $cat["category"]; + html_table_row_begin (); + html_table_col_begin (); + html_text_header (2, ucwords ($cat)); + html_table_col_end (); + html_table_row_end (); + + $query2 = sql_query ("SELECT DISTINCT subcategory FROM settings WHERE category = '$cat'"); + while ($sub = mysql_fetch_array ($query2)) + { + $sub = $sub["subcategory"]; + html_table_row_begin (); + html_table_col_begin (); + html_table_col_end (); + html_table_col_begin (); + html_text_header (3, ucwords ($sub)); + html_table_col_end (); + html_table_row_end (); + + $query3 = sql_query ("SELECT DISTINCT subsubcategory FROM settings WHERE category = '$cat' AND subcategory = '$sub'"); + while ($subsub = mysql_fetch_array ($query3)) + { + $subsub = $subsub["subsubcategory"]; + html_table_row_begin (); + html_table_col_begin (); + html_table_col_end (); + html_table_col_begin (); + html_table_col_end (); + html_table_col_begin (); + html_text_header (4, ucwords ($subsub)); + html_table_col_end (); + html_table_row_end (); + + $query4 = sql_query ("SELECT * FROM settings WHERE category = '$cat' AND subcategory = '$sub' AND subsubcategory = '$subsub'"); + while ($settings = mysql_fetch_array ($query4)) + { + $desc = htmlspecialchars ($settings["description"]); + $original = htmlspecialchars ($settings["original"]); + if (($original == NULL || !$original) && !is_int ($original)) + $original = "None"; + $info = $settings["info"]; + $shortcut = $settings["shortcut"]; + html_table_row_begin (); + html_table_col_begin (); + html_table_col_end (); + html_table_col_begin (); + html_table_col_end (); + html_table_col_begin (); + html_table_col_end (); + html_table_col_begin (); + html_text_underline (ucwords ($desc)); + html_font_set (2); + html_break (1, html_nbsp (3, 1)); + html_text ("Shortcut: " . $shortcut); + html_break (1, html_nbsp (3, 1)); + html_text ("Default: " . $original); + html_break (1, html_nbsp (3, 1)); + html_font_end (); + html_form_textarea ($shortcut, 5, 50, $info); + html_table_col_end (); + html_table_row_end (); + } + } + } + +} + +html_table_end (); +html_break (2); +html_form_input ("submit", "commit", "Commit changes"); +html_nbsp (10); +html_form_input ("submit", "set", "Save changes as Defaults"); +html_nbsp (10); +html_form_input ("reset", NULL, "Reset to Session Defaults"); +html_nbsp (10); +html_form_input ("submit", "reset", "Reset to Saved Defaults"); +html_form_end (); +html_page_close (); + +?> diff --git a/filemanager/groups.php b/filemanager/groups.php new file mode 100755 index 0000000000..97ef1a2ba1 --- /dev/null +++ b/filemanager/groups.php @@ -0,0 +1,729 @@ + + +require ("main.inc"); +error_reporting (4); + +### +# Authenticate user +### + +$userinfo = check_auth(); + +### +# Groups can allow/disallow access for anonymous users +# Update: actually not anymore, but we still need this +# for a few display options +### + +if ($userinfo["username"] == "anonymous") + $anonymous = 1; + +if (!$group) + choose_group (); + +$query = sql_query ("SELECT * FROM groupinfo WHERE groupname = '$group'"); + +if (!$groupinfo = mysql_fetch_array($query)) + choose_group ("Group $group does not exist"); + +$group_access = group_auth (); + +### +# Something's gone wrong if we get GROUP_NONE +### + +if ($group_access <= GROUP_NONE) + choose_group ("You do not have access to $groupinfo[groupname]"); + +if ($group_access >= GROUP_VIEW) + $view = 1; + +if ($group_access >= GROUP_WRITE) + $write = 1; + +if ($group_access >= GROUP_ADMIN) + $admin = 1; + +if ($group_access >= GROUP_FOUNDER) + $founder = 1; + +$phpwh->fs->set_account_type ("group"); + +$query = sql_query ("SELECT * FROM groupinfo WHERE groupname = '$group'"); + +if (!$sortby) + $sortby = "name"; + +if (!$path) + $path = "/"; + +if ($path != "/" && $nextdir) + $path = $path . "/" . $nextdir; +else + $path = $path . $nextdir; + +if ($path == "/") + $disppath = ""; +else + $disppath = $path; + +$cwd = substr ($path, strrpos ($path, "/") +1); + +if (!($lesspath = substr ($path, 0, strrpos ($path, "/")))) + $lesspath = "/"; + +if ($rename) +{ + for ($j = 0; $j != $numoffiles; $j++) + $filesman = array_push ($fileman[$j]); +} + +if ($path != "/") +{ + $query = sql_query ("SELECT name FROM groupfiles WHERE groupname = '$groupinfo[groupname]' AND name = '$cwd' AND type = 'Directory' AND directory = '$lesspath'"); + if (!mysql_fetch_row($query)) + { + html_text_error ("Directory does not exist", 1); + html_link ("$hostname/groups.php?group=$groupinfo[groupname]", HTML_TEXT_NAVIGATION_BACK_TO_GROUP); + exit; + } +} + +$query = sql_query ("SELECT * FROM groupfiles WHERE groupname = '$groupinfo[groupname]' AND directory = '$path' ORDER BY $sortby"); +$files = mysql_fetch_array($query); +$numoffiles = mysql_affected_rows($db_main); + +if ($op != 'showinfo' && $op != 'changeinfo' && $op != 'delete') +{ + html_page_begin ("Groups :: $groupinfo[groupname]"); + html_page_body_begin (HTML_PAGE_BODY_COLOR); +} + +if (!$op && !$delete && !$createdir && !$renamefiles) +{ + html_table_begin ("100%"); + html_table_row_begin (); + html_table_col_begin (NULL, NULL, "top"); + html_font_set (2); + html_text ("Welcome to " . html_text_bold ("$groupinfo[groupname]", 1)); + html_break (2, html_text_bold ("$userinfo[username]", 1)); + + if ($anonymous) + { + html_break (2, html_link ("$hostname/login.php", "Login", 1)); + html_break (2, html_link ("$hostname/signup.php", "Create an account", 1)); + } + else + html_break (2, html_link ("$hostname/users.php", "Your user page", 1)); + + if ($admin) + html_break (2, html_link ("$hostname/groups.php?group=$groupinfo[groupname]&op=showinfo", "Edit this group", 1)); + + if ($founder) + html_break (2, html_link ("$hostname/groups.php?group=$groupinfo[groupname]&op=delete", "Delete this group", 1)); + + html_break (2, html_link ("$hostname/index.php", "Home", 1)); + html_break (2); + html_break (1); + + html_text_bold ($group_access_names[$group_access]); + html_text ("access"); + html_font_end (); + html_table_col_end (); + html_table_col_begin ("center", NULL, "top"); + html_align ("center"); + html_form_begin ("$hostname/groups.php?group=$groupinfo[groupname]&path=$path"); + if ($numoffiles || $cwd) + { + html_table_begin (); + html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_HEADER_BG_COLOR); + html_table_col_begin ("center", NULL, NULL, NULL, 8); + html_table_begin ("100%"); + html_table_row_begin (); + html_table_col_begin ("left"); + + if ($cwd) + html_link ("$hostname/groups.php?group=$groupinfo[groupname]&path=$lesspath", html_image ("$hostname/images/folder-up.gif", "Up", "left", 0, NULL, 1)); + html_table_col_end (); + html_table_col_begin ("center"); + + if ($cwd) + html_image ("$hostname/images/folder.gif", "Folder", "center"); + else + html_image ("$hostname/images/folder-home.gif", "Home"); + + html_font_set (4, HTML_TABLE_FILES_HEADER_TEXT_COLOR); + html_text_bold (strtoupper($cwd)); + html_table_col_end (); + html_table_col_begin ("right"); + + if ($cwd) + html_link ("$hostname/groups.php?group=$groupinfo[groupname]", html_image ("$hostname/images/folder-home.gif", "Home", "right", 0, NULL, 1)); + + html_table_col_end (); + html_table_row_end (); + html_table_end (); + html_table_col_end (); + html_table_row_end (); + html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR); + + ### + # Start File Table Column Headers + ### + + html_table_col_begin (); + html_text ("Sort by:" . html_nbsp (5, 1)); + html_table_col_end (); + + html_table_col_begin (); + html_link ("$hostname/groups.php?group=$groupinfo[groupname]&path=$path&sortby=name", html_text_bold ("Filename", 1)); + html_table_col_end (); + + html_table_col_begin (); + html_link ("$hostname/groups.php?group=$groupinfo[groupname]&path=$path&sortby=type", html_text_bold ("Type", 1)); + html_table_col_end (); + + html_table_col_begin (); + html_link ("$hostname/groups.php?group=$groupinfo[groupname]&path=$path&sortby=size", html_text_bold ("Size", 1)); + html_table_col_end (); + + html_table_col_begin (); + html_link ("$hostname/groups.php?group=$groupinfo[groupname]&path=$path&sortby=createdby", html_text_bold ("Created By", 1)); + html_table_col_end (); + + html_table_col_begin (); + html_link ("$hostname/groups.php?group=$groupinfo[groupname]&path=$path&sortby=modifiedby", html_text_bold ("Modified By", 1)); + html_table_col_end (); + + html_table_col_begin (); + html_link ("$hostname/groups.php?group=$groupinfo[groupname]&path=$path&sortby=created", html_text_bold ("Created", 1)); + html_table_col_end (); + + html_table_col_begin (); + html_link ("$hostname/groups.php?group=$groupinfo[groupname]&path=$path&sortby=modified", html_text_bold ("Modified", 1)); + html_table_col_end (); + + html_table_col_begin (); + html_table_col_end (); + html_table_row_end (); + + ### + # List all of the files, with their attributes + ### + + $i = 0; + while ($i != $numoffiles) + { + if ($rename) + { + unset($renamethis); + for ($j = 0; $j != $numoffiles; $j++) + { + if ($fileman[$j] == $files["name"]) + { + $renamethis = 1; + break; + } + } + } + + html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_BG_COLOR); + html_table_col_begin ("right"); + + if ($write) + { + if (!$rename) + html_form_input ("checkbox", "fileman[$i]", "$files[name]"); + elseif ($renamethis) + html_form_input ("checkbox", "fileman[$files[name]]", "$files[name]", NULL, NULL, "checked"); + else + html_nbsp; + } + + html_table_col_end (); + html_table_col_begin (); + + if ($renamethis) + { + if ($files["type"] == "Directory") + html_image ("$hostname/images/folder.gif", "Folder"); + html_form_input ("text", "renamefiles[$files[name]]", "$files[name]", 255); + } + else + { + if ($files["type"] == "Directory") + { + html_image ("$hostname/images/folder.gif", "Folder"); + html_link ("$hostname/groups.php?group=$groupinfo[groupname]&path=$path&nextdir=$files[name]", $files["name"]); + } + else + { + html_link ("$hostname/groups/$groupinfo[groupname]$disppath/$files[name]", $files["name"]); + } + } + + html_table_col_end (); + html_table_col_begin (); + html_text ($files["type"]); + html_table_col_end (); + html_table_col_begin (); + + if ($files["type"] == "Directory") + { + $query2 = sql_query ("SELECT SUM(size) FROM groupfiles WHERE groupname = '$groupinfo[groupname]' AND directory RLIKE '^$disppath/$files[name]'"); + $fileinfo = mysql_fetch_row($query2); + if ($fileinfo[0]) + borkb($fileinfo[0]+1024); + else + echo "1KB"; + } + else + borkb($files["size"]); + + html_table_col_end (); + + html_table_col_begin (); + html_text ($files["createdby"]); + html_table_col_end (); + + html_table_col_begin (); + html_text ($files["modifiedby"]); + html_table_col_end (); + + html_table_col_begin (); + html_text ($files["created"]); + html_table_col_end (); + + html_table_col_begin (); + html_text ($files["modified"]); + html_table_col_end (); + + html_table_col_begin (); + html_text ($files["owner"]); + html_table_col_end (); + + if ($files["deleteable"] == "N") + { + html_table_col_begin (); + html_image ("$hostname/images/locked.gif", "Locked"); + html_table_col_end (); + } + else + { + html_table_col_begin (); + html_table_col_end (); + } + + html_table_row_end (); + + if ($files["type"] == "Directory") + $usedspace += $fileinfo[0]; + else + $usedspace += $files["size"]; + $files = mysql_fetch_array($query); + $i++; + } + + html_table_end (); + html_break (2); + + if ($write) + { + html_form_input ("submit", "rename", "Rename"); + html_nbsp (3); + if (!$rename) + { + html_form_input ("submit", "delete", "Delete"); + html_nbsp (3); + } + } + } + if (!$rename) + { + if ($write) + { + html_form_input ("text", "createdir", NULL, 255); + html_nbsp (); + html_form_input ("submit", "newdir", "Create Folder"); + html_form_end (); + } + + html_break (1); + html_text_bold ("Files: "); + html_text ($numoffiles); + html_nbsp (3); + + html_text_bold ("Used space: "); + html_text (borkb ($usedspace, NULL, 1)); + html_nbsp (3); + + if ($path == "/") + { + html_text_bold ("Unused space: "); + html_text (borkb ($groupinfo["hdspace"] - $usedspace, NULL, 1)); + + $query = sql_query ("SELECT name FROM groupfiles WHERE groupname = '$groupinfo[groupname]'"); + $i = mysql_affected_rows($db_main); + + html_break (2); + html_text_bold ("Total Files: "); + html_text ($i); + } + } + if ($write) + { + html_break (2); + html_form_begin ("$hostname/groups.php?group=$groupinfo[groupname]&op=upload&path=$path", "post", "multipart/form-data"); + html (html_form_input ("file", "file[]", NULL, 255, NULL, NULL, NULL, 1) . "\n"; + $imgfile = $phpgw->common->get_image_dir ($appname) . '/' . $appname . '.gif'; + if (file_exists ($imgfile)) + { + $imgpath = $phpgw->common->get_image_path ($appname) . '/' . $appname . '.gif'; + } + else + { + $imgfile = $phpgw->common->get_image_dir ($appname) . '/navbar.gif'; + if (file_exists ($imgfile)) + { + $imgpath = $phpgw->common->get_image_path ($appname) . '/navbar.gif'; + } + else + { + $imgpath = ''; + } + } + + section_start (ucfirst ($appname), $imgpath); + + echo '' . lang ('PHPWebHosting preferences') . ''; + + section_end (); +} +?> diff --git a/filemanager/inc/html.inc.php b/filemanager/inc/html.inc.php new file mode 100755 index 0000000000..f5c65aaa46 --- /dev/null +++ b/filemanager/inc/html.inc.php @@ -0,0 +1,411 @@ + + +function html_form_begin ($action, $method = "post", $enctype = NULL, $string = HTML_FORM_BEGIN_STRING, $return = 0) +{ + global $phpgw; + global $sep; + + $action = string_encode ($action, 1); + $action = $sep . $action; + $action = $phpgw->link ($action); + + if ($method != NULL && $method) + $method = "method=$method"; + if ($enctype != NULL && $enctype) + $enctype = "enctype=$enctype"; + $rstring = "
'; + return (eor ($rstring, $return)); +} + +function html_nbsp ($times = 1, $return = 0) +{ + if ($times == NULL) + $times = 1; + for ($i = 0; $i != $times; $i++) + { + if ($return) + $rstring .= " "; + else + echo " "; + } + if ($return) + return ($rstring); +} + +function html ($string, $times = 1, $return = 0) +{ + for ($i = 0; $i != $times; $i++) + { + if ($return) + $rstring .= $string; + else + echo $string; + } + if ($return) + return ($rstring); +} + +function html_break ($break, $string = "", $return = 0) +{ + if ($break == 1) + $break = ''; + if ($break == 5) + $break = '
";
+ return (eor ($rstring, $return));
+}
+
+function html_image ($src = NULL, $alt = NULL, $align = NULL, $border = NULL, $string = HTML_IMAGE_MAIN_STRING, $return = 0)
+{
+ if ($src != NULL && $src)
+ $src = "src=$src";
+ if ($alt != NULL && $alt)
+ $alt = "alt=\"$alt\"";
+ if ($align != NULL && $align)
+ $align = "align=$align";
+ if (is_int ($border) && $border >= 0)
+ $border = "border=$border";
+ $rstring = "";
+ return (eor ($rstring, $return));
+}
+
+?>
diff --git a/filemanager/inc/main.inc.php b/filemanager/inc/main.inc.php
new file mode 100755
index 0000000000..ecbf7f66c3
--- /dev/null
+++ b/filemanager/inc/main.inc.php
@@ -0,0 +1,159 @@
+
+
+### Start Configuration Options ###
+### These are automatically set in phpGW - do not edit ###
+
+$sep = $phpgw_info["server"]["dir_separator"];
+$filesdir = $phpgw_info["server"]["files_dir"];
+$rootdir = $phpgw->vfs->basedir;
+$fakebase = $phpgw->vfs->fakebase;
+$hostname = $phpgw_info["server"]["webserver_url"] . $filesdir;
+$appname = $phpgw_info["flags"]["currentapp"];
+$settings = $phpgw_info["user"]["preferences"][$appname];
+
+### End Configuration Options ###
+
+define ("NULL", "");
+
+require ("./inc/db.inc.php");
+
+/* Set up any initial db settings */
+db_init ();
+
+###
+# Get user settings from database
+###
+
+/* We have to define these by hand in phpGW, or rely on it's templates */
+
+define ('HTML_TABLE_FILES_HEADER_BG_COLOR', "");
+define ('HTML_TABLE_FILES_HEADER_TEXT_COLOR', "maroon");
+define ('HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR', "");
+define ('HTML_TABLE_FILES_COLUMN_HEADER_TEXT_COLOR', "maroon");
+define ('HTML_TABLE_FILES_BG_COLOR', "");
+define ('HTML_TABLE_FILES_TEXT_COLOR', "maroon");
+define ('HTML_TEXT_ERROR_COLOR', "red");
+define ('HTML_TEXT_NAVIGATION_BACK_TO_USER', "Back to file manager");
+
+###
+# Need to include this here so they recognize the settings
+###
+
+require ("./inc/html.inc.php");
+
+###
+# Define the list of file attributes. Format is "internal_name" => "Displayed name"
+# This is used both by internally and externally for things like preferences
+###
+
+$file_attributes = array ("name" => "Filename", "mime_type" => "MIME Type", "size" => "Size", "created" => "Created", "modified" => "Modified", "owner" => "Owner", "createdby_id" => "Created by", "modifiedby_id" => "Created by", "modifiedby_id" => "Modified by", "app" => "Application", "comment" => "Comment");
+
+###
+# Calculate and display B or KB
+# And yes, that first if is strange,
+# but it does do something
+###
+
+function borkb ($size, $enclosed = NULL, $return = 0)
+{
+ if (!$size)
+ $size = 0;
+
+ if ($enclosed)
+ {
+ $left = "(";
+ $right = ")";
+ }
+
+ if ($size < 1024)
+ $rstring = $left . $size . "B" . $right;
+ else
+ $rstring = $left . round($size/1024) . "KB" . $right;
+
+ return (eor ($rstring, $return));
+}
+
+###
+# Check for and return the first unwanted character
+###
+
+function bad_chars ($string, $return = 0)
+{
+ if (preg_match("-([\\\|/|\||\?|\`|\@|\#|\$|%|\&|\*|\(|\)|\[|\{|\]|\}|\;|\:|\"|\'|\<|\>|\,|\ ])-", $string, $badchars))
+ $rstring = $badchars[1];
+
+ return trim ((eor ($rstring, $return)));
+}
+
+###
+# Check for and return the first character that can't be used in a file or directory name
+###
+
+function bad_chars_file ($string, $return = 0)
+{
+ if (preg_match ("-([\\\|\/|\&|\(|\)])-", $string, $badchars))
+ $rstring = $badchars[1];
+
+ return trim ((eor ($rstring, $return)));
+}
+
+###
+# Decide whether to echo or return. Used by HTML functions
+###
+
+function eor ($rstring, $return)
+{
+ if ($return)
+ return ($rstring);
+ else
+ {
+ html_text ($rstring . "\n");
+ return (0);
+ }
+}
+
+###
+# URL encode a string
+# First check if its a query string, then if its just a URL, then just encodes it all
+# Note: this is a hack. It was made to work with form actions, form values, and links only,
+# but should be able to handle any normal query string or URL
+###
+
+function string_encode ($string, $return)
+{
+ global $hostname;
+
+ if (preg_match ("/=(.*)(&|$)/U", $string))
+ $rstring = preg_replace ("/=(.*)(&|$)/Ue", "'=' . rawurlencode ('\\1') . '\\2'", $string);
+ elseif (ereg ("^$hostname", $string))
+ {
+ $rstring = ereg_replace ("^$hostname/", "", $string);
+ $rstring = preg_replace ("/(.*)(\/|$)/Ue", "rawurlencode ('\\1') . '\\2'", $rstring);
+ $rstring = "$hostname/$rstring";
+ }
+ else
+ {
+ $rstring = rawurlencode ($string);
+
+ /* Terrible hack, decodes all /'s back to normal */
+ $rstring = preg_replace ("/%2F/", "/", $rstring);
+ }
+
+ return (eor ($rstring, $return));
+}
+
+function string_decode ($string, $return)
+{
+ $rstring = urldecode ($string);
+
+ return (eor ($rstring, $return));
+}
+
+function translate ($text)
+{
+ global $phpgw;
+
+ return ($phpgw->lang ($text));
+}
+
+?>
diff --git a/filemanager/index.php b/filemanager/index.php
new file mode 100755
index 0000000000..662f9c3963
--- /dev/null
+++ b/filemanager/index.php
@@ -0,0 +1,989 @@
+
+
+$phpgw_info["flags"] = array("currentapp" => "phpwebhosting",
+ "noheader" => False,
+ "noappheader" => False,
+ "enable_vfs_class" => True);
+include("../header.inc.php");
+
+error_reporting (4);
+
+###
+# Page to process users
+# Code is fairly hackish at the beginning, but it gets better
+# Highly suggest turning wrapping off due to long SQL queries
+###
+
+###
+# Note that $userinfo["username"] is actually the id number, not the login name
+###
+
+$userinfo["username"] = $phpgw_info["user"]["account_id"];
+$userinfo["account_lid"] = $phpgw->accounts->id2name ($userinfo["username"]);
+$userinfo["hdspace"] = 10000000000;
+$homedir = "$fakebase/$userinfo[account_lid]";
+
+###
+# Enable this to display some debugging info
+###
+
+$phpwh_debug = 0;
+
+if ($download && $fileman[0])
+{
+ $phpgw->browser->content_header ($fn);
+ echo $phpgw->vfs->read ($path/$fileman[0]);
+ $phpgw->common->phpgw_exit ();
+}
+
+###
+# Default is to sort by name
+###
+
+if (!$sortby)
+ $sortby = "name";
+
+###
+# Some hacks to set and display directory paths correctly
+###
+
+if (!$path)
+{
+ $path = $phpgw->vfs->pwd ();
+ if (!$path || $phpgw->vfs->pwd (False) == "")
+ $path = $homedir;
+}
+
+$extra_dir = substr ($path, strlen ($homedir) + 1);
+$phpgw->vfs->cd (False, False, array (RELATIVE_NONE));
+$phpgw->vfs->cd ($path, False, array (RELATIVE_NONE));
+
+$pwd = $phpgw->vfs->pwd ();
+
+if (!$cwd = substr ($path, strlen ($homedir) + 1))
+ $cwd = "/";
+else
+ $cwd = substr ($pwd, strrpos ($pwd, "/") + 1);
+
+$disppath = $path;
+
+/* This just prevents // in some cases */
+if ($path == "/")
+ $dispsep = "";
+else
+ $dispsep = "/";
+
+if (!($lesspath = substr ($path, 0, strrpos ($path, "/"))))
+ $lesspath = "/";
+
+$now = date ("Y-m-d");
+
+//This will hopefully be replaced by a session management working_id
+//if (!$phpgw->vfs->working_id = preg_replace ("/\$fakebase\/(.*)\/(.*)$/U", "\\1", $path))
+
+$userinfo["working_id"] = $phpgw->vfs->working_id;
+$userinfo["working_lid"] = $phpgw->accounts->id2name ($userinfo["working_id"]);
+
+if ($phpwh_debug)
+{
+ echo "PHPWebHosting debug:
+ path: $path
+ disppath: $disppath
+ cwd: $cwd
+ lesspath: $lesspath
+
+ phpGW debug:
+ real getabsolutepath: " . $phpgw->vfs->getabsolutepath (False, False, False) . "
+ fake getabsolutepath: " . $phpgw->vfs->getabsolutepath (False) . "
+ appsession: " . $phpgw->common->appsession () . "
+ pwd: " . $phpgw->vfs->pwd () . "
";
+}
+
+###
+# Verify path is real
+###
+
+if ($path != $homedir && $path != "/" && $path != $fakebase)
+{
+ if ($phpwh_debug)
+ {
+ echo "SELECT name FROM phpgw_vfs WHERE owner_id = '$userinfo[username]' AND name = '$cwd' AND mime_type = 'Directory' AND directory = '$lesspath'
";
+ }
+
+ $query = db_query ("SELECT name FROM phpgw_vfs WHERE owner_id = '$userinfo[username]' AND name = '$cwd' AND mime_type = 'Directory' AND directory = '$lesspath'");
+ if (!$phpgw->db->next_record ($query))
+ {
+ html_text_error ("Directory $dir does not exist", 1);
+ html_break (2);
+ html_link ("$appname/index.php?path=$homedir", "Go to your home directory");
+ html_break (2);
+ html_link_back ();
+ html_page_close ();
+ }
+}
+
+###
+# Read in file info from database to use in the rest of the script
+# $files in the loop below uses $query
+###
+
+$files_query = db_query ("SELECT * FROM phpgw_vfs WHERE owner_id = '$userinfo[username]' AND directory = '$path' AND name != '' ORDER BY $sortby");
+$numoffiles = db_call ("affected_rows", $files_query);
+
+###
+# Start Main Page
+###
+
+if ($op != "changeinfo" && $op != "logout" && $op != "delete")
+{
+ html_page_begin ("Users :: $userinfo[username]");
+ html_page_body_begin (HTML_PAGE_BODY_COLOR);
+}
+
+###
+# Start Main Table
+###
+
+if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$edit && !$comment_files)
+{
+ html_table_begin ("100%");
+ html_table_row_begin ();
+ html_table_col_begin ("center", NULL, "top");
+ html_align ("center");
+ html_form_begin ("$appname/index.php?path=$path");
+ if ($numoffiles || $cwd)
+ {
+ while (list ($num, $name) = each ($settings))
+ {
+ if ($name)
+ $columns++;
+ }
+ $columns++;
+ html_table_begin ();
+ html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_HEADER_BG_COLOR);
+ html_table_col_begin ("center", NULL, NULL, NULL, $columns);
+ html_table_begin ("100%");
+ html_table_row_begin ();
+ html_table_col_begin ("left");
+
+ if ($path != "/")
+ html_link ("$appname/index.php?path=$lesspath", html_image ("images/folder-up.gif", "Up", "left", 0, NULL, 1));
+
+ html_table_col_end ();
+ html_table_col_begin ("center");
+
+ if ($cwd)
+ {
+ if ($path == $homedir)
+ html_image ("images/folder-home.gif", "Folder", "center");
+ else
+ html_image ("images/folder.gif", "Folder", "center");
+ }
+ else
+ html_image ("images/folder-home.gif", "Home");
+
+ html_font_set (4, HTML_TABLE_FILES_HEADER_TEXT_COLOR);
+ html_text_bold (strtoupper ($disppath));
+ html_font_end ();
+ html_table_col_end ();
+ html_table_col_begin ("right");
+
+ if ($path != $homedir)
+ html_link ("$appname/index.php?path=$homedir", html_image ("images/folder-home.gif", "Home", "right", 0, NULL, 1));
+
+ html_table_col_end ();
+ html_table_row_end ();
+ html_table_end ();
+ html_table_col_end ();
+ html_table_row_end ();
+ html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR);
+
+ ###
+ # Start File Table Column Headers
+ # Reads values from $file_attributes array and preferences
+ ###
+
+ html_table_col_begin ();
+ html_text ("Sort by:" . html_nbsp (1, 1), NULL, NULL, 1);
+ html_table_col_end ();
+
+ reset ($file_attributes);
+ while (list ($internal, $displayed) = each ($file_attributes))
+ {
+ if ($settings[$internal])
+ {
+ html_table_col_begin ();
+ html_link ("$appname/index.php?path=$path&sortby=$internal", html_text_bold ("$displayed", 1, 1));
+ html_table_col_end ();
+ }
+ }
+
+ html_table_col_begin ();
+ html_table_col_end ();
+ html_table_row_end ();
+
+ if ($settings["dotdot"] && $settings["name"] && $path != "/")
+ {
+ html_table_row_begin ();
+ html_table_col_begin ();
+ html_table_col_end ();
+
+ /* We can assume the next column is the name */
+ html_table_col_begin ();
+ html_image ("images/folder.gif", "Folder");
+ html_link ("$appname/index.php?path=$lesspath", "..");
+ html_table_col_end ();
+
+ if ($settings["mime_type"])
+ {
+ html_table_col_begin ();
+ html_text ("Directory");
+ html_table_col_end ();
+ }
+
+ html_table_row_end ();
+ }
+
+ ###
+ # List all of the files, with their attributes
+ ###
+
+ for ($i = 0; $i != $numoffiles; $i++)
+ {
+ $files = db_fetch_array ($files_query);
+
+ if ($rename || $edit_comments)
+ {
+ unset ($this_selected);
+ unset ($renamethis);
+ unset ($edit_this_comment);
+
+ for ($j = 0; $j != $numoffiles; $j++)
+ {
+ if ($fileman[$j] == string_encode ($files["name"], 1))
+ {
+ $this_selected = 1;
+ break;
+ }
+ }
+
+ if ($rename && $this_selected)
+ $renamethis = 1;
+ elseif ($edit_comments && $this_selected)
+ $edit_this_comment = 1;
+ }
+
+ if (!$settings["dotfiles"] && ereg ("^\.", $files["name"]))
+ {
+ continue;
+ }
+
+ html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_BG_COLOR);
+
+ ###
+ # Checkboxes
+ ###
+
+ html_table_col_begin ("right");
+
+ if (!$rename && !$edit_comments)
+ html_form_input ("checkbox", "fileman[$i]", "$files[name]");
+ elseif ($renamethis)
+ html_form_input ("hidden", "fileman[" . string_encode ($files[name], 1) . "]", "$files[name]", NULL, NULL, "checked");
+ else
+ html_nbsp;
+
+ html_table_col_end ();
+
+ ###
+ # File name and icon
+ ###
+
+ if ($settings["name"])
+ {
+ html_table_col_begin ();
+
+ if ($renamethis)
+ {
+ if ($files["mime_type"] == "Directory")
+ html_image ("images/folder.gif", "Folder");
+ html_form_input ("text", "renamefiles[" . string_encode ($files[name], 1) . "]", "$files[name]", 255);
+ }
+ else
+ {
+ if ($files["mime_type"] == "Directory")
+ {
+ html_image ("images/folder.gif", "Folder");
+ html_link ("$appname/index.php?path=$path$dispsep$files[name]", $files["name"]);
+ }
+ else
+ {
+ html_link ("$filesdir$pwd/$files[name]", $files["name"]);
+ }
+ }
+
+ html_table_col_end ();
+ }
+
+ ###
+ # MIME type
+ ###
+
+ if ($settings["mime_type"])
+ {
+ html_table_col_begin ();
+ html_text ($files["mime_type"]);
+ html_table_col_end ();
+ }
+
+ ###
+ # File size
+ ###
+
+ if ($settings["size"])
+ {
+ html_table_col_begin ();
+
+ if ($files["mime_type"] == "Directory")
+ {
+ $size_query = db_query ("SELECT SUM(size) FROM phpgw_vfs WHERE owner_id = '$userinfo[username]' AND directory RLIKE '^$disppath/$files[name]'");
+ $fileinfo = db_fetch_array ($size_query);
+ db_call ("free", $size_query);
+ if ($fileinfo[0])
+ borkb ($fileinfo[0]+1024);
+ else
+ echo "1KB";
+ }
+ else
+ borkb ($files["size"]);
+
+ html_table_col_end ();
+ }
+
+ ###
+ # Date created
+ ###
+ if ($settings["created"])
+ {
+ html_table_col_begin ();
+ html_text ($files["created"]);
+ html_table_col_end ();
+ }
+
+ ###
+ # Date modified
+ ###
+
+ if ($settings["modified"])
+ {
+ html_table_col_begin ();
+ if ($files["modified"] != "0000-00-00")
+ html_text ($files["modified"]);
+ html_table_col_end ();
+ }
+
+ ###
+ # Owner name
+ ###
+
+ if ($settings["owner"])
+ {
+ html_table_col_begin ();
+ html_text ($phpgw->accounts->id2name ($files["owner_id"]));
+ html_table_col_end ();
+ }
+
+ ###
+ # Creator name
+ ###
+
+ if ($settings["createdby_id"])
+ {
+ html_table_col_begin ();
+ html_text ($phpgw->accounts->id2name ($files["createdby_id"]));
+ html_table_col_end ();
+ }
+
+ ###
+ # Modified by name
+ ###
+
+ if ($settings["modifiedby_id"])
+ {
+ html_table_col_begin ();
+ html_text ($phpgw->accounts->id2name ($files["modifiedby_id"]));
+ html_table_col_end ();
+ }
+
+ ###
+ # Application
+ ###
+
+ if ($settings["app"])
+ {
+ html_table_col_begin ();
+ html_text ($files["app"]);
+ html_table_col_end ();
+ }
+
+ ###
+ # Comment
+ ###
+
+ if ($settings["comment"])
+ {
+ html_table_col_begin ();
+ if ($edit_this_comment)
+ {
+ html_form_input ("text", "comment_files[" . string_encode ($files[name], 1) . "]", "$files[comment]", 255);
+ }
+ else
+ {
+ html_text ($files["comment"]);
+ }
+ html_table_col_end ();
+ }
+
+ ###
+ # Deleteable (currently not used)
+ ###
+
+ if ($settings["deleteable"])
+ {
+ if ($files["deleteable"] == "N")
+ {
+ html_table_col_begin ();
+ html_image ("images/locked.gif", "Locked");
+ html_table_col_end ();
+ }
+ else
+ {
+ html_table_col_begin ();
+ html_table_col_end ();
+ }
+ }
+
+ html_table_row_end ();
+
+ if ($files["mime_type"] == "Directory")
+ {
+ $usedspace += $fileinfo[0];
+ }
+ else
+ {
+ $usedspace += $files["size"];
+ }
+ }
+
+ html_table_end ();
+ html_break (2);
+
+ if (!$rename && !$edit_comments)
+ {
+ html_form_input ("submit", "edit", "Edit");
+ html_nbsp (3);
+ }
+
+ if (!$edit_comments)
+ {
+ html_form_input ("submit", "rename", "Rename");
+ html_nbsp (3);
+ }
+
+ if (!$rename && !$edit_comments)
+ {
+ html_form_input ("submit", "delete", "Delete");
+ html_nbsp (3);
+ }
+
+ if (!$rename)
+ {
+ html_form_input ("submit", "edit_comments", "Edit comments");
+ }
+ }
+
+ ###
+ # Display some inputs and info, but not when renaming or editing comments
+ ###
+
+ if (!$rename && !$edit_comments)
+ {
+ ###
+ # Begin Copy to/Move to selection
+ ###
+
+ html_break (1);
+ html_form_input ("submit", "copy", "Copy to:");
+
+ html_form_input ("submit", "move", "Move to:");
+ html_form_select_begin ("todir");
+
+ $query3 = db_query ("SELECT name, directory FROM phpgw_vfs WHERE owner_id = '$userinfo[username]' AND mime_type = 'Directory' ORDER BY name");
+ while ($dirs = db_fetch_array ($query3))
+ {
+ ###
+ # So we don't display //
+ ###
+
+ if ($dirs["directory"] != '/')
+ {
+ $dirs["directory"] .= '/';
+ }
+
+ ###
+ # No point in displaying the current directory
+ ###
+
+ if (($dirs["directory"] . $dirs["name"]) != $path)
+ {
+ html_form_option ($dirs["directory"] . $dirs["name"]);
+ }
+ }
+
+ html_form_select_end ();
+
+ html_break (1);
+ html_form_input ("submit", "download", "Download");
+ html_nbsp (3);
+
+ html_form_input ("text", "createdir", NULL, 255, 15);
+ html_form_input ("submit", "newdir", "Create Folder");
+
+ html_form_end ();
+
+ html_break (1);
+ html_text_bold ("Files: ");
+ html_text ($numoffiles);
+ html_nbsp (3);
+
+ html_text_bold ("Used space: ");
+ html_text (borkb ($usedspace, NULL, 1));
+ html_nbsp (3);
+
+ if ($path == $homedir)
+ {
+ html_text_bold ("Unused space: ");
+ html_text (borkb ($userinfo["hdspace"] - $usedspace, NULL, 1));
+
+ $query4 = db_query ("SELECT name FROM phpgw_vfs WHERE owner_id = '$userinfo[username]'");
+ $i = db_call ("affected_rows", $query4);
+
+ html_break (2);
+ html_text_bold ("Total Files: ");
+ html_text ($i);
+ }
+
+ ###
+ # Show file upload boxes. Note the last argument to html (). Repeats 5 times
+ ###
+
+ html_break (2);
+ html_form_begin ("$appname/index.php?op=upload&path=$path", "post", "multipart/form-data");
+ html_table_begin ();
+ html_table_row_begin ("center");
+ html_table_col_begin ();
+ html_text_bold ("File");
+ html_table_col_end ();
+ html_table_col_begin ();
+ html_text_bold ("Comment");
+ html_table_col_end ();
+ html_table_row_end ();
+
+ html_table_row_begin ();
+ html_table_col_begin ();
+ html (html_form_input ("file", "file[]", NULL, 255, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), 5);
+ html_table_col_end ();
+ html_table_col_begin ();
+ html (html_form_input ("text", "comment[]", NULL, NULL, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), 5);
+ html_table_col_end ();
+ html_table_row_end ();
+ html_table_end ();
+ html_form_input ("submit", "upload_files", "Upload files");
+ html_form_end ();
+ }
+
+ html_table_col_end ();
+ html_table_row_end ();
+ html_table_end ();
+ html_page_close ();
+}
+
+###
+# Handle Editing files
+###
+
+if ($edit)
+{
+ ###
+ # If $edit is "Edit", we do nothing, and let the for loop take over
+ ###
+
+ if ($edit_preview)
+ {
+ $content = $$edit_file;
+
+ html_break (1);
+ html_text_bold ("Preview of $path/$edit_file");
+ html_break (2);
+
+ html_table_begin ("90%");
+ html_table_row_begin ();
+ html_table_col_begin ();
+ html_text (nl2br ($content));
+ html_table_col_end ();
+ html_table_row_end ();
+ html_table_end ();
+ }
+ elseif ($edit_save)
+ {
+ $content = $$edit_file;
+
+ if ($phpgw->vfs->write ($edit_file, $content))
+ {
+ html_text_bold ("Saved $path/$edit_file");
+ html_break (2);
+ }
+ else
+ {
+ html_text_error ("Could not save $path/$edit_file");
+ html_break (2);
+ }
+ }
+
+/* This doesn't work just yet
+ elseif ($edit_save_all)
+ {
+ for ($j = 0; $j != $numoffiles; $j++)
+ {
+ $content = $$fileman[$j];
+ echo "fileman[$j]: $fileman[$j]
$content
";
+ continue;
+
+ if ($phpgw->vfs->write ($fileman[$j], $content))
+ {
+ html_text_bold ("Saved $path/$fileman[$j]");
+ html_break (1);
+ }
+ else
+ {
+ html_text_error ("Could not save $path/$fileman[$j]");
+ html_break (1);
+ }
+ }
+
+ html_break (1);
+ }
+*/
+
+ ###
+ # Now we display the edit boxes and forms
+ ###
+
+ for ($j = 0; $j != $numoffiles; $j++)
+ {
+ if ($content = $phpgw->vfs->read ($fileman[$j]))
+ {
+ html_table_begin ("100%");
+ html_form_begin ("$appname/index.php?path=$path");
+ html_form_input ("hidden", "edit", True);
+ html_form_input ("hidden", "edit_file", "$fileman[$j]");
+
+ ###
+ # We need to include all of the fileman entries for each file's form,
+ # so we loop through again
+ ###
+
+ for ($i = 0; $i != $numoffiles; $i++)
+ {
+ html_form_input ("hidden", "fileman[$i]", "$fileman[$i]");
+ }
+
+ html_table_row_begin ();
+ html_table_col_begin ();
+ html_form_textarea ($fileman[$j], 35, 75, $content);
+ html_table_col_end ();
+ html_table_col_begin ("center");
+ html_form_input ("submit", "edit_preview", "Preview $fileman[$j]");
+ html_break (1);
+ html_form_input ("submit", "edit_save", "Save $fileman[$j]");
+// html_break (1);
+// html_form_input ("submit", "edit_save_all", "Save all");
+ html_table_col_end ();
+ html_table_row_end ();
+ html_break (2);
+ html_form_end ();
+ html_table_end ();
+ }
+ }
+}
+
+###
+# Handle File Uploads
+###
+
+elseif ($op == "upload")
+{
+ for ($i = 0; $i != 5; $i++)
+ {
+ if ($file_size[$i] != 0)
+ {
+ ###
+ # Check to see if the file exists in the database
+ ###
+
+ $query = db_query ("SELECT * FROM phpgw_vfs WHERE name = '$file_name[$i]' AND owner_id = '$userinfo[username]' AND directory = '$path'");
+
+ if ($fileinfo = db_fetch_array ($query))
+ {
+ if ($fileinfo["mime_type"] == "Directory")
+ {
+ html_text_summary_error ("Cannot replace $fileinfo[name] because it is a directory");
+ continue;
+ }
+
+ $query = db_query ("SELECT SUM(size) FROM phpgw_vfs WHERE owner_id = '$userinfo[username]' AND name != '$file_name[$i]'");
+ $files = db_fetch_array ($query);
+ $usedspace = $files[0];
+
+ if (($file_size[$i] + $usedspace) > $userinfo["hdspace"])
+ {
+ html_text_summary_error ("Sorry, you do not have enough space to upload those files");
+ continue;
+ }
+
+ if ($fileinfo["deleteable"] != "N")
+ {
+ $phpgw->vfs->set_attributes ($file_name[$i], array ("owner_id" => $userinfo["username"], "modifiedby_id" => $userinfo["username"], "modified" => $now, "size" => $file_size[$i], mime_type => $file_type[$i], "deleteable" => "Y", "comment" => $comment[$i]), array (RELATIVE_ALL));
+ $phpgw->vfs->cp ($file[$i], "$file_name[$i]", array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL));
+
+ html_text_summary ("Replaced $disppath/$file_name[$i]", $file_size[$i]);
+ }
+ }
+ else
+ {
+ $query = db_query ("SELECT SUM(size) FROM phpgw_vfs WHERE owner_id = '$userinfo[username]'");
+ $files = db_fetch_array ($query);
+ $usedspace = $files[0];
+
+ if (($file_size[$i] + $usedspace) > $userinfo["hdspace"])
+ {
+ html_text_summary_error ("Not enough space to upload $file_name[$i]", NULL, $file_size[$i]);
+ continue;
+ }
+
+ $phpgw->vfs->cp ($file[$i], $file_name[$i], array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL));
+ $phpgw->vfs->set_attributes ($file_name[$i], array ("mime_type" => $file_type[$i], "comment" => $comment[$i]), array (RELATIVE_ALL));
+
+ html_text_summary ("Created $disppath/$file_name[$i]", $file_size[$i]);
+ }
+ }
+ }
+
+ html_break (2);
+ html_link_back ();
+}
+
+###
+# Handle Editing comments
+###
+
+elseif ($comment_files)
+{
+ while (list ($file) = each ($comment_files))
+ {
+ $phpgw->vfs->set_attributes ($file, array ("comment" => $comment_files[$file]));
+
+ html_text_summary ("Updated comment for $path/$file");
+ }
+
+ html_break (2);
+ html_link_back ();
+}
+
+###
+# Handle Renaming Files and Directories
+###
+
+elseif ($renamefiles)
+{
+ while (list ($file) = each ($renamefiles))
+ {
+ $file_decoded = string_decode ($file, 1);
+
+ if (ereg ("/", $renamefiles[$file]))
+ {
+ echo $phpgw->common->error_list (array ("File names cannot contain /"));
+ }
+ elseif (!$phpgw->vfs->mv ($file_decoded, $renamefiles[$file]))
+ {
+ echo $phpgw->common->error_list (array ("Could not rename $disppath/$file_decoded to $disppath/$renamefiles[$file]"));
+ }
+ else
+ {
+ html_text_summary ("Renamed $disppath/$file_decoded to $disppath/$renamefiles[$file]");
+ }
+ }
+
+ html_break (2);
+ html_link_back ();
+}
+
+###
+# Handle Moving Files and Directories
+###
+
+elseif ($move)
+{
+ while (list ($num, $file) = each ($fileman))
+ {
+ $file_decoded = string_decode ($file, 1);
+ if ($phpgw->vfs->mv ($file_decoded, $todir . "/" . $file_decoded, array (RELATIVE_ALL, RELATIVE_NONE)))
+ {
+ $moved++;
+ html_text_summary ("Moved $disppath/$file_decoded to $todir/$file_decoded");
+ }
+ else
+ {
+ echo $phpgw->common->error_list (array ("Could not move $disppath/$file_decoded to $todir/$file_decoded"));
+ }
+ }
+
+ if ($moved)
+ {
+ html_break (2);
+ html_link ("$appname/index.php?path=$todir", "Go to $todir");
+ }
+
+ html_break (2);
+ html_link_back ();
+}
+
+###
+# Handle Copying of Files and Directories
+###
+
+elseif ($copy)
+{
+ while (list ($num, $file) = each ($fileman))
+ {
+ $file_decoded = string_decode ($file, 1);
+
+ if ($phpgw->vfs->cp ($file_decoded, $todir . "/" . $file_decoded, array (RELATIVE_ALL, RELATIVE_NONE)))
+ {
+ $copied++;
+ html_text_summary ("Copied $disppath/$file_decoded to $todir/$file_decoded");
+ }
+ else
+ {
+ echo $phpgw->common->error_list (array ("Could not copy $disppath/$file_decoded to $todir/$file_decoded"));
+ }
+ }
+
+ if ($copied)
+ {
+ html_break (2);
+ html_link ("$appname/index.php?path=$todir", "Go to $todir");
+ }
+
+ html_break (2);
+ html_link_back ();
+}
+
+###
+# Handle Deleting Files and Directories
+###
+
+elseif ($delete)
+{
+ $query = db_query ("SELECT name FROM phpgw_vfs WHERE owner_id = '$userinfo[username]'");
+ $numoffiles = db_call ("affected_rows", $query);
+ for ($i = 0; $i != $numoffiles; $i++)
+ {
+ if ($fileman[$i])
+ {
+ ###
+ # There is no need to create a separate $fileman_decode variable, because it will never be passed again
+ ###
+
+ $fileman[$i] = string_decode ($fileman[$i], 1);
+
+ if ($phpgw->vfs->delete ($fileman[$i]))
+ {
+ html_text_summary ("Deleted $disppath/$fileman[$i]", $fileinfo["size"]);
+ }
+ else
+ {
+ $phpgw->common->error_list (array ("Could not delete $disppath/$fileman[$i]"));
+ }
+ }
+ }
+
+ html_break (2);
+ html_link_back ();
+}
+
+elseif ($newdir && $createdir)
+{
+ if ($badchar = bad_chars_file ($createdir, 1))
+ {
+ html_text_summary_error ("Cannot create directory $createdir (name contains \"$badchar\")");
+ html_break (2);
+ html_link_back ();
+ html_page_close ();
+ }
+
+ if ($createdir[strlen($createdir)-1] == " " || $createdir[0] == " ")
+ {
+ html_text_summary_error ("Cannot create directory $createdir because it begins or ends in a space", 1);
+ html_break (2);
+ html_link_back ();
+ html_page_close ();
+ }
+
+ $query = db_query ("SELECT name,mime_type FROM phpgw_vfs WHERE name = '$createdir' AND owner_id = '$userinfo[username]' AND directory = '$path'");
+ if ($fileinfo = db_fetch_array ($query))
+ {
+ if ($fileinfo[1] != "Directory")
+ {
+ html_text_summary_error ("$fileinfo[0] already exists as a file");
+ html_break (2);
+ html_link_back ();
+ html_page_close ();
+ }
+ else
+ {
+ html_text_summary_error ("Directory $fileinfo[0] already exists");
+ html_break (2);
+ html_link_back ();
+ html_page_close ();
+ }
+ }
+ else
+ {
+ $query = db_query ("SELECT SUM(size) FROM phpgw_vfs WHERE owner_id = '$userinfo[username]' AND name != '$file_name[$i]'");
+ $files = db_fetch_array ($query);
+ $usedspace = $files[0];
+
+ if (($usedspace + 1024) > $userinfo["hdspace"])
+ {
+ html_text_summary_error ("Sorry, you do not have enough space to create a new directory", 1);
+ html_page_close ();
+ }
+
+ if ($phpgw->vfs->mkdir ($createdir))
+ {
+ html_text_summary ("Created directory $disppath/$createdir");
+ html_break (2);
+ html_link ("$appname/index.php?path=$disppath/$createdir", "Go to $disppath/$createdir");
+ }
+ else
+ echo $phpgw->common->error_list (array ("Could not create $disppath/$createdir"));
+ }
+
+ html_break (2);
+ html_link_back ();
+}
+
+html_page_close ();
+
+?>
diff --git a/filemanager/login.php b/filemanager/login.php
new file mode 100755
index 0000000000..3b116231ec
--- /dev/null
+++ b/filemanager/login.php
@@ -0,0 +1,48 @@
+
+
+require ("main.inc");
+error_reporting (4);
+
+if ($htaccess)
+{
+ $username = $PHP_AUTH_USER;
+ $password = $PHP_AUTH_PW;
+}
+
+if ($username && $password)
+{
+ $query = sql_query ("SELECT * FROM userinfo WHERE username = '$username'");
+
+ if (!mysql_num_rows($query))
+ {
+ echo "No such username";
+ login();
+ }
+
+ $query = sql_query ("SELECT * FROM userinfo WHERE username = '$username' AND password = PASSWORD('$password')");
+
+ if (!mysql_num_rows($query))
+ {
+ echo "Invalid password";
+ login ();
+ }
+
+ setcookie ("cookieusername", $username, 0, "$hostname_path", "$hostname_domain");
+ setcookie ("cookiepassword", $password, 0, "$hostname_path", "$hostname_domain");
+
+ $query = sql_query ("UPDATE userinfo SET lastlogin = NOW() WHERE username = '$username'");
+ $query = sql_query ("UPDATE userinfo SET lastip = '$REMOTE_ADDR' WHERE username = '$username'");
+
+ header ("Location: $hostname/users.php");
+}
+
+if ($cookieusername && $cookiepassword)
+{
+ header ("Location: $hostname/users.php");
+ exit;
+}
+
+if (!$username || !$password)
+ login();
+
+?>
diff --git a/filemanager/preferences.php b/filemanager/preferences.php
new file mode 100644
index 0000000000..63bd3f9135
--- /dev/null
+++ b/filemanager/preferences.php
@@ -0,0 +1,108 @@
+ "phpwebhosting", "enable_nextmatchs_class" => True, "noheader" => True, "nonavbar" => True);
+ include("../header.inc.php");
+
+ /*
+ To add a preference, just add it here. Key is internal name, value is displayed name
+ */
+ $other_checkboxes = array ("dotdot" => "Show ..", "dotfiles" => "Show .files");
+
+ if ($submit)
+ {
+ $phpgw->preferences->read_repository ();
+
+ reset ($file_attributes);
+ while (list ($internal, $displayed) = each ($file_attributes))
+ {
+ $phpgw->preferences->add ($phpgw_info["flags"]["currentapp"], $internal, $$internal);
+ }
+
+ reset ($other_checkboxes);
+ while (list ($internal, $displayed) = each ($other_checkboxes))
+ {
+ $phpgw->preferences->add ($phpgw_info["flags"]["currentapp"], $internal, $$internal);
+ }
+
+ $phpgw->preferences->save_repository (True);
+
+ Header('Location: '.$phpgw->link('/preferences/index.php'));
+ $phpgw->common->phpgw_exit();
+ }
+
+ function display_item ($field,$data)
+ {
+ global $phpgw, $p, $tr_color;
+
+ $tr_color = $phpgw->nextmatchs->alternate_row_color ($tr_color);
+ $var = array (
+ 'bg_color' => $tr_color,
+ 'field' => $field,
+ 'data' => $data
+ );
+ $p->set_var ($var);
+ $p->parse ('row', 'pref_list', True);
+ }
+
+ $phpgw->common->phpgw_header ();
+ echo parse_navbar ();
+
+ $p = CreateObject ('phpgwapi.Template', $phpgw->common->get_tpl_dir ('phpwebhosting'));
+ $templates = array (
+ 'pref' => 'pref.tpl',
+ 'pref_colspan' => 'pref_colspan.tpl',
+ 'pref_list' => 'pref_list.tpl',
+ );
+ $p->set_file ($templates);
+
+ $var = array (
+ 'title' => lang ('PHPWebHosting preferences'),
+ 'action_url' => $phpgw->link ('/' . $phpgw_info['flags']['currentapp'] . '/preferences.php'),
+ 'bg_color' => $phpgw_info['theme']['th_bg'],
+ 'submit_lang' => lang ('submit')
+ );
+
+ $p->set_var ($var);
+ $p->set_var ('text', ' ');
+ $p->parse ('row', 'pref_colspan', True);
+
+ if ($totalerrors)
+ {
+ echo '
+ | |||
+
|
+ + {small_calendar} + | +
{open_link}{time}{close_link} |
+ {small_calendar_prev} + | +
+ {month_identifier}
+ {username} + |
+ + {small_calendar_next} + | +
+
+{print}
+
diff --git a/filemanager/templates/default/link_pict.tpl b/filemanager/templates/default/link_pict.tpl
new file mode 100755
index 0000000000..fe1c2e4c90
--- /dev/null
+++ b/filemanager/templates/default/link_pict.tpl
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/filemanager/templates/default/list.tpl b/filemanager/templates/default/list.tpl
new file mode 100755
index 0000000000..0ad7059a4e
--- /dev/null
+++ b/filemanager/templates/default/list.tpl
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/filemanager/templates/default/matrix_query.tpl b/filemanager/templates/default/matrix_query.tpl
new file mode 100755
index 0000000000..391217d70c
--- /dev/null
+++ b/filemanager/templates/default/matrix_query.tpl
@@ -0,0 +1,19 @@
+
+
+{field}:
+ {data}
+ {matrix_action}
+
+
+{cancel_button}
+
{month} | ++ | |||||
+ | ||||||
+ |
+
{overlap_text} |
|
{title}:
+
diff --git a/filemanager/templates/default/pref_colspan.tpl b/filemanager/templates/default/pref_colspan.tpl new file mode 100755 index 0000000000..e6fae732b8 --- /dev/null +++ b/filemanager/templates/default/pref_colspan.tpl @@ -0,0 +1,4 @@ +
+
+
+
+ |
+ {nmr}
+
+{output} +
+ diff --git a/filemanager/templates/default/search_list.tpl b/filemanager/templates/default/search_list.tpl new file mode 100755 index 0000000000..4255e81551 --- /dev/null +++ b/filemanager/templates/default/search_list.tpl @@ -0,0 +1,4 @@ + + +
+{edit_button} {delete_button} +
+ {small_calendar_prev} + | ++ {prev_week_link} + | +
+ {small_calendar_this}
+ {week_identifier}
+ {username} + |
+ + {next_week_link} + | ++ {small_calendar_next} + | +
+ | |||
+
|
+ + {small_calendar} + | +
{open_link}{time}{close_link} |
+ {small_calendar_prev} + | +
+ {month_identifier}
+ {username} + |
+ + {small_calendar_next} + | +
+
+{print}
+
diff --git a/filemanager/templates/idsociety/link_pict.tpl b/filemanager/templates/idsociety/link_pict.tpl
new file mode 100755
index 0000000000..fe1c2e4c90
--- /dev/null
+++ b/filemanager/templates/idsociety/link_pict.tpl
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/filemanager/templates/idsociety/list.tpl b/filemanager/templates/idsociety/list.tpl
new file mode 100755
index 0000000000..0ad7059a4e
--- /dev/null
+++ b/filemanager/templates/idsociety/list.tpl
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/filemanager/templates/idsociety/matrix_query.tpl b/filemanager/templates/idsociety/matrix_query.tpl
new file mode 100755
index 0000000000..391217d70c
--- /dev/null
+++ b/filemanager/templates/idsociety/matrix_query.tpl
@@ -0,0 +1,19 @@
+
+
+{field}:
+ {data}
+ {matrix_action}
+
+
+{cancel_button}
+
{month} | ++ | |||||
+ | ||||||
+ |
+
{overlap_text} |
|
{title}:
+
diff --git a/filemanager/templates/idsociety/pref_colspan.tpl b/filemanager/templates/idsociety/pref_colspan.tpl new file mode 100755 index 0000000000..e6fae732b8 --- /dev/null +++ b/filemanager/templates/idsociety/pref_colspan.tpl @@ -0,0 +1,4 @@ +
+
+
+
+ |
+ {nmr}
+
+{output} +
+ diff --git a/filemanager/templates/idsociety/search_list.tpl b/filemanager/templates/idsociety/search_list.tpl new file mode 100755 index 0000000000..4255e81551 --- /dev/null +++ b/filemanager/templates/idsociety/search_list.tpl @@ -0,0 +1,4 @@ + + +
+{edit_button} {delete_button} +
+ {small_calendar_prev} + | ++ {prev_week_link} + | +
+ {small_calendar_this}
+ {week_identifier}
+ {username} + |
+ + {next_week_link} + | ++ {small_calendar_next} + | +