2004-04-13 08:46:28 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
<!-- $Revision$ -->
|
2004-05-29 21:56:21 +00:00
|
|
|
<sect1 id="language.function.fetch">
|
2005-05-25 19:13:20 +00:00
|
|
|
<title>{fetch}</title>
|
2005-09-13 19:03:11 +00:00
|
|
|
<para>
|
2006-09-26 02:02:55 +00:00
|
|
|
<varname>{fetch}</varname> is used to retrieve files from the
|
|
|
|
local file system, http, or ftp and display the contents.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem><para>
|
|
|
|
If the file name begins with
|
|
|
|
<parameter>http://</parameter>, the web site page will be fetched and displayed.
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
This will not support http redirects, be sure to
|
|
|
|
include a trailing slash on your web page fetches where necessary.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</para></listitem>
|
|
|
|
|
|
|
|
<listitem><para>
|
|
|
|
If the file name begins with <parameter>ftp://</parameter>, the file will
|
|
|
|
be downloaded from the ftp server and displayed.
|
|
|
|
</para></listitem>
|
|
|
|
|
|
|
|
<listitem><para>
|
|
|
|
For local files, either a full system file path
|
|
|
|
must be given, or a path relative to the executed php script.
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
If template <link linkend="variable.security">
|
|
|
|
<parameter>$security</parameter></link>
|
|
|
|
is enabled and you are
|
|
|
|
fetching a file from the local file system, <varname>{fetch}</varname>
|
|
|
|
will only allow files from within one of the defined
|
|
|
|
<link linkend="variable.secure.dir">secure directories</link>.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</para></listitem>
|
|
|
|
|
|
|
|
<listitem><para>
|
|
|
|
If the <parameter>assign</parameter> attribute is set, the output of the
|
|
|
|
<varname>{fetch}</varname> function will be assigned to this template
|
|
|
|
variable instead of being output to the template.
|
|
|
|
</para></listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
|
2004-05-29 21:56:21 +00:00
|
|
|
<informaltable frame="all">
|
|
|
|
<tgroup cols="5">
|
|
|
|
<colspec colname="param" align="center" />
|
|
|
|
<colspec colname="type" align="center" />
|
|
|
|
<colspec colname="required" align="center" />
|
|
|
|
<colspec colname="default" align="center" />
|
|
|
|
<colspec colname="desc" />
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>Attribute Name</entry>
|
|
|
|
<entry>Type</entry>
|
|
|
|
<entry>Required</entry>
|
|
|
|
<entry>Default</entry>
|
|
|
|
<entry>Description</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry>file</entry>
|
|
|
|
<entry>string</entry>
|
|
|
|
<entry>Yes</entry>
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
2006-09-26 02:02:55 +00:00
|
|
|
<entry>The file, http or ftp site to fetch</entry>
|
2004-05-29 21:56:21 +00:00
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>assign</entry>
|
|
|
|
<entry>string</entry>
|
|
|
|
<entry>No</entry>
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
2006-09-26 02:02:55 +00:00
|
|
|
<entry>The template variable the output will be assigned
|
2004-05-29 21:56:21 +00:00
|
|
|
to</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</informaltable>
|
2005-09-13 19:03:11 +00:00
|
|
|
|
2006-09-26 02:02:55 +00:00
|
|
|
|
2004-05-29 21:56:21 +00:00
|
|
|
<example>
|
2006-03-13 22:48:14 +00:00
|
|
|
<title>{fetch} examples</title>
|
2004-05-29 21:56:21 +00:00
|
|
|
<programlisting>
|
|
|
|
<![CDATA[
|
2004-04-13 08:46:28 +00:00
|
|
|
{* include some javascript in your template *}
|
2006-03-13 22:48:14 +00:00
|
|
|
{fetch file='/export/httpd/www.example.com/docs/navbar.js'}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
|
|
{* embed some weather text in your template from another web site *}
|
2006-03-13 22:48:14 +00:00
|
|
|
{fetch file='http://www.myweather.com/68502/'}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
|
|
{* fetch a news headline file via ftp *}
|
2006-03-13 22:48:14 +00:00
|
|
|
{fetch file='ftp://user:password@ftp.example.com/path/to/currentheadlines.txt'}
|
|
|
|
{* as above but with variables *}
|
|
|
|
{fetch file="ftp://`$user`:`$password`@`$server`/`$path`"}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
|
|
{* assign the fetched contents to a template variable *}
|
2006-03-13 22:48:14 +00:00
|
|
|
{fetch file='http://www.myweather.com/68502/' assign='weather'}
|
|
|
|
{if $weather ne ''}
|
|
|
|
<div id="weather">{$weather}</div>
|
2004-05-29 21:56:21 +00:00
|
|
|
{/if}
|
2004-05-29 22:01:12 +00:00
|
|
|
]]>
|
2004-05-29 21:56:21 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
2005-05-23 15:43:01 +00:00
|
|
|
<para>
|
2005-05-24 14:01:49 +00:00
|
|
|
See also
|
2006-09-26 02:02:55 +00:00
|
|
|
<link linkend="language.function.capture"><varname>{capture}</varname></link>,
|
|
|
|
<link linkend="language.function.eval"><varname>{eval}</varname></link>,
|
|
|
|
<link linkend="language.function.assign"><varname>{assign}</varname></link>
|
2005-05-24 14:01:49 +00:00
|
|
|
and
|
2006-09-26 02:02:55 +00:00
|
|
|
<link linkend="api.fetch"><varname>fetch()</varname></link>.
|
2005-05-23 15:43:01 +00:00
|
|
|
</para>
|
2004-04-13 08:46:28 +00:00
|
|
|
</sect1>
|
|
|
|
<!-- 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
|
2004-11-21 02:04:01 +00:00
|
|
|
-->
|