Доброго времени суток! Помогите пожалуйста обойти проверку расширения файла при загрузке. Загружать файлы с любым содержанием возможно, но вот обойти расширение файла не могу. Задача загрузить файл с последующим выполнением кода. Векторы: 1 - обойти расширение файла, и загрузить что то типа 1.jpg.php, 2 - загрузить графический файл таким обзором что бы при обращении в последствии к нему выполнялся код, что то типа 1.php%00.jpg. Помогите с вариантами. Код формы загрузки: PHP: case 'uploadFiles' : $canOverwrite = ("1"==$_REQUEST ['canOverwrite']) ? true : false; $doSimulate = ("1"==$_REQUEST ['doSimulate']) ? true : false; $newDir = ($_REQUEST ['d']) ? trim($_REQUEST ['d']) : null; $currDir = $newDir; $target = AdminFileManager::buildPath ( $newDir ); if ($target [strlen ( $target ) - 1] != '/') $target = $target . '/'; $count = 0; $report=array(); $tagRed="<span class='er'>"; $tagEnd="</span>"; $singleReport.="Opzioni attive:<br />Permetti sovrascrizione file: ".( ($canOverwrite)? "<b>SI</b>" : $tagRed."NO".$tagEnd )."<br />"; $singleReport.="Simulazione attiva: ".( ($doSimulate)? $tagRed."SI".$tagEnd : "<b>NO</b>" )."<br />"; $report[]=$singleReport; // FIXME unificare gestione array $arrayext=array ('jpg', 'jpeg', 'gif', 'txt', 'png','JPG','PDF','pdf' ); $array_lang_code=array ('_IT','_ES','_PT','_RU','_FR','_EN'); foreach ( $_FILES ['uplfile'] ['name'] as $filename ) { $singleReport = "- $filename : "; $fileInfo = pathinfo ( $filename ); $ext = (strlen ( $fileInfo ['extension'] ) > 0) ? $fileInfo ['extension'] : null; // controllo 0) - estesione file if (in_array ( strtolower ( $ext ), $arrayext )) { // controllo sul codice lingua $fname = (strlen ( $fileInfo ['filename'] ) > 0) ? $fileInfo ['filename'] : null; $lang_code = substr ( $fname, - 3 ); if (! in_array ( $lang_code, $array_lang_code )) { $temp = $target; $tmp = $_FILES ['uplfile'] ['tmp_name'] [$count]; // controlli // 1) file proveniente da un http if (is_uploaded_file ( $tmp )) { // 2) c'è stato qualche errore nell'upload if ($_FILES ['uplfile'] ['error'] [$count] == UPLOAD_ERR_OK) { $count = $count + 1; $temp = $temp . basename ( $filename ); $overWrite = false; $doMove = false; if (file_exists ( $temp )) { $overWrite = true; if ($canOverwrite) { // copia $doMove = true; } else { $singleReport .= "ERR! FILE ESISTENTE!"; } } else { // copia $doMove = true; } if ($doMove) { if ($doSimulate) { // simula risultato true $res = 1; } else { $res = move_uploaded_file ( $tmp, $temp ); } if ($res) { $singleReport .= " OK! " . (($overWrite) ? " (sovrascritto!) " : ""); } else { $singleReport .= $tagRed." ERR! ERRORE NEL COPIARE IL FILE DA $tmp ".$tagEnd; } } $temp = ''; $tmp = ''; } else { $singleReport .= $tagRed." ERR! - CODICE ERRORE " . $_FILES ['uplfile'] ['error'] [$count].$tagEnd; } } else { $singleReport .= $tagRed." ERR! - File non proveniente da protocollo HTTP.".$tagEnd; } } else { $singleReport .= $tagRed." ERR! - File con codice lingua in maiuscolo!".$tagEnd; } } else { $singleReport .= $tagRed." ERR! - Estensione del file non supportata `$ext` !".$tagEnd; } $report[]=$singleReport; $cod=base64_encode(gzcompress(json_encode($report))) ; //var_dump ($cod,json_encode($report)); die (); } header ( "Location: $page.php?d=" . $currDir . "&op=upload&res=" .urlencode($cod) ); exit (0); break;
Увы, не могу загрузить .htaccess. Та же проблема что и с файлами не проходящие фильтрацию. А идея хорошая, спс.