From cce860ee66bf50a3d76689c4230229ed356c2494 Mon Sep 17 00:00:00 2001 From: skeeter Date: Mon, 10 Dec 2001 04:04:56 +0000 Subject: [PATCH] Hopefully I didn't screw anything up. Changed over to use GLOBALS, and alot of coding stds. Also, found a little problem with the filesize field. Trying to get the value, prior to having it filled in the database. Always returning '0'. --- filemanager/inc/functions.inc.php | 2 +- filemanager/inc/html.inc.php | 209 ++++++--- filemanager/inc/main.inc.php | 92 ++-- filemanager/index.php | 703 +++++++++++++++-------------- phpgwapi/inc/class.vfs_sql.inc.php | 185 ++++---- 5 files changed, 658 insertions(+), 533 deletions(-) diff --git a/filemanager/inc/functions.inc.php b/filemanager/inc/functions.inc.php index 414702e4ed..b57faf4f2f 100644 --- a/filemanager/inc/functions.inc.php +++ b/filemanager/inc/functions.inc.php @@ -1,5 +1,5 @@ diff --git a/filemanager/inc/html.inc.php b/filemanager/inc/html.inc.php index fb976fac85..b299bcfbe4 100755 --- a/filemanager/inc/html.inc.php +++ b/filemanager/inc/html.inc.php @@ -1,82 +1,110 @@ "; + { + $text .= ' enctype="'.$enctype.'"'; + } + + $rstring = '
'; return (eor ($rstring, $return)); } function html_form_input ($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = HTML_FORM_INPUT_STRING, $return = 0) { + $text = ' '; if ($type != NULL && $type) { - if ($type == "checkbox") + if ($type == 'checkbox') { $value = string_encode ($value, 1); } - $type = "type=$type"; + $text .= 'type="'.$type.'" '; } if ($name != NULL && $name) - $name = "name=\"$name\""; + { + $text .= 'name="'.$name.'" '; + } if ($value != NULL && $value) { - $value = "value=\"$value\""; + $text .= 'value="'.$value.'" '; } if (is_int ($maxlength) && $maxlength >= 0) - $maxlength = "maxlength=$maxlength"; + { + $text .= 'maxlength="'.$maxlength.'" '; + } if (is_int ($size) && $size >= 0) - $size = "size=$size"; + { + $text .= 'size="'.$size.'" '; + } if ($checked != NULL && $checked) - $checked = "checked"; - $rstring = ""; + { + $text .= 'checked '; + } + + $rstring = ''; return (eor ($rstring, $return)); } function html_form_textarea ($name = NULL, $rows = NULL, $cols = NULL, $value = NULL, $string = HTML_FORM_TEXTAREA_STRING, $return = 0) { + $text =' '; if ($name != NULL && $name) - $name = "name=\"$name\""; + { + $text .= 'name="'.$name.'" '; + } if (is_int ($rows) && $rows >= 0) - $rows = "rows=$rows"; + { + $text .= 'rows="'.$rows.'" '; + } if (is_int ($cols) && $cols >= 0) - $cols = "cols=$cols"; - $rstring = ""; + { + $text .= 'cols="'.$cols.'" '; + } + $rstring = ''.$value.''; return (eor ($rstring, $return)); } function html_form_select_begin ($name = NULL, $return = 0) { + $test = ' '; if ($name != NULL && $name) - $name = "name=$name"; - $rstring = ""; + $rstring = ''; return (eor ($rstring, $return)); } function html_form_option ($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) { + $text = ' '; if ($value != NULL && $value) - $value = "value=\"$value\""; + { + $text .= ' value="'.$value.'" '; + } if ($selected != NULL && $selected) - $selected = "selected"; - $rstring = ""; + { + $text .= ' selected'; + } + $rstring = ''.$displayed.''; return (eor ($rstring, $return)); } @@ -89,16 +117,24 @@ function html_form_end ($return = 0) function html_nbsp ($times = 1, $return = 0) { if ($times == NULL) + { $times = 1; + } for ($i = 0; $i != $times; $i++) { if ($return) - $rstring .= " "; + { + $rstring .= ' '; + } else - echo " "; + { + echo ' '; + } } if ($return) + { return ($rstring); + } } function html ($string, $times = 1, $return = 0) @@ -106,23 +142,35 @@ 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) +function html_break ($break, $string = '', $return = 0) { - if ($break == 1) - $break = '
'; - if ($break == 2) - $break = '

'; - if ($break == 5) - $break = '


'; - return (eor ($break . $string, $return)); + switch($break) + { + case 1: + $break_str = '
'; + break; + case 2: + $break_str = '

'; + break; + case 5: + $break_str = '


