mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 07:36:16 +00:00
make the random generation more secure
This commit is contained in:
parent
6f1037f829
commit
efadbb3f58
1 changed files with 4 additions and 2 deletions
|
@ -606,14 +606,16 @@ class Ticket{
|
||||||
public static function add_Attachment($TId,$filename,$author,$tempFile){
|
public static function add_Attachment($TId,$filename,$author,$tempFile){
|
||||||
|
|
||||||
global $FILE_STORAGE_PATH;
|
global $FILE_STORAGE_PATH;
|
||||||
$length = 20;
|
$length = mt_rand(20, 25);
|
||||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_';
|
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*\'(),';
|
||||||
$randomString = '';
|
$randomString = '';
|
||||||
for ($i = 0; $i < $length; $i++) {
|
for ($i = 0; $i < $length; $i++) {
|
||||||
$randomString .= $characters[rand(0, strlen($characters) - 1)];
|
$randomString .= $characters[rand(0, strlen($characters) - 1)];
|
||||||
}
|
}
|
||||||
$targetFile = $FILE_STORAGE_PATH . $randomString . "/" . $filename;
|
$targetFile = $FILE_STORAGE_PATH . $randomString . "/" . $filename;
|
||||||
|
|
||||||
|
if(file_exists($targetFile)) { return self::add_Attachment($TId,$filename,$author,$tempFile); }
|
||||||
|
|
||||||
$ticket = new Ticket();
|
$ticket = new Ticket();
|
||||||
$ticket->load_With_TId($TId);
|
$ticket->load_With_TId($TId);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue