kheb een php script gemaakt voor een website die ik voor sschool moet maken
het is om emailadressen in een tekstbestand op te slaan.
die emailadressen moeten niet voor iedereen beschikbaar zijn om te zien.
ik probeerde het in de map private op te slaan maar hij zegt dat dat niet mag
(is not an allowed path)
dit is script 1:
[code]
<form action="nieuwsbrief2.php" method="post">
Emailadres: <input type="text" name="emailadres" size="40"> <input type="submit" name="submit" value="Verstuur">
[/code]
IF ($lengte > $max || $lengte == $min) {
echo "Is dit wel een emailadres?
De tekst die u ingevuld heeft is te lang of u heeft helemaal niets ingevuld.
Probeer het nog eens.
Heeft u echt zo'n lang emailadres mail dan naar XXX.";
}
ELSE {
fputs ($file, $_POST["emailadres"] );
fputs ($file,", ");
fclose ($file);
echo "Uw emailadres is toegevoegd";
}
?>
[/code]
ik weet het; het is geen geweldig script maar ik ben eigenlijk pas net begonnen met een beetje php.
weet iemand hoe ik het toch goed beveiligd krijg??
(ik heb het emailadressen.txt bestand wel gechmod (kdacht naar 777))
ga geen script van websites plukken, ik wil het gewoon met dit script doen en hier een oplossing voor.
Wie helpt mij?
Moderator: er is een speciale [ code ] [ /code ] tag ;)
bedankt mod:)
Weet niemand hier een oplossing voor?
11 januari 2007 21:59
blacksorcerer
Ik ben geen held in PHP, maar volgens mij kan ../../ vaak fouten opleveren.
Misschien dat je beter vanaf de root kunt werken met bijv.
[code]$_SERVER['DOCUMENT_ROOT']."/niv1/niv2/private/emailadressen.txt"[/code]
waarbij niv1 & niv2 nog meerdere niveau's tussen root en private map voorstellen.
edit: als je CHMOD 777 gebruikt betekent dit wel dat iedereen dus gewoon aan die map/file kan, tenzij je iets speciaals hebt met die 'private' map.
12 januari 2007 17:00
gerjan
de map private is een speciale map die in de hoofddirectorie van de server staat.
dit staat in een txt file die in die map staat.
[i]Access to this directory is available only to you.
The directory cannot be accessed via any web or system services, so you can
store any private information here.[/i]
Ik dacht dat dit standaard was maar blijkbaar niet. (toch?)
Maar ik wil in elk geval ergens die emailadressen veilig opslaan zonder dat iemand anders die kan zien (dus niet file renamen naar wcbkjqkpn.txt zodat nieand ze vind)
Is er ook nog een andere oplossing?
12 januari 2007 22:08
blacksorcerer
De gegevens die je opslaat coderen, of de map/file op CHMOD 600 zetten zodat die admin read en write only is.
Als je de gegevens erin wel nog nodig hebt op de site, kun je ze wel nog gewoon vanuit een script bereiken, maar je kan er niet zomaar bijkomen door de link in te vullen o.i.d.
Of hoef je het zelfs alleen maar op te slaan en vervolgens via ftp er gewoon afhalen?
12 januari 2007 22:31
gerjan
ja ik hoef er alleen maar eens in de maand bij ong. via ftp server
12 januari 2007 22:33
blacksorcerer
Dan is het met die CHMOD op 600 wss al opgelost
12 januari 2007 22:35
gerjan
helaas werkt het nog niet en dat komt denk ik doordat je niet in die map private kan schrijven op een 1 of andere manier.
deze error geeft hij (of moet ik nog iets anders chmodden (kheb alleen map private incl inhoud))
deze error geeft hij:
[code]Warning: fopen() [function.fopen]: open_basedir restriction in effect. File(../../private/emailadressen.txt) is not within the allowed path(s): (/var/www/vhosts/enormdekoning.nl/httpdocs:/tmp) in /var/www/vhosts/enormdekoning.nl/httpdocs/nieuw/nieuwsbrief2.php on line 13
[/code]
is er ook nog een andere oplossing om tekst wat mensen zenden op te slaan en alleen toegankelijk te maken voor de webmaster?
13 januari 2007 18:44
blacksorcerer
Probeer het eerst ff simpel met een nieuwe map die je in de dir maakt waar het script zelf gewoon staat en noem die map 'tijdelijk' ofzo, en zet het textbestand erin. CHMOD die map naar 600, en probeer het dan nog eens.
Zoals ik al aangaf vind ik ../../ niet zo verstandig.
13 januari 2007 18:56
gerjan
kheb het weer geprobeerd maar het lukt nog steeds niet.
het is toch zeker enkel het emailadressen.txt bestand dat ik moet chmodden naar 600.
13 januari 2007 19:20
blacksorcerer
Maak de dir + adressenfile eens 711 dan, ik zie dat het bij veel pwd-protected sites enzo gebruikt (bv adhv .htaccess) wordt, en 600 wordt echt alleen gebruikt om er pwd's in op te slaan.
Als het echt aan je code zou liggen kan ik daar niet veel bij helpen, omdat ik zoiets zelf niet heb gedaan met php.
Ik zou dus een mooi scripte ergens van internet plukken, als de beveiliging belangrijk zou zijn :p