Mindstorm
03-15-2004, 11:01 PM
Hello,
It's my first post here, and though I read the rules, I'm sorry if I break any that I don't know of.
I'm using a script on my website to allow some users to upload files without FTP access. The only problem is that it upload files with 0600 permissions, which makes them unreadable to global users.
I'd like to alter the script to chmod the files on upload, but my knowledge of php is (very) close to none.
$replaces = Array(
'%fullname' => $_POST['targetdir'] . '/' . $thisfile['name'],
'%filename' => $thisfile['name'],
'%dir' => $_POST['targetdir']
);
$commandline =
strtr(
$GLOBALS['default']['UPLOAD_APPLICATIONS'][ $_POST[ 'app' . $i ] ] ['commandline'],
$replaces
);
if ( !eregi( '^.*WIN.*$', PHP_OS ) )
$commandline = escapeshellcmd( $commandline );
if ( !chdir( $_POST['targetdir'] ) )
$failed = 2;
else {
exec( $commandline, $output );
$message .=
'<LI>' .
$commandline . '<BR>' . NL .
'<TEXTAREA COLS=80 ROWS=4>' .
implode( NL, $output ) .
'</TEXTAREA><BR>';
if ( isset( $_POST[ 'drop' . $i ] ) && ( $_POST[ 'drop' . $i ] == 'on' ) ) {
if (!unlink( $_POST['targetdir'] . '/' . $thisfile['name'] ))
$failed = 3;
}
(Sorry for the long code, but I'm not quite sure what matters. I've attached the complete file in case I'm missing something..)
I've read through the PHP documentation and "learnt" about the chmod function, but while I know I must use "chmod( $string , 0674 )", I'm not sure how to get the $string.
Can somebody help me with this?
Thanks in advance
Jorge Soares
PS: The script is not mine, it's https://sourceforge.net/projects/fsguide/ from trajic. It is GLPed, and I hope I'm not breaking the license by posting this here.
It's my first post here, and though I read the rules, I'm sorry if I break any that I don't know of.
I'm using a script on my website to allow some users to upload files without FTP access. The only problem is that it upload files with 0600 permissions, which makes them unreadable to global users.
I'd like to alter the script to chmod the files on upload, but my knowledge of php is (very) close to none.
$replaces = Array(
'%fullname' => $_POST['targetdir'] . '/' . $thisfile['name'],
'%filename' => $thisfile['name'],
'%dir' => $_POST['targetdir']
);
$commandline =
strtr(
$GLOBALS['default']['UPLOAD_APPLICATIONS'][ $_POST[ 'app' . $i ] ] ['commandline'],
$replaces
);
if ( !eregi( '^.*WIN.*$', PHP_OS ) )
$commandline = escapeshellcmd( $commandline );
if ( !chdir( $_POST['targetdir'] ) )
$failed = 2;
else {
exec( $commandline, $output );
$message .=
'<LI>' .
$commandline . '<BR>' . NL .
'<TEXTAREA COLS=80 ROWS=4>' .
implode( NL, $output ) .
'</TEXTAREA><BR>';
if ( isset( $_POST[ 'drop' . $i ] ) && ( $_POST[ 'drop' . $i ] == 'on' ) ) {
if (!unlink( $_POST['targetdir'] . '/' . $thisfile['name'] ))
$failed = 3;
}
(Sorry for the long code, but I'm not quite sure what matters. I've attached the complete file in case I'm missing something..)
I've read through the PHP documentation and "learnt" about the chmod function, but while I know I must use "chmod( $string , 0674 )", I'm not sure how to get the $string.
Can somebody help me with this?
Thanks in advance
Jorge Soares
PS: The script is not mine, it's https://sourceforge.net/projects/fsguide/ from trajic. It is GLPed, and I hope I'm not breaking the license by posting this here.