cvs: phpdoc /nl/features file-upload.xml http-auth.xml

From: Date: Thu, 09 Nov 2000 19:50:57 +0000
Subject: cvs: phpdoc /nl/features file-upload.xml http-auth.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969332847@lists.php.net to get a copy of this message
mathieu Thu Nov 9 11:50:57 2000 EDT Modified files: /phpdoc/nl/features file-upload.xml http-auth.xml Log: - Finished initial translations in features/ # Check wether it still builds derick, still can't # get is to build here..

Index: phpdoc/nl/features/file-upload.xml diff -u phpdoc/nl/features/file-upload.xml:1.2 phpdoc/nl/features/file-upload.xml:1.3 --- phpdoc/nl/features/file-upload.xml:1.2 Tue Nov 7 15:11:07 2000 +++ phpdoc/nl/features/file-upload.xml Thu Nov 9 11:50:57 2000 @@ -1,105 +1,102 @@ <chapter id="features.file-upload"> - <title>Handling file uploads</title> + <title>Bestanden uploaden naar server</title> <sect1 id="features.file-upload.post-method"> - <title>POST method uploads</title> + <title>Met de POST methode uploaden</title> <simpara> - PHP is capable of receiving file uploads from any RFC-1867 - compliant browser (which includes Netscape Navigator 3 or later, - Microsoft Internet Explorer 3 with a patch from Microsoft, or - later without a patch). This feature lets people upload both text - and binary files. With PHP's authentication and file manipulation - functions, you have full control over who is allowed to upload and - what is to be done with the file once it has been uploaded. + PHP kan 'file uploads' ontvangen van elke browser welke de + RFC-1867 standaard volgt (Zoals Netscape Navigator 3+ en Microsoft + Internet Explorer 3 met een patch van Microsoft, of ouder zonder patch). + Dit maakt het mogelijk voor mensen om text en binary bestanden te + uploaden. Met PHP's authenticatie en bestands functies heb je volledige + controle over wie waar wat mag uploaden en wat er met het bestand gebeurd + zogauw het geupload is. </simpara> <para> - Note that PHP also supports PUT-method file uploads as used by - Netscape Composer and W3C's Amaya clients. See the <link - linkend="features.file-upload.put-method">PUT Method - Support</link> for more details. + PHP ondersteunt ook de PUT-methode voor bestand uploads. Dit wordt + onderandere gebruikt door Netscape Composer en programma's die W3C's + Amaya gebruiken. Zie <link linkend="features.file-upload.put-method"> + PUT Methode Ondersteuning</link> voor meer details. </para> <para> - A file upload screen can be built by creating a special form which - looks something like this: + Een 'bestands upload' scherm kan gemaakt worden met een speciaal form + welke er zo uit ziet: <example> - <title>File Upload Form</title> + <title>Bestand Upload Form</title> <programlisting> &lt;FORM ENCTYPE=&quot;multipart/form-data&quot; ACTION=&quot;_URL_&quot; METHOD=POST&gt; &lt;INPUT TYPE=&quot;hidden&quot; name=&quot;MAX_FILE_SIZE&quot; value=&quot;1000&quot;&gt; Send this file: &lt;INPUT NAME=&quot;userfile&quot; TYPE=&quot;file&quot;&gt; -&lt;INPUT TYPE=&quot;submit&quot; VALUE=&quot;Send File&quot;&gt; +&lt;INPUT TYPE=&quot;submit&quot; VALUE=&quot;Stuur Bestand&quot;&gt; &lt;/FORM&gt; </programlisting> </example> - The _URL_ should point to a PHP file. The MAX_FILE_SIZE hidden - field must precede the file input field and its value is the - maximum filesize accepted. The value is in bytes. + De URL moet naar een PHP bestand wijzen. Het MAX_FILE_SIZE 'hidden' + veld moet VOOR het 'file input' veld komen en de waarde hiervan wordt + gebruikt als de maximaal toegestane grootte van het bestand dat + geupload wordt. Deze waarde is in bytes. </para> <para> - In PHP 3, the following variables will be defined within the - destination script upon a successful upload, assuming that <link - linkend="ini.register-globals">register_globals</link> is turned - on in <filename>php3.ini</filename>. If <link - linkend="ini.track-vars">track_vars</link> is turned on, they will - also be available in PHP 3 within the global array - <varname>$HTTP_POST_VARS</varname>. Note that the following - variable names assume the use of the file upload name 'userfile', - as used in the example above: + In PHP 3 worden de volgende variablen gevuld in het script + zogauw de upload succesvol is afgerond.(aangenomen wordt dat + <link linkend="ini.register-globals">register_globals</link> + aan is gezet in de <filename>php.ini</filename>). Als <link + linkend="ini.track-vars">track_vars</a> aanstaat zijn ze (ook) te + vinden in de globale array <varname>$HTTP_POST_VARS</varname>. + Let op: De variablen in het volgende voorbeeld hebben de prefix + 'userfile' zoals aangegeven was in het bovenstaande voorbeeld: <itemizedlist> <listitem> <simpara> - <varname>$userfile</varname> - The temporary filename in which - the uploaded file was stored on the server machine. + <varname>$userfile</varname> - De tijdelijke bestands naam waarin het geuploade bestand + is opgeslagen op de server. </simpara> </listitem> <listitem> <simpara> - <varname>$userfile_name</varname> - The original name or path - of the file on the sender's system. + <varname>$userfile_name</varname> - De originele naam of het originele pad van + het bestand op het systeem van de gebruiker. </simpara> </listitem> <listitem> <simpara> - <varname>$userfile_size</varname> - The size of the uploaded - file in bytes. + <varname>$userfile_size</varname> - De grootte van het 'ge-uploade' bestand in bytes. </simpara> </listitem> <listitem> <simpara> - <varname>$userfile_type</varname> - The mime type of the file - if the browser provided this information. An example would be - &quot;image/gif&quot;. + <varname>$userfile_type</varname> - Het mime-type van het bestand + als de browser deze informatie heeft meegestuurd. Een voorbeeld + zou zijn: &quot;image/gif&quot;. </simpara> </listitem> </itemizedlist> - Note that the &quot;$userfile&quot; part of the above variables is - whatever the name of the INPUT field of TYPE=file is in the upload - form. In the above upload form example, we chose to call it - &quot;userfile&quot; + Let op: het deel &quot;$userfile&quot; van de bovenstaande variablen + is wat het NAME= veld van het INPUT veld met TYPE=file is. In het bovenstaande + voorbeeld kozen we ervoor om het &quot;userfile&quot; te noemen. </para> <para> - In PHP 4, the behaviour is slightly different, in that the new - global array <varname>$HTTP_POST_FILES</varname> is provided to - contain the uploaded file information. This is still only - available if <link linkend="ini.track-vars">track_vars</link> is - turned on, but <link linkend="ini.track-vars">track_vars</link> is - always turned on in versions of PHP after PHP 4.0.2. + PHP 4 gedraagt zich enigzins anders, in PHP4 word de globale array + <varname>$HTTP_POST_FILES</varname> aangemaakt waarin informatie over + het ge-uploade bestand wordt opgeslagen. Deze is alleen te gebruiken + als <link linkend="ini.track-vars">track_vars</link> is aangezet. + In alle versies na PHP 4.0.2 staat deze echter standaard aan. </para> <para> - The contents of <varname>$HTTP_POST_FILES</varname> are as - follows. Note that this assumes the use of the file upload name - 'userfile', as used in the example above: + De inhoud van <varname>$HTTP_POST_FILES</varname> is als volgd. + Hier word weer gebruik gemaakt van &quot;userfile&quot; zoals in het + bovenstaande voorbeeld. <variablelist> <varlistentry> <term><varname>$HTTP_POST_FILES['userfile']['name']</varname></term> <listitem> <para> - The original name of the file on the client machine. + De originele naam van het bestand op het systeem van de gebruiker. </para> </listitem> </varlistentry> @@ -107,9 +104,8 @@ <term><varname>$HTTP_POST_FILES['userfile']['type']</varname></term> <listitem> <para> - The mime type of the file, if the browser provided this - information. An example would be - <literal>&quot;image/gif&quot;</literal>. + Het mime-type van het bestand als de browser deze informatie + meegestuurd heeft. Bijvoorbeeld: <literal>&quot;image/gif&quot;</literal>. </para> </listitem> </varlistentry> @@ -117,7 +113,7 @@ <term><varname>$HTTP_POST_FILES['userfile']['size']</varname></term> <listitem> <para> - The size, in bytes, of the uploaded file. + De grootte van het ge-uploade bestand in bytes. </para> </listitem> </varlistentry> @@ -125,8 +121,8 @@ <term><varname>$HTTP_POST_FILES['userfile']['tmp_name']</varname></term> <listitem> <para> - The temporary filename of the file in which the uploaded file - was stored on the server. + De tijdelijke bestandsnaam waarin het ge-uploade bestand is + opgeslagen op de server. </para> </listitem> </varlistentry> @@ -134,122 +130,121 @@ </para> <para> - Files will by default be stored in the server's default temporary - directory, unless another location has been given with the <link - linkend="ini.upload-tmp-dir">upload_tmp_dir</link> directive in - <filename>php.ini</filename>. The server's default directory can - be changed by setting the environment variable - <envar>TMPDIR</envar> in the environment in which PHP runs. - Setting it using <function>putenv</function> from within a PHP - script will not work. This environment variable can also be used - to make sure that other operations are working on uploaded files, - as well. + Ge-uploade bestanden worden standaard in de server zijn standaard tijdelijke + directory opgeslagen, tenzij er een andere locatie is opgegeven met het + <link linkend="ini.upload-tmp-dir">upload_tmp_dir</link> directive in + <filename>php.ini</filename>. De server zijn standaard tijdelijke + kan worden veranderd worden door de 'environment' variable + <envar>TMPDIR</envar> te veranderen in het 'environment' waar PHP + in draait. Dit kan je <emphasis>niet</emphasis> doen in een script + met de PHP functie <function>putenv</function>. Deze 'environment' + variable kan ook gebruikt worden om te controleren of bewerkingen + op ge-uploade bestanden wel juist werken. <example> <title>Validating file uploads</title> <para> - The following examples are for versions of PHP 3 greater than - 3.0.16, and versions of PHP 4 greater than 4.0.2. See the - function entries for <function>is_uploaded_file</function> and - <function>move_uploaded_file</function>. + De volgende voorbeelden zijn voor PHP 3 versies boven 3.0.16 en + voor PHP 4 versies boven 4.0.2. Kijk voor meer informatie bij + de functies <function>is_uploaded_file</function> en <function>move_uploaded_file</function>. </para> <programlisting role="php"> &lt?php if (is_uploaded_file($userfile)) { - copy($userfile, "/place/to/put/uploaded/file"); + copy($userfile, "/plaats/voor/ge-uploadbestand"); } else { - echo "Possible file upload attack: filename '$userfile'."; + echo "Mogelijke file-upload aanval: bestandsnaam '$userfile'."; } /* ...or... */ -move_uploaded_file($userfile, "/place/to/put/uploaded/file"); +move_uploaded_file($userfile, "/plaats/voor/ge-uploadbestand"); ?> </programlisting> <para> - For earlier versions of PHP, you'll need to do something like - the following. + Voor eerdere versies van PHP zal je iets als het volgende moeten + gebruiken. <note> <para> - This will <emphasis>not</emphasis> work in versions of PHP 4 - after 4.0.2. It depends on internal functionality of PHP which - changed after that version. + Dit zal <emphasis>niet</emphasis> werken in PHP 4 versies ouder + dan 4.0.2. Dit voorbeeld is afhankelijk van een bepaalde + functionaliteit in PHP welke veranderd is na deze versie. </para> </note> </para> <programlisting role="php"> &lt?php -/* Userland test for uploaded file. */ +/* Gebruikerstest voor ge-upload bestand. */ function is_uploaded_file($filename) { if (!$tmp_file = get_cfg_var('upload_tmp_dir')) { $tmp_file = dirname(tempnam('', '')); } $tmp_file .= '/' . basename($filename); - /* User might have trailing slash in php.ini... */ + /* Gebruiker kan een slash als einde hebbe in php.ini... */ return (ereg_replace('/+', '/', $tmp_file) == $filename); } if (is_uploaded_file($userfile)) { - copy($userfile, "/place/to/put/uploaded/file"); + copy($userfile, "/plaats/voor/ge-uploadbestand"); } else { - echo "Possible file upload attack: filename '$userfile'."; + echo "Mogelijke bestands-upload aanval: bestandsnaam '$userfile'."; } ?> </programlisting> </example> </para> <simpara> - The PHP script which receives the uploaded file should implement - whatever logic is necessary for determining what should be done - with the uploaded file. You can for example use the - <varname>$file_size</varname> variable to throw away any files - that are either too small or too big. You could use the - <varname>$file_type</varname> variable to throw away any files - that didn't match a certain type criteria. Whatever the logic, - you should either delete the file from the temporary directory or - move it elsewhere. + Het PHP script welke het ge-uploade bestand ontvangt moet zelf + implementeren wat er moet gebeuren met het ge-uploade bestand. + Je kan bijvoorbeeld besluiten om bestanden weg te gooien welke + groter of juist kleiner zijn dan de <varname>$file_size</varname> + variable. Je kan de <varname>$file_type</varname> variable gebruiken + om bestanden te verwijderen welke niet voldoen aan een bepaald criteria. + Wat je ook doet, je moet het bestand uit de tijdelijke directory + verwijderen of het verplaatsen naar een andere directory. </simpara> <simpara> - The file will be deleted from the temporary directory at the end - of the request if it has not been moved away or renamed. + Het bestand zal worden verwijderd uit de tijdelijke directory aan + het einde van het script als het bestand niet verplaatst of hernoemd is. </simpara> </sect1> <sect1 id="features.file-upload.common-pitfalls"> - <title>Common Pitfalls</title> + <title>Standaard valkuilen</title> <simpara> - The MAX_FILE_SIZE item cannot specify a file size greater than the file - size that has been set in the upload_max_filesize in the PHP 3.ini file - or the corresponding php3_upload_max_filesize Apache .conf directive. - The default is 2 Megabytes. + Het veld MAX_FILE_SIZE kan geen grotere bestandsgrootte opgeven dan + de maximale grootte die is aangegeven met upload_max_filesize in php.ini + of met het php_upload_max_filesize Apache .conf directive. + Standaard is de maximale grootte 2 Megabytes. </simpara> <simpara> - Not validating which file you operate on may mean that users can access - sensitive information in other directories. + Als je niet controleert of je op het juiste bestand bewerkingen uitvoert, + kunnen gebruikers hiervan misbruik maken en gevoelige informatie in andere + directories benaderen. </simpara> <simpara> - Please note that the CERN httpd seems to strip off everything - starting at the first whitespace in the content-type mime header - it gets from the client. As long as this is the case, CERN httpd - will not support the file upload feature. + Let op: CERN httpd haalt alles voor de eerste spatie weg in de + content-type mime header die gestuurd word door de gebruiker. + Zolang CERN httpd dit doet ondersteunt PHP voor deze server + niet de bestands-upload mogelijkheid. </simpara> </sect1> <sect1 id="feature-fileupload.multiple"> - <title>Uploading multiple files</title> + <title>Meerdere bestanden uploaden</title> <simpara> - It is possible to upload multiple files simultaneously and have - the information organized automatically in arrays for you. To - do so, you need to use the same array submission syntax in the - HTML form as you do with multiple selects and checkboxes: + Het is mogelijk meerdere bestanden tegelijk te uploaden. Deze + informatie kan je ge-ordend in arrays verkrijgen. Om dit mogelijk + te maken moet je de zelfde syntax gebruiken als bij een HTML form + met meerdere selects en/of checkboxes. </simpara> <note> <para> - Support for multiple file uploads was added in version 3.0.10. + Ondersteuning voor meerdere file uploads werd toegevoegd in versie 3.0.10. </para> </note> <para> <example> - <title>Uploading multiple files</title> + <title>Meerdere bestanden uploaden</title> <programlisting> -&lt;form action=&quot;file-upload.html&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt; +&lt;form action=&quot;file-upload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt; Send these files:&lt;br&gt; &lt;input name=&quot;userfile[]&quot; type=&quot;file&quot;&gt;&lt;br&gt; &lt;input name=&quot;userfile[]&quot; type=&quot;file&quot;&gt;&lt;br&gt; @@ -259,58 +254,57 @@ </example> </para> <simpara> - When the above form is submitted, the arrays - <computeroutput>$userfile</computeroutput>, - <computeroutput>$userfile_name</computeroutput>, and - <computeroutput>$userfile_size</computeroutput> will be formed in - the global scope (as well as in $HTTP_POST_FILES ($HTTP_POST_VARS - in PHP 3)). Each of these will be a numerically indexed array of - the appropriate values for the submitted files. - </simpara> - <simpara> - For instance, assume that the filenames - <filename>/home/test/review.html</filename> and - <filename>/home/test/xwp.out</filename> are submitted. In this - case, <computeroutput>$userfile_name[0]</computeroutput> would - contain the value <computeroutput>review.html</computeroutput>, - and <computeroutput>$userfile_name[1]</computeroutput> would - contain the value - <computeroutput>xwp.out</computeroutput>. Similarly, - <computeroutput>$userfile_size[0]</computeroutput> would contain - <filename>review.html</filename>'s filesize, and so forth. + Als het bovenstaande form verstuurd wordt, worden de globale arrays + <computeroutput>$userfile</computeroutput>, + <computeroutput>$userfile_name</computeroutput> and + <computeroutput>$userfile_size</computeroutput> aangemaakt in + de globale scope (ook $HTTP_POST_FILES (PHP 4) en $HTTP_POST_VARS (PHP 3) + worden aangemaakt.) Deze arrays zijn numeriek geindexeerde arrays met de + juiste waarden voor de ge-uploade bestanden. + </simpara> + <simpara> + Bijvoorbeeld, stel dat de bestanden + <filename>/home/test/review.html</filename> en + <filename>/home/test/xwp.out</filename> ge-upload worden. + In dit geval zou <computeroutput>$userfile_name[0]</computeroutput> + de waarde <computeroutput>review.html</computeroutput> en + <computeroutput>$userfile_name[1]</computeroutput> de waarde + <computeroutput>xwp.out</computeroutput> bevatten. Navolgend + zou <computeroutput>$userfile_size[0]</computeroutput> de grootte + van het bestand <computeroutput>review.html</filename>'s bevatten, + enzovoort. </simpara> <simpara> <computeroutput>$userfile['name'][0]</computeroutput>, <computeroutput>$userfile['tmp_name'][0]</computeroutput>, - <computeroutput>$userfile['size'][0]</computeroutput>, and - <computeroutput>$userfile['type'][0]</computeroutput> are also set. + <computeroutput>$userfile['size'][0]</computeroutput> en + <computeroutput>$userfile['type'][0]</computeroutput> zijn ook beschikbaar. </simpara> </sect1> <sect1 id="features.file-upload.put-method"> - <title>PUT method support</title> + <title>PUT methode ondersteuning</title> <para> - PHP provides support for the HTTP PUT method used by clients such - as Netscape Composer and W3C Amaya. PUT requests are much simpler - than a file upload and they look something like this: + PHP ondersteunt ook de HTTP PUT methode welke gebruikt wordt door + o.a. Netscape Composer en W3C Amaya. PUT aanvragen zijn veel simpeler + dan een bestand uploaden en zien er ongeveer als volgt uit: <informalexample> <programlisting> -PUT /path/filename.html HTTP/1.1 +PUT /pad/bestandsnaam.html HTTP/1.1 </programlisting> </informalexample> </para> <para> - This would normally mean that the remote client would like to save - the content that follows as: /path/filename.html in your web tree. - It is obviously not a good idea for Apache or PHP to automatically - let everybody overwrite any files in your web tree. So, to handle - such a request you have to first tell your web server that you - want a certain PHP script to handle the request. In Apache you do - this with the <emphasis>Script</emphasis> directive. It can be - placed almost anywhere in your Apache configuration file. A - common place is inside a &lt;Directory&gt; block or perhaps inside - a &lt;Virtualhost&gt; block. A line like this would do the trick: + Dit betekent normaal gezien dat de server het bestand ook als + /pad/filename.html wilt opslaan. Dit is natuurlijk geen goed idee + omdat je niet wilt dat anderen bestanden overschrijven in je web tree. + Om zo'n 'request' te verwerken vertel je je server eerst met wat voor + PHP script je dit request wilt verwerken. Met Apache kan je dit doen + met het <emphasis>Script</emphasis> directive. Het kan ongeveer + overal in je configuratie bestand geplaatst worden. Een standaard + plaats hiervoor is bijvoorbeeld een &lt;Directory&gt; blok. + Een enkele regel als voorbeeld: <informalexample> <programlisting> Script PUT /put.php3 @@ -318,13 +312,13 @@ </informalexample> </para> <simpara> - This tells Apache to send all PUT requests for URIs that match the - context in which you put this line to the put.php3 script. This - assumes, of course, that you have PHP enabled for the .php3 - extension and PHP is active. + Dat verteld Apache om alle PUT requests waarvoor URIs die overeenkomen + met de context waarin deze regel geplaatst is, naar het put.php3 script + te sturen. We gaan er vanuit dat je de juist mime-headers heb gebruikt + om PHP met de .php3 extensie te laten werken en dat PHP actief is. </simpara> <simpara> - Inside your put.php3 file you would then do something like this: + In je 'put.php3' zou je dan iets als volgt neer zetten: </simpara> <para> <informalexample><programlisting> @@ -332,21 +326,19 @@ </programlisting></informalexample> </para> <simpara> - This would copy the file to the location requested by the remote - client. You would probably want to perform some checks and/or - authenticate the user before performing this file copy. The only - trick here is that when PHP sees a PUT-method request it stores - the uploaded file in a temporary file just like those handled but - the <link - linkend="features.file-upload.post-method">POST-method</link>. - When the request ends, this temporary file is deleted. So, your - PUT handling PHP script has to copy that file somewhere. The - filename of this temporary file is in the $PHP_PUT_FILENAME - variable, and you can see the suggested destination filename in - the $REQUEST_URI (may vary on non-Apache web servers). This - destination filename is the one that the remote client specified. - You do not have to listen to this client. You could, for example, - copy all uploaded files to a special uploads directory. + Dit kopieert het bestand naar de locatie welke gevraagd werd in + het request. Waarschijnlijk zal je nog enige tests uitvoeren op + het bestand voordat je het bestand daadwerkelijk kopieert. De enige + truc hier is dat PHP het bestand opslaat in een tijdelijk bestand + zoals bij de <link linkend="features.file-upload.post-method">POST-methode</link>. + Zogauw het request is afgehandeld word het tijdelijke bestand verwijderd. + Let dus op dat je script het tijdelijke bestand verplaatst of hernoemd. + De naam van dit tijdelijke bestand is opgeslagen in de variable + <varname>$PHP_PUT_FILENAME</varname> en je kan de voorgestelde locatie + vinden in <varname>$REQUEST_URI</varname> (Dit kan anders zijn bij + niet-Apache web servers). Dit is nogmaals een suggestie van de + gebruiker. Je hoeft deze suggestie niet te gebruiken, je kan bijvoorbeeld + alle bestanden in een speciale uploads directory plaatsen. </simpara> </sect1> Index: phpdoc/nl/features/http-auth.xml diff -u phpdoc/nl/features/http-auth.xml:1.1 phpdoc/nl/features/http-auth.xml:1.2 --- phpdoc/nl/features/http-auth.xml:1.1 Tue Oct 10 15:07:53 2000 +++ phpdoc/nl/features/http-auth.xml Thu Nov 9 11:50:57 2000 @@ -2,92 +2,90 @@ <title>HTTP authentication with PHP</title> <simpara> - The HTTP Authentication hooks in PHP are only available when it is - running as an Apache module and is hence not available in the CGI version. - In an Apache module PHP script, it is possible to use the - <function>Header</function> function to send an "Authentication Required" - message to the client browser causing it to pop up a Username/Password - input window. Once the user has filled in a username and a password, - the URL containing the PHP script will be called again with the variables, - $PHP_AUTH_USER, $PHP_AUTH_PW and $PHP_AUTH_TYPE set to the user - name, password and authentication type respectively. Only "Basic" - authentication is supported at this point. See the <function>Header</function> - function for more information.</simpara> - + De HTTP Authenticatie functies in PHP zijn alleen te gebruiken als + PHP gebruikt wordt als Apache module en is zijn NIET te gebruiken in + de CGI versie. In een PHP script is het dan mogelijk, met de + <function>Header</function> functie, een "Authentication Required" + bericht naar de browser te sturen. Dit veroorzaakt dat de browser + een "Login/Password" invul window aan de gebruiker laat zien. Zogauw + de gebruiker een login naam en een password heeft ingevuld wordt de URL + met het PHP script dat de header stuurde opnieuw aangeroepen. Nu zijn de + variablen $PHP_AUTH_USER, $PHP_AUTH_PW en $PHP_AUTH_TYPE gevuld met de + waarden die de gebruiker heeft ingevuld. Op dit moment word alleen de + &quot;Basic&quot; authenticatie ondersteund. Zie de <function>Header</function> + functie voor meer informatie.</simpara> <para> - An example script fragment which would force client authentication - on a page would be the following: - + Dit voorbeeld script dwingt gebruiker authenticatie af: <example> - <title>HTTP Authentication example</title> + <title>HTTP Authentication voorbeeld</title> <programlisting role="php"> &lt;?php if(!isset($PHP_AUTH_USER)) { - Header(&quot;WWW-Authenticate: Basic realm=\&quot;My Realm\&quot;&quot;); + Header(&quot;WWW-Authenticate: Basic realm=\&quot;Mijn Realm\&quot;&quot;); Header(&quot;HTTP/1.0 401 Unauthorized&quot;); - echo &quot;Text to send if user hits Cancel button\n&quot;; + echo &quot;Tekst om te sturen als de gebruiker op Annuleren klikt.\n&quot;; exit; } else { - echo &quot;Hello $PHP_AUTH_USER.&lt;P&gt;&quot;; - echo &quot;You entered $PHP_AUTH_PW as your password.&lt;P&gt;&quot;; + echo &quot;Hallo $PHP_AUTH_USER.&lt;P&gt;&quot;; + echo &quot;Je gebruikte $PHP_AUTH_PW als je password.&lt;P&gt;&quot;; } ?> </programlisting> </example></para> <para> - Instead of simply printing out the $PHP_AUTH_USER and - $PHP_AUTH_PW, you would probably want to check the username and - password for validity. Perhaps by sending a query to a database, - or by looking up the user in a dbm file.</para> - + In plaats van slechts de ingevoerde waarden aan de gebruiker te + laten zien, wil je waarschijnlijk $PHP_AUTH_USER en $PHP_AUTH_PW + gebruiken om de gebruiker te valideren tegen bijvoorbeeld een database. + </para> <para> - Watch out for buggy Internet Explorer browsers out there. They - seem very picky about the order of the headers. Sending the - <emphasis>WWW-Authenticate</emphasis> header before the - <errorcode>HTTP/1.0 401</errorcode> header seems to do the trick - for now.</para> + Kijk uit voor buggy Internet Explorer browsers. Sommige zijn + erg nauwkeurig over de volgorde dat de headers gestuurd worden. + Door eerst de <emphasis>WWW-Authenticate</emphasis> header te sturen + en dan de <errorcode>HTTP/1.0 401</errorcode> header lijkt het probleem + opgelost te zijn. </para> <simpara> - In order to prevent someone from writing a script which reveals - the password for a page that was authenticated through a - traditional external mechanism, the PHP_AUTH variables will not be - set if external authentication is enabled for that particular - page. In this case, the $REMOTE_USER variable can be used to - identify the externally-authenticated user.</simpara> + Om te voorkomen dat iemand een script schrijft die de passworden + achterhaald van iemand die al eerder geauthenticeerd was door middel + van het externe authenticatie systeem worden de PHP_AUTH_* variablen + niet gevuld als er gebruik word gemaakt van het externe authenticatie + systeem voor die bepaalde pagina. In dit geval kan de variable $REMOTE_USER + gebruikt worden om de extern geauthenticeerde gebruiker te identificeren. + </simpara> <simpara> - Note, however, that the above does not prevent someone who - controls a non-authenticated URL from stealing passwords from - authenticated URLs on the same server.</simpara> + Dit weerhoud iemand er echter niet van om passworden te stelen + via een niet-geauthenticeerde URL op dezelfde server.</simpara> + <simpara> - Both Netscape and Internet Explorer will clear the local browser - window's authentication cache for the realm upon receiving a - server response of 401. This can effectively "log out" a user, - forcing them to re-enter their username and password. Some people - use this to "time out" logins, or provide a "log-out" button.</simpara> + Netscape zowel als Internet Explorer zullen hun huidige cache in het + huidige Window legen zogauw ze een 401 header van de server krijgen. + Op deze manier kan je op een efficiente manier een gebruiker "uit loggen". + Sommige mensen gebruiken dit om een login te laten verlopen of gebruiken + dit met een "log-out" knop.</simpara> <simpara></simpara> <example> - <title>HTTP Authentication example forcing a new name/password</title> + <title>HTTP Authentication voorbeeld welke een nieuwe loginnaam en password vereist.</title> <programlisting role="php"> &lt;?php function authenticate() { - Header( &quot;WWW-authenticate: basic realm=\&quot;Test Authentication System\&quot;&quot;); + Header( &quot;WWW-authenticate: basic realm=\&quot;Test Authentication Systeem\&quot;&quot;); Header( &quot;HTTP/1.0 401 Unauthorized&quot;); - echo &quot;You must enter a valid login ID and password to access this resource\n&quot;; + echo &quot;Je moet een geldige login en password opgeven om bij deze pagina te komen\n&quot;; exit; } - if(!isset($PHP_AUTH_USER) || ($SeenBefore == 1 &amp;&amp; !strcmp($OldAuth, $PHP_AUTH_USER)) ) { + if(!isset($PHP_AUTH_USER) || ($EerderGezien == 1 &amp;&amp; !strcmp($VorigeNaam, $PHP_AUTH_USER)) ) { authenticate(); } else { echo &quot;Welcome: $PHP_AUTH_USER&lt;BR&gt;&quot;; - echo &quot;Old: $OldAuth&quot;; + echo &quot;Old: $VorigeNaam&quot;; echo &quot;&lt;FORM ACTION=\&quot;$PHP_SELF\&quot; METHOD=POST&gt;\n&quot;; - echo &quot;&lt;INPUT TYPE=HIDDEN NAME=\&quot;SeenBefore\&quot; VALUE=\&quot;1\&quot;&gt;\n&quot;; - echo &quot;&lt;INPUT TYPE=HIDDEN NAME=\&quot;OldAuth\&quot; VALUE=\&quot;$PHP_AUTH_USER\&quot;&gt;\n&quot;; - echo &quot;&lt;INPUT TYPE=Submit VALUE=\&quot;Re Authenticate\&quot;&gt;\n&quot;; + echo &quot;&lt;INPUT TYPE=HIDDEN NAME=\&quot;EerderGezien\&quot; VALUE=\&quot;1\&quot;&gt;\n&quot;; + echo &quot;&lt;INPUT TYPE=HIDDEN NAME=\&quot;VorigeNaam\&quot; VALUE=\&quot;$PHP_AUTH_USER\&quot;&gt;\n&quot;; + echo &quot;&lt;INPUT TYPE=Submit VALUE=\&quot;Opnieuw inloggen\&quot;&gt;\n&quot;; echo &quot;&lt;/FORM&gt;\n&quot;; } @@ -95,16 +93,16 @@ </programlisting> </example> <simpara> - This behavior is not required by the HTTP Basic authentication - standard, so you should never depend on this. Testing with Lynx - has shown that Lynx does not clear the authentication credentials - with a 401 server response, so pressing back and then forward - again will open the resource (as long as the credential - requirements haven't changed).</simpara> + Dit gedrag is niet vereist door de HTTP Basic authenticatie standaard, + dus je moet hier nooit op vertrouwen. Tests met de Lynx browser wijzen + uit dat Lynx zijn cache NIET leegt als hij een 401 header van de server + krijgt. Dus als je 'back' en 'forward' gaat krijg je gewoon de pagina + te zien met de eerder ingevoerde waarden (Tenzij de login voorwaarden + zijn gewijzigd). + </simpara> <simpara> - Also note that this does not work using Microsoft's IIS server and - the CGI version of PHP due to a limitation of IIS.</simpara> - + Let op: Dit werkt niet met Microsoft's IIS server en de CGI versie + van PHP vanwege een gebrek in IIS.</simpara> </chapter> <!-- Keep this comment at the end of the file
« previous php.doc (#969332847) next »