function phpftp_view($ftp, $tempdir, $dir, $file) { srand((double) microtime() * 1000000); $randval = rand(); $tmpfile = "{$tempdir}/" . $file . "." . $randval; ftp_chdir($ftp, $dir); $remotefile = $dir . "/" . $file; if (!ftp_get($ftp, $tmpfile, $remotefile, FTP_BINARY)) { echo "tmpfile=\"{$tmpfile}\",file=\"{$remotefile}\"<BR>\n"; macro_get_Link('newlogin', 'Start over?'); $retval = 0; } else { $content_type = getMimeType($remotefile); header('Content-Type: ' . $content_type); readfile($tmpfile); $retval = 1; } @unlink($tmpfile); return $retval; }
$ul_select = '<input type="file" name="uploadfile" size="30">' . "\n"; $ul_submit = '<input type="submit" name="upload" value="Upload">' . "\n"; $ul_form_close = '</form>' . "\n"; // set up the create directory $crdir_form_open = '<form name="mkdir" action="' . createLink($GLOBALS['target']) . '" method="post" >' . "\n" . "\t" . '<input type="hidden" name="olddir" value="' . $cwd . '">' . "\n" . "\t" . '<input type="hidden" name="action" value="mkdir">' . "\n"; $crdir_form_close = '</form>' . "\n"; $crdir_textfield = "\t" . '<input type="text" size="30" name="newdirname" value="">' . "\n"; $crdir_submit = "\t" . '<input type="submit" name="submit" value="Create New Dir">' . "\n"; $ftp_location = 'ftp://' . $connInfo['username'] . '@' . $connInfo['ftpserver'] . $cwd; $newdir = ''; $temp = $olddir; $olddir = $homedir; $home_link = macro_get_Link('cwd', '<img border="0" src="' . $GLOBALS['phpgw']->common->image('ftp', 'home.gif') . '">') . "\n"; $olddir = $temp; // set up all the global variables for the template $GLOBALS['phpgw']->template->set_var(array('ftp_location' => $ftp_location, 'relogin_link' => macro_get_Link('newlogin', lang('logout/relogin')), 'home_link' => $home_link, 'ul_select' => $ul_select, 'ul_submit' => $ul_submit, 'ul_form_open' => $ul_form_open, 'ul_form_close' => $ul_form_close, 'crdir_form_open' => $crdir_form_open, 'crdir_form_close' => $crdir_form_close, 'crdir_textfield' => $crdir_textfield, 'crdir_submit' => $crdir_submit)); $total = count(ftp_rawlist($ftp, '')); $GLOBALS['phpgw']->template->set_var('nextmatchs_left', $GLOBALS['phpgw']->nextmatchs->left('/ftp/index.php', $start, $total)); $GLOBALS['phpgw']->template->set_var('nextmatchs_right', $GLOBALS['phpgw']->nextmatchs->right('/ftp/index.php', $start, $total)); $contents = phpftp_getList($ftp, '.', $start); $GLOBALS['phpgw']->template->set_var('lang_name', lang('Name')); $GLOBALS['phpgw']->template->set_var('lang_owner', lang('Owner')); $GLOBALS['phpgw']->template->set_var('lang_group', lang('Group')); $GLOBALS['phpgw']->template->set_var('lang_permissions', lang('Permissions')); $GLOBALS['phpgw']->template->set_var('lang_size', lang('Size')); $GLOBALS['phpgw']->template->set_var('lang_delete', lang('Delete')); $GLOBALS['phpgw']->template->set_var('lang_rename', lang('Rename')); $newdir = $olddir; $GLOBALS['phpgw']->template->set_var('name', macro_get_link('up', '..')); $GLOBALS['phpgw']->template->set_var('del_link', ' '); $GLOBALS['phpgw']->template->set_var('rename_link', ' ');
function phpftp_view($ftp, $tempdir, $dir, $file) { $tmpfile = tempnam('/tmp', 'egwftp'); ftp_chdir($ftp, $dir); $remotefile = $dir . '/' . $file; if (!ftp_get($ftp, $tmpfile, $remotefile, FTP_BINARY)) { echo 'tmpfile="' . $tmpfile . '",file="' . $remotefile . '"<br>' . "\n"; macro_get_Link('newlogin', 'Start over?'); $retval = 0; } else { $content_type = getMimeType($remotefile); header('Content-Type: ' . $content_type); readfile($tmpfile); $retval = 1; } @unlink($tmpfile); return $retval; }