plik pokaz_emblemat.php
<?php function pokaz_emblemat () { // Ladowanie skrypty JavaScripts potrzebnego do otwierania okienek pomocy echo\" <script language=\"JavaScript\"> <!-- function show(prm) { url = \"\" +prm; params = \"width=200 height=150 toolbar=0, location=0, directories=0, status=0, border
= , scrollbars=1, menubar=0, resizable=0\"; db = window.open(url, \"okienko\" , params); db.focus(); } //--> </script> \"; echo\" $thefile <br> $thefile_name <br> $thefile_size <br> $thefile_type <br> \"; if ( $_POST[emblemat_usun] != ON ) { if (isset($_POST['emblemat_hdd'])) { if( empty($_POST['emblemat_hdd']) ) { $emblemat_hdd=1; } if( empty($_POST['emblemat_url']) ) { $emblemat_url=1; } if ( $emblemat_hdd != 1 && $emblemat_url != 1 ) { $emblemat_hdd=1; $emblemat_url=1; } } if (!isset($_POST['emblemat_hdd']) || ( $emblemat_hdd != 1 && $emblemat_url != 1 ) || ( $emblemat_hdd == 1 || $emblemat_url == 1 ) ) { $action=\"edycja_profil.php?mode=pokaz_emblemat&m=spr\"; } if ( isset($_POST['emblemat_hdd']) && ( $emblemat_hdd !== 1 || $emblemat_url !== 1 ) && ( $emblemat_hdd == 1 || $emblemat_url == 1 ) ) { session_start(); $_SESSION['emblemat_hdd_name']=$emblemat_hdd_type; $_SESSION['emblemat_url']=$_POST['emblemat_url']; $_SESSION['emblemat_url']=$_POST['emblemat_url']; $_SESSION['emblemat_url']=$_POST['emblemat_url']; $_SESSION['emblemat_url']=$_POST['emblemat_url']; header(\"Location: edycja_profil.php?mode=zapis_emblemat\"); exit(); } } elseif ( $_POST[emblemat_usun] == ON ) { $_SESSION['usun']=1; header(\"Location: edycja_profil.php?mode=zapis_emblemat\"); exit(); } $sql = \"SELECT * FROM users WHERE login='$_SESSION[log]' LIMIT 1\"; $wykonaj = mysql_query ( $sql ); $users_emblemat = mysql_fetch_array ( $wykonaj ); echo\" <center> <img src='./emblematy/$users_emblemat[emblemat]'></img> <table width='745'> <center> \"; if ( isset($_GET[m]) ) { if ( $emblemat_hdd == 1 ) { $clas=\"form_error\"; } else { $clas=\"form\"; } } else { $clas=\"form\"; } echo\" <tr class='$clas'> <form enctype='multipart/form-data' method='POST' action='$action'> <input type='hidden' name='MAX_FILE_SIZE' value='1000000'> <td align='right'>Emblemat z Twojego dysku: </td> <td colspan='2'> <input type='file' name='userfile' size='20'></br> </td> \"; if ( isset($_GET[m]) ) { if ( $emblemat_url == 1 ) { $clas=\"form_error\"; } else { $clas=\"form\"; } } else { $clas=\"form\"; } echo\" </tr> <tr class='$clas'> <td align='right'>Emblemat z zewnetrznego URL: </td> <td colspan='2'> <input type='text' value='$_POST[emblemat_url]' name='emblemat_url' size='20'></br> </td> </tr> <tr class='form'> <td align='right'>Emblemat z Galerii:</br></br> </td> <td colspan='2'><a href=''> Pokaż galerie</a></br></br> </td> </tr> <tr class='form'> <td align='right'>Usuń Emblemat:</br></br> </td> <td colspan='2'><input name='emblemat_usun' type='checkbox' value='ON'></br></br> </td> </tr> <tr class='form'> <td align='right'> </td> <td colspan='2'> <input type='submit' value='wyślj' name='s1' size='20'></br> </td> </tr> </table> </center> \"; } ?>
plik zapis_emblemat.php
<?php function pokaz_emblemat () { // $userfile - miejsce tymczasowej lokalizacji pliku na serwerze WWW $userfile = $HTTP_POST_FILES['userfile']['tmp_name']; // $userfile_name - nazwa pliku w systemie użytkownika $userfile_name = $HTTP_POST_FILES['userfile']['name']; // $userfile_size - wielkość pliku w bajtach $userfile_size = $HTTP_POST_FILES['userfile']['size']; // $userfile_type - typ pliku w systemie MIME, np. image/gif $userfile_type = $HTTP_POST_FILES['userfile']['type']; // $userfile_error - kod błędu związanego z wysyłaniem pliku $userfile_error = $HTTP_POST_FILES['userfile']['error']; // userfile_error został dodany do php 4.2.0 // ten kod można stosować z nowszymi wersjami if ($userfile_error > 0) { switch ($userfile_error) { } exit; } // umieszczenie pliku w pożądanej lokalizacji $lokalizacja = 'wyslane/'.$userfile_name; // is_uploaded_file and move_uploaded_file dodane w wersji 4.0.3 { { exit; } } else { exit; } } ?>
caly czas wywala 'Problem: możliwy atak podczas wysyłania pliku