Skip to content

Commit

Permalink
PHP<7 Fix add microseconds to filename to make it harder to predict
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisjacquet committed Feb 19, 2023
1 parent 54f1ea8 commit 630d3e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
@@ -1,6 +1,10 @@
# CHANGES
## RosarioSIS Student Information System

Changes in 10.8.2
-----------------
- PHP<7 Fix add microseconds to filename to make it harder to predict in StudentAssignments.fnc.php, thanks to @jeffreygaor

Changes in 10.8.1
-----------------
- Use CheckBoxOnclick() in StudentBalances.php & Schedule.inc.php
Expand Down
8 changes: 2 additions & 6 deletions modules/Grades/includes/StudentAssignments.fnc.php
Expand Up @@ -65,10 +65,8 @@ function StudentAssignmentSubmit( $assignment_id, &$error )
$files = issetVal( $old_data['files'] );

$timestamp = new \DateTime();

// @since 8.9.5 Add microseconds to filename format to make it harder to predict.
$timestamp = $timestamp->format( 'Y-m-d H:i:s.u' );
$timestamp = date( 'Y-m-d His' ) . '.' . substr( (string) microtime(), 2, 6 );

$assignments_path = GetAssignmentsFilesPath( $assignment['STAFF_ID'] );

Expand Down Expand Up @@ -530,10 +528,8 @@ function UploadAssignmentTeacherFile( $assignment_id, $teacher_id, $file_input_i
return '';
}

$microseconds = new \DateTime();

// @since 9.0 Add microseconds to filename format to make it harder to predict.
$microseconds = $microseconds->format( 'u' );
$microseconds = substr( (string) microtime(), 2, 6 );

// Filename = [course_title]_[assignment_ID].ext.
$file_name_no_ext = no_accents( $assignment['COURSE_TITLE'] . '_' . $assignment_id . '.' . $microseconds );
Expand Down

0 comments on commit 630d3e3

Please sign in to comment.