Benim txt dosyası güvenli yapmak istiyorum

2 Cevap php

Current status. I have to set 606 for my foobaa.txt.

I wrote a php code, that read and write foobaa.txt,

and I want to make the permission of the foobaa.txt as 600.

But when I tested 600, the PHP code can not read and write foobaa.txt.

so I changed to 606 the foobaa.txt, then my PHP code can read and write the foobaa.txt.

Bu, problom çünkü

Birisi koyduğunuzda

ttp :/ / blabla.foobaa.com / foobaa.txt

directly, then he can see the contents of the foobaa.txt.

Bu güvenlik açığı olduğunu.

so I want to make 600 for the permission of the foobaa.txt, but if I do so, then the php code can not read and write foobaa.txt.

I think the admin can modify some apatch settings for we can set the txt file's permission as 600.

ya da bazı başka şeyler yapmak gerekiyor?

gibi. htaccess falan.

2 Cevap

PHP kodu web sunucusu değil, dikkate SSH'ing ve izinleri değişiyor kullanıcı olarak çalışır. Metin dosyası komut dosyası tarafından okunabilir olup olmadığını Yani, sunucu tarafından okunabilir. Sen yöntemleri birkaç biri tarafından dosyaya dış kullanıcıların erişimini kontrol etmek isteyeceksiniz.

  1. Komut erişebilirsiniz, böylece DocumentRoot dışında dosya koymak, ancak HTTP tarafından talep imkansız.

  2. Sadece okuyan bir .htaccess dosyası ile bir dizindeki dosya koymak Deny From All. Ayrıca tek tek dosya korumak olabilir, ama bu özel tutulmalıdır ki diğer ilgili dosyalara sahip olacak büyük olasılıkla. Sadece aynı dizinde bu koyabilirsiniz.

. Htaccess üzerinden erişimi kısıtlamak olabilir:

<Files foobaa.txt>
    Deny from all
</Files>

ya da benzer bir şey. Ama bu daha iyi public_htm (veya eşdeğeri) klasörün dışındaki dosyayı hareketli olacağını ... mükemmel değildir.