cvs: phpdoc-el /features commandline.xml file-upload.xml http-auth.xml persistent-connections.xml remote-files.xml

From: Date: Tue, 27 May 2003 02:35:59 +0000
Subject: cvs: phpdoc-el /features commandline.xml file-upload.xml http-auth.xml persistent-connections.xml remote-files.xml
Groups: php.doc.el 
Request: Send a blank email to doc-el+get-10@lists.php.net to get a copy of this message
subbie Mon May 26 22:35:59 2003 EDT Added files: /phpdoc-el/features http-auth.xml persistent-connections.xml remote-files.xml Modified files: /phpdoc-el/features commandline.xml file-upload.xml Log: added 3 files in features, fixed commandline and file-upload

Index: phpdoc-el/features/commandline.xml diff -u phpdoc-el/features/commandline.xml:1.2 phpdoc-el/features/commandline.xml:1.3 --- phpdoc-el/features/commandline.xml:1.2 Sun May 25 21:49:31 2003 +++ phpdoc-el/features/commandline.xml Mon May 26 22:35:58 2003 @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="iso-8859-7"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- EN-Revision: 1.21 Maintainer: subbie Status: ready --> <chapter id="features.commandline"> <title>×ñçóéìïðïéþíôáò ôçí PHP áðü ôçí ãñáììÞ åíôïëþí</title> <!-- NEW DOCUMENTATION STARTS --> - <para>da + <para> Áðü ôçí Ýêäïóç 4.3.0, ç <literal>PHP</literal> õðïóôçñßæåé Ýíá íÝï ôýðï <literal>SAPI</literal> (Server Application Programming Interface) ìå üíïìá <literal>CLI</literal> ôï ïðïßï óçìáßíåé <emphasis>Command Line Index: phpdoc-el/features/file-upload.xml diff -u phpdoc-el/features/file-upload.xml:1.1 phpdoc-el/features/file-upload.xml:1.2 --- phpdoc-el/features/file-upload.xml:1.1 Mon May 26 20:49:05 2003 +++ phpdoc-el/features/file-upload.xml Mon May 26 22:35:58 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-7"?> -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <!-- EN-Revision: 1.59 Maintainer: subbie Status: ready --> <chapter id="features.file-upload"> <title>×åéñßæïíôáò upload áñ÷åßùí</title> Index: phpdoc-el/features/http-auth.xml +++ phpdoc-el/features/http-auth.xml <?xml version="1.0" encoding="iso-8859-7"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.34 Maintainer: subbie Status: ready --> <chapter id="features.http-auth"> <title>HTTP áíáãíþñéóç ìå ôçí PHP</title> <simpara> Ç HTTP áíáãíþñéóç ìå ôçí PHP åßíáé äéáèÝóéìç ìüíï üôáí åêôåëåßôáé óáí Apache module êáé Ýôóé äåí åßíáé äéáèÝóéìç óôçí CGI Ýêäïóç. Óå Ýíá Apache module PHP script, åßíáé äõíáôüí íá ÷ñçóéìïðïéçèåß ç <function>header</function> óõíÜñôçóç ãéá íá óôáëåß Ýíá "Authentication Required" ìÞíõìá óôïí browser ôïõ client áíáãêÜæïíôáò ôïí íá ðåôÜîåé Ýíá Username/Password ðáñÜèõñï åéóüäïõ. ¼ôáí ï ÷ñÞóôçò åéóÜãåé Ýíá username êáé Ýíá password, ôï URL ðïõ ðåñéÝ÷åé ôï PHP script èá êáëåóôåß îáíÜ ìå ôéò <link linkend="reserved.variables">ðñïêáèïñéóìÝíåò ìåôáâëçôÝò</link> <varname>PHP_AUTH_USER</varname>, <varname>PHP_AUTH_PW</varname>, êáé <varname>AUTH_TYPE</varname> ïñéóìÝíåò óôï username, password êáé ôïí ôýðï ôïõ authentication áíôßóôïé÷á. ÁõôÝò ïé ðñïêáèïñéóìÝíåò ìåôáâëçôÝò âñßóêïíôáé óôïõò <link linkend="reserved.variables.server">$_SERVER</link> êáé <varname>$HTTP_SERVER_VARS</varname> ðßíáêåò. Ìüíï ç "Basic" áíáãíþñéóç õðïóôçñßæåôáé. Äåßôå ôçí <function>header</function> óõíÜñôçóç ãéá ðåñéóóüôåñåò ðëçñïöïñßåò. </simpara> <note> <title>Óçìåßùóç ãéá ôéò PHP åêäüóåéò</title> <para> Ïé <link linkend="language.variables.superglobals">Autoglobals</link>, üðùò ç <link linkend="reserved.variables.server">$_SERVER</link>, Ýãéíáí äéáèÝóéìåò óôçí PHP Ýêäïóç <ulink url="&url.php.release4.1.0;">4.1.0</ulink>. Ç <varname>$HTTP_SERVER_VARS</varname> åßíáé äéáèÝóéìç áðü ôçí PHP 3. </para> </note> <para> ¸íá ðááñÜäåéãìá åíüò êïììÜôéïý åíüò script ôï ïðïßï åðéâÜëëåé client authentication óå ìéá óåëßäá áêïëïõèåß: </para> <para> <example> <title>ÐáñÜäåéãìá HTTP Authentication</title> <programlisting role="php"> <![CDATA[ <?php if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Text to send if user hits Cancel button'; exit; } else { echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>"; echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>"; } ?> ]]> </programlisting> </example> </para> <note> <title>Óçìåßùóç Óõìâáôüôçôáò</title> <para> Ðáñáêáëïýìå íá åßóôå ðñïóåêôéêïß üôáí ðñïãñáììáôßæåôå ôéò HTTP header ãñáììÝò óáò. Ãéá íá åããõçèåßôå óõìâáôüôçôá ìå üëïõò ôïõò client, ç ëÝîç-êëåéäß "Basic" ðñÝðåé íá ãñÜöåôáé ìå êåöáëáßï "B", ôï realm string ðñÝðåé íá åßíáé åóþêëåéóôï óå äéðëÜ (ü÷é ìïíÜ) åéóáãùãéêÜ (quotes), êáé áêñéâþò Ýíáò êåíüò ÷áñáêôÞñáò ðñÝðåé íá ðñïçãåßôáé ôïõ <emphasis>401</emphasis> êùäéêïý óôçí <emphasis>HTTP/1.0 401</emphasis> header ãñáììÞ. </para> </note> <para> Áíôß íá åêôõðþíåôå áðëÜ ôá <varname>PHP_AUTH_USER</varname> êáé <varname>PHP_AUTH_PW</varname>, üðùò ãßíåôáé óôï ðáñáðÜíù ðáñÜäåéãìá, ìðïñåß íá èÝëåôå íá åëÝãîåôå ôçí åãêõñüôçôá ôïõ username êáé ôïõ password. ºóùò óôÝëíïíôáò ìéá åñþôçóç óå ìéá âÜóç äåäïìÝíùí, Þ áíáæçôþíôáò ôïí ÷ñÞóôç óå Ýíá dbm áñ÷åßï. </para> <para> ÐñïóÝîôå ãéá åëáôôùìáôéêïýò Internet Explorer browser åêåß Ýîù. Öáßíïíôáé ðïëý åðéëåêôéêïß ãéá ôç óåéñÜ ôùí header. Ç áðïóôïëÞ ôïõ <emphasis>WWW-Authenticate</emphasis> header ðñéí ôïõ <literal>HTTP/1.0 401</literal> header öáßíåôáé íá êÜíåé ôï êüëðï ðñïò ôï ðáñþí. </para> <simpara> Áðü ôçí PHP 4.3.0, ãéá íá åìðïäßæåôáé êÜðïéïò íá ãñÜöåé Ýíá script ôï ïðïßï áðïêáëýðôåé ôï password ãéá ìéá óåëßäá ç ïðïßá Ý÷åé áíáãíùñéóôåß ìÝóá áðü êÜðïéï ðáñáäïóéáêü åîùôåñéêü ìç÷áíéóìü, ïé PHP_AUTH ìåôáâëçôÝò äåí èá ïñßæïíôáé áí ôï åîùôåñéêü authentication åßíáé åíåñãïðïéçìÝíï ãéá ôç óõãêåêñéìÝíç óåëßäá êáé ôï &safemode; åßíáé åíåñãïðïéçìÝíï. ¼ðùò êáé íá'÷åé, ôï <varname>REMOTE_USER</varname> ìðïñåß íá ÷ñçóéìïðïéçèåß ãéá íá áíáãíùñßóåôå ôïí åîùôåñéêÜ-authenticated ÷ñÞóôç. ¸ôóé, ìðïñåßôå íá ÷ñçóéìïðïéÞóåôå ôï <varname>$_SERVER['REMOTE_USER']</varname>. </simpara> <note> <title>Óçìåßùóç Ñõèìßóåùí</title> <para> Ç PHP ÷ñçóéìïðïéåß ôçí ðáñïõóßá åíüò <literal>AuthType</literal> directive ãéá íá ðñïóäéïñßóåé áí åßíáé åí åíåñãåßá êÜðïéï åîùôåñéêü authentication. </para> </note> <simpara> Óçìåéþóôå, ùóôüóï, ðùò ôï ðáñáðÜíù äåí åìðïäßæåé êÜðïéïí ï ïðïßïò åëÝã÷åé Ýíá non-authenticated URL áðü ôï íá êëÝâåé êùäéêïýò áðü áíáãíùñéóìÝíá URL óôïí ßäéï server. </simpara> <simpara> Ôüóï ï Netscape Navigator üóï êáé ï Internet Explorer èá êáèáñßóïõí ôï cache ôïõ ôïðéêïý browser ãéá Ýíá realm üôáí ëÜâïõí ìéá áðÜíôçóç áðü ôïí server ôýðïõ 401. Áõôü ðñáêôéêÜ êÜíåé "log out" Ýíá ÷ñÞóôç, áíáãêÜæïíôáò ôïõò íá åðáíá-åéóÜãïõí ôá username êáé password ôïõò. ÊÜðïéïé Üíèñùðïé ôï ÷ñçóéìïðïéïýí áõôü ãéá íá êÜíïõí "time out" ôá login, Þ íá ðñïóöÝñïõí êÜðïéï "log-out" êïõìðß. </simpara> <para> <example> <title>ÐáñÜäåéãìá ãéá HTTP Authentication áíáãêÜæïíôáò íÝá name/password</title> <programlisting role="php"> <![CDATA[ <?php function authenticate() { header('WWW-Authenticate: Basic realm="Test Authentication System"'); header('HTTP/1.0 401 Unauthorized'); echo "You must enter a valid login ID and password to access this resource\n"; exit; } if (!isset($_SERVER['PHP_AUTH_USER']) || ($_POST['SeenBefore'] == 1 && $_POST['OldAuth'] == $_SERVER['PHP_AUTH_USER'])) { authenticate(); } else { echo "<p>Welcome: {$_SERVER['PHP_AUTH_USER']}<br>"; echo "Old: {$_REQUEST['OldAuth']}"; echo "<form action='{$_SERVER['PHP_SELF']}' METHOD='POST'>\n"; echo "<input type='hidden' name='SeenBefore' value='1'>\n"; echo "<input type='hidden' name='OldAuth' value='{$_SERVER['PHP_AUTH_USER']}'>\n"; echo "<input type='submit' value='Re Authenticate'>\n"; echo "</form></p>\n"; } ?> ]]> </programlisting> </example> </para> <simpara> ÁõôÞ ç óõìðåñéöïñÜ äåí áðáéôåßôáé áðü ôï HTTP Basic authentication ðñüôõðï, Ýôóé äåí ðñÝðåé ðïôÝ íá óôçñßæåóôå óå áõôü. ÄïêéìÝò ìå ôï Lynx Ýäåéîáí ðùò ôï Lynx äåí êáèáñßæåé ôá ðéóôïðïéçôéêÜ áíáãíþñéóçò ìå ìéá áðÜíôçóç ôïõ server ôýðïõ 401, Ýôóé ðáôþíôáò back êáé ìåôÜ forward îáíÜ èá áíïßîåé ôçí óýíäåóç ìéá êáé ïé áðáéôÞóåéò áíáãíùñéóôéêþí äåí Üëëáîáí. Ï ÷ñÞóôçò ìðïñåß íá ðáôÞóåé ôï '_' êïõìðß ãéá íá êáèáñßóåé ôéò ðëçñïöïñßåò áíáãíþñéóçò, ùóôüóï. </simpara> <simpara> Åðßóçò óçìåéþóôå ðùò áõôü äåí ëåéôïõñãåß ìå ôïí Microsoft IIS server êáé ôçí CGI Ýêäïóç ôçò PHP ëüãù êÜðïéïõ ðåñéïñéóìïý ôïõ IIS. Áí ÷ñçóéìïðïéåßôå ôï IIS module (ISAPI), ìðïñåßôå íá ÷ñçóéìïðïéÞóåôå ôçí <literal>HTTP_AUTHORIZATION </literal> ìåôáâëçôÞ ãéá ðáñÜäåéãìá: <literal>list($user, $pw) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); </literal> </simpara> <note> <para> Áí ôï <link linkend="ini.safe-mode">safe mode</link> åßíáé åíåñãïðïéçìÝíï, ôï uid ôïõ script ðñïóôßèåôáé óôï <literal>realm</literal> êïììÜôé ôïõ <literal>WWW-Authenticate</literal> header. </para> </note> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-el/features/persistent-connections.xml +++ phpdoc-el/features/persistent-connections.xml <?xml version="1.0" encoding="iso-8859-7"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.21 Maintainer: subbie Status: ready --> <chapter id="features.persistent-connections"> <title>Óõíå÷åßò ÓõíäÝóåéò ÂÜóåùí ÄåäïìÝíùí</title> <simpara> Persistent connections are SQL links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there's already an identical persistent connection (that remained open from earlier) - and if it exists, it uses it. If it does not exist, it creates the link. An 'identical' connection is a connection that was opened to the same host, with the same username and the same password (where applicable). </simpara> <note> <para> There are other extensions that provide persistent connections, such as the <link linkend="ref.imap">IMAP extension</link>. </para> </note> <simpara> People who aren't thoroughly familiar with the way web servers work and distribute the load may mistake persistent connects for what they're not. In particular, they do <emphasis>not</emphasis> give you an ability to open 'user sessions' on the same SQL link, they do <emphasis>not</emphasis> give you an ability to build up a transaction efficiently, and they don't do a whole lot of other things. In fact, to be extremely clear about the subject, persistent connections don't give you <emphasis>any</emphasis> functionality that wasn't possible with their non-persistent brothers. </simpara> <simpara> Why? </simpara> <simpara> This has to do with the way web servers work. There are three ways in which your web server can utilize PHP to generate web pages. </simpara> <simpara> The first method is to use PHP as a CGI "wrapper". When run this way, an instance of the PHP interpreter is created and destroyed for every page request (for a PHP page) to your web server. Because it is destroyed after every request, any resources that it acquires (such as a link to an SQL database server) are closed when it is destroyed. In this case, you do not gain anything from trying to use persistent connections -- they simply don't persist. </simpara> <simpara> The second, and most popular, method is to run PHP as a module in a multiprocess web server, which currently only includes Apache. A multiprocess server typically has one process (the parent) which coordinates a set of processes (its children) who actually do the work of serving up web pages. When each request comes in from a client, it is handed off to one of the children that is not already serving another client. This means that when the same client makes a second request to the server, it may be serviced by a different child process than the first time. What a persistent connection does for you in this case it make it so each child process only needs to connect to your SQL server the first time that it serves a page that makes use of such a connection. When another page then requires a connection to the SQL server, it can reuse the connection that child established earlier. </simpara> <simpara> The last method is to use PHP as a plug-in for a multithreaded web server. Currently PHP 4 has support for ISAPI, WSAPI, and NSAPI (on Windows), which all allow PHP to be used as a plug-in on multithreaded servers like Netscape FastTrack (iPlanet), Microsoft's Internet Information Server (IIS), and O'Reilly's WebSite Pro. The behavior is essentially the same as for the multiprocess model described before. Note that SAPI support is not available in PHP 3. </simpara> <simpara> If persistent connections don't have any added functionality, what are they good for? </simpara> <simpara> The answer here is extremely simple -- efficiency. Persistent connections are good if the overhead to create a link to your SQL server is high. Whether or not this overhead is really high depends on many factors. Like, what kind of database it is, whether or not it sits on the same computer on which your web server sits, how loaded the machine the SQL server sits on is and so forth. The bottom line is that if that connection overhead is high, persistent connections help you considerably. They cause the child process to simply connect only once for its entire lifespan, instead of every time it processes a page that requires connecting to the SQL server. This means that for every child that opened a persistent connection will have its own open persistent connection to the server. For example, if you had 20 different child processes that ran a script that made a persistent connection to your SQL server, you'd have 20 different connections to the SQL server, one from each child. </simpara> <simpara> Note, however, that this can have some drawbacks if you are using a database with connection limits that are exceeded by persistent child connections. If your database has a limit of 16 simultaneous connections, and in the course of a busy server session, 17 child threads attempt to connect, one will not be able to. If there are bugs in your scripts which do not allow the connections to shut down (such as infinite loops), the database with only 16 connections may be rapidly swamped. Check your database documentation for information on handling abandoned or idle connections. </simpara> <warning> <simpara> There are a couple of additional caveats to keep in mind when using persistent connections. One is that when using table locking on a persistent connection, if the script for whatever reason cannot release the lock, then subsequent scripts using the same connection will block indefinitely and may require that you either restart the httpd server or the database server. Another is that when using transactions, a transaction block will also carry over to the next script which uses that connection if script execution ends before the transaction block does. In either case, you can use <function>register_shutdown_function</function> to register a simple cleanup function to unlock your tables or roll back your transactions. Better yet, avoid the problem entirely by not using persistent connections in scripts which use table locks or transactions (you can still use them elsewhere). </simpara> </warning> <simpara> An important summary. Persistent connections were designed to have one-to-one mapping to regular connections. That means that you should <emphasis>always</emphasis> be able to replace persistent connections with non-persistent connections, and it won't change the way your script behaves. It <emphasis>may</emphasis> (and probably will) change the efficiency of the script, but not its behavior! </simpara> <para> See also <function>fbsql_pconnect</function>, <function>ibase_pconnect</function>, <function>ifx_pconnect</function>, <function>imap_popen</function>, <function>ingres_pconnect</function>, <function>msql_pconnect</function>, <function>mssql_pconnect</function>, <function>mysql_pconnect</function>, <function>ociplogon</function>, <function>odbc_pconnect</function>, <function>ora_plogon</function>, <function>pfsockopen</function>, <function>pg_pconnect</function>, and <function>sybase_pconnect</function>. </para> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-el/features/remote-files.xml +++ phpdoc-el/features/remote-files.xml <?xml version="1.0" encoding="iso-8859-7"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.22 Maintainer: subbie Status: ready --> <chapter id="features.remote-files"> <title>AðïìáêñõóìÝíá áñ÷åßá</title> <para> ¼óï ôï <parameter>allow_url_fopen</parameter> åßíáé åíåñãïðïéçìÞíï óôï &php.ini;, ìðïñåßôå íá ÷ñçóéìïðïéåßôå ôá HTTP êáé FTP URL ìå ôéò ðåñéóóüôåñåò óõíáñôÞóåéò ðïõ ðáßñíïõí Ýíá üíïìá áñ÷åßïõ óáí ðáñÜìåôñï. ÅðéðëÝïí, ôá URL ìðïñïýí íá ÷ñçóéìïðïéçèïýí ìå ôéò <function>include</function>, <function>include_once</function>, <function>require</function> êáé <function>require_once</function> äçëþóåéò. Äåßôå ôï <xref linkend="wrappers"/> ãéá ðåñéóóüôåñåò ðëçñïöïñßåò ó÷åôéêÜ ìå ôá ðñùôüêïëëá ðïõ õðïóôçñßæïíôáé áðü ôçí &php;. </para> <note> <para> Óôçí PHP 4.0.3 êáé ðáëáéüôåñá, ãéá íá ÷ñçóéìïðïéÞóåôå ôáURL wrappers, ÷ñåéáæüôáí íá êÜíåôå configure ôç PHP ÷ñçóéìïðïéþíôáò ôçí åðéëïãÞ ôïõ configure <option>--enable-url-fopen-wrapper</option>. </para> </note> <para> <note> <para> Ïé Windows åêäüóåéò ôçò <literal>PHP</literal> ðñéí ôçí PHP 4.3 äåí õðïóôÞñéæáí ðñüóâáóç áðïìáêñõóìÝíùí áñ÷åßùí ãéá ôéò áêüëïõèåò óõíáñôÞóåéò: <function>include</function>, <function>include_once</function>, <function>require</function>, <function>require_once</function>, êáé ôéò imagecreatefromXXX óõíáñôÞóåéò óôçí <xref linkend="ref.image"/> åðÝêôáóç. </para> </note> </para> <para> Ãéá ðáñÜäåéãìá, ìðïñåßôå íá ÷ñçóéìïðïéÞóåôå ôï åîÞò ãéá íá áíïßîåôå Ýíá áñ÷åßï óå Ýíá remote web server, íá äéáâÜóåôå ôá äåäïìÝíá ðïõ èÝëåôå, êáé ìåôÜ íá ÷ñçóéìïðïéÞóåôå ôá äåäïìÝíá óå ìéá åñþôçóç âÜóçò äåäïìÝíùí, Þ áðëÜ íá êÜíåôå output óå Ýíá óôõë ðïõ ôáéñéÜæåé ôçí õðüëïéðç éóôïóåëßäá óáò. </para> <para> <example> <title>Ðáßñíïíôáò ôïí ôßôëï ìéáò áðïìáêñõóìÝíçò óåëßäáò</title> <programlisting role="php"> <![CDATA[ <?php $file = fopen ("http://www.example.com/", "r"); if (!$file) { echo "<p>Unable to open remote file.\n"; exit; } while (!feof ($file)) { $line = fgets ($file, 1024); /* This only works if the title and its tags are on one line */ if (eregi ("<title>(.*)</title>", $line, $out)) { $title = $out[1]; break; } } fclose($file); ?> ]]> </programlisting> </example> </para> <para> Ìðïñåßôå åðßóçò íá ãñÜøåôå áñ÷åßá óå Ýíá FTP server (äåäïìÝíïõ ôïõ üôé Ý÷åôå óõíäåèåß óáí Ýíáò ÷ñÞóôçò ìå ôá óùóôÜ äéêáéþìáôá ðñüóâáóçò). Ìðïñåßôå ìüíï íá äçìéïõñãÞóåôå íÝá áñ÷åßá ìå áõôÞ ôç ìÝèïäï, áí ðñïóðáèÞóåôå íá êÜíåôå overwrite Ýíá áñ÷åßï ðïõ õðÜñ÷åé Þäç, ç êëÞóç ôçò <function>fopen</function> èá áðïôý÷åé. </para> <para> Ãéá íá óõíäåèåßôå óáí Ýíáò ÷ñÞóôçò Üëëïò áðü ôïí 'anonymous', ðñÝðåé íá ïñßóåôå ôï username (êáé ðéèáíþò ôï password) ìÝóá óôï URL, êÜðùò Ýôóé: 'ftp://user:password@ftp.example.com/path/to/file'. (Ìðïñåßôå íá ÷ñçóéìïðïéÞóåôå ôçí ßäéá ìïñöÞ óýíôáîçò ãéá íá ðñïóðåëÜóåôå áñ÷åßá ìÝóù ôïõ HTTP üôáí áðáéôïýí âáóéêÞ áíáãíþñéóç.) </para> <para> <example> <title>ÁðïèÞêåõóç äåäïìÝíùí óå Ýíá áðïìáêñõóìÝíï server</title> <programlisting role="php"> <![CDATA[ <?php $file = fopen ("ftp://ftp.example.com/incoming/outputfile", "w"); if (!$file) { echo "<p>Unable to open remote file for writing.\n"; exit; } /* Write the data here. */ fputs ($file, $_SERVER['HTTP_USER_AGENT'] . "\n"); fclose ($file); ?> ]]> </programlisting> </example> </para> <para> <note> <para> Ìðïñåß íá ðÞñáôå ôçí éäÝá áðü ôï ðáñáðÜíù ðáñÜäåéãìá ðùò ìðïñåßôå íá ÷ñçóéìïðïéÞóåôå áõôÞ ôçí ôå÷íéêÞ ãéá íá ãñÜøåôå óå Ýíá áðïìáêñõóìÝíï logfile. Äõóôõ÷þò áõôü äåí èá äïõëÝøåé åðåéäÞ ç êëÞóç ôçò <function>fopen</function> èá áðïôý÷åé áí ôï áðïìáêñõóìÝíï áñ÷åßï õðÜñ÷åé Þäç. Ãéá íá êÜíåôå êáôáíåìçìÝíï logging Ýôóé, ðñÝðåé íá ñßîåôå ìéá ìáôéÜ óôçí <function>syslog</function>. </para> </note> </para> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.doc.el (#10) next »