| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 
 | <?xml version="1.0" encoding="utf-8"?>
 <chapter id="features.remote-files">
  <title>Using remote files</title>
  <para>
	여러분이 PHP를 설정할 때 "URL fopen wrapper"를 enable로 설정하였다면
	(이 설정은 PHP 4.0.3 이하에서는 configure 스크립트에서 
	<option>--disable-url-fopen-wrapper</option>로 명시하지 하거나,
	그 이후의 버전에서는 php.ini 파일에 <parameter>allow_url_fopen</parameter>을 
	off로 설정하지 않으면 설정된다.), 
	여러분은 파일이름을 파라메타로 가지는 대부분의 함수에 HTTP나 FTP URL을 
	파일이름으로 사용할 수 있다. 심지어 <function>require</function>와 
	<function>include</function>  함수에도 사용이 가능하다.
  </para>
  <para>
   <note>
    <para>
	단, Windows환경의 <function>require</function>와
	<function>include</function> 함수에서는 사용할 수 없다.
    </para>
   </note>
  </para>
  <para>
	예를 들어, 이 기능을 사용하여 원격 웹 서버가 출력하는 내용을 파일로 열고, 
	그 출력 내용에서 원하는 데이타를 분석하여, 
	이 원하는 데이타로 데이타베이스 질의에 사용하거나, 
	웹 사이트에 맞는 모양으로 변형 시켜 출력할 수 있다
  </para>
  <para>
   <example>
    <title>Getting the title of a remote page</title>
    <programlisting role="php">
<![CDATA[
<?php
$file = fopen ("http://www.php.net/", "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를 이용한 파일에 쓸 수도 있다. 
	'anonymous'가 아닌 사용자로 접속하려면, URL내에 username을 
	(필요하다면 password도) 다음과 같이 명시해야 한다 : 
	'ftp://user:password@ftp.example.com/path/to/file'. 
	(또한 HTTP에서 Basic authentication을 사용한 인증을 요구하는 경우에도 이와 같은 문법을 사용할 수 있다.) 
  </para>
  <para>
   <example>
    <title>Storing data on a remote server</title>
    <programlisting role="php">
<![CDATA[
<?php
$file = fopen ("ftp://ftp.php.net/incoming/outputfile", "w");
if (!$file) {
    echo "<p>Unable to open remote file for writing.\n";
    exit;
}
/* Write the data here. */
fputs ($file, "$HTTP_USER_AGENT\n");
fclose ($file);
?>
]]>  
    </programlisting>
   </example>
  </para>
  <para>
   <note>
    <para>
	여러분은 위의 예제를 보고, 이 테크닉을 사용하여 remote log를 작성할 수 있겠다고 생각할 수도 있다. 
	그러나 위에 언급한대로 URL fopen() wrapper는 새 파일에만 쓸 수 있다. 
	여러분이 원하는 대로 분산된 log를 하고 싶다면 <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:
-->
 |