Skip to content

Commit

Permalink
Add microseconds to filename format to make it harder to predict
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisjacquet committed Apr 11, 2023
1 parent aa40df6 commit 09d5afa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -10,6 +10,7 @@ Changes in 11.0
- Translate "Zip" & "Zipcode" to "Zip Code" in GetStuList.fnc.php, MyReport.php, Registration.fnc.php, Schools.php & Address.inc.php
- HTML Text input min size is 2 in Inputs.php
- Skip School Period column if has no students scheduled for selected date in Administration.php
- Add microseconds to filename format to make it harder to predict in FileUpload.fnc.php, Accounting/functions.php, PortalNotes.php & Student_Billing/functions.php

Changes in 10.9.3
-----------------
Expand Down
3 changes: 2 additions & 1 deletion ProgramFunctions/FileUpload.fnc.php
Expand Up @@ -408,7 +408,8 @@ function FilesUploadUpdate( $table, $request, $path, $id = 0 )
mb_strrpos( $_FILES[ $input ]['name'], '.' )
) );

$file_name_no_ext .= '_' . date( 'Y-m-d_His' );
// @since 11.0 Add microseconds to filename format to make it harder to predict.
$file_name_no_ext .= '_' . date( 'Y-m-d_His' ) . '.' . substr( (string) microtime(), 2, 6 );

$new_file = FileUpload(
$input,
Expand Down
3 changes: 2 additions & 1 deletion modules/Accounting/functions.inc.php
Expand Up @@ -351,7 +351,8 @@ function _saveSalariesFile( $id )
mb_strrpos( $_FILES[ $input ]['name'], '.' )
) );

$file_name_no_ext .= '_' . date( 'Y-m-d_His' );
// @since 11.0 Add microseconds to filename format to make it harder to predict.
$file_name_no_ext .= '_' . date( 'Y-m-d_His' ) . '.' . substr( (string) microtime(), 2, 6 );

$file_attached = FileUpload(
$input,
Expand Down
14 changes: 13 additions & 1 deletion modules/School_Setup/PortalNotes.php
Expand Up @@ -127,12 +127,24 @@

if ( isset( $_FILES['FILE_ATTACHED_FILE'] ) )
{
$file_name_no_ext = no_accents( mb_substr(
$_FILES['FILE_ATTACHED_FILE']['name'],
0,
mb_strrpos( $_FILES['FILE_ATTACHED_FILE']['name'], '.' )
) );

// @since 11.0 Add microseconds to filename format to make it harder to predict.
$file_name_no_ext .= '_' . date( 'Y-m-d_His' ) . '.' . substr( (string) microtime(), 2, 6 );

// File attached to portal notes
$columns['FILE_ATTACHED'] = FileUpload(
'FILE_ATTACHED_FILE',
$PortalNotesFilesPath,
FileExtensionWhiteList(),
0,
$error
$error,
'',
$file_name_no_ext
);

// @since 6.8 Fix SQL error when quote in uploaded file name.
Expand Down
3 changes: 2 additions & 1 deletion modules/Student_Billing/functions.inc.php
Expand Up @@ -429,7 +429,8 @@ function _saveFeesFile( $id )
mb_strrpos( $_FILES[ $input ]['name'], '.' )
) );

$file_name_no_ext .= '_' . date( 'Y-m-d_His' );
// @since 11.0 Add microseconds to filename format to make it harder to predict.
$file_name_no_ext .= '_' . date( 'Y-m-d_His' ) . '.' . substr( (string) microtime(), 2, 6 );

$file_attached = FileUpload(
$input,
Expand Down

0 comments on commit 09d5afa

Please sign in to comment.