[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] ftp/inc functions.inc.php,1.16
From: |
skwashd |
Subject: |
[Phpgroupware-cvs] ftp/inc functions.inc.php,1.16 |
Date: |
Sun, 15 May 2005 15:34:00 +0200 |
Update of ftp/inc
Modified Files:
Branch: MAIN
functions.inc.php lines: +80 -57
Log Message:
merge from 16
====================================================
Index: ftp/inc/functions.inc.php
diff -u ftp/inc/functions.inc.php:1.15 ftp/inc/functions.inc.php:1.16
--- ftp/inc/functions.inc.php:1.15 Sat May 11 23:55:05 2002
+++ ftp/inc/functions.inc.php Sun May 15 13:34:12 2005
@@ -12,24 +12,37 @@
/* $Id$ */
+ //NOTE: This is a hack to fix the register_globals problems with this
app in 16
+ //TODO: Fix it properly
+ foreach($_GET as $name => $value)
+ {
+ $$name = $value;
+ $HTTP_GET_VARS[$name] = $value;
+ }
+
+ foreach($_POST as $name => $value)
+ {
+ $$name = $value;
+ $HTTP_POST_VARS[$name] = $value;
+ }
+
function createLink($string,$params='')
{
return $GLOBALS['phpgw']->link($string,$params);
}
- function getConnectionInfo()
+ function getConnectionInfo()
{
- $unencrypted = $GLOBALS['phpgw']->session->appsession();
- return $unencrypted;
+ return $GLOBALS['phpgw']->session->appsession();
}
function phpftp_connect($host,$user,$pass)
{
// echo "connecting to $host with $user and $pass\n";
$ftp = ftp_connect($host);
- if($ftp)
+ if ( $ftp )
{
- if(ftp_login($ftp,$user,$pass))
+ if ( ftp_login($ftp,$user,$pass) )
{
return $ftp;
}
@@ -64,7 +77,7 @@
$GLOBALS['phpgw']->template->parse('out','rename',true);
// $template->p('renameform');
-
$GLOBALS['phpgw']->template->set_var('return',$template->get('out'));
+
$GLOBALS['phpgw']->template->set_var('return',$GLOBALS['phpgw']->template->get('out'));
return $GLOBALS['phpgw']->template->get('return');
}
@@ -76,7 +89,7 @@
. '<input type="hidden" name="newdir"
value="'.$directory.'">'."\n"
. '<input type="hidden" name="file"
value="'.$filename.'">'."\n";
$delete_form_end = '</form>'."\n";
- $delete_form_question = 'Are you sure you want to delete ' .
$filename . ' ?';
+ $delete_form_question = lang ('Are you sure you want to delete
%1 ?', $filename);
$delete_form_from= $directory . '/' . $filename;
$delete_form_to='<input type="text" name="newname" size=20"
value="">';
$delete_form_confirm='<input type="submit" name="confirm"
value="' . lang('delete') . '">'."\n";
@@ -91,11 +104,11 @@
));
$GLOBALS['phpgw']->template->parse('out','confirm_delete',true);
-
$GLOBALS['phpgw']->template->set_var('return',$template->get('out'));
+
$GLOBALS['phpgw']->template->set_var('return',$GLOBALS['phpgw']->template->get('out'));
return $GLOBALS['phpgw']->template->get('return');
}
- function newLogin($dfhost,$dfuser,$dfpass)
+ function newLogin($dfhost,$dfuser,$dfpass)
{
$login_form_begin= '<form
action="'.createLink($GLOBALS['target']).'" method="post">'."\n".'<input
type="hidden" name="action" value="login">'."\n";
$login_form_end='</form>'."\n";
@@ -114,7 +127,7 @@
'login_form_submit' => $login_form_submit,
'lang_username' => lang('username'),
'lang_password' => lang('password'),
- 'langserver' => lang('ftpserver')
+ 'langserver' => lang('Ftp Server')
));
$GLOBALS['phpgw']->template->set_var('lang_login',lang('Log
into FTP server'));
$GLOBALS['phpgw']->template->set_var('lang_ftpserver',lang('FTP
hostname'));
@@ -131,18 +144,18 @@
$tmpfile=$tempdir.'/'.$file.".".$randval;
ftp_chdir($ftp,$dir);
$remotefile=$dir . '/' . $file;
- if(!ftp_get($ftp, $tmpfile, $remotefile, FTP_BINARY))
+ if ( ! ftp_get( $ftp, $tmpfile, $remotefile, FTP_BINARY ) )
{
echo 'tmpfile="' . $tmpfile . '",file="' . $remotefile
. '"<br>' . "\n";
- ftp_quit($ftp);
+ ftp_quit( $ftp );
echo macro_get_Link('newlogin','Start over?');
$retval=0;
}
else
{
- ftp_quit($ftp);
+ ftp_quit( $ftp );
$b = CreateObject('phpgwapi.browser');
- if($GLOBALS['phpgw_info']['server']['ftp_use_mime'])
+ if ($GLOBALS['phpgw_info']['server']['ftp_use_mime'])
{
$mime = getMimeType($file);
$b->content_header($file,$mime);
@@ -153,34 +166,34 @@
}
//header( "Content-Type: application/octet-stream" );
//header( "Content-Disposition: attachment; filename="
. $file );
- readfile($tmpfile);
- $retval = 1;
+ readfile( $tmpfile );
+ $retval=1;
}
- @unlink($tmpfile);
+ @unlink( $tmpfile );
return $retval;
}
function getMimeType($file)
{
- $file = basename($file);
+ $file=basename($file);
$mimefile = PHPGW_APP_ROOT . SEP . 'mime.types';
- $fp = fopen($mimefile,"r");
+ $fp=fopen($mimefile,"r");
$contents = explode("\n",fread ($fp, filesize($mimefile)));
fclose($fp);
- $parts = explode(".",$file);
- $ext = $parts[(sizeof($parts)-1)];
+ $parts=explode(".",$file);
+ $ext=$parts[(sizeof($parts)-1)];
for($i=0;$i<sizeof($contents);$i++)
{
- if(!ereg("^#",$contents[$i]))
+ if (! ereg("^#",$contents[$i]))
{
- $line = split("[[:space:]]+", $contents[$i]);
- if(sizeof($line) >= 2)
+ $line=split("[[:space:]]+", $contents[$i]);
+ if (sizeof($line) >= 2)
{
for($j=1;$j<sizeof($line);$j++)
{
- if($line[$j] == $ext)
+ if ($line[$j] == $ext)
{
$mimetype=$line[0];
return $mimetype;
@@ -192,27 +205,27 @@
return 'text/plain';
}
- function phpftp_view($ftp, $tempdir, $dir, $file)
+ function phpftp_view( $ftp, $tempdir, $dir, $file )
{
srand((double)microtime()*1000000);
$randval = rand();
- $tmpfile = "$tempdir/" . $file . "." . $randval;
+ $tmpfile="$tempdir/" . $file . "." . $randval;
ftp_chdir($ftp,$dir);
$remotefile=$dir . "/" . $file;
- if(!ftp_get( $ftp, $tmpfile, $remotefile, FTP_BINARY))
+ if ( ! ftp_get( $ftp, $tmpfile, $remotefile, FTP_BINARY ) )
{
echo "tmpfile=\"$tmpfile\",file=\"$remotefile\"<BR>\n";
macro_get_Link('newlogin','Start over?');
- $retval = 0;
+ $retval=0;
}
else
{
$content_type=getMimeType($remotefile);
header('Content-Type: '.$content_type);
readfile( $tmpfile );
- $retval = 1;
+ $retval=1;
}
- @unlink($tmpfile);
+ @unlink( $tmpfile );
return $retval;
}
@@ -224,18 +237,18 @@
function analysedir($dirline)
{
- if(ereg("([-dl])[rwxst-]{9}",substr($dirline,0,10)))
+ if (ereg("([-dl])[rwxst-]{9}",substr($dirline,0,10)))
{
- $systyp = 'UNIX';
+ $GLOBALS['systyp'] = 'UNIX';
}
- if(substr($dirline,0,5) == 'total')
+ if (substr($dirline,0,5) == 'total')
{
$dirinfo[0] = -1;
}
- elseif($systyp=='Windows_NT')
+ elseif($GLBALS['systyp'] == 'Windows_NT')
{
- if(ereg("[-0-9]+ *[0-9:]+[PA]?M? +<DIR>
{10}(.*)",$dirline,$regs))
+ if (ereg("[-0-9]+ *[0-9:]+[PA]?M? +<DIR>
{10}(.*)",$dirline,$regs))
{
$dirinfo[0] = 1;
$dirinfo[1] = 0;
@@ -248,14 +261,16 @@
$dirinfo[2] = $regs[2];
}
}
- elseif($systyp=='UNIX')
+ elseif($GLOBALS['systyp'] == 'UNIX')
{
- if(ereg("([-d][rwxst-]{9}).* ([a-zA-Z0-9]*) ([a-zA-Z]+
[0-9: ]*[0-9]) (.+)",$dirline,$regs))
+ //echo "$dirline <br />";
+ $ta = explode(' ',$dirline);
+
+ if(count($ta))
{
- $ta = explode(' ',$dirline);
- while(list(,$p) = each($ta))
+ foreach($ta as $p)
{
- if($p)
+ if(trim($p) != '')//need to let 0 thru
{
$a[] = $p;
}
@@ -264,30 +279,33 @@
$fileinfo['owner'] = $a[2];
$fileinfo['group'] = $a[3];
$fileinfo['size'] = $a[4];
- $fileinfo['date'] = $regs[3];
- $fileinfo['name'] = $regs[4];
- //echo '<pre>'; print_r($regs); echo '</pre>';
+ $fileinfo['date'] = $a[5] . '-' . $a[6]
. '-' . $a[7];
+ $fileinfo['name'] = $a[8];
+ }
+ else //if something goes wrong
+ {
+ $fileinfo['name'] = $ta[0];
}
+ //echo '<pre>'; print_r($fileinfo); echo '</pre>';
}
-
- if(($dirinfo[2]=='.') || ($dirinfo[2]=='..'))
+
+ if (($dirinfo[2]=='.') || ($dirinfo[2]=='..'))
{
$dirinfo[0] = 0;
}
-
+
return $fileinfo;
}
function phpftp_getList($ftp,$dir,$start)
{
- global $real_systyp;
- $real_systyp = ftp_systype($ftp);
+ $GLOBALS['real_systyp'] = ftp_systype($ftp);
ftp_chdir($ftp,$dir);
$dirlist = ftp_rawlist($ftp,'');
- for($i=$start;
$i<($start+$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']);
$i++)
+ for ($i=$start;
$i<($start+$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']);
$i++)
{
- if($i < count($dirlist))
+ if ($i < count($dirlist))
{
$dirinfo[] = analysedir($dirlist[$i]);
}
@@ -295,15 +313,20 @@
return $dirinfo;
}
- function macro_get_Link($action,$string)
+ function macro_get_Link($action,$string)
{
// globals everything it needs but the string to link
global $olddir, $newdir, $file;
+
$retval = '<a href="'
. $GLOBALS['phpgw']->link($GLOBALS['target'],
-
'olddir='.urlencode($olddir).'&action='.urlencode($action)
- .
'&file='.urlencode($file).'&newdir='.urlencode($newdir)
- )
+ array(
+ 'olddir' => $olddir,
+ 'action' => $action,
+ 'file' => $file,
+ 'newdir' => $newdir
+ )
+ )
. '">';
$retval .= $string;
$retval .= '</a>';
@@ -314,7 +337,7 @@
{
}
- function phpftp_rename($origfile,$newfile,$confirm)
+ function phpftp_rename($origfile,$newfile,$confirm)
{
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] ftp/inc functions.inc.php,1.16,
skwashd <=
- Prev by Date:
[Phpgroupware-cvs] ftp/setup phpgw_sp.lang, 1.4 setup.inc.php, 1.7 phpgw_no.lang, 1.4 phpgw_nl.lang, 1.4 phpgw_br.lang, 1.3 phpgw_cs.lang, 1.4 phpgw_de.lang, 1.3 phpgw_kr.lang, 1.4 phpgw_it.lang, 1.3 phpgw_fr.lang, 1.9 phpgw_en.lang, 1.6 phpgw_fi.lang, 1.3 phpgw_pl.lang, 1.4 phpgw_ja.lang, 1.2
- Next by Date:
[Phpgroupware-cvs] setup applications.php,1.25
- Previous by thread:
[Phpgroupware-cvs] ftp/setup phpgw_sp.lang, 1.4 setup.inc.php, 1.7 phpgw_no.lang, 1.4 phpgw_nl.lang, 1.4 phpgw_br.lang, 1.3 phpgw_cs.lang, 1.4 phpgw_de.lang, 1.3 phpgw_kr.lang, 1.4 phpgw_it.lang, 1.3 phpgw_fr.lang, 1.9 phpgw_en.lang, 1.6 phpgw_fi.lang, 1.3 phpgw_pl.lang, 1.4 phpgw_ja.lang, 1.2
- Next by thread:
[Phpgroupware-cvs] setup applications.php,1.25
- Index(es):