PHP Upload feature - series of bugfixes

- Fixed a bunch of config file generation bugs
 - Increased static file upload in lighttpd to 3GB (for now static)
 - Set the new stream setting for upload
 - Clean up the tmp file on "share" as well
 - Ingore Warning if chmod feat. disabled (on FAT32 USB Stick relevant)
This commit is contained in:
Matthias Strubel 2018-03-05 20:32:01 +01:00
parent 239b449770
commit 4be12aa378
7 changed files with 16 additions and 8 deletions

View File

@ -169,7 +169,7 @@ generate_lighttpd_env() {
)
var.PIRATEBOX_HOSTNAME = \"$HOSTNAME\"
var.CONFDIR = \"$CONFDIR\"
var.CONFDIR = \"$CONFIG_PATH\"
" > $LIGHTTPD_ENV_CONFIG
}
@ -181,9 +181,9 @@ php_ini_entry(){
in_parm=$1
in_val=$2
if grep -q "$in_parm" "$work_php_ini" ;
if grep -q "$in_parm" "$work_php_ini" ; then
old_val=$( grep "$in_parm" "$work_php_ini" | head -n 1 )
sed -e "s|${old_val}|${in_parm} = ${in_val}|g" "$work_php_ini"
sed -i -e "s|${old_val}|${in_parm} = ${in_val}|g" "$work_php_ini"
else
echo "ERROR php.ini : Old val. $in_parm not found"
fi
@ -198,8 +198,8 @@ generate_php_ini(){
-e 's|^upload_max_filesize|;upload_max_filesize|g' \
-e 's|^post_max_size|;post_max_size|g' \
-e 's|^max_file_uploads|;max_file_uploads|g' \
"${PIRATEBOX_FOLDER}/tmp/php.ini.original" > "$CONFDIR/php.ini"
work_php_ini="$CONFDIR/php.ini"
"${PIRATEBOX_FOLDER}/tmp/php.ini.original" > "$CONFIG_PATH/php.ini"
work_php_ini="$CONFIG_PATH/php.ini"
php_ini_entry 'upload_tmp_dir' "$UPLOAD_TMP_FOLDER"
php_ini_entry 'upload_max_filesize' "$UPLOAD_MAX_SIZE"
@ -215,7 +215,7 @@ generate_piratebox_php(){
-e "s|####OVERWRITE####|${UPLOAD_ALLOW_OVERWRITE}|g" \
-e "s|####DO_CHMOD####|${UPLOAD_DO_CHMOD}|g" \
-e "s|####CHMOD####|${UPLOAD_CHMOD}|g" \
"$CONFDIR/piratebox_config.php.template" > "${PIRATEBOX_FOLDER}/www"
"$CONFIG_PATH/piratebox_config.php.template" > "${PIRATEBOX_FOLDER}/www/piratebox_config.php"
}
if [ -z $1 ] ; then

View File

@ -16,7 +16,8 @@ server.document-root = "/opt/piratebox/www"
## the device from dieing because OUT-OF-RAM exceptions
## in KB => 5MB
server.upload-dirs = ( "/tmp" )
server.max-request-size = 5120
server.max-request-size = 3221225472
server.stream-request-body = 2
server.errorlog = "/opt/piratebox/tmp/error.log"
server.breakagelog = "/opt/piratebox/tmp/break.log"

View File

@ -8,7 +8,7 @@
# Upload enabled
$config['upload_enabled'] = '####UPLOAD_ENABLED####' ;
# Where to store
$config['upload_folder'] = ""####UPLOAD_FOLDER####;
$config['upload_folder'] = "####UPLOAD_FOLDER####";
# Rename dublicate files with suffix or overwrite it
$config['allow_overwrite'] = '####OVERWRITE####' ;
# Set permissions afterwards

View File

@ -92,6 +92,7 @@ case "$1" in
echo "Empty tmp folder"
find $PIRATEBOX/tmp/ -mindepth 1 -exec rm {} \;
find $PIRATEBOX/share/tmp/ -mindepth 1 -exec rm {} \;
# Captive Portal Housekeeping file in /tmp (ram)
"$PIRATEBOX/bin/captive_notify_lease.sh" refresh

View File

@ -85,6 +85,7 @@ case "$1" in
echo "Empty tmp folder"
find $PIRATEBOX/tmp/ -mindepth 1 -exec rm {} \;
find $PIRATEBOX/share/tmp/ -mindepth 1 -exec rm {} \;
# Captive Portal Housekeeping file in /tmp (ram)
"$PIRATEBOX/bin/captive_notify_lease.sh" refresh

View File

@ -91,6 +91,11 @@ try {
}
$path = $config['upload_folder']. "/" . $filename ;
if ( $config['do_chmod'] == 'no' ) {
/* Ok, we want whatever a filepermission and we want to ignore Warnings from
* move_uploaded_file */
error_reporting(E_ERROR | E_PARSE);
}
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
if ( $config['do_chmod'] == 'yes' ) {
// set proper permissions on the new file