'; + break; + } + return (eor ($break_str . $string, $return)); } function html_page_begin ($title = NULL, $return = 0) @@ -133,71 +181,91 @@ function html_page_begin ($title = NULL, $return = 0) function html_page_body_begin ($bgcolor = HTML_PAGE_BODY_COLOR, $background = NULL, $text = NULL, $link = NULL, $vlink = NULL, $alink = NULL, $string = HTML_PAGE_BODY_STRING, $return = 0) { + $text_out = ' '; if ($bgcolor != NULL && $bgcolor) - $bgcolor = "bgcolor=$bgcolor"; + { + $text_out .= 'bgcolor="'.$bgcolor.'" '; + } if ($background != NULL && $background) - $background = "background=$background"; + { + $text_out .= 'background="'.$background.'" '; + } if ($text != NULL && $text) - $text = "text=$text"; + { + $text_out .= 'text="'.$text.'" '; + } if ($link != NULL && $link) - $link = "link=$link"; + { + $text_out .= 'link="'.$link.'" '; + } if ($vlink != NULL && $vlink) - $vlink = "vlink=$vlink"; + { + $text_out .= 'vlink="'.$vlink.'" '; + } if ($alink != NULL && $alink) - $alink = "alink=$alink"; -// $rstring = ""; + { + $text_out .= 'alink="'.$alink.'" '; + } +// $rstring = ''; return (eor ($rstring, $return)); } function html_page_body_end ($return = 0) { -// $rstring = ""; +// $rstring = ''; return (eor ($rstring, $return)); } function html_page_end ($return = 0) { -// $rstring = ""; +// $rstring = ''; return (eor ($rstring, $return)); } function html_page_close () { - global $phpgw; // html_page_body_end (); // html_page_end (); - $phpgw->common->phpgw_footer (); - $phpgw->common->phpgw_exit (); + $GLOBALS['phpgw']->common->phpgw_footer (); + $GLOBALS['phpgw']->common->phpgw_exit (); } function html_text_bold ($text = NULL, $return = 0, $lang = 0) { if ($lang) + { $text = translate ($text); - $rstring = "$text"; + } + $rstring = ''.$text.''; return (eor ($rstring, $return)); } function html_text_underline ($text = NULL, $return = 0, $lang = 0) { if ($lang) + { $text = translate ($text); - $rstring = "$text"; + } + $rstring = ''.$text.''; return (eor ($rstring, $return)); } function html_text_italic ($text = NULL, $return = 0, $lang = 0) { if ($lang) + { $text = translate ($text); - $rstring = "$text"; + } + $rstring = ''.$text.''; return (eor ($rstring, $return)); } function html_text_summary ($text = NULL, $size = NULL, $return = 0, $lang = 0) { if ($lang) + { $text = translate ($text); - $rstring .= html_break (1, NULL, $return); + } + $rstring = html_break (1, NULL, $return); $rstring .= html_text_bold ($text, $return); $rstring .= html_nbsp (3, $return); if ($size != NULL && $size >= 0) @@ -206,24 +274,36 @@ function html_text_summary ($text = NULL, $size = NULL, $return = 0, $lang = 0) $rstring = html_encode ($rstring, 1); if ($return) + { return ($rstring); + } } function html_text_summary_error ($text = NULL, $text2 = NULL, $size = NULL, $return = 0, $lang = 0) { if ($lang) + { $text = translate ($lang); - $rstring .= html_text_error ($text, 1, $return); + } + $rstring = html_text_error ($text, 1, $return); if (($text2 != NULL && $text2) || ($size != NULL && $size)) + { $rstring .= html_nbsp (3, $return); + } if ($text2 != NULL && $text2) + { $rstring .= html_text_error ($text2, NULL, $return); + } if ($size != NULL && $size >= 0) + { $rstring .= borkb ($size, 1, $return); + } if ($return) + { return ($rstring); + } } function html_font_set ($size = NULL, $color = NULL, $family = NULL, $return = 0) @@ -272,10 +352,6 @@ function html_page_error ($errorwas = NULL, $title = "Error", $return = 0) function html_link ($href = NULL, $text = NULL, $return = 0, $encode = 1, $linkonly = 0, $target = NULL) { - global $phpgw; - global $sep; - global $appname; - if ($encode) $href = string_encode ($href, 1); @@ -288,11 +364,11 @@ function html_link ($href = NULL, $text = NULL, $return = 0, $encode = 1, $linko /* Auto-detect and don't disturb absolute links */ if (!preg_match ("|^http(.{0,1})://|", $href)) { - $href = $sep . $href; + $href = SEP . $href; /* $phpgw->link requires that the extra vars be passed separately */ $link_parts = explode ("?", $href, 2); - $address = $phpgw->link ($link_parts[0], $link_parts[1]); + $address = $GLOBALS['phpgw']->link ($link_parts[0], $link_parts[1]); } else { @@ -307,9 +383,11 @@ function html_link ($href = NULL, $text = NULL, $return = 0, $encode = 1, $linko else { if ($target) - $target = "target=$target"; + { + $target = 'target='.$target; + } - $rstring = "$text"; + $rstring = ''.$text.''; } return (eor ($rstring, $return)); @@ -317,12 +395,9 @@ function html_link ($href = NULL, $text = NULL, $return = 0, $encode = 1, $linko function html_link_back ($return = 0) { - global $hostname; global $path; - global $groupinfo; - global $appname; - $rstring .= html_link ("$appname/index.php?path=$path", HTML_TEXT_NAVIGATION_BACK_TO_USER, 1); + $rstring .= html_link ($GLOBALS['appname'].'/index.php?path='.$path, HTML_TEXT_NAVIGATION_BACK_TO_USER, 1); return (eor ($rstring, $return)); } diff --git a/filemanager/inc/main.inc.php b/filemanager/inc/main.inc.php index 784494e0f6..f134b807f0 100755 --- a/filemanager/inc/main.inc.php +++ b/filemanager/inc/main.inc.php @@ -2,48 +2,48 @@ error_reporting (4); -if (@!$phpgw->vfs) +if (@!is_object($GLOBALS['phpgw']->vfs)) { - $phpgw->vfs = CreateObject ('phpgwapi.vfs'); + $GLOBALS['phpgw']->vfs = CreateObject ('phpgwapi.vfs'); } ### Start Configuration Options ### ### These are automatically set in phpGW - do not edit ### $sep = SEP; -$rootdir = $phpgw->vfs->basedir; -$fakebase = $phpgw->vfs->fakebase; -$appname = $phpgw_info["flags"]["currentapp"]; -$settings = $phpgw_info["user"]["preferences"][$appname]; +$GLOBALS['rootdir'] = $GLOBALS['phpgw']->vfs->basedir; +$GLOBALS['fakebase'] = $GLOBALS['phpgw']->vfs->fakebase; +$GLOBALS['appname'] = $GLOBALS['phpgw_info']['flags']['currentapp']; +$GLOBALS['settings'] = $GLOBALS['phpgw_info']['user']['preferences'][$appname]; -if (stristr ($rootdir, PHPGW_SERVER_ROOT)) +if (stristr ($GLOBALS['rootdir'], PHPGW_SERVER_ROOT)) { - $filesdir = substr ($rootdir, strlen (PHPGW_SERVER_ROOT)); + $GLOBALS['filesdir'] = substr ($GLOBALS['rootdir'], strlen (PHPGW_SERVER_ROOT)); } else { - unset ($filesdir); + unset ($GLOBALS['filesdir']); } -$hostname = $phpgw_info["server"]["webserver_url"] . $filesdir; +$GLOBALS['hostname'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . $GLOBALS['filesdir']; ### # 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]"; +$GLOBALS['userinfo']['username'] = $GLOBALS['phpgw_info']['user']['account_id']; +$GLOBALS['userinfo']['account_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['userinfo']['username']); +$GLOBALS['userinfo']['hdspace'] = 10000000000; +$GLOBALS['homedir'] = $GLOBALS['fakebase'].'/'.$GLOBALS['userinfo']['account_lid']; ### End Configuration Options ### -if (!defined ("NULL")) +if (!defined ('NULL')) { - define ("NULL", ""); + define ('NULL', ''); } -require (PHPGW_APP_INC . "/db.inc.php"); +require (PHPGW_APP_INC . '/db.inc.php'); /* Set up any initial db settings */ db_init (); @@ -54,27 +54,40 @@ db_init (); /* 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"); +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 (PHPGW_APP_INC . "/html.inc.php"); +require (PHPGW_APP_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", "version" => "Version"); +$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', + 'version' => 'Version' +); ### # Calculate and display B or KB @@ -89,14 +102,14 @@ function borkb ($size, $enclosed = NULL, $return = 0) if ($enclosed) { - $left = "("; - $right = ")"; + $left = '('; + $right = ')'; } if ($size < 1024) - $rstring = $left . $size . "B" . $right; + $rstring = $left . $size . 'B' . $right; else - $rstring = $left . round($size/1024) . "KB" . $right; + $rstring = $left . round($size/1024) . 'KB' . $right; return (eor ($rstring, $return)); } @@ -164,24 +177,22 @@ function eor ($rstring, $return) function string_encode ($string, $return = False) { - global $hostname; - if (preg_match ("/=(.*)(&|$)/U", $string)) { $rstring = preg_replace ("/=(.*)(&|$)/Ue", "'=' . rawurlencode (base64_encode ('\\1')) . '\\2'", $string); } - elseif (ereg ("^$hostname", $string)) + elseif (ereg ('^'.$GLOBALS['hostname'], $string)) { - $rstring = ereg_replace ("^$hostname/", "", $string); + $rstring = ereg_replace ('^'.$GLOBALS['hostname'].'/', '', $string); $rstring = preg_replace ("/(.*)(\/|$)/Ue", "rawurlencode (base64_encode ('\\1')) . '\\2'", $rstring); - $rstring = "$hostname/$rstring"; + $rstring = $GLOBALS['hostname'].'/'.$rstring; } else { $rstring = rawurlencode ($string); /* Terrible hack, decodes all /'s back to normal */ - $rstring = preg_replace ("/%2F/", "/", $rstring); + $rstring = preg_replace ("/%2F/", '/', $rstring); } return (eor ($rstring, $return)); @@ -208,13 +219,10 @@ function html_encode ($string, $return) function translate ($text) { - global $phpgw; - - return ($phpgw->lang ($text)); + return ($GLOBALS['phpgw']->lang($text)); } -$help_info = array - ( +$help_info = Array( array ("up", "The Up button takes you to the directory above the current directory. For example, if you're in /home/jdoe/mydir, the Up button would take you to /home/jdoe."), array ("directory_name", "The name of the directory you're currently in."), array ("home", "The Home button takes you to your personal home directory."), diff --git a/filemanager/index.php b/filemanager/index.php index 84302d7a9a..979bfa79ed 100755 --- a/filemanager/index.php +++ b/filemanager/index.php @@ -6,12 +6,19 @@ $phpwh_debug = 0; -reset ($GLOBALS['HTTP_POST_VARS']); +@reset ($GLOBALS['HTTP_POST_VARS']); while (list ($name,) = each ($GLOBALS['HTTP_POST_VARS'])) { $$name = $GLOBALS['HTTP_POST_VARS'][$name]; } +@reset ($GLOBALS['HTTP_GET_VARS']); +while (list ($name,) = each ($GLOBALS['HTTP_GET_VARS'])) +{ + $$name = $GLOBALS['HTTP_GET_VARS'][$name]; +} + + $to_decode = array ( /* @@ -63,29 +70,29 @@ while (list ($var, $conditions) = each ($to_decode)) } } -if ($noheader || $nofooter || ($download && (count ($fileman) > 0)) || ($op == "view" && $file) || ($op == "history" && $file) || ($op == help && $help_name)) +if ($noheader || $nofooter || ($download && (count ($fileman) > 0)) || ($op == 'view' && $file) || ($op == 'history' && $file) || ($op == 'help' && $help_name)) { $noheader = True; $nofooter = True; } -$phpgw_info["flags"] = array +$GLOBALS['phpgw_info']['flags'] = array ( - "currentapp" => "phpwebhosting", - "noheader" => $noheader, - "nofooter" => $nofooter, - "noappheader" => False, - "enable_vfs_class" => True, - "enable_browser_class" => True + 'currentapp' => 'phpwebhosting', + 'noheader' => $noheader, + 'nofooter' => $nofooter, + 'noappheader' => False, + 'enable_vfs_class' => True, + 'enable_browser_class' => True ); -include ("../header.inc.php"); +include ('../header.inc.php'); if ($execute && $command_line) { - if ($result = $phpgw->vfs->command_line (stripslashes ($command_line))) + if ($result = $GLOBALS['phpgw']->vfs->command_line (stripslashes ($command_line))) { - $messages = html_text_bold ("Command sucessfully run", 1); + $messages = html_text_bold ('Command sucessfully run', 1); if ($result != 1 && strlen ($result) > 0) { $messages .= html_break (2, NULL, 1) . $result; @@ -93,7 +100,7 @@ if ($execute && $command_line) } else { - $messages = $phpgw->common->error_list (array ("Error running command")); + $messages = $GLOBALS['phpgw']->common->error_list (array ('Error running command')); } } @@ -114,40 +121,40 @@ if ($go) if (!$path) { - $path = $phpgw->vfs->pwd (); + $path = $GLOBALS['phpgw']->vfs->pwd (); - if (!$path || $phpgw->vfs->pwd (False) == "") + if (!$path || $GLOBALS['phpgw']->vfs->pwd (False) == '') { - $path = $homedir; + $path = $GLOBALS['homedir']; } } -$phpgw->vfs->cd (False, False, array (RELATIVE_NONE)); -$phpgw->vfs->cd ($path, False, array (RELATIVE_NONE)); +$GLOBALS['phpgw']->vfs->cd (False, False, array (RELATIVE_NONE)); +$GLOBALS['phpgw']->vfs->cd ($path, False, array (RELATIVE_NONE)); -$pwd = $phpgw->vfs->pwd (); +$pwd = $GLOBALS['phpgw']->vfs->pwd (); -if (!$cwd = substr ($path, strlen ($homedir) + 1)) +if (!$cwd = substr ($path, strlen ($GLOBALS['homedir']) + 1)) { - $cwd = "/"; + $cwd = '/'; } else { - $cwd = substr ($pwd, strrpos ($pwd, "/") + 1); + $cwd = substr ($pwd, strrpos ($pwd, '/') + 1); } $disppath = $path; /* This just prevents // in some cases */ -if ($path == "/") - $dispsep = ""; +if ($path == '/') + $dispsep = ''; else - $dispsep = "/"; + $dispsep = '/'; -if (!($lesspath = substr ($path, 0, strrpos ($path, "/")))) - $lesspath = "/"; +if (!($lesspath = substr ($path, 0, strrpos ($path, '/')))) + $lesspath = '/'; -$now = date ("Y-m-d"); +$now = date ('Y-m-d'); if ($phpwh_debug) { @@ -158,17 +165,17 @@ if ($phpwh_debug) 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 () . "
"; + real getabsolutepath: " . $GLOBALS['phpgw']->vfs->getabsolutepath (False, False, False) . "
+ fake getabsolutepath: " . $GLOBALS['phpgw']->vfs->getabsolutepath (False) . "
+ appsession: " . $GLOBALS['phpgw']->session->appsession ('vfs','') . "
+ pwd: " . $GLOBALS['phpgw']->vfs->pwd () . "
"; } ### # Get their memberships to be used throughout the script ### -$memberships = $phpgw->accounts->membership ($userinfo["username"]); +$memberships = $GLOBALS['phpgw']->accounts->membership ($GLOBALS['userinfo']['username']); if (!is_array ($memberships)) { @@ -177,10 +184,10 @@ if (!is_array ($memberships)) while (list ($num, $group_array) = each ($memberships)) { - $membership_id = $phpgw->accounts->name2id ($group_array["account_name"]); + $membership_id = $GLOBALS['phpgw']->accounts->name2id ($group_array['account_name']); $group_applications = CreateObject('phpgwapi.applications', $membership_id); - $membership_applications[$group_array["account_name"]] = $group_applications->read_account_specific (); + $membership_applications[$group_array['account_name']] = $group_applications->read_account_specific (); } ### @@ -188,47 +195,47 @@ while (list ($num, $group_array) = each ($memberships)) # and set the VFS working_id appropriately ### -if ((preg_match ("+^$fakebase\/(.*)(\/|$)+U", $path, $matches)) && $matches[1] != $userinfo["account_lid"]) +if ((preg_match ('+^'.$GLOBALS['fakebase'].'\/(.*)(\/|$)+U', $path, $matches)) && $matches[1] != $GLOBALS['userinfo']['account_lid']) { - $phpgw->vfs->working_id = $phpgw->accounts->name2id ($matches[1]); + $GLOBALS['phpgw']->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id ($matches[1]); } else { - $phpgw->vfs->working_id = $userinfo["username"]; + $GLOBALS['phpgw']->vfs->working_id = $GLOBALS['userinfo']['username']; } -if ($path != $homedir && $path != $fakebase && $path != "/" && !$phpgw->vfs->acl_check ($path, array (RELATIVE_NONE), PHPGW_ACL_READ)) +if ($path != $GLOBALS['homedir'] && $path != $GLOBALS['fakebase'] && $path != '/' && !$GLOBALS['phpgw']->vfs->acl_check ($path, array (RELATIVE_NONE), PHPGW_ACL_READ)) { - echo $phpgw->common->error_list (array ("You do not have access to $path")); + echo $GLOBALS['phpgw']->common->error_list (array ('You do not have access to '.$path)); html_break (2); - html_link ("$appname/index.php?path=$homedir", "Go to your home directory"); + html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], 'Go to your home directory'); html_page_close (); } -$userinfo["working_id"] = $phpgw->vfs->working_id; -$userinfo["working_lid"] = $phpgw->accounts->id2name ($userinfo["working_id"]); +$GLOBALS['userinfo']['working_id'] = $GLOBALS['phpgw']->vfs->working_id; +$GLOBALS['userinfo']['working_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['userinfo']['working_id']); ### # If their home directory doesn't exist, we create it # Same for group directories ### -if (($path == $homedir) && !$phpgw->vfs->file_exists ($homedir, array (RELATIVE_NONE))) +if (($path == $GLOBALS['homedir']) && !$GLOBALS['phpgw']->vfs->file_exists ($GLOBALS['homedir'], array (RELATIVE_NONE))) { - $phpgw->vfs->override_acl = 1; - $phpgw->vfs->mkdir ($homedir, array (RELATIVE_NONE)); - $phpgw->vfs->override_acl = 0; +// $GLOBALS['phpgw']->vfs->override_acl = 1; + $GLOBALS['phpgw']->vfs->mkdir ($GLOBALS['homedir'], array (RELATIVE_NONE)); +// $GLOBALS['phpgw']->vfs->override_acl = 0; } -elseif (preg_match ("|^$fakebase\/(.*)$|U", $path, $matches)) +elseif (preg_match ('|^'.$GLOBALS['fakebase'].'\/(.*)$|U', $path, $matches)) { - if (!$phpgw->vfs->file_exists ($path, array (RELATIVE_NONE))) + if (!$GLOBALS['phpgw']->vfs->file_exists ($path, array (RELATIVE_NONE))) { - $phpgw->vfs->override_acl = 1; - $phpgw->vfs->mkdir ($path, array (RELATIVE_NONE)); - $phpgw->vfs->override_acl = 0; +// $GLOBALS['phpgw']->vfs->override_acl = 1; + $GLOBALS['phpgw']->vfs->mkdir ($path, array (RELATIVE_NONE)); +// $GLOBALS['phpgw']->vfs->override_acl = 0; - $group_id = $phpgw->accounts->name2id ($matches[1]); - $phpgw->vfs->set_attributes ($path, array (RELATIVE_NONE), array ("owner_id" => $group_id, "createdby_id" => $group_id)); + $group_id = $GLOBALS['phpgw']->accounts->name2id ($matches[1]); + $GLOBALS['phpgw']->vfs->set_attributes ($path, array (RELATIVE_NONE), array ('owner_id' => $group_id, 'createdby_id' => $group_id)); } } @@ -236,13 +243,13 @@ elseif (preg_match ("|^$fakebase\/(.*)$|U", $path, $matches)) # Verify path is real ### -if ($path != $homedir && $path != "/" && $path != $fakebase) +if ($path != $GLOBALS['homedir'] && $path != '/' && $path != $GLOBALS['fakebase']) { - if (!$phpgw->vfs->file_exists ($path, array (RELATIVE_NONE))) + if (!$GLOBALS['phpgw']->vfs->file_exists ($path, array (RELATIVE_NONE))) { - echo $phpgw->common->error_list (array ("Directory $path does not exist")); + echo $GLOBALS['phpgw']->common->error_list (array ('Directory '.$path.' does not exist')); html_break (2); - html_link ("$appname/index.php?path=$homedir", "Go to your home directory"); + html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], 'Go to your home directory'); html_break (2); html_link_back (); html_page_close (); @@ -253,7 +260,7 @@ if ($path != $homedir && $path != "/" && $path != $fakebase) srand ((double) microtime() * 1000000); if ($update || rand (0, 19) == 4) { - $phpgw->vfs->update_real ($path, array (RELATIVE_NONE)); + $GLOBALS['phpgw']->vfs->update_real ($path, array (RELATIVE_NONE)); } ### @@ -262,7 +269,7 @@ if ($update || rand (0, 19) == 4) if (!$sortby) { - $sortby = "name"; + $sortby = 'name'; } ### @@ -271,7 +278,7 @@ if (!$sortby) if (!$show_upload_boxes || $show_upload_boxes <= 0) { - if (!$show_upload_boxes = $settings["show_upload_boxes"]) + if (!$show_upload_boxes = $GLOBALS['settings']['show_upload_boxes']) { $show_upload_boxes = 5; } @@ -284,16 +291,19 @@ if (!$show_upload_boxes || $show_upload_boxes <= 0) # home directory and the directories for the groups they're in ### -if ($path == $fakebase) +$numoffiles = 0; +if ($path == $GLOBALS['fakebase']) { - if (!$phpgw->vfs->file_exists ($homedir, array (RELATIVE_NONE))) + if (!$GLOBALS['phpgw']->vfs->file_exists ($GLOBALS['homedir'], array (RELATIVE_NONE))) { - $phpgw->vfs->mkdir ($homedir, array (RELATIVE_NONE)); + $GLOBALS['phpgw']->vfs->mkdir ($GLOBALS['homedir'], array (RELATIVE_NONE)); } - $ls_array = $phpgw->vfs->ls ($homedir, array (RELATIVE_NONE), False, False, True); + $ls_array = $GLOBALS['phpgw']->vfs->ls ($GLOBALS['homedir'], array (RELATIVE_NONE), False, False, True); $files_array[] = $ls_array[0]; $numoffiles++; +// $files_array = $ls_array; +// $numoffiles = count($ls_array); reset ($memberships); while (list ($num, $group_array) = each ($memberships)) @@ -302,18 +312,18 @@ if ($path == $fakebase) # If the group doesn't have access to this app, we don't show it ### - if (!$membership_applications[$group_array["account_name"]][$appname]["enabled"]) + if (!$membership_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) { continue; } - if (!$phpgw->vfs->file_exists ("$fakebase/$group_array[account_name]", array (RELATIVE_NONE))) + if (!$GLOBALS['phpgw']->vfs->file_exists ($GLOBALS['fakebase'].'/'.$group_array['account_name'], array (RELATIVE_NONE))) { - $phpgw->vfs->mkdir ("$fakebase/$group_array[account_name]", array (RELATIVE_NONE)); - $phpgw->vfs->set_attributes ("$fakebase/$group_array[account_name]", array (RELATIVE_NONE), array ("owner_id" => $group_array["account_id"], "createdby_id" => $group_array["account_id"])); + $GLOBALS['phpgw']->vfs->mkdir ($GLOBALS['fakebase'].'/'.$group_array['account_name'], array (RELATIVE_NONE)); + $GLOBALS['phpgw']->vfs->set_attributes ($GLOBALS['fakebase'].'/'.$group_array['account_name'], array (RELATIVE_NONE), array ('owner_id' => $group_array['account_id'], 'createdby_id' => $group_array['account_id'])); } - $ls_array = $phpgw->vfs->ls ("$fakebase/$group_array[account_name]", array (RELATIVE_NONE), False, False, True); + $ls_array = $GLOBALS['phpgw']->vfs->ls ($GLOBALS['fakebase'].'/'.$group_array['account_name'], array (RELATIVE_NONE), False, False, True); $files_array[] = $ls_array[0]; @@ -322,12 +332,21 @@ if ($path == $fakebase) } else { - $ls_array = $phpgw->vfs->ls ($path, array (RELATIVE_NONE), False, False, False, $sortby); + $ls_array = $GLOBALS['phpgw']->vfs->ls ($path, array (RELATIVE_NONE), False, False, False, $sortby); + + if ($phpwh_debug) + { + echo '# of files found in "'.$path.'" : '.count($ls_array).'
'."\n"; + } while (list ($num, $file_array) = each ($ls_array)) { $numoffiles++; $files_array[] = $file_array; + if ($phpwh_debug) + { + echo 'Filename: '.$file_array['name'].'
'."\n"; + } } } @@ -347,62 +366,68 @@ if ($download) $download_browser = CreateObject ('phpgwapi.browser'); $download_browser->content_header ($fileman[$i]); - echo $phpgw->vfs->read ($fileman[$i]); - $phpgw->common->phpgw_exit (); + echo $GLOBALS['phpgw']->vfs->read ($fileman[$i]); + $GLOBALS['phpgw']->common->phpgw_exit (); } } -if ($op == "view" && $file) +if ($op == 'view' && $file) { - $ls_array = $phpgw->vfs->ls ($file, array (RELATIVE_ALL), False, False, True); +// $ls_array = $GLOBALS['phpgw']->vfs->ls ($path.'/'.$file, array (RELATIVE_ALL), False, False, True); - if ($ls_array[0]["mime_type"]) - { - $mime_type = $ls_array[0]["mime_type"]; - } - elseif ($settings["viewtextplain"]) - { - $mime_type = "text/plain"; - } +// if ($ls_array[0]['mime_type']) +// { +// $mime_type = $ls_array[0]['mime_type']; +// } +// elseif ($GLOBALS['settings']['viewtextplain']) +// { +// $mime_type = 'text/plain'; +// } - header('Content-type: ' . $mime_type); - echo $phpgw->vfs->read ($file); - $phpgw->common->phpgw_exit (); + Header('Content-length: '.$GLOBALS['phpgw']->vfs->get_size($path.'/'.$file,array(RELATIVE_ALL))); + Header('Content-type: '.$GLOBALS['phpgw']->vfs->file_type($path.'/'.$file,array(RELATIVE_ALL))); + Header('Content-disposition: attachment; filename="'.$file.'"'); + echo $GLOBALS['phpgw']->vfs->read($path.'/'.$file,array(RELATIVE_ALL)); + flush(); + +// header('Content-type: ' . $mime_type); +// echo $GLOBALS['phpgw']->vfs->read ($path.'/'.$file); + $GLOBALS['phpgw']->common->phpgw_exit (); } -if ($op == "history" && $file) +if ($op == 'history' && $file) { html_table_begin (); html_table_row_begin (); html_table_col_begin (); - html_text_bold ("Date"); + html_text_bold ('Date'); html_table_col_end (); html_table_col_begin (); - html_text_bold ("Version"); + html_text_bold ('Version'); html_table_col_end (); html_table_col_begin (); - html_text_bold ("Who"); + html_text_bold ('Who'); html_table_col_end (); html_table_col_begin (); - html_text_bold ("Operation"); + html_text_bold ('Operation'); html_table_col_end (); html_table_row_end (); - $journal_array = $phpgw->vfs->get_journal ($file, array (RELATIVE_ALL)); + $journal_array = $GLOBALS['phpgw']->vfs->get_journal ($file, array (RELATIVE_ALL)); while (list ($num, $journal_entry) = each ($journal_array)) { html_table_row_begin (); html_table_col_begin (); - html_text ($journal_entry["created"] . html_nbsp (3, 1)); + html_text ($journal_entry['created'] . html_nbsp (3, 1)); html_table_col_end (); html_table_col_begin (); - html_text ($journal_entry["version"] . html_nbsp (3, 1)); + html_text ($journal_entry['version'] . html_nbsp (3, 1)); html_table_col_end (); html_table_col_begin (); - html_text ($phpgw->accounts->id2name ($journal_entry["owner_id"]) . html_nbsp (3, 1)); + html_text ($GLOBALS['phpgw']->accounts->id2name ($journal_entry['owner_id']) . html_nbsp (3, 1)); html_table_col_end (); html_table_col_begin (); - html_text ($journal_entry["comment"]); + html_text ($journal_entry['comment']); html_table_col_end (); } @@ -414,21 +439,21 @@ if ($newfile && $createfile) { if ($badchar = bad_chars ($createfile, True, True)) { - echo $phpgw->common->error_list (array (html_encode ("Filenames cannot contain \"$badchar\"", 1))); + echo $GLOBALS['phpgw']->common->error_list (array (html_encode ('Filenames cannot contain "'.$badchar.'"', 1))); html_break (2); html_link_back (); html_page_close (); } - if ($phpgw->vfs->file_exists ($createfile, array (RELATIVE_ALL))) + if ($GLOBALS['phpgw']->vfs->file_exists ($createfile, array (RELATIVE_ALL))) { - echo $phpgw->common->error_list (array ("File $createfile already exists. Please edit it or delete it first.")); + echo $GLOBALS['phpgw']->common->error_list (array ('File '.$createfile.' already exists. Please edit it or delete it first.')); html_break (2); html_link_back (); html_page_close (); } - if ($phpgw->vfs->touch ($createfile, array (RELATIVE_ALL))) + if ($GLOBALS['phpgw']->vfs->touch ($createfile, array (RELATIVE_ALL))) { $fileman = array (); $fileman[0] = $createfile; @@ -436,11 +461,11 @@ if ($newfile && $createfile) } else { - echo $phpgw->common->error_list (array ("File $createfile could not be created.")); + echo $GLOBALS['phpgw']->common->error_list (array ('File '.$createfile.' could not be created.')); } } -if ($op == "help" && $help_name) +if ($op == 'help' && $help_name) { while (list ($num, $help_array) = each ($help_info)) { @@ -450,27 +475,27 @@ if ($op == "help" && $help_name) $help_array[1] = preg_replace ("/\[(.*)\|(.*)\]/Ue", "html_help_link ('\\1', '\\2', False, True)", $help_array[1]); $help_array[1] = preg_replace ("/\[(.*)\]/Ue", "html_help_link ('\\1', '\\1', False, True)", $help_array[1]); - html_font_set ("4"); - $title = ereg_replace ("_", " ", $help_array[0]); + html_font_set ('4'); + $title = ereg_replace ('_', ' ', $help_array[0]); $title = ucwords ($title); html_text ($title); html_font_end (); html_break (2); - html_font_set ("2"); + html_font_set ('2'); html_text ($help_array[1]); html_font_end (); } - $phpgw->common->phpgw_exit (); + $GLOBALS['phpgw']->common->phpgw_exit (); } ### # Start Main Page ### -html_page_begin ("Users :: $userinfo[username]"); +html_page_begin ('Users :: '.$GLOBALS['userinfo']['username']); html_page_body_begin (HTML_PAGE_BODY_COLOR); if ($messages) @@ -478,13 +503,13 @@ if ($messages) html_text ($messages); } -if (!is_array ($settings)) +if (!is_array ($GLOBALS['settings'])) { - $pref = CreateObject ('phpgwapi.preferences', $userinfo["username"]); - $phpgw->common->hook_single ('add_def_pref', $appname); + $pref = CreateObject ('phpgwapi.preferences', $GLOBALS['userinfo']['username']); + $GLOBALS['phpgw']->common->hook_single ('add_def_pref', $GLOBALS['appname']); $pref->save_repository (True); $pref_array = $pref->read_repository (); - $settings = $pref_array[$appname]; + $GLOBALS['settings'] = $pref_array[$GLOBALS['appname']]; } ### @@ -493,14 +518,14 @@ if (!is_array ($settings)) if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$edit && !$comment_files) { - html_table_begin ("100%"); + 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"); + html_table_col_begin ('center', NULL, 'top'); + html_align ('center'); + html_form_begin ($GLOBALS['appname'].'/index.php?path='.$path); if ($numoffiles || $cwd) { - while (list ($num, $name) = each ($settings)) + while (list ($num, $name) = each ($GLOBALS['settings'])) { if ($name) { @@ -510,47 +535,47 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed $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_col_begin ('center', NULL, NULL, NULL, $columns); + html_table_begin ('100%'); html_table_row_begin (); - html_table_col_begin ("left"); + html_table_col_begin ('left'); - if ($path != "/") + if ($path != '/') { - html_link ("$appname/index.php?path=$lesspath", html_image ("images/folder-up.gif", "Up", "left", 0, NULL, 1)); - html_help_link ("up"); + html_link ($GLOBALS['appname'].'/index.php?path='.$lesspath, html_image ('images/folder-up.gif', 'Up', 'left', 0, NULL, 1)); + html_help_link ('up'); } html_table_col_end (); - html_table_col_begin ("center"); + html_table_col_begin ('center'); if ($cwd) { - if ($path == $homedir) + if ($path == $GLOBALS['homedir']) { - html_image ("images/folder-home.gif", "Folder", "center"); + html_image ('images/folder-home.gif', 'Folder', 'center'); } else { - html_image ("images/folder.gif", "Folder", "center"); + html_image ('images/folder.gif', 'Folder', 'center'); } } else { - html_image ("images/folder-home.gif", "Home"); + 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_help_link ("directory_name"); + html_help_link ('directory_name'); html_table_col_end (); - html_table_col_begin ("right"); + html_table_col_begin ('right'); - if ($path != $homedir) + if ($path != $GLOBALS['homedir']) { - html_link ("$appname/index.php?path=$homedir", html_image ("images/folder-home.gif", "Home", "right", 0, NULL, 1)); - html_help_link ("home"); + html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], html_image ('images/folder-home.gif', 'Home', 'right', 0, NULL, 1)); + html_help_link ('home'); } html_table_col_end (); @@ -566,18 +591,18 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed ### html_table_col_begin (); - html_text ("Sort by:" . html_nbsp (1, 1), NULL, NULL, 1); - html_help_link ("sort_by"); + html_text ('Sort by:' . html_nbsp (1, 1), NULL, NULL, 1); + html_help_link ('sort_by'); html_table_col_end (); reset ($file_attributes); while (list ($internal, $displayed) = each ($file_attributes)) { - if ($settings[$internal]) + if ($GLOBALS['settings'][$internal]) { html_table_col_begin (); - html_link ("$appname/index.php?path=$path&sortby=$internal", html_text_bold ("$displayed", 1, 1)); - html_help_link (strtolower (ereg_replace (" ", "_", $displayed))); + html_link ($GLOBALS['appname'].'/index.php?path='.$path.'&sortby='.$internal, html_text_bold ($displayed, 1, 1)); + html_help_link (strtolower (ereg_replace (' ', '_', $displayed))); html_table_col_end (); } } @@ -586,7 +611,7 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed html_table_col_end (); html_table_row_end (); - if ($settings["dotdot"] && $settings["name"] && $path != "/") + if ($GLOBALS['settings']['dotdot'] && $GLOBALS['settings']['name'] && $path != '/') { html_table_row_begin (); html_table_col_begin (); @@ -594,14 +619,14 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed /* 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_image ('images/folder.gif', 'Folder'); + html_link ($GLOBALS['appname'].'/index.php?path='.$lesspath, '..'); html_table_col_end (); - if ($settings["mime_type"]) + if ($GLOBALS['settings']['mime_type']) { html_table_col_begin (); - html_text ("Directory"); + html_text ('Directory'); html_table_col_end (); } @@ -623,14 +648,14 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed unset ($renamethis); unset ($edit_this_comment); - for ($j = 0; $j != $numoffiles; $j++) + for ($j = 0; $j != $numoffiles; $j++) { - if ($fileman[$j] == $files["name"]) + if ($fileman[$j] == $files['name']) { - $this_selected = 1; + $this_selected = 1; break; } - } + } if ($rename && $this_selected) { @@ -642,7 +667,7 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed } } - if (!$settings["dotfiles"] && ereg ("^\.", $files["name"])) + if (!$GLOBALS['settings']['dotfiles'] && ereg ("^\.", $files['name'])) { continue; } @@ -653,19 +678,19 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Checkboxes ### - html_table_col_begin ("right"); + html_table_col_begin ('right'); - if (!$rename && !$edit_comments && $path != $fakebase && $path != "/") + if (!$rename && !$edit_comments && $path != $GLOBALS['fakebase'] && $path != '/') { - html_form_input ("checkbox", "fileman[$i]", base64_encode ("$files[name]")); + html_form_input ('checkbox', 'fileman['.$i.']', base64_encode ($files['name'])); } elseif ($renamethis) { - html_form_input ("hidden", "fileman[" . base64_encode ($files[name]) . "]", "$files[name]", NULL, NULL, "checked"); + html_form_input ('hidden', 'fileman[' . base64_encode ($files['name']) . ']', $files['name'], NULL, NULL, 'checked'); } else { - html_nbsp; + html_nbsp(); } html_table_col_end (); @@ -674,44 +699,50 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # File name and icon ### - if ($settings["name"]) + if ($GLOBALS['settings']['name']) { + if ($phpwh_debug) + { + echo 'Setting file name: '.$files['name'].'
'."\n"; + } + html_table_col_begin (); if ($renamethis) { - if ($files["mime_type"] == "Directory") + if ($files['mime_type'] == 'Directory') { - html_image ("images/folder.gif", "Folder"); + html_image ('images/folder.gif', 'Folder'); } - html_form_input ("text", "renamefiles[" . base64_encode ($files[name]) . "]", $files["name"], 255); + html_form_input ('text', 'renamefiles[' . base64_encode ($files['name']) . ']', $files['name'], 255); } else { - if ($files["mime_type"] == "Directory") + if ($files['mime_type'] == 'Directory') { - html_image ("images/folder.gif", "Folder"); - html_link ("$appname/index.php?path=$path$dispsep$files[name]", $files["name"]); - } + html_image ('images/folder.gif', 'Folder'); + html_link ($GLOBALS['appname'].'/index.php?path='.$path.$dispsep.$files['name'], $files['name']); + } else { - if ($settings["viewonserver"] && isset ($filesdir) && !$files["link_directory"]) + if ($GLOBALS['settings']['viewonserver'] && isset ($GLOBALS['filesdir']) && !$files['link_directory']) { - $clickview = "$filesdir$pwd/$files[name]"; + $clickview = $GLOBALS['filesdir'].$pwd.'/'.$files['name']; + echo 'Setting clickview = '.$clickview.'
'."\n"; } else { - $clickview = "$appname/index.php?op=view&file=$files[name]&path=$path"; + $clickview = $GLOBALS['appname'].'/index.php?op=view&file='.$files['name'].'&path='.$path; } - if ($settings["viewinnewwin"]) + if ($GLOBALS['settings']['viewinnewwin']) { - $target = "_new"; + $target = '_new'; } - html_link ($clickview, $files["name"], 0, 1, 0, $target); + html_link ($clickview, $files['name'], 0, 1, 0, $target); } - } + } html_table_col_end (); } @@ -720,10 +751,10 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # MIME type ### - if ($settings["mime_type"]) + if ($GLOBALS['settings']['mime_type']) { html_table_col_begin (); - html_text ($files["mime_type"]); + html_text ($files['mime_type']); html_table_col_end (); } @@ -731,11 +762,11 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # File size ### - if ($settings["size"]) + if ($GLOBALS['settings']['size']) { html_table_col_begin (); - $size = $phpgw->vfs->get_size ($files["directory"] . "/" . $files["name"], array (RELATIVE_NONE)); + $size = $GLOBALS['phpgw']->vfs->get_size ($files['directory'] . '/' . $files['name'], array (RELATIVE_NONE)); borkb ($size); html_table_col_end (); @@ -744,10 +775,10 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed ### # Date created ### - if ($settings["created"]) + if ($GLOBALS['settings']['created']) { html_table_col_begin (); - html_text ($files["created"]); + html_text ($files['created']); html_table_col_end (); } @@ -755,12 +786,12 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Date modified ### - if ($settings["modified"]) + if ($GLOBALS['settings']['modified']) { html_table_col_begin (); - if ($files["modified"] != "0000-00-00") + if ($files['modified'] != '0000-00-00') { - html_text ($files["modified"]); + html_text ($files['modified']); } html_table_col_end (); } @@ -769,10 +800,10 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Owner name ### - if ($settings["owner"]) + if ($GLOBALS['settings']['owner']) { html_table_col_begin (); - html_text ($phpgw->accounts->id2name ($files["owner_id"])); + html_text ($GLOBALS['phpgw']->accounts->id2name ($files['owner_id'])); html_table_col_end (); } @@ -780,12 +811,12 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Creator name ### - if ($settings["createdby_id"]) + if ($GLOBALS['settings']['createdby_id']) { html_table_col_begin (); - if ($files["createdby_id"]) + if ($files['createdby_id']) { - html_text ($phpgw->accounts->id2name ($files["createdby_id"])); + html_text ($GLOBALS['phpgw']->accounts->id2name ($files['createdby_id'])); } html_table_col_end (); } @@ -794,12 +825,12 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Modified by name ### - if ($settings["modifiedby_id"]) + if ($GLOBALS['settings']['modifiedby_id']) { html_table_col_begin (); - if ($files["modifiedby_id"]) + if ($files['modifiedby_id']) { - html_text ($phpgw->accounts->id2name ($files["modifiedby_id"])); + html_text ($GLOBALS['phpgw']->accounts->id2name ($files['modifiedby_id'])); } html_table_col_end (); } @@ -808,10 +839,10 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Application ### - if ($settings["app"]) + if ($GLOBALS['settings']['app']) { html_table_col_begin (); - html_text ($files["app"]); + html_text ($files['app']); html_table_col_end (); } @@ -819,16 +850,16 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Comment ### - if ($settings["comment"]) + if ($GLOBALS['settings']['comment']) { html_table_col_begin (); if ($edit_this_comment) { - html_form_input ("text", "comment_files[" . base64_encode ($files[name]) . "]", html_encode ($files["comment"], 1), 255); + html_form_input ('text', 'comment_files[' . base64_encode ($files['name']) . ']', html_encode ($files['comment'], 1), 255); } else { - html_text ($files["comment"]); + html_text ($files['comment']); } html_table_col_end (); } @@ -837,10 +868,10 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Version ### - if ($settings["version"]) + if ($GLOBALS['settings']['version']) { html_table_col_begin (); - html_link ("$appname/index.php?op=history&file=$files[name]&path=$path", $files["version"], NULL, True, NULL, "_new"); + html_link ($GLOBALS['appname'].'/index.php?op=history&file='.$files['name'].'&path='.$path, $files['version'], NULL, True, NULL, '_new'); html_table_col_end (); } @@ -848,12 +879,12 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Deleteable (currently not used) ### - if ($settings["deleteable"]) + if ($GLOBALS['settings']['deleteable']) { - if ($files["deleteable"] == "N") + if ($files['deleteable'] == 'N') { html_table_col_begin (); - html_image ("images/locked.gif", "Locked"); + html_image ('images/locked.gif', 'Locked'); html_table_col_end (); } else @@ -865,46 +896,46 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed html_table_row_end (); - if ($files["mime_type"] == "Directory") + if ($files['mime_type'] == 'Directory') { $usedspace += $fileinfo[0]; } else { - $usedspace += $files["size"]; + $usedspace += $files['size']; } } html_table_end (); html_break (2); - if ($path != "/" && $path != $fakebase) + if ($path != '/' && $path != $GLOBALS['fakebase']) { if (!$rename && !$edit_comments) { - html_form_input ("submit", "edit", "Edit"); - html_help_link ("edit"); + html_form_input ('submit', 'edit', 'Edit'); + html_help_link ('edit'); html_nbsp (3); } if (!$edit_comments) { - html_form_input ("submit", "rename", "Rename"); - html_help_link ("rename"); + html_form_input ('submit', 'rename', 'Rename'); + html_help_link ('rename'); html_nbsp (3); } if (!$rename && !$edit_comments) { - html_form_input ("submit", "delete", "Delete"); - html_help_link ("delete"); + html_form_input ('submit', 'delete', 'Delete'); + html_help_link ('delete'); html_nbsp (3); } if (!$rename) { - html_form_input ("submit", "edit_comments", "Edit comments"); - html_help_link ("edit_comments"); + html_form_input ('submit', 'edit_comments', 'Edit comments'); + html_help_link ('edit_comments'); } } } @@ -920,19 +951,19 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed ### html_break (1); - html_form_input ("submit", "go", "Go to:"); - html_help_link ("go_to"); + html_form_input ('submit', 'go', 'Go to:'); + html_help_link ('go_to'); - if ($path != "/" && $path != $fakebase) + if ($path != '/' && $path != $GLOBALS['fakebase']) { - html_form_input ("submit", "copy", "Copy to:"); - html_help_link ("copy_to"); + html_form_input ('submit', 'copy', 'Copy to:'); + html_help_link ('copy_to'); - html_form_input ("submit", "move", "Move to:"); - html_help_link ("move_to"); + html_form_input ('submit', 'move', 'Move to:'); + html_help_link ('move_to'); } - html_form_select_begin ("todir"); + html_form_select_begin ('todir'); html_break (1); @@ -940,9 +971,9 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # First we get the directories in their home directory ### - $dirs[] = array ("directory" => $fakebase, "name" => $userinfo["account_lid"]); + $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $GLOBALS['userinfo']['account_lid']); - $ls_array = $phpgw->vfs->ls ($homedir, array (RELATIVE_NONE), True, "Directory"); + $ls_array = $GLOBALS['phpgw']->vfs->ls ($GLOBALS['homedir'], array (RELATIVE_NONE), True, 'Directory'); while (list ($num, $dir) = each ($ls_array)) { $dirs[] = $dir; @@ -959,14 +990,14 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Don't list directories for groups that don't have access ### - if (!$membership_applications[$group_array["account_name"]][$appname]["enabled"]) + if (!$membership_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) { continue; } - $dirs[] = array ("directory" => $fakebase, "name" => $group_array["account_name"]); + $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $group_array['account_name']); - $ls_array = $phpgw->vfs->ls ("$fakebase/$group_array[account_name]", array (RELATIVE_NONE), True, "Directory"); + $ls_array = $phpgw->vfs->ls ($GLOBALS['fakebase'].'/'.$group_array[account_name], array (RELATIVE_NONE), True, 'Directory'); while (list ($num, $dir) = each ($ls_array)) { $dirs[] = $dir; @@ -976,7 +1007,7 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed reset ($dirs); while (list ($num, $dir) = each ($dirs)) { - if (!$dir["directory"]) + if (!$dir['directory']) { continue; } @@ -985,82 +1016,82 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # So we don't display // ### - if ($dir["directory"] != '/') + if ($dir['directory'] != '/') { - $dir["directory"] .= '/'; + $dir['directory'] .= '/'; } ### # No point in displaying the current directory, or a directory that doesn't exist ### - if ((($dir["directory"] . $dir["name"]) != $path) && $phpgw->vfs->file_exists ($dir["directory"] . $dir["name"], array (RELATIVE_NONE))) + if ((($dir['directory'] . $dir['name']) != $path) && $GLOBALS['phpgw']->vfs->file_exists ($dir['directory'] . $dir['name'], array (RELATIVE_NONE))) { - html_form_option ($dir["directory"] . $dir["name"], $dir["directory"] . $dir["name"]); + html_form_option ($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); } } html_form_select_end (); - html_help_link ("directory_list"); + html_help_link ('directory_list'); - if ($path != "/" && $path != $fakebase) + if ($path != '/' && $path != $GLOBALS['fakebase']) { html_break (1); - html_form_input ("submit", "download", "Download"); - html_help_link ("download"); + html_form_input ('submit', 'download', 'Download'); + html_help_link ('download'); html_nbsp (3); - html_form_input ("text", "createdir", NULL, 255, 15); - html_form_input ("submit", "newdir", "Create Folder"); - html_help_link ("create_folder"); + html_form_input ('text', 'createdir', NULL, 255, 15); + html_form_input ('submit', 'newdir', 'Create Folder'); + html_help_link ('create_folder'); } html_break (1); - html_form_input ("submit", "update", "Update"); - html_help_link ("update"); + html_form_input ('submit', 'update', 'Update'); + html_help_link ('update'); - if ($path != "/" && $path != $fakebase) + if ($path != '/' && $path != $GLOBALS['fakebase']) { html_nbsp (3); - html_form_input ("text", "createfile", NULL, 255, 15); - html_form_input ("submit", "newfile", "Create File"); - html_help_link ("create_file"); + html_form_input ('text', 'createfile', NULL, 255, 15); + html_form_input ('submit', 'newfile', 'Create File'); + html_help_link ('create_file'); } - if ($settings["show_command_line"]) + if ($GLOBALS['settings']['show_command_line']) { html_break (2); - html_form_input ("text", "command_line", NULL, NULL, 50); - html_help_link ("command_line"); + html_form_input ('text', 'command_line', NULL, NULL, 50); + html_help_link ('command_line'); html_break (1); - html_form_input ("submit", "execute", "Execute"); - html_help_link ("execute"); + html_form_input ('submit', 'execute', 'Execute'); + html_help_link ('execute'); } html_form_end (); - html_help_link ("file_stats"); + html_help_link ('file_stats'); html_break (1); - html_text_bold ("Files: "); + html_text_bold ('Files: '); html_text ($numoffiles); html_nbsp (3); - html_text_bold ("Used space: "); + html_text_bold ('Used space: '); html_text (borkb ($usedspace, NULL, 1)); html_nbsp (3); - if ($path == $homedir || $path == $fakebase) + if ($path == $GLOBALS['homedir'] || $path == $GLOBALS['fakebase']) { - html_text_bold ("Unused space: "); - html_text (borkb ($userinfo["hdspace"] - $usedspace, NULL, 1)); + html_text_bold ('Unused space: '); + html_text (borkb ($GLOBALS['userinfo']['hdspace'] - $usedspace, NULL, 1)); - $ls_array = $phpgw->vfs->ls ($path, array (RELATIVE_NONE)); + $ls_array = $GLOBALS['phpgw']->vfs->ls ($path, array (RELATIVE_NONE)); $i = count ($ls_array); html_break (2); - html_text_bold ("Total Files: "); + html_text_bold ('Total Files: '); html_text ($i); } @@ -1068,47 +1099,47 @@ if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$ed # Show file upload boxes. Note the last argument to html (). Repeats $show_upload_boxes times ### - if ($path != "/" && $path != $fakebase) + if ($path != '/' && $path != $GLOBALS['fakebase']) { html_break (2); - html_form_begin ("$appname/index.php?op=upload&path=$path", "post", "multipart/form-data"); + html_form_begin ($GLOBALS['appname'].'/index.php?op=upload&path='.$path, 'post', 'multipart/form-data'); html_table_begin (); - html_table_row_begin ("center"); + html_table_row_begin ('center'); html_table_col_begin (); - html_text_bold ("File"); - html_help_link ("upload_file"); + html_text_bold ('File'); + html_help_link ('upload_file'); html_table_col_end (); html_table_col_begin (); - html_text_bold ("Comment"); - html_help_link ("upload_comment"); + html_text_bold ('Comment'); + html_help_link ('upload_comment'); html_table_col_end (); html_table_row_end (); html_table_row_begin (); html_table_col_begin (); - html_form_input ("hidden", "show_upload_boxes", base64_encode ($show_upload_boxes)); - html (html_form_input ("file", "upload_file[]", NULL, 255, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); + html_form_input ('hidden', 'show_upload_boxes', base64_encode ($show_upload_boxes)); + html (html_form_input ('file', 'upload_file[]', NULL, 255, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); html_table_col_end (); html_table_col_begin (); - html (html_form_input ("text", "upload_comment[]", NULL, NULL, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); + html (html_form_input ('text', 'upload_comment[]', NULL, NULL, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); html_table_col_end (); html_table_row_end (); html_table_end (); - html_form_input ("submit", "upload_files", "Upload files"); - html_help_link ("upload_files"); + html_form_input ('submit', 'upload_files', 'Upload files'); + html_help_link ('upload_files'); html_break (2); - html_text ("Show" . html_nbsp (1, True)); - html_link ("$appname/index.php?show_upload_boxes=5", "5"); + html_text ('Show' . html_nbsp (1, True)); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=5', '5'); html_nbsp (); - html_link ("$appname/index.php?show_upload_boxes=10", "10"); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=10', '10'); html_nbsp (); - html_link ("$appname/index.php?show_upload_boxes=20", "20"); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=20', '20'); html_nbsp (); - html_link ("$appname/index.php?show_upload_boxes=50", "50"); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=50', '50'); html_nbsp (); - html_text ("upload fields"); + html_text ('upload fields'); html_nbsp (); - html_help_link ("show_upload_fields"); + html_help_link ('show_upload_fields'); html_form_end (); } } @@ -1139,10 +1170,10 @@ if ($edit) $content = $edit_file_content; html_break (1); - html_text_bold ("Preview of $path/$edit_file"); + html_text_bold ('Preview of '.$path.'/'.$edit_file); html_break (2); - html_table_begin ("90%"); + html_table_begin ('90%'); html_table_row_begin (); html_table_col_begin (); html_text (nl2br ($content)); @@ -1154,15 +1185,15 @@ if ($edit) { $content = $edit_file_content; - if ($phpgw->vfs->write ($edit_file, array (RELATIVE_ALL), $content)) + if ($GLOBALS['phpgw']->vfs->write ($edit_file, array (RELATIVE_ALL), $content)) { - html_text_bold ("Saved $path/$edit_file"); + html_text_bold ('Saved '.$path.'/'.$edit_file); html_break (2); html_link_back (); } else { - html_text_error ("Could not save $path/$edit_file"); + html_text_error ('Could not save '.$path.'/'.$edit_file); html_break (2); html_link_back (); } @@ -1176,17 +1207,17 @@ if ($edit) $fileman[$j]; $content = $$fileman[$j]; - echo "fileman[$j]: $fileman[$j]
$content
"; + echo 'fileman['.$j.']: '.$fileman[$j].'
'.$content.'
'; continue; - if ($phpgw->vfs->write ($fileman[$j], array (RELATIVE_ALL), $content)) + if ($GLOBALS['phpgw']->vfs->write ($fileman[$j], array (RELATIVE_ALL), $content)) { - html_text_bold ("Saved $path/$fileman[$j]"); + html_text_bold ('Saved '.$path.'/'.$fileman[$j]); html_break (1); } else { - html_text_error ("Could not save $path/$fileman[$j]"); + html_text_error ('Could not save '.$path.'/'.$fileman[$j]); html_break (1); } } @@ -1211,7 +1242,7 @@ if ($edit) continue; } - if ($fileman[$j] && $phpgw->vfs->file_exists ($fileman[$j], array (RELATIVE_ALL))) + if ($fileman[$j] && $GLOBALS['phpgw']->vfs->file_exists ($fileman[$j], array (RELATIVE_ALL))) { if ($edit_file) { @@ -1219,13 +1250,13 @@ if ($edit) } else { - $content = $phpgw->vfs->read ($fileman[$j]); + $content = $GLOBALS['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]); + html_table_begin ('100%'); + html_form_begin ($GLOBALS['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, @@ -1234,19 +1265,19 @@ if ($edit) for ($i = 0; $i != $numoffiles; $i++) { - html_form_input ("hidden", "fileman[$i]", base64_encode ($fileman[$i])); + html_form_input ('hidden', 'fileman['.$i.']', base64_encode ($fileman[$i])); } html_table_row_begin (); html_table_col_begin (); - html_form_textarea ("edit_file_content", 35, 75, $content); + html_form_textarea ('edit_file_content', 35, 75, $content); html_table_col_end (); - html_table_col_begin ("center"); - html_form_input ("submit", "edit_preview", "Preview " . html_encode ($fileman[$j], 1)); + html_table_col_begin ('center'); + html_form_input ('submit', 'edit_preview', 'Preview ' . html_encode ($fileman[$j], 1)); html_break (1); - html_form_input ("submit", "edit_save", "Save " . html_encode ($fileman[$j], 1)); + html_form_input ('submit', 'edit_save', 'Save ' . html_encode ($fileman[$j], 1)); // html_break (1); -// html_form_input ("submit", "edit_save_all", "Save all"); +// html_form_input ('submit', 'edit_save_all', 'Save all'); html_table_col_end (); html_table_row_end (); html_break (2); @@ -1260,13 +1291,13 @@ if ($edit) # Handle File Uploads ### -elseif ($op == "upload" && $path != "/" && $path != $fakebase) +elseif ($op == 'upload' && $path != '/' && $path != $GLOBALS['fakebase']) { for ($i = 0; $i != $show_upload_boxes; $i++) { if ($badchar = bad_chars ($upload_file_name[$i], True, True)) { - echo $phpgw->common->error_list (array (html_encode ("Filenames cannot contain \"$badchar\"", 1))); + echo $GLOBALS['phpgw']->common->error_list (array (html_encode ('Filenames cannot contain "'.$badchar.'"', 1))); continue; } @@ -1275,41 +1306,41 @@ elseif ($op == "upload" && $path != "/" && $path != $fakebase) # Check to see if the file exists in the database, and get its info at the same time ### - $ls_array = $phpgw->vfs->ls ($path . "/" . $upload_file_name[$i], array (RELATIVE_NONE), False, False, True); + $ls_array = $GLOBALS['phpgw']->vfs->ls ($path . '/' . $upload_file_name[$i], array (RELATIVE_NONE), False, False, True); $fileinfo = $ls_array[0]; - if ($fileinfo["name"]) + if ($fileinfo['name']) { - if ($fileinfo["mime_type"] == "Directory") + if ($fileinfo['mime_type'] == 'Directory') { - echo $phpgw->common->error_list (array ("Cannot replace $fileinfo[name] because it is a directory")); + echo $GLOBALS['phpgw']->common->error_list (array ('Cannot replace '.$fileinfo['name'].' because it is a directory')); continue; } } if ($upload_file_size[$i] > 0) { - if ($fileinfo["name"] && $fileinfo["deleteable"] != "N") + if ($fileinfo['name'] && $fileinfo['deleteable'] != 'N') { - $phpgw->vfs->set_attributes ($upload_file_name[$i], array (RELATIVE_ALL), array ("owner_id" => $userinfo["username"], "modifiedby_id" => $userinfo["username"], "modified" => $now, "size" => $upload_file_size[$i], mime_type => $upload_file_type[$i], "deleteable" => "Y", "comment" => stripslashes ($upload_comment[$i]))); - $phpgw->vfs->cp ($upload_file[$i], "$upload_file_name[$i]", array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)); + $GLOBALS['phpgw']->vfs->set_attributes ($upload_file_name[$i], array (RELATIVE_ALL), array ('owner_id' => $GLOBALS['userinfo']['username'], 'modifiedby_id' => $GLOBALS['userinfo']['username'], 'modified' => $now, 'size' => $upload_file_size[$i], 'mime_type' => $upload_file_type[$i], 'deleteable' => 'Y', 'comment' => stripslashes ($upload_comment[$i]))); + $GLOBALS['phpgw']->vfs->cp ($upload_file[$i], $upload_file_name[$i], array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)); - html_text_summary ("Replaced $disppath/$upload_file_name[$i]", $upload_file_size[$i]); + html_text_summary ('Replaced '.$disppath.'/'.$upload_file_name[$i], $upload_file_size[$i]); } else { - $phpgw->vfs->cp ($upload_file[$i], $upload_file_name[$i], array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)); - $phpgw->vfs->set_attributes ($upload_file_name[$i], array (RELATIVE_ALL), array ("mime_type" => $upload_file_type[$i], "comment" => stripslashes ($upload_comment[$i]))); + $GLOBALS['phpgw']->vfs->cp ($upload_file[$i], $upload_file_name[$i], array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)); + $GLOBALS['phpgw']->vfs->set_attributes ($upload_file_name[$i], array (RELATIVE_ALL), array ('mime_type' => $upload_file_type[$i], 'comment' => stripslashes ($upload_comment[$i]))); - html_text_summary ("Created $disppath/$upload_file_name[$i]", $upload_file_size[$i]); + html_text_summary ('Created '.$disppath.'/'.$upload_file_name[$i], $upload_file_size[$i]); } } elseif ($upload_file_name[$i]) { - $phpgw->vfs->touch ($upload_file_name[$i], array (RELATIVE_ALL)); - $phpgw->vfs->set_attributes ($upload_file_name[$i], array (RELATIVE_ALL), array ("mime_type" => $upload_file_type[$i], "comment" => $upload_comment[$i])); + $GLOBALS['phpgw']->vfs->touch ($upload_file_name[$i], array (RELATIVE_ALL)); + $GLOBALS['phpgw']->vfs->set_attributes ($upload_file_name[$i], array (RELATIVE_ALL), array ('mime_type' => $upload_file_type[$i], 'comment' => $upload_comment[$i])); - html_text_summary ("Created $disppath/$upload_file_name[$i]", $file_size[$i]); + html_text_summary ('Created '.$disppath.'/'.$upload_file_name[$i], $file_size[$i]); } } @@ -1327,13 +1358,13 @@ elseif ($comment_files) { if ($badchar = bad_chars ($comment_files[$file], False, True)) { - echo $phpgw->common->error_list (array (html_text_italic ($file, 1) . html_encode (": Comments cannot contain \"$badchar\"", 1))); + echo $GLOBALS['phpgw']->common->error_list (array (html_text_italic ($file, 1) . html_encode (': Comments cannot contain "'.$badchar.'"', 1))); continue; } - $phpgw->vfs->set_attributes ($file, array (RELATIVE_ALL), array ("comment" => stripslashes ($comment_files[$file]))); + $GLOBALS['phpgw']->vfs->set_attributes ($file, array (RELATIVE_ALL), array ('comment' => stripslashes ($comment_files[$file]))); - html_text_summary ("Updated comment for $path/$file"); + html_text_summary ('Updated comment for '.$path.'/'.$file); } html_break (2); @@ -1350,21 +1381,21 @@ elseif ($renamefiles) { if ($badchar = bad_chars ($to, True, True)) { - echo $phpgw->common->error_list (array (html_encode ("File names cannot contain \"$badchar\"", 1))); + echo $GLOBALS['phpgw']->common->error_list (array (html_encode ('File names cannot contain "'.$badchar.'"', 1))); continue; } if (ereg ("/", $to) || ereg ("\\\\", $to)) { - echo $phpgw->common->error_list (array ("File names cannot contain \\ or /")); + echo $GLOBALS['phpgw']->common->error_list (array ("File names cannot contain \\ or /")); } - elseif (!$phpgw->vfs->mv ($from, $to)) + elseif (!$GLOBALS['phpgw']->vfs->mv ($from, $to)) { - echo $phpgw->common->error_list (array ("Could not rename $disppath/$from to $disppath/$to")); + echo $GLOBALS['phpgw']->common->error_list (array ('Could not rename '.$disppath.'/'.$from.' to '.$disppath.'/'.$to)); } else { - html_text_summary ("Renamed $disppath/$from to $disppath/$to"); + html_text_summary ('Renamed '.$disppath.'/'.$from.' to '.$disppath.'/'.$to); } } @@ -1380,21 +1411,21 @@ elseif ($move) { while (list ($num, $file) = each ($fileman)) { - if ($phpgw->vfs->mv ($file, $todir . "/" . $file, array (RELATIVE_ALL, RELATIVE_NONE))) + if ($GLOBALS['phpgw']->vfs->mv ($file, $todir . '/' . $file, array (RELATIVE_ALL, RELATIVE_NONE))) { $moved++; - html_text_summary ("Moved $disppath/$file to $todir/$file"); + html_text_summary ('Moved '.$disppath.'/'.$file.' to '.$todir.'/'.$file); } else { - echo $phpgw->common->error_list (array ("Could not move $disppath/$file to $todir/$file")); + echo $GLOBALS['phpgw']->common->error_list (array ('Could not move '.$disppath.'/'.$file.' to '.$todir.'/'.$file)); } } if ($moved) { html_break (2); - html_link ("$appname/index.php?path=$todir", "Go to $todir"); + html_link ($GLOBALS['appname'].'/index.php?path='.$todir, 'Go to '.$todir); } html_break (2); @@ -1409,21 +1440,21 @@ elseif ($copy) { while (list ($num, $file) = each ($fileman)) { - if ($phpgw->vfs->cp ($file, $todir . "/" . $file, array (RELATIVE_ALL, RELATIVE_NONE))) + if ($GLOBALS['phpgw']->vfs->cp ($file, $todir . '/' . $file, array (RELATIVE_ALL, RELATIVE_NONE))) { $copied++; - html_text_summary ("Copied $disppath/$file to $todir/$file"); + html_text_summary ('Copied '.$disppath.'/'.$file.' to '.$todir.'/'.$file); } else { - echo $phpgw->common->error_list (array ("Could not copy $disppath/$file to $todir/$file")); + echo $GLOBALS['phpgw']->common->error_list (array ('Could not copy '.$disppath.'/'.$file.' to '.$todir.'/'.$file)); } } if ($copied) { html_break (2); - html_link ("$appname/index.php?path=$todir", "Go to $todir"); + html_link ($GLOBALS['appname'].'/index.php?path='.$todir, 'Go to '.$todir); } html_break (2); @@ -1440,13 +1471,13 @@ elseif ($delete) { if ($fileman[$i]) { - if ($phpgw->vfs->delete ($fileman[$i])) + if ($GLOBALS['phpgw']->vfs->delete ($fileman[$i])) { - html_text_summary ("Deleted $disppath/$fileman[$i]", $fileinfo["size"]); + html_text_summary ('Deleted '.$disppath.'/'.$fileman[$i], $fileinfo['size']); } else { - $phpgw->common->error_list (array ("Could not delete $disppath/$fileman[$i]")); + $GLOBALS['phpgw']->common->error_list (array ('Could not delete '.$disppath.'/'.$fileman[$i])); } } } @@ -1459,35 +1490,35 @@ elseif ($newdir && $createdir) { if ($badchar = bad_chars ($createdir, True, True)) { - echo $phpgw->common->error_list (array (html_encode ("Directory names cannot contain \"$badchar\"", 1))); + echo $GLOBALS['phpgw']->common->error_list (array (html_encode ('Directory names cannot contain "'.$badchar.'"', 1))); html_break (2); html_link_back (); html_page_close (); } - if ($createdir[strlen($createdir)-1] == " " || $createdir[0] == " ") + if ($createdir[strlen($createdir)-1] == ' ' || $createdir[0] == ' ') { - echo $phpgw->common->error_list (array ("Cannot create directory because it begins or ends in a space")); + echo $GLOBALS['phpgw']->common->error_list (array ('Cannot create directory because it begins or ends in a space')); html_break (2); html_link_back (); html_page_close (); } - $ls_array = $phpgw->vfs->ls ($path . "/" . $createdir, array (RELATIVE_NONE), False, False, True); + $ls_array = $GLOBALS['phpgw']->vfs->ls ($path . '/' . $createdir, array (RELATIVE_NONE), False, False, True); $fileinfo = $ls_array[0]; - if ($fileinfo["name"]) + if ($fileinfo['name']) { - if ($fileinfo["mime_type"] != "Directory") + if ($fileinfo['mime_type'] != 'Directory') { - echo $phpgw->common->error_list (array ("$fileinfo[name] already exists as a file")); + echo $GLOBALS['phpgw']->common->error_list (array ($fileinfo['name'].' already exists as a file')); html_break (2); html_link_back (); html_page_close (); } else { - echo $phpgw->common->error_list (array ("Directory $fileinfo[name] already exists")); + echo $GLOBALS['phpgw']->common->error_list (array ('Directory '.$fileinfo['name'].' already exists')); html_break (2); html_link_back (); html_page_close (); @@ -1495,15 +1526,15 @@ elseif ($newdir && $createdir) } else { - if ($phpgw->vfs->mkdir ($createdir)) + if ($GLOBALS['phpgw']->vfs->mkdir ($createdir)) { - html_text_summary ("Created directory $disppath/$createdir"); + html_text_summary ('Created directory '.$disppath.'/'.$createdir); html_break (2); - html_link ("$appname/index.php?path=$disppath/$createdir", "Go to $disppath/$createdir"); + html_link ($GLOBALS['appname'].'/index.php?path='.$disppath.'/'.$createdir, 'Go to '.$disppath.'/'.$createdir); } else { - echo $phpgw->common->error_list (array ("Could not create $disppath/$createdir")); + echo $GLOBALS['phpgw']->common->error_list (array ('Could not create '.$disppath.'/'.$createdir)); } } diff --git a/phpgwapi/inc/class.vfs_sql.inc.php b/phpgwapi/inc/class.vfs_sql.inc.php index 3d130a2231..e39bbee6a8 100644 --- a/phpgwapi/inc/class.vfs_sql.inc.php +++ b/phpgwapi/inc/class.vfs_sql.inc.php @@ -91,6 +91,7 @@ var $override_acl; var $linked_dirs; var $meta_types; + var $now; /*! @function vfs @@ -103,12 +104,15 @@ $this->working_id = $GLOBALS['phpgw_info']['user']['account_id']; $this->working_lid = $GLOBALS['phpgw']->accounts->id2name($this->working_id); $this->now = date ('Y-m-d'); - $this->override_acl = 0; +// $this->override_acl = 0; + $this->override_acl = 1; /* File/dir attributes, each corresponding to a database field. Useful for use in loops If an attribute was added to the table, add it here and possibly add it to set_attributes () + + set_attributes now uses this array(). 07-Dec-01 skeeter */ $this->attributes = array( @@ -355,7 +359,7 @@ { return False; } - $value = "Copied $state_one to $state_two"; + $value = 'Copied '.$state_one.' to '.$state_two; $incversion = False; break; case VFS_OPERATION_MOVED: @@ -367,7 +371,7 @@ { return False; } - $value = "Moved $state_one to $state_two"; + $value = 'Moved '.$state_one.' to '.$state_two; $incversion = False; break; case VFS_OPERATION_DELETED: @@ -480,14 +484,14 @@ We copy it going the other way as well, so both files show the operation. The code is a bad hack to prevent recursion. Ideally it would use VFS_OPERATION_COPIED */ - $this->add_journal ($state_two, array (RELATIVE_NONE), "Copied $state_one to $state_two", NULL, NULL, False); + $this->add_journal ($state_two, array (RELATIVE_NONE), 'Copied '.$state_one.' to '.$state_two, NULL, NULL, False); } if ($operation == VFS_OPERATION_MOVED) { $state_one_path_parts = $this->path_parts ($state_one, array (RELATIVE_NONE)); - $query = $GLOBALS['phpgw']->db->query ("UPDATE phpgw_vfs SET mime_type='journal-deleted' WHERE directory='$state_one_path_parts->fake_leading_dirs_clean' AND name='$state_one_path_parts->fake_name_clean' AND mime_type='journal'"); + $query = $GLOBALS['phpgw']->db->query ("UPDATE phpgw_vfs SET mime_type='journal-deleted' WHERE directory='".$state_one_path_parts->fake_leading_dirs_clean."' AND name='".$state_one_path_parts->fake_name_clean."' AND mime_type='journal'"); /* We create the file in addition to logging the MOVED operation. This is an @@ -532,7 +536,7 @@ $p = $this->path_parts ($string, array ($relatives[0])); - $sql = "DELETE FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'"; + $sql = "DELETE FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'"; if (!$deleteall) { @@ -582,7 +586,7 @@ return False; } - $sql = "SELECT * FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'"; + $sql = "SELECT * FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'"; if ($type == 1) { @@ -896,7 +900,7 @@ $basedir = ereg_replace ($sep . $sep, $sep, $basedir); } - $basedir = ereg_replace ("$sep$", '', $basedir); + $basedir = ereg_replace ($sep.'$', '', $basedir); return $basedir; } @@ -923,9 +927,6 @@ return True; } - $account_id = $GLOBALS['phpgw_info']['user']['account_id']; - $account_lid = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['phpgw_info']['user']['account_id']); - $p = $this->path_parts ($file, array ($relatives[0])); /* Temporary, until we get symlink type files set up */ @@ -956,7 +957,7 @@ } /* Read access is always allowed here, but nothing else is */ - if ($file == "/" || $file == $this->fakebase) + if ($file == '/' || $file == $this->fakebase) { if ($operation == PHPGW_ACL_READ) { @@ -972,22 +973,22 @@ We don't use ls () to get owner_id as we normally would, because ls () calls acl_check (), which would create an infinite loop */ - $query = $GLOBALS['phpgw']->db->query ("SELECT owner_id FROM phpgw_vfs WHERE directory='$p2->fake_leading_dirs_clean' AND name='$p2->fake_name_clean'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); + $query = $GLOBALS['phpgw']->db->query ("SELECT owner_id FROM phpgw_vfs WHERE directory='".$p2->fake_leading_dirs_clean."' AND name='".$p2->fake_name_clean."'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); $GLOBALS['phpgw']->db->next_record (); $group_id = $GLOBALS['phpgw']->db->Record['owner_id']; /* They always have access to their own files */ - if ($group_id == $account_id) + if ($group_id == $GLOBALS['phpgw_info']['user']['account_id']) { return True; } /* Check if they're in the group. If so, they have access */ - $memberships = $GLOBALS['phpgw']->accounts->membership ($account_id); + $memberships = $GLOBALS['phpgw']->accounts->membership ($GLOBALS['phpgw_info']['user']['account_id']); if (is_array ($memberships)) { - reset ($memberships); + @reset ($memberships); while (list ($num, $group_array) = @each ($memberships)) { @@ -1060,7 +1061,7 @@ } else { - $currentdir = $GLOBALS['phpgw']->common->appsession (); + $currentdir = $GLOBALS['phpgw']->session->appsession('vfs',''); $basedir = $this->getabsolutepath ($currentdir . $sep . $target, array ($relatives[0]), True); } } @@ -1069,7 +1070,7 @@ $basedir = $this->getabsolutepath ($target, array ($relatives[0])); } - $GLOBALS['phpgw']->common->appsession ($basedir); + $GLOBALS['phpgw']->session->appsession('vfs','',$basedir); return True; } @@ -1082,7 +1083,7 @@ */ function pwd ($full = True) { - $currentdir = $GLOBALS['phpgw']->common->appsession (); + $currentdir = $GLOBALS['phpgw']->session->appsession('vfs',''); if (!$full) { @@ -1139,10 +1140,11 @@ @param $contents contents @result Boolean True/False */ - function write ($file, $relatives = '', $contents) + function write ($file, $relatives = '', $contents = '') { if (!is_array ($relatives)) { + settype($relatives,'array'); $relatives = array (RELATIVE_CURRENT); } @@ -1171,12 +1173,12 @@ */ $this->touch ($p->fake_full_path, array ($p->mask)); - if ($fp = fopen ($p->real_full_path, "wb")) + if ($fp = fopen ($p->real_full_path, 'wb')) { fwrite ($fp, $contents, strlen ($contents)); fclose ($fp); - $this->set_attributes ($p->fake_full_path, array ($p->mask), array ('size' => $this->get_size ($p->real_full_path, array (RELATIVE_NONE|VFS_REAL)))); + $this->set_attributes ($p->fake_full_path, array ($p->mask), array ('size' => filesize($p->real_full_path))); if ($journal_operation) { @@ -1205,9 +1207,6 @@ $relatives = array (RELATIVE_CURRENT); } - $account_id = $GLOBALS['phpgw_info']['user']['account_id']; - $currentapp = $GLOBALS['phpgw_info']['flags']['currentapp']; - $p = $this->path_parts ($file, array ($relatives[0])); umask (000); @@ -1224,7 +1223,7 @@ } /* We, however, have to decide this ourselves */ - if ($this->file_exists ($p->fake_full_path, array ($p->mask))) + if ($this->file_exists($p->fake_full_path, array ($p->mask))) { if (!$this->acl_check ($p->fake_full_path, array ($p->mask), PHPGW_ACL_EDIT)) { @@ -1235,7 +1234,7 @@ $p->fake_full_path, array ($p->mask), array ( - 'modifiedby_id' => $account_id, + 'modifiedby_id' => $GLOBALS['phpgw_info']['user']['account_id'], 'modified' => $this->now ) ); @@ -1247,17 +1246,18 @@ return False; } - $query = $GLOBALS['phpgw']->db->query ("INSERT INTO phpgw_vfs (owner_id, directory, name) VALUES ($this->working_id, '$p->fake_leading_dirs_clean', '$p->fake_name_clean')", __LINE__, __FILE__); - $this->set_attributes( $p->fake_full_path, array ($p->mask), array ( - 'createdby_id' => $account_id, + 'owner_id' => $this->working_id, + 'directory' => $p->fake_leading_dirs_clean, + 'name' => $p->fake_name_clean, + 'createdby_id' => $GLOBALS['phpgw_info']['user']['account_id'], 'created' => $this->now, 'size' => 0, 'deleteable' => 'Y', - 'app' => $currentapp + 'app' => $GLOBALS['phpgw_info']['flags']['currentapp'] ) ); $this->correct_attributes ($p->fake_full_path, array ($p->mask)); @@ -1703,12 +1703,13 @@ if (!$this->file_exists ($p->fake_full_path, array ($p->mask))) { - $query = $GLOBALS['phpgw']->db->query ("INSERT INTO phpgw_vfs (owner_id, name, directory) VALUES ($this->working_id, '$p->fake_name_clean', '$p->fake_leading_dirs_clean')", __LINE__, __FILE__); - $this->set_attributes( $p->fake_full_path, array ($p->mask), array ( + 'owner_id' => $this->working_id, + 'name' => $p->fake_name_clean, + 'directory' => $p->fake_leading_dirs_clean, 'createdby_id' => $account_id, 'size' => 4096, 'mime_type' => 'Directory', @@ -1804,6 +1805,8 @@ link_directory link_name version + name + directory */ function set_attributes ($file, $relatives = '', $attributes = '') { @@ -1830,63 +1833,78 @@ if (!$this->file_exists ($file, array ($relatives[0]))) { - return False; + $exists = False; } - + else + { + $exists = True; + } + /* All this voodoo just decides which attributes to update depending on if the attribute was supplied in the $attributes array */ + $ls_array = $this->ls ($p->fake_full_path, array ($p->mask), False, False, True); $record = $ls_array[0]; - $attribute_names = array( - 'owner_id', 'createdby_id', 'modifiedby_id', - 'created', 'modified', 'size', 'mime_type', - 'deleteable', 'comment', 'app', - 'link_directory', 'link_name', 'version' - ); - - $sql = 'UPDATE phpgw_vfs SET '; - - $change_attributes = 0; - while (list ($num, $attribute) = each ($attribute_names)) + $sql_array = Array(); + $sql_fields = ''; + $sql_vals = ''; + @reset($this->attributes); + while (list ($num, $attribute) = each ($this->attributes)) { - if (isset ($attributes[$attribute])) + if (isset($attributes[$attribute])) { - $$attribute = $attributes[$attribute]; - - /* - Indicate that the EDITED_COMMENT operation needs to be journaled, - but only if the comment changed - */ - if ($attribute == 'comment' && $attributes[$attribute] != $record[$attribute]) + if($exists) { - $edited_comment = 1; + if($sql_vals) + { + $sql_vals .= ', '; + } + $sql_vals .= "$attribute='".$this->db_clean($attributes[$attribute])."'"; } - - $$attribute = $this->db_clean ($$attribute); - - if ($change_attributes > 0) + else { - $sql .= ', '; + if($sql_fields) + { + $sql_fields .= ','; + } + if($sql_vals) + { + $sql_vals .= ','; + } + $sql_fields .= $attribute; + $sql_vals .= "'".$this->db_clean($attributes[$attribute])."'"; } - - $sql .= "$attribute='" . $$attribute . "'"; - - $change_attributes++; } } - $sql .= " WHERE file_id='$record[file_id]'"; - $sql .= $this->extra_sql (VFS_SQL_UPDATE); - - $query = $GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__); + if($exists) + { + if($sql_vals) + { + $sql = "UPDATE phpgw_vfs SET $sql_vals WHERE file_id='".$record['file_id']."'".$this->extra_sql(VFS_SQL_UPDATE); + } + else + { + $sql = ''; + } + } + else + { + $sql = "INSERT INTO phpgw_vfs($sql_fields) VALUES ($sql_vals)"; + } + $query = ($sql?$GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__):False); if ($query) { - if ($edited_comment) + /* + Indicate that the EDITED_COMMENT operation needs to be journaled, + but only if the comment changed + */ + if (isset($attributes['comment']) && $attributes['comment'] != $record['comment']) { $this->add_journal ($p->fake_full_path, array ($p->mask), VFS_OPERATION_EDITED_COMMENT); } @@ -1919,19 +1937,16 @@ { $ls_array = $this->ls ($p->fake_leading_dirs, array ($p->mask), False, False, True); $this->set_attributes ($p->fake_full_path, array ($p->mask), array ('owner_id' => $ls_array[0]['owner_id'])); - return True; } elseif (preg_match ("+^$this->fakebase\/(.*)$+U", $p->fake_full_path, $matches)) { - $this->set_attributes ($p->fake_full_path, array ($p->mask), array ("owner_id" => $GLOBALS['phpgw']->accounts->name2id ($matches[1]))); - + $this->set_attributes ($p->fake_full_path, array ($p->mask), array ('owner_id' => $GLOBALS['phpgw']->accounts->name2id ($matches[1]))); return True; } else { $this->set_attributes ($p->fake_full_name, array ($p->mask), array ('owner_id' => 0)); - return True; } } @@ -1999,14 +2014,12 @@ if ($p->outside) { - $rr = file_exists ($p->real_full_path); - - return $rr; + return file_exists ($p->real_full_path); } - $query = $GLOBALS['phpgw']->db->query ("SELECT name FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); + $query = $GLOBALS['phpgw']->db->query ("SELECT name FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); - if ($GLOBALS['phpgw']->db->next_record ()) + if ($GLOBALS['phpgw']->db->num_rows()) { return True; } @@ -2140,10 +2153,10 @@ $sql .= ', '; } - $sql .= "$attribute"; + $sql .= $attribute; } - $sql .= " FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'"; + $sql .= " FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'"; $sql .= $this->extra_sql (VFS_SQL_SELECT); @@ -2200,19 +2213,19 @@ $sql .= ", "; } - $sql .= "$attribute"; + $sql .= $attribute; } $dir_clean = $this->db_clean ($dir); - $sql .= " FROM phpgw_vfs WHERE directory LIKE '$dir_clean%'"; + $sql .= " FROM phpgw_vfs WHERE directory LIKE '".$dir_clean."%'"; $sql .= $this->extra_sql (VFS_SQL_SELECT); if ($mime_type) { - $sql .= " AND mime_type='$mime_type'"; + $sql .= " AND mime_type='".$mime_type."'"; } - $sql .= " ORDER BY $orderby"; + $sql .= ' ORDER BY '.$orderby; $query = $GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__); @@ -2427,12 +2440,10 @@ $mime_type = 'Directory'; } - $size = filesize ($p->real_full_path); - $rarray = array( 'directory' => $p->fake_leading_dirs, 'name' => $p->fake_name, - 'size' => $size, + 'size' => filesize ($p->real_full_path), 'mime_type' => $mime_type );