• 26-04-2009, 00:13:07
    #10
    Üyeliği durduruldu
    Windows sunucularda çalışmaz.
    Ben yinede az evvel yazdım lazım olanlar kullanabilirler.
    // Semih VURAL Dosya Kipi Kontrol ve Değiştirme
    $klasor_yada_dosya = "resimler";
    $kontrol_et = substr(sprintf('%o', fileperms($klasor_yada_dosya)), -4);
    if(!$kontrol_et == "0777"){ // klasor 0777 değilse
    chmod($klasor_yada_dosya, 0777);} // klasörü 0777 yap
    // yükleme kodların burda başlar
    $yuklendimi =  move_uploaded_file(...)
    // yükleme kodları burda biter
    if($yuklendimi){ // yükleme başarılı ise
    chmod($klasor_yada_dosya, 0644);} // dosya yükleme başarılı ise CHMOD'u tekrar 0644 yap
    Kolay Gelsin.
    Semih VURAL
  • 26-04-2009, 01:38:19
    #11
    suPHP kurun suPHP kullanın sunucuda. suPHP varken hiçbir klasöre chmod vermeniz gerekmez. gereksiz riske girmezsiniz.
  • 26-04-2009, 21:53:53
    #12
    Üyeliği durduruldu
    theFallen adlı üyeden alıntı: mesajı görüntüle
    suPHP kurun suPHP kullanın sunucuda. suPHP varken hiçbir klasöre chmod vermeniz gerekmez. gereksiz riske girmezsiniz.
    +1.
    tek kötü tarafi php yi cgi olarak kurmanız gerektigi. şahsen denemiştim bu sorunu kökünden hallediyor
    http://www.suphp.org/Home.html
  • 26-04-2009, 22:35:44
    #13
    Kurumsal Üye
    <FilesMatch "\.(php|php3|php4|php5|phps)$">
    Deny From All
    </FilesMatch>
    Bu kodu .htaccess içerisine atarsan php dosyalarının o klasör içerisinde çalışmasını önlemiş olursun. Umarım işini görür.
  • 26-04-2009, 22:40:55
    #14
    .htaccess
    Alıntı
    <Files ^(*.jpeg|*.jpg|*.png|*.gif)>
    order deny,allow
    deny from all
    </Files>
    Kaynak: Protecting 777 chmodded folders
  • 27-04-2009, 02:58:02
    #15
    Üyeliği durduruldu
    Bilgisayar adlı üyeden alıntı: mesajı görüntüle
    Kod için teşekkürler, Sanırım bu konuda en güvenli yol bu olsa gerek.
  • 07-05-2009, 00:29:49
    #16
    Üyeliği durduruldu
    Onurss'unki işe yarıyor ama 2. verilen kodu çalıştıramadım hiçbi şekilde

    tehlikeli yani engellememiz gereken uzantılar neler bilen paylaşırsa sevinirim.

    yada sadece belirlediğimiz uzantılar çalışsa / upload edilebilse varmı böyle birşey?
  • 07-05-2009, 00:47:22
    #17
    vezir adlı üyeden alıntı: mesajı görüntüle
    Onurss'unki işe yarıyor ama 2. verilen kodu çalıştıramadım hiçbi şekilde
    tehlikeli yani engellememiz gereken uzantılar neler bilen paylaşırsa sevinirim.
    yada sadece belirlediğimiz uzantılar çalışsa / upload edilebilse varmı böyle birşey?
    Tabi var

    Örnek
    $kaynak		= $_FILES["resim"]["tmp_name"]; // Resim yolunu çektik
    $resim		= $_FILES["resim"]["name"]; // Resim adını çektik
    $resimtipi		= $_FILES["resim"]["type"]; // Resimin tipini çekiyoruz
    $resimboyutu	= $_FILES["resim"]["size"]; // Resim boyutunu çektik
    
    // Sorguluyoruz
    if (($resimtipi != "image/gif") && ($resimtipi != "image/jpeg") && ($resimboyutu != 10000)) {
    echo "Resimin tipini beğenmedim"; // :)
    }else {
    // Burda kayıt işlemleri falan filan
    }
  • 07-05-2009, 09:51:59
    #18
    FTP Upload
    upload.html
    <html>
    <head>
    <title>VainSoft - Upload Form</title>
    </head>
    <body>
    
    <p>Upload Images here, 10 images at a time, hit back after upload to upload more. (100M MAX)</p>
    <p>
    <form name="fileup" method="post" enctype="multipart/form-data" action="upload.Php">
    <input type="file" name="userfiles[]"><br>
    <input type="file" name="userfiles[]"><br>
    <input type="file" name="userfiles[]"><br>
    <input type="file" name="userfiles[]"><br>
    <input type="file" name="userfiles[]"><br>
    <input type="file" name="userfiles[]"><br>
    <input type="file" name="userfiles[]"><br>
    <input type="file" name="userfiles[]"><br>
    <input type="file" name="userfiles[]"><br>
    <input type="file" name="userfiles[]"><br>
    <br>
    <!-- change below to your max -->
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000000">
    <input type="submit" value="submit" name="submit">
    </form>
    upload.php
    <?
    //uses $_FILES[] global array
    //see manual for older PHP version info
    
    //This function will be used to get the extension from the filename
    Function get_extension($file,$length=-1){
    $p = strrpos($file,".");
    $p++;
    If($length!=-1){
    $ext = substr($file,$p,$length);
    }
    If($length==-1){
    $ext = substr($file,$p);
    }
    $ext = strtolower($ext);
    Return $ext;
    }
    
    //Not good practice, but here anyway
    //change to suit your needs
    //also some have to be set in the ini
    //for this to correctly work
    
    //2meg max
    Ini_set("upload_max_filesize","100M");
    
    //turn on file uploads
    Ini_set("file_uploads","1");
    
    //set your temp dir
    Ini_set("upload_tmp_dir","/tmp");
    
    //set post size large enough to accomidate
    //3 100meg files and some overhead
    Ini_set("post_max_size","180M");
    
    ?>
    
    </p>
    <?
    //check to see if we have submited yet
    If($_POST["submit"]!="submit"){
    //not yet so lets make the form
    ?>
    
    <?
    }
    //see if we have submited and that the files array has been set
    If(($_POST["submit"]=="submit")&&(is_array($_FILES['userfiles']))){
    
    $ftp_user_name="*****"; //change to ftp username
    $ftp_user_pass="*****"; //change to ftp password
    $ftp_server="******"; //change to ftp url
    $ftp_dump_dir="/files"; //change to destination directory
    
    //go through all the files
    For($x=0;$x<count($_FILES['userfiles']['name']);$x++){
    
    //now we do some file checking
    
    //check to see if file is there
    If($_FILES['userfiles']['name'][$x]!="none"){
    //file has a name
    //check filesize
    If($_FILES['userfiles']['size'][$x]!=0){
    //file is larger than 0 bytes
    //Check to see if it is uploaded
    If(is_uploaded_file($_FILES['userfiles']['tmp_name'][$x])){
    //file has been uploaded!
    //let the user know their file has be uploaded
    Echo "file ".$_FILES['userfiles']['name'][$x]." uploaded!<br>";
    //conect to ftp server
    $conn_id = ftp_connect($ftp_server);
    // login with username and password
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    // check connection
    If ((!$conn_id) || (!$login_result)) {
    Echo "FTP connection has failed!<br>";
    Echo "Attempted to connect to $ftp_server for user $ftp_user_name";
    Exit;
    } else {
    Echo "Connected to $ftp_server! <br>";
    //set PASV mode
    If(!ftp_pasv($conn_id,TRUE)){
    Echo "Could not enter PASV mode!";
    }
    //rename to file#_date.Ext
    $filename = $_FILES['userfiles']['name'][$x];
    //$filename.= ".".Get_extension($_FILES['userfiles']['name'][$x],3);
    
    //change directory
    If (@ftp_chdir($conn_id, $ftp_dump_dir)) {
    //maybe you want to make sure we are in the correct directory
    Echo "Current directory is now : ", ftp_pwd($conn_id), "\and";
    } else {
    //you want to know if it didn't work
    Echo "Couldn't change directory\and";
    }
    
    //upload the file and let the user know what happened
    If(ftp_put($conn_id,$filename,$_FILES['userfiles']['tmp_name'][$x],FTP_BINARY)){
    Echo "File ".$_FILES['userfiles']['name'][$x]." was sent successfully<br>";
    Echo "File was named ".$filename."<br>";
    }else{
    Echo "There was a problem sending file ".$_FILES['userfiles']['name'][$x]."<br>";;
    }
    }
    // close the FTP stream
    Ftp_close($conn_id);
    }
    Else echo"File was not uploaded!<br>";
    }
    }
    Echo "<br>";
    
    }//end for loop
    
    }
    //That's all folks!
    ?>
    Kaynak: Php Ftp Upload Form - Open Discussion