CAdvBanner :: makeFileArrayFromArray: Bitrix method

      
<?php 
//  CAdvBanner :: makeFileArrayFromArray()
//  /dist/bitrix/modules/advertising/classes/general/advertising.php:2019

    
private static function makeFileArrayFromArray($file_array$description null$options = array())
    {
        
$result false;

        if (
is_uploaded_file($file_array["tmp_name"]))
        {
            
$result $file_array;
            if (!
is_null($description))
                
$result["description"] = $description;
        }
        elseif (
            
strlen($file_array["tmp_name"]) > 0
            
&& strpos($file_array["tmp_name"], CTempFile::GetAbsoluteRoot()) === 0
        
)
        {
            
$io CBXVirtualIo::GetInstance();
            
$absPath $io->CombinePath("/"$file_array["tmp_name"]);
            
$tmpPath CTempFile::GetAbsoluteRoot()."/";
            if (
strpos($absPath$tmpPath) === || (($absPath ltrim($absPath"/")) && strpos($absPath$tmpPath) === 0))
            {
                
$result $file_array;
                
$result["tmp_name"] = $absPath;
                
$result["error"] = intval($result["error"]);
                if (!
is_null($description))
                    
$result["description"] = $description;
            }
        }
        elseif (
strlen($file_array["tmp_name"]) > 0)
        {
            
$io CBXVirtualIo::GetInstance();
            
$normPath $io->CombinePath("/"$file_array["tmp_name"]);
            
$absPath $io->CombinePath(CTempFile::GetAbsoluteRoot(), $normPath);
            
$tmpPath CTempFile::GetAbsoluteRoot()."/";
            if (
strpos($absPath$tmpPath) === && $io->FileExists($absPath) ||
                (
$absPath $io->CombinePath($_SERVER["DOCUMENT_ROOT"], $normPath)) && strpos($absPath$tmpPath) === 0)
            {
                
$result $file_array;
                
$result["tmp_name"] = $absPath;
                
$result["error"] = intval($result["error"]);
                if (!
is_null($description))
                    
$result["description"] = $description;
            }
        }
        else
        {
            
$emptyFile = array(
                
"name" => null,
                
"type" => null,
                
"tmp_name" => null,
                
"error" => 4,
                
"size" => 0,
            );
            if (
$file_array == $emptyFile)
            {
                
$result $emptyFile;
                if (!
is_null($description))
                    
$result["description"] = $description;
            }
        }

        return 
$result;
    }