Update all references to old Password class

This commit is contained in:
Kijin Sung 2016-03-13 23:39:31 +09:00
parent f4dc7e6b21
commit 9d6284faad
8 changed files with 53 additions and 58 deletions

View file

@ -285,8 +285,7 @@ class fileController extends file
// Redirect to procFileOutput using file key
if(!isset($_SESSION['__XE_FILE_KEY__']) || !is_string($_SESSION['__XE_FILE_KEY__']) || strlen($_SESSION['__XE_FILE_KEY__']) != 32)
{
$random = new Password();
$_SESSION['__XE_FILE_KEY__'] = $random->createSecureSalt(32, 'hex');
$_SESSION['__XE_FILE_KEY__'] = Rhymix\Framework\Security::getRandom(32, 'hex');
}
$file_key_data = $file_obj->file_srl . $file_obj->file_size . $file_obj->uploaded_filename . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'];
$file_key = substr(hash_hmac('sha256', $file_key_data, $_SESSION['__XE_FILE_KEY__']), 0, 32);
@ -735,9 +734,6 @@ class fileController extends file
// Sanitize filename
$file_info['name'] = Rhymix\Framework\Security\FilenameFilter::clean($file_info['name']);
// Get random number generator
$random = new Password();
// Set upload path by checking if the attachement is an image or other kinds of file
if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name']))
{
@ -747,7 +743,7 @@ class fileController extends file
// change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter
$ext = substr(strrchr($file_info['name'],'.'),1);
//$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']);
$_filename = $random->createSecureSalt(32, 'hex').'.'.$ext;
$_filename = Rhymix\Framework\Security::getRandom(32, 'hex') . '.' . $ext;
$filename = $path.$_filename;
$idx = 1;
while(file_exists($filename))
@ -760,15 +756,12 @@ class fileController extends file
else
{
$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
$filename = $path.$random->createSecureSalt(32, 'hex');
$filename = $path . Rhymix\Framework\Security::getRandom(32, 'hex');
$direct_download = 'N';
}
// Create a directory
if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create');
// Get random number generator
$random = new Password();
// Move the file
if($manual_insert)
@ -776,7 +769,7 @@ class fileController extends file
@copy($file_info['tmp_name'], $filename);
if(!file_exists($filename))
{
$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
$filename = $path . Rhymix\Framework\Security::getRandom(32, 'hex') . '.' . $ext;
@copy($file_info['tmp_name'], $filename);
}
}
@ -784,7 +777,7 @@ class fileController extends file
{
if(!@move_uploaded_file($file_info['tmp_name'], $filename))
{
$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
$filename = $path . Rhymix\Framework\Security::getRandom(32, 'hex') . '.' . $ext;
if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error');
}
}
@ -803,7 +796,7 @@ class fileController extends file
$args->file_size = @filesize($filename);
$args->comment = NULL;
$args->member_srl = $member_srl;
$args->sid = $random->createSecureSalt(32, 'hex');
$args->sid = Rhymix\Framework\Security::getRandom(32, 'hex');
$output = executeQuery('file.insertFile', $args);
if(!$output->toBool()) return $output;
@ -978,13 +971,12 @@ class fileController extends file
if(preg_match("/\.(jpg|jpeg|gif|png|wmv|wma|mpg|mpeg|avi|swf|flv|mp1|mp2|mp3|mp4|asf|wav|asx|mid|midi|asf|mov|moov|qt|rm|ram|ra|rmm|m4v)$/i", $file_info->source_filename))
{
$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl);
$new_file = $path.$file_info->source_filename;
$new_file = $path . $file_info->source_filename;
}
else
{
$path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl);
$random = new Password();
$new_file = $path.$random->createSecureSalt(32, 'hex');
$new_file = $path . Rhymix\Framework\Security::getRandom(32, 'hex');
}
// Pass if a target document to move is same
if($old_file == $new_file) continue;