<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lecciones Prácticas &#187; PHP</title>
	<atom:link href="http://www.leccionespracticas.com/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leccionespracticas.com</link>
	<description>informática y bibliotecas 2.0</description>
	<lastBuildDate>Thu, 02 Feb 2012 11:27:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Widget para wordpress: mostrar los twitts favoritos de tu cuenta twitter</title>
		<link>http://www.leccionespracticas.com/php/widget-para-wordpress-mostrar-los-twitts-favoritos-de-tu-cuenta-twitter/</link>
		<comments>http://www.leccionespracticas.com/php/widget-para-wordpress-mostrar-los-twitts-favoritos-de-tu-cuenta-twitter/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 09:46:12 +0000</pubDate>
		<dc:creator>Miguel</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[favoritos]]></category>
		<category><![CDATA[favourites]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://leccionespracticas.com/?p=1591</guid>
		<description><![CDATA[Basándome en elTwitter Widget para WordPress de Sean Spalding, he modificado ligeramente el código para que muestre únicamente los twitts favoritos de un determinado usuario. El fuente es éste: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [...]
Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/php/anadir-meta-informacion-a-wordpress/' rel='bookmark' title='Añadir meta-información a wordpress'>Añadir meta-información a wordpress</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-web/wordpress/wordpress-wp-postviews-en-espanol-resuelto/' rel='bookmark' title='WordPress WP-Postviews en español [RESUELTO]'>WordPress WP-Postviews en español [RESUELTO]</a></li>
<li><a href='http://www.leccionespracticas.com/vufind-2/vufind-mostrar-informacion-de-reservas-en-los-registros/' rel='bookmark' title='vufind: mostrar información de reservas en los registros'>vufind: mostrar información de reservas en los registros</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Basándome en el<a href="http://seanys.com/2007/10/12/twitter-wordpress-widget/">Twitter Widget</a> para WordPress de <a href="http://seanys.com/">Sean Spalding</a>, he modificado ligeramente el código para que muestre únicamente los twitts favoritos de un determinado usuario.</p>
<p>El fuente es éste:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
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
110
111
112
113
114
115
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Twitter Widget Favoritos
Plugin URI: http://leccionespracticas.com/php/widget-para-wordpress-mostrar-los-twitts-favoritos-de-tu-cuenta-twitter/
Description: Muestra favoritos de twitter de un usuario (usa Javascript &lt;a href=&quot;http://twitter.com/badges/which_badge&quot;&gt;Twitter 'badge'&lt;/a&gt;)
Version: 1.0.0
Author: Miguel Martin
Author URI: http://www.leccionespracticas.com
License: GPL
Basado en: Twitter Widget by Sean Spalding - http://seanys.com/2007/10/12/twitter-wordpress-widget/
&nbsp;
This software comes without any warranty, express or otherwise, and if it
breaks your blog or results in your cat being shaved, it's not my fault.
&nbsp;
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> widget_Twidget_Favoritos_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'register_sidebar_widget'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> widget_Twidget_Favoritos<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// &quot;$args is an array of strings that help widgets to conform to</span>
		<span style="color: #666666; font-style: italic;">// the active theme: before_widget, before_title, after_widget,</span>
		<span style="color: #666666; font-style: italic;">// and after_title are the array keys.&quot; - These are set up by the theme</span>
		<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// These are our own options</span>
		<span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_Twidget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$account</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'account'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Your Twitter account name</span>
		<span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Title in sidebar for widget</span>
		<span style="color: #000088;">$show</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// # of Updates to show</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Output</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_widget</span> <span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// start</span>
		<span style="color: #666666; font-style: italic;">//echo '&lt;div id=&quot;twitter_div&quot;&gt;'</span>
        <span style="color: #666666; font-style: italic;">//      .$before_title.$title.$after_title;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_title</span><span style="color: #339933;">.</span><span style="color: #000088;">$title</span><span style="color: #339933;">.</span><span style="color: #000088;">$after_title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;div id=&quot;twitter_div&quot;&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ul id=&quot;twitter_update_list&quot;&gt;&lt;/ul&gt;&lt;/div&gt;
		      &lt;script type=&quot;text/javascript&quot; src=&quot;http://twitter.com/javascripts/blogger.js&quot;&gt;&lt;/script&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Con esta linea buscamos TODOS los twitts de el usuario identificado por $account</span>
		<span style="color: #666666; font-style: italic;">/*echo '&lt;script type=&quot;text/javascript&quot; src=&quot;http://twitter.com/statuses/user_timeline/'.$account.'.json?callback=twitterCallback2&amp;amp;count='.$show.'&quot;&gt;&lt;/script&gt;';*/</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Con esta linea buscamos los favoritos del usuario identificado por $account</span>
		<span style="color: #666666; font-style: italic;">// http://api.twitter.com/1/favorites/bibliouz.json?callback=twitterCallback2&amp;count=5</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot; src=&quot;http://api.twitter.com/1/favorites/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$account</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.json?callback=twitterCallback2&amp;amp;count='</span><span style="color: #339933;">.</span><span style="color: #000088;">$show</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;&lt;/script&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Con esta otra linea se filtra por $account y por $hashtag</span>
		<span style="color: #666666; font-style: italic;">// http://search.twitter.com/search.json?q=%23HASHTAG+from:USERNAME</span>
		<span style="color: #666666; font-style: italic;">// similar a (parámetro rpp final es el número de tweets qse muestran</span>
		<span style="color: #666666; font-style: italic;">// http://search.twitter.com/search?q=&amp;ands=&amp;phrase=&amp;ors=&amp;nots=&amp;tag=bibliotecas&amp;lang=all&amp;from=bibliouz&amp;to=&amp;ref=&amp;near=&amp;within=15&amp;units=mi&amp;since=&amp;until=&amp;rpp=5</span>
        <span style="color: #666666; font-style: italic;">//$hashtag = '%23'.'listado';</span>
		<span style="color: #666666; font-style: italic;">/*echo '&lt;script type=&quot;text/javascript&quot; src=&quot;http://search.twitter.com/search.json?q=listado+from:bibliouz&quot;&gt;&lt;/script&gt;';*/</span>
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">// echo widget closing tag</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$after_widget</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Settings form</span>
	<span style="color: #000000; font-weight: bold;">function</span> widget_Twidget_Favoritos_control<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Get options</span>
		<span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_Twidget_Favoritos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// options exist? if not set defaults</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'account'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'seanys'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'title'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Twitter Updates'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'show'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// form posted?</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Twitter-submit'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// Remember to sanitize and format use input appropriately.</span>
			<span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'account'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Twitter-account'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Twitter-title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Twitter-show'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_Twidget_Favoritos'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Get options for form fields to show</span>
		<span style="color: #000088;">$account</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'account'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$show</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// The form fields</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p style=&quot;text-align:right;&quot;&gt;
				&lt;label for=&quot;Twitter-account&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Account:'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'
				&lt;input style=&quot;width: 200px;&quot; id=&quot;Twitter-account&quot; name=&quot;Twitter-account&quot; type=&quot;text&quot; value=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$account</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;
				&lt;/label&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p style=&quot;text-align:right;&quot;&gt;
				&lt;label for=&quot;Twitter-title&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title:'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'
				&lt;input style=&quot;width: 200px;&quot; id=&quot;Twitter-title&quot; name=&quot;Twitter-title&quot; type=&quot;text&quot; value=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;
				&lt;/label&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p style=&quot;text-align:right;&quot;&gt;
				&lt;label for=&quot;Twitter-show&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Show:'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'
				&lt;input style=&quot;width: 200px;&quot; id=&quot;Twitter-show&quot; name=&quot;Twitter-show&quot; type=&quot;text&quot; value=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$show</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;
				&lt;/label&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;hidden&quot; id=&quot;Twitter-submit&quot; name=&quot;Twitter-submit&quot; value=&quot;1&quot; /&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #666666; font-style: italic;">// Register widget for use</span>
	register_sidebar_widget<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Twitter-favoritos'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widgets'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widget_Twidget_Favoritos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Register settings for use, 300x200 pixel form</span>
	register_widget_control<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Twitter-favoritos'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widgets'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widget_Twidget_control'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">300</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Run code and init</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widgets_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widget_Twidget_Favoritos_init'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Las instrucciones de instalación son de lo más simple:</p>
<p>1. Copiar el archivo superior (twitter-widget-favoritos.php) en <em>/wp-content/plugins/widgets</em> (si no existe la carpeta, la crearemos).<br />
2. Activar el plugin en el menú <em>plugins</em> de wordpress<br />
3. Añadir el widget a la barra lateral en el menú <em>widgets</em> de wordpress y rellenar el menú con el id del usuario (por ejemplo, <em>bibliouz</em>).</p>
<p>Lo he testeado y funciona a la perfección con el tema <a href="http://newwpthemes.net/comfy/">WP Comfy</a> en <b>wordpress 3.0.4</em></p>
<p>Podéis consultar <a href="http://apiwiki.twitter.com/w/page/22554703/Twitter-REST-API-Method:-favorites">La API de favoritos de twitter</a> y la del <a href="http://dev.twitter.com/doc/get/statuses/user_timeline">statuses/user_timeline</a> o a <a href="http://search.twitter.com/api/">API de búsquedas</a> para más detalles.</p>
<p>Si queréis saber más sobre la creación de widgets para wordpress podéis hacerlo <a href="http://www.entrecodigos.com/2009/01/como-crear-un-widget-de-wordpress.html">en este sencillo manual</a></p>
<p>Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/php/anadir-meta-informacion-a-wordpress/' rel='bookmark' title='Añadir meta-información a wordpress'>Añadir meta-información a wordpress</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-web/wordpress/wordpress-wp-postviews-en-espanol-resuelto/' rel='bookmark' title='WordPress WP-Postviews en español [RESUELTO]'>WordPress WP-Postviews en español [RESUELTO]</a></li>
<li><a href='http://www.leccionespracticas.com/vufind-2/vufind-mostrar-informacion-de-reservas-en-los-registros/' rel='bookmark' title='vufind: mostrar información de reservas en los registros'>vufind: mostrar información de reservas en los registros</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leccionespracticas.com/php/widget-para-wordpress-mostrar-los-twitts-favoritos-de-tu-cuenta-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saber la URL actual desde php (o &#8220;dónde estás&#8221;) [resuelto] + consejillos SEO</title>
		<link>http://www.leccionespracticas.com/php/saber-la-url-actual-desde-php-o-donde-estas-resuelto-consejillos-seo/</link>
		<comments>http://www.leccionespracticas.com/php/saber-la-url-actual-desde-php-o-donde-estas-resuelto-consejillos-seo/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 19:58:05 +0000</pubDate>
		<dc:creator>Miguel</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.leccionespracticas.com/?p=1487</guid>
		<description><![CDATA[¿Cómo saber la URL en la que &#8220;estás&#8221; con PHP? Echa un vistazo a este código (pruébalo en tu server): $host = $_SERVER&#91;'HTTP_HOST'&#93;; $self = $_SERVER&#91;'PHP_SELF'&#93;; $query = !empty&#40;$_SERVER&#91;'QUERY_STRING'&#93;&#41; ? $_SERVER&#91;'QUERY_STRING'&#93; : null; $url = !empty&#40;$query&#41; ? &#34;http://$host$self?$query&#34; : &#34;http://$host$self&#34;; echo $url; ¿Para qué quiero saber la URL en la que estoy? Motivos de SEO [...]
Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/informatica-web/php-check-if-url-exists-or-file-via-url/' rel='bookmark' title='PHP: check if url exists (or file via url)'>PHP: check if url exists (or file via url)</a></li>
<li><a href='http://www.leccionespracticas.com/php/montar-unidad-remota-con-samba-en-redhat5-desde-programa-php/' rel='bookmark' title='Montar unidad remota con SAMBA en linux RedHat5 (desde PHP)'>Montar unidad remota con SAMBA en linux RedHat5 (desde PHP)</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-web/anadir-boton-de-facebook-dinamico-para-la-pagina-actual-solucionado/' rel='bookmark' title='Añadir botón de facebook dinámico (para la página actual) [SOLUCIONADO]'>Añadir botón de facebook dinámico (para la página actual) [SOLUCIONADO]</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>¿Cómo saber la URL en la que &#8220;estás&#8221; con PHP?</p>
<p>Echa un vistazo a este código (pruébalo en tu server):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$host</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$self</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'QUERY_STRING'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'QUERY_STRING'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$host</span><span style="color: #006699; font-weight: bold;">$self</span>?<span style="color: #006699; font-weight: bold;">$query</span>&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$host</span><span style="color: #006699; font-weight: bold;">$self</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span></pre></div></div>

<h3>¿Para qué quiero saber la URL en la que estoy?</h3>
<p>Motivos de <a href="http://www.leccionespracticas.com/informatica-utilidades-internet/posicionamiento-en-google-ii/">SEO</a><br />
Imagina que diseñas una web y la cabecera (la llamaré <em>header.php</em>) es común a todas tus páginas. </p>
<p>Algo asi:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span> esto es <span style="color: #990000;">header</span><span style="color: #339933;">.</span>php <span style="color: #339933;">--&gt;</span>
<span style="color: #339933;">&lt;!</span>DOCTYPE html <span style="color: #000000; font-weight: bold;">PUBLIC</span> <span style="color: #0000ff;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span style="color: #0000ff;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html xmlns<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.w3.org/1999/xhtml&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>meta http<span style="color: #339933;">-</span>equiv<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Content-Type&quot;</span> content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>miguel martin <span style="color: #339933;">|</span> fotografía de moda y retrato en Zaragoza<span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;css/styles.css&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;!--</span> Muestro imágenes<span style="color: #339933;">,</span> cabecera o lo que sea <span style="color: #339933;">--&gt;</span></pre></div></div>

<p>Después, desde cada página de tu web (las llamaré <em>index1.php</em>&#8230;<em>indexN.php</em>) haces un</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;!-- esto es indexI.php --&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'header.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># o un include('header.php');
</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>De forma que, escribiendo el código de header.php una única vez, éste se &#8220;empotre&#8221; en todas tus páginas. Hasta aqui, perfecto. Pero como algunos sabréis, google penaliza aquéllos sitios que considera con información duplicada&#8230;y la duplicidad de títulos.</p>
<p>¿Cómo puedo entonces saber dónde estoy <u>desde el fichero <em>header.php</em></u> para que la información del título cambie en cada página?</p>
<p>Pues con algo asi&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;!-- esto es header.php --&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/* ¿Dónde demonios estoy? $_SERVER['PHP_SELF']; me dice la parte que me interesa... */</span>
<span style="color: #000088;">$self</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$self</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;beauty&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// si la cadena &quot;self&quot; contiene la palabra &quot;beauty&quot; entonces quiero que mi título sea...</span>
 <span style="color: #000088;">$self</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Beauty portfolio |&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// y bla, bla, bla</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$self</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;fashion&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$self</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Fashion portfolio |&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$self</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;sports&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$self</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Sports portfolio |&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$self</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;beauty&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$self</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Glamour portfolio |&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$self</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;contact&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$self</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Contacto |&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$self</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;about&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$self</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;About |&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$self</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;title&gt;miguel martin | <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$self</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> fotografía de moda y retrato en Zaragoza&lt;/title&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/styles.css&quot; /&gt;</pre></div></div>

<p>Creo que no hacen falta explicaciones adicionales. ¿No?</p>
<p>Ah! Hace algún tiempo escribí un artículo similar a este pero <a href="http://www.leccionespracticas.com/php/joomla-templating-know-where-you-are-full-article-view-or-article-listing-solved/">para joomla</a>, por si os es de utilidad.</p>
<p>Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/informatica-web/php-check-if-url-exists-or-file-via-url/' rel='bookmark' title='PHP: check if url exists (or file via url)'>PHP: check if url exists (or file via url)</a></li>
<li><a href='http://www.leccionespracticas.com/php/montar-unidad-remota-con-samba-en-redhat5-desde-programa-php/' rel='bookmark' title='Montar unidad remota con SAMBA en linux RedHat5 (desde PHP)'>Montar unidad remota con SAMBA en linux RedHat5 (desde PHP)</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-web/anadir-boton-de-facebook-dinamico-para-la-pagina-actual-solucionado/' rel='bookmark' title='Añadir botón de facebook dinámico (para la página actual) [SOLUCIONADO]'>Añadir botón de facebook dinámico (para la página actual) [SOLUCIONADO]</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leccionespracticas.com/php/saber-la-url-actual-desde-php-o-donde-estas-resuelto-consejillos-seo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joomla templating &#8211; know where you are (full article view or article-listing) [SOLVED]</title>
		<link>http://www.leccionespracticas.com/php/joomla-templating-know-where-you-are-full-article-view-or-article-listing-solved/</link>
		<comments>http://www.leccionespracticas.com/php/joomla-templating-know-where-you-are-full-article-view-or-article-listing-solved/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 19:41:35 +0000</pubDate>
		<dc:creator>Miguel</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[com_content]]></category>
		<category><![CDATA[full article]]></category>
		<category><![CDATA[getCmd]]></category>
		<category><![CDATA[getVar]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[templating]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://www.leccionespracticas.com/?p=1197</guid>
		<description><![CDATA[Some time ago I talked about how to know if you are in the frontpage or not But you might want to know (for instance, for plugin displaying) if you are viewing a full article or just a listing of articles (with just a preview of the articles&#8217; content). How do you do this? You [...]
Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/informatica-web/joomla-informatica-web/joomla-know-the-section/' rel='bookmark' title='Joomla: know the section of an article [SOLVED]'>Joomla: know the section of an article [SOLVED]</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-web/joomla-plugin-and-templating-how-to-know-if-you-are-in-the-frontpage/' rel='bookmark' title='Joomla plugin and templating: how to know if you are in the frontpage'>Joomla plugin and templating: how to know if you are in the frontpage</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-web/joomla-informatica-web/addthis-plugin-for-joomla-1-5/' rel='bookmark' title='AddThis plugin for joomla 1.5'>AddThis plugin for joomla 1.5</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Some time ago I talked about <a href="http://www.leccionespracticas.com/informatica-web/joomla-plugin-and-templating-how-to-know-if-you-are-in-the-frontpage/">how to know if you are in the frontpage or not</a></p>
<p>But you might want to know (for instance, for plugin displaying) if you are viewing a full article or just a listing of articles (with just a preview of the articles&#8217; content).</p>
<p>How do you do this? You must use the <code>JRequest::getVar</code> function as in:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">if (JRequest::getVar('view')=='article'){
    // then you are displaying a full article
    // do whatever you want in full article visualization...
}
else{
  // stuff to be displayed in the rest of the pages...
}</pre></div></div>

<p>You could also use <code>JRequest::getvar('option', '')</code> or <code>JRequest::getCmd( 'option' )</code>to know if you are, for instance, in <code>com_content</code> or in any other module as in:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">   &lt;?php if((JRequest::getCmd( 'view' ) == 'article') or (JRequest::getCmd( 'option' ) == 'com_twc4j')) :?&gt;</pre></div></div>

<p>With this lines you could hack some plugins (like, for example, <a href="http://www.leccionespracticas.com/informatica-utilidades-internet/addthis-plugin-for-joomla-1-5/">addthis plugin for joomla</a>) to display just as you want. Take a look at this self-explained code:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">function getButtonCode(&amp;$params) {
	if($_REQUEST['view']==&quot;frontpage&quot;) return ''; //we are in the frontpage, so return an empty string
	if (JRequest::getVar('view')!='article') return ''; //we are not showing an article, so return an empty string
&nbsp;
        // Here we know that we are displaying an article... so I want to show addthis code.
        $code = $this-&gt;params-&gt;get('code');
        if( empty($code) )
            $code = '&lt;br/&gt;&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; onmouseover=&quot;return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')&quot; onmouseout=&quot;addthis_close()&quot; onclick=&quot;return addthis_sendto()&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/lg-share-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a3f0b283a364b52&quot;&gt;&lt;/script&gt;&lt;br/&gt;';
        return $code;
}</pre></div></div>

<p>Thanks a lot to <em>shockM</em> user of joomlaspanish.org forums for the explanation! (Read full post in spanish <a href="http://www.joomlaspanish.org/foros/showthread.php?t=44004">here</a>).</p>
<p>Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/informatica-web/joomla-informatica-web/joomla-know-the-section/' rel='bookmark' title='Joomla: know the section of an article [SOLVED]'>Joomla: know the section of an article [SOLVED]</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-web/joomla-plugin-and-templating-how-to-know-if-you-are-in-the-frontpage/' rel='bookmark' title='Joomla plugin and templating: how to know if you are in the frontpage'>Joomla plugin and templating: how to know if you are in the frontpage</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-web/joomla-informatica-web/addthis-plugin-for-joomla-1-5/' rel='bookmark' title='AddThis plugin for joomla 1.5'>AddThis plugin for joomla 1.5</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leccionespracticas.com/php/joomla-templating-know-where-you-are-full-article-view-or-article-listing-solved/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Montar unidad remota con SAMBA en linux RedHat5 (desde PHP)</title>
		<link>http://www.leccionespracticas.com/php/montar-unidad-remota-con-samba-en-redhat5-desde-programa-php/</link>
		<comments>http://www.leccionespracticas.com/php/montar-unidad-remota-con-samba-en-redhat5-desde-programa-php/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 12:04:17 +0000</pubDate>
		<dc:creator>Miguel</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cd]]></category>
		<category><![CDATA[cifs]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[montar]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[requiretty]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[selinux]]></category>
		<category><![CDATA[sudoers]]></category>
		<category><![CDATA[umount]]></category>

		<guid isPermaLink="false">http://www.leccionespracticas.com/?p=564</guid>
		<description><![CDATA[Estos días pasados he estado peleándome con lo siguiente: necesitaba que un programa en PHP (ejecutado en máquina llamada RH5, que corre sobre un Red Hat 5) fuera capaz de montar una unidad de cd/dvd remota (más en concreto, de un equipo local Windows XP SP3). Os comento, un poco por encima, los pasos a [...]
Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/informatica-sistemas-y-servidores/linux-sustitucion-de-texto-en-multiples-ficheros-usando-sed-resuelto/' rel='bookmark' title='Linux: Sustitución de texto en múltiples ficheros usando SED [resuelto]'>Linux: Sustitución de texto en múltiples ficheros usando SED [resuelto]</a></li>
<li><a href='http://www.leccionespracticas.com/uncategorized/vnc-desde-samsung-omnia/' rel='bookmark' title='VNC desde Samsung Omnia'>VNC desde Samsung Omnia</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-sistemas-y-servidores/accediendo-a-maquinas-remotas-putty-y-nx-server/' rel='bookmark' title='Accediendo a máquinas remotas: PuTTY y NX-Server'>Accediendo a máquinas remotas: PuTTY y NX-Server</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Estos días pasados he estado peleándome con lo siguiente: necesitaba que un programa en <b>PHP</b> (ejecutado en máquina llamada RH5, que corre sobre un Red Hat 5) fuera capaz de <b>montar una unidad de cd/dvd remota</b> (más en concreto, de un equipo local Windows XP SP3).</p>
<p>Os comento, un poco por encima, los pasos a seguir para conseguir esto:</p>
<ol>
<li><b>Compartir la unidad del equipo windows</b> con nombre de usuario apache (para ello el usuario apache debe existir en el sistema W&#8217;s y en este ejemplo, tendrá contraseña=<code>apache</code>). Supongamos que la máquina Windows tiene ip=IPW y el nombre del recurso compartido es <code>E</code>. </li>
<p></p>
<li>Verificar que tenemos el cliente <b>samba</b> instalado en la máquina RedHat5. Para ello podemos comprobar, una vez realizado el paso (1), que desde línea de comandos podemos montar la unidad remota, en, por ejemplo <code>/mnt/miunidadremota</code> (evidentemente, este directorio debe existir en nuestra máquina RH5). Ejecutamos:
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-t</span> cifs <span style="color: #000000; font-weight: bold;">//</span>IPW<span style="color: #000000; font-weight: bold;">/</span>E <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>miunidadremota <span style="color: #660033;">-o</span> <span style="color: #007800;">user</span>=apache,<span style="color: #007800;">pass</span>=apache,<span style="color: #007800;">uid</span>=apache,<span style="color: #007800;">gid</span>=apache
<span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>miunidadremota</pre></div></div>

<p></code></p>
<p>Una vez ejecutados los dos comandos de arriba deberíamos ver los ficheros del cd. Si no lo vemos, hay algo mal en los puntos (1) y (2). Revísalos.</li>
<li>Habilitar en <code>/etc/sudoers</code> que el usuario <code>apache</code> pueda montar y desmontar la unidad remota <code>E</code> (Si no sabes qué es <code>sudoers</code> o <code>mount</code> o para qué se utiliza, googlea <i>man sudo</i> y <i>man moun</i>).
<p>Evidentemente, el usuario <code>apache</code> debe existir en el sistema RH5. Para comprobar que existe, ejecuta:<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">more</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> apache</pre></div></div>

<p></code></p>
<p>Y deberías ver algo asi:<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">apache:x:<span style="color: #000000;">48</span>:<span style="color: #000000;">48</span>:Apache:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www:<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span></pre></div></div>

<p></code><br />
Nota que el usuario apache tiene <b>shell</b>! (<code>/bin/bash</code>, para más señas).</p>
<p>Continuamos editando <code>/etc/sudoers</code>. Lo puedes hacer con el comando <code>visudo</code>, o directamente editando <code>/etc/sudoers</code> (este último método no lo recomiendo). Una vez editado, añade al final las siguientes líneas:<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">apache ALL = NOPASSWD: <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">mount</span>
apache ALL = NOPASSWD: <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">umount</span>
apache ALL = <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>mount.cifs
apache ALL = <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>umount.cifs</pre></div></div>

<p></code>
</li>
<li>A continuación, comprueba si tienes activado <b>SELinux</b>. En mi caso está desactivado. Si sigues todos los pasos restantes y al final no te funciona, chequea <code>/var/messages</code> para ver qué está pasando&#8230;y seguramente encontrarás que SELinux te está impidiendo realizar el montado de la unidad remota&#8230;</li>
<p></p>
<li>Haz un <code>more /etc/sudores | grep requiretty</code><br />
comprueba que esa línea <b>está comentada</b>, esto es:<br />
<code>#Defaults    requiretty</code>.<br />
Si la tienes descomentada <b>no funcionará</b>.</li>
<p></p>
<li>Crea tu programa en PHP para montar la unidad remota! <img src='http://www.leccionespracticas.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
En mi caso es algo asi (las líneas 8 y 10 son las que importan):<br />
<code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;functions.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;config.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Librerias cargadas...&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ipCD</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// es un rec externo... montarlo!</span>
&nbsp;
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Montando unidad remota...&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$mountlike</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'sudo /bin/mount -t cifs //'</span><span style="color: #339933;">.</span><span style="color: #000088;">$ipCD</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$unidadCD</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000088;">$rutaEntrada</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' -o user='</span><span style="color: #339933;">.</span><span style="color: #000088;">$userCD</span><span style="color: #339933;">.</span><span style="color: #0000ff;">',pass='</span><span style="color: #339933;">.</span><span style="color: #000088;">$passCD</span><span style="color: #339933;">.</span><span style="color: #0000ff;">',uid=apache,gid=apache'</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$mountlike</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mountlike</span><span style="color: #339933;">,</span> <span style="color: #000088;">$out</span><span style="color: #339933;">,</span> <span style="color: #000088;">$retval</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p></code></li>
<p>Esto es todo amigos!<br />
Si consideras que se puede hacer mejor, o ves algún fallo que yo no veo&#8230; (dejemos la seguridad al margen <img src='http://www.leccionespracticas.com/wp-includes/images/smilies/icon_cool.gif' alt='8-)' class='wp-smiley' /> ), deja un comentario.</p>
<p>Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/informatica-sistemas-y-servidores/linux-sustitucion-de-texto-en-multiples-ficheros-usando-sed-resuelto/' rel='bookmark' title='Linux: Sustitución de texto en múltiples ficheros usando SED [resuelto]'>Linux: Sustitución de texto en múltiples ficheros usando SED [resuelto]</a></li>
<li><a href='http://www.leccionespracticas.com/uncategorized/vnc-desde-samsung-omnia/' rel='bookmark' title='VNC desde Samsung Omnia'>VNC desde Samsung Omnia</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-sistemas-y-servidores/accediendo-a-maquinas-remotas-putty-y-nx-server/' rel='bookmark' title='Accediendo a máquinas remotas: PuTTY y NX-Server'>Accediendo a máquinas remotas: PuTTY y NX-Server</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leccionespracticas.com/php/montar-unidad-remota-con-samba-en-redhat5-desde-programa-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Añadir meta-información a wordpress</title>
		<link>http://www.leccionespracticas.com/php/anadir-meta-informacion-a-wordpress/</link>
		<comments>http://www.leccionespracticas.com/php/anadir-meta-informacion-a-wordpress/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 06:31:16 +0000</pubDate>
		<dc:creator>Miguel</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[meta-information]]></category>
		<category><![CDATA[posicionamiento]]></category>
		<category><![CDATA[SEF]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.leccionespracticas.com/?p=548</guid>
		<description><![CDATA[Cuando un motor de búsqueda indexa tu sitio web recopila información del título, cabecera, contenido y meta-etiquetas (como descripción y palabras clave). Gracias a esta información tu página será mostrada en una determinada posición de los resultados de búsqueda ofrecidos por un motor. A esta posición se la conoce como ranking. WordPress, en su instalación [...]
Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/uncategorized/seo-las-mejores-herramientas-gratis/' rel='bookmark' title='SEO: las mejores herramientas gratis'>SEO: las mejores herramientas gratis</a></li>
<li><a href='http://www.leccionespracticas.com/uncategorized/posicionamiento-en-google-ii/' rel='bookmark' title='Posicionamiento en Google (II)'>Posicionamiento en Google (II)</a></li>
<li><a href='http://www.leccionespracticas.com/cds-invenio/cds-invenio-add-meta-information-tag-keywords-description/' rel='bookmark' title='CDS Invenio: add meta information (tag keywords / description)'>CDS Invenio: add meta information (tag keywords / description)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Cuando un motor de búsqueda <strong>indexa</strong> tu sitio web recopila información del título, cabecera, contenido y <strong>meta-etiquetas</strong> (como descripción y palabras clave). Gracias a esta información tu página será mostrada en una determinada posición de los resultados de búsqueda ofrecidos por un motor. A esta posición se la conoce como <em>ranking</em>.</p>
<p><strong>WordPress</strong>, en su instalación por defecto, no incluye meta información, por lo que nos veremos obligados a añadir esta información manualmente, cambiando el código fuente del <em>theme</em> que tengamos instalado. También podemos añadir esta meta información instalando plugins específicos.</p>
<h3>¿Qué son los <em>meta-tags</em>?</h3>
<p>La palabra meta significa <em>información acerca de</em>. Las meta-etiquetas se concibieron inicialmente para proporcionar información detallada acerca de un sitio web. La información en meta-etiquetas incluye el autor de la página web, las palabras clave, la descripción del sitio web, el tipo de documento, copyright, etc</p>
<p>Un ejemplo de meta-información de descripción es:</p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">Algunas de las meta-etiquetas más comunes son:</pre></div></div>

<p></code></p>
<p>Y algunas de las etiquetas de meta información más comunes son:<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;meta http-equiv=&quot;author&quot; content=&quot;Miguel Martin&quot; /&gt;
&lt;meta http-equiv=&quot;contact&quot; content=&quot;admin@leccionespracticas.com&quot; /&gt;
&lt;meta name=&quot;copyright&quot; content=&quot;Copyright (c)2009-2013 Miguel Martin. All Rights Reserved.&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;lecciones practicas - aprende informatica&quot; /&gt;
&lt;meta name=&quot;keywords&quot; content=&quot;lecciones practicas, leccionespracticas, cds invenio, repositorios, seo, sef, posicionamiento, google, wordpress, joomla, php, python, preservacion&quot; /&gt;</pre></div></div>

<p></code></p>
<p>El significado de cada una de estas etiquetas es fácilmente deducible, por lo que no me extenderé en este punto <img src='http://www.leccionespracticas.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>¿Son los meta-tags necesarios todavía?</h3>
<p>Es una buena pregunta. Hace algunos años rellenar de forma correcta esta información era fundamental. A día de hoy algunos <strong>motores de búsqueda</strong> no utilizan esta información debido a que, históricamente, se ha abusado en la utilización de esta información a cargo de algunos <strong>webmasters</strong>. De hecho, las meta-etiquetas pueden NO reflejar el contenido de tu sitio web&#8230;</p>
<p>De todos modos, sigue siendo una buena práctica utilizar estos pequeños fragmentos de información, siempre que sean utilizados de forma correcta, para completar información de tu sitio web. Algunos motores de búsqueda utilizan la meta-etiqueta <strong>keywords</strong> (palabras clave) para categorizar y asignar ranking a tu sitio web. Estos motores comparan tus palabras clave con el contenido de tu página y <em>premian</em> a aquéllos sitios en los que las palabras clave coinciden con el tipo de contenido mostrado. Por tanto, <strong>sí es importante añadir, al menos, la etiqueta de <em>meta-keywords</em>. </strong></p>
<p>Aunque no te engañes, a día de hoy el<strong> elemento diferenciador de cara al posicionamiento es el <strong>contenido</strong> de tu sitio</strong>, es decir, la información en sí misma.</p>
<h3><strong>¿Cómo añado <em>meta-tags</em> a mi blog en WordPress</strong></h3>
<p>Para añadir meta información a tu sitio web, simplemente edita el archivo <code>header.php</code> del <em>theme</em> que estés utilizando.</p>
<p>A modo de ejemplo puedes ver parte de mi archivo <code>header.php</code><br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> language_attributes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;
&lt;head profile=&quot;http://gmpg.org/xfn/11&quot;&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'html_type'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>; charset=<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'charset'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=EmulateIE7&quot; /&gt;
&lt;title&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_home <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> single_cat_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' - '</span> <span style="color: #339933;">;</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span>is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> single_post_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">': '</span><span style="color: #339933;">;</span> single_post_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> wp_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/title&gt;
&nbsp;
&lt;meta http-equiv=&quot;author&quot; content=&quot;Miguel Martin&quot; /&gt;
&lt;meta http-equiv=&quot;contact&quot; content=&quot;admin@leccionespracticas.com&quot; /&gt;
&lt;meta name=&quot;copyright&quot; content=&quot;Copyright (c)2009-2013 Miguel Martin. All Rights Reserved.&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;lecciones practicas - aprende informatica&quot; /&gt;
&lt;meta name=&quot;keywords&quot; content=&quot;lecciones practicas, leccionespracticas, cds invenio, repositorios, seo, sef, posicionamiento, google, wordpress, joomla, php, python, preservacion&quot; /&gt;
&nbsp;
&nbsp;
&lt;script type=&quot;text/javascript&quot; src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/script.js&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stylesheet_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;</pre></div></div>

<p></code></p>
<p>A estas alturas te estarás preguntando ¿y la meta-información<strong> <strong>dinámica</strong></strong>? Con las líneas que hemos añadido anteriormente, ésta información se mostrará en todas las páginas de tu sitio web. Al colocalas en <code>header.php</code> la información no cambiará, será estática.</p>
<p>De cara a añadir información dinámica, una solución simple pasa por utilizar editar <code>header.php</code> y añadir las siguientes líneas:<strong></strong><br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;meta name=&quot;description&quot; content=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        single_post_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; - &quot;</span><span style="color: #339933;">;</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;</pre></div></div>

<p></code></p>
<p>Estas líneas hacen que, si estamos ante un único post se muestre el título del mismo, mientras que si estamos ante un conjunto de posts, se muestre el nombre del blog y su descripción.</p>
<p>Otra solución es utilizar alguno de los<strong> <a href="http://wordpress.org/extend/plugins/">múltiples plugins de WordPress</a>. </strong></p>
<p>Por ejemplo, puedes usar<strong> <a href="http://wordpress.org/extend/plugins/headspace2/">head space 2</a>, </strong>un<strong> plugin </strong>que sugiere<strong> </strong> qué meta-keywords añadir a cada post, qué descripción darle, etc.</p>
<p>¿Te interesa el tema? Puede seguir informándote en los siguientes links:<br />
[1] <a href="http://www.w3.org/TR/REC-html40/struct/global.html#h-7.4.4">W3 Organization&#8217;s Global Structure of an HTML Document and Meta Tags</a><br />
[2] <a href="http://www.askapache.com/seo/wordpress-robotstxt-optimized-for-seo.html">header.php code y tutoriales: robots, googlebot, and msnbot. metadatos en páginas, post simples, página principal&#8230; </a><br />
[3] <a href="http://www.lib.berkeley.edu/TeachingLib/Guides/Internet/SearchEngines.html">UC Berkeley&#8217;s Guide to Search Engines</a><br />
[4] <a href="http://www.searchenginewatch.com/webmasters/meta.html">SearchengineWatch.com: how to use metadata</a><br />
[5]<a href="http://www.webdeveloper.com/html/html_metatags.html">webdeveloper&#8217;s metatag information</a></p>
<p>Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/uncategorized/seo-las-mejores-herramientas-gratis/' rel='bookmark' title='SEO: las mejores herramientas gratis'>SEO: las mejores herramientas gratis</a></li>
<li><a href='http://www.leccionespracticas.com/uncategorized/posicionamiento-en-google-ii/' rel='bookmark' title='Posicionamiento en Google (II)'>Posicionamiento en Google (II)</a></li>
<li><a href='http://www.leccionespracticas.com/cds-invenio/cds-invenio-add-meta-information-tag-keywords-description/' rel='bookmark' title='CDS Invenio: add meta information (tag keywords / description)'>CDS Invenio: add meta information (tag keywords / description)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leccionespracticas.com/php/anadir-meta-informacion-a-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parse XML file into array (PHP)</title>
		<link>http://www.leccionespracticas.com/informatica-web/parse-xml-file-into-array-php/</link>
		<comments>http://www.leccionespracticas.com/informatica-web/parse-xml-file-into-array-php/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 06:11:34 +0000</pubDate>
		<dc:creator>miguel</dc:creator>
				<category><![CDATA[Informática - web]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[parse xml]]></category>
		<category><![CDATA[xml to mysql]]></category>
		<category><![CDATA[xsd]]></category>

		<guid isPermaLink="false">http://miguelmartin.x10hosting.com/blog/?p=483</guid>
		<description><![CDATA[Nowadays XML-based information storing is increasing its use, so usually you&#8217;ll have to parse these files. If you want a PHP function that resolves these needs, take a look at this: &#38;lt;?php /** * xml2array() will convert the given XML text to an array in the XML structure. * Link: http://www.bin-co.com/php/scripts/xml2array/ * Arguments : $contents [...]
Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/informatica-web/smarty-templates-print_r-an-array-solved/' rel='bookmark' title='Smarty templates: print_r an array [SOLVED]'>Smarty templates: print_r an array [SOLVED]</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-web/php-check-if-url-exists-or-file-via-url/' rel='bookmark' title='PHP: check if url exists (or file via url)'>PHP: check if url exists (or file via url)</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-sistemas-y-servidores/solved-apache-error-client-xxx-file-does-not-exist/' rel='bookmark' title='[SOLVED] Apache: &#8216;[error] [client ::XXX] File does not exist:&#8217;'>[SOLVED] Apache: &#8216;[error] [client ::XXX] File does not exist:&#8217;</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Nowadays XML-based information storing is increasing its use, so usually you&#8217;ll have to parse these files. If you want a PHP function that resolves these needs, take a look at this:<br />
<font size="2pt"><br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>?php
<span style="color: #009933; font-style: italic;">/**
 * xml2array() will convert the given XML text to an array in the XML structure.
 * Link: http://www.bin-co.com/php/scripts/xml2array/
 * Arguments : $contents - The XML text
 *                $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag values - this results in a different array structure in the return value.
 *                $priority - Can be 'tag' or 'attribute'. This will change the way the resulting array sturcture. For 'tag', the tags are given more importance.
 * Return: The parsed XML in an array form. Use print_r() to see the resulting array structure.
 * Examples: $array =  xml2array(file_get_contents('feed.xml'));
 *              $array =  xml2array(file_get_contents('feed.xml', 1, 'attribute'));
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> xml2array<span style="color: #009900;">&#40;</span><span style="color: #000088;">$contents</span><span style="color: #339933;">,</span> <span style="color: #000088;">$get_attributes</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$priority</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'tag'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$contents</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'xml_parser_create'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//print &quot;'xml_parser_create()' function not found!&quot;;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Get the XML parser of PHP - PHP must have this module for the parser to work</span>
    <span style="color: #000088;">$parser</span> <span style="color: #339933;">=</span> <span style="color: #990000;">xml_parser_create</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">xml_parser_set_option</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">,</span> XML_OPTION_TARGET_ENCODING<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
</span>    <span style="color: #990000;">xml_parser_set_option</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">,</span> XML_OPTION_CASE_FOLDING<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">xml_parser_set_option</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">,</span> XML_OPTION_SKIP_WHITE<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">xml_parse_into_struct</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">,</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$contents</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$xml_values</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">xml_parser_free</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$xml_values</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//Hmm...</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Initializations</span>
    <span style="color: #000088;">$xml_array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$parents</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$opened_tags</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$arr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$current</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$xml_array</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Refference</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//Go through the tags.</span>
    <span style="color: #000088;">$repeated_tag_index</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//Multiple tags with same name will be turned into an array</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml_values</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes</span><span style="color: #339933;">,</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//Remove existing values, or there will be trouble</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//This command will extract these variables into the foreach scope</span>
        <span style="color: #666666; font-style: italic;">// tag(string), type(string), level(int), attributes(array).</span>
        <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//We could use the array by itself, but this cooler.</span>
&nbsp;
        <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$attributes_data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$priority</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'tag'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">else</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Put the value in a assoc array if we are in the 'Attribute' mode</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//Set the attributes too.</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes</span><span style="color: #009900;">&#41;</span> and <span style="color: #000088;">$get_attributes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$attr</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$priority</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'tag'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributes_data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attr</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">else</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attr'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attr</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Set all the attributes in a array called 'attr'</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//See tag status and do the needed.</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;open&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//The starting of the tag '&amp;lt;tag&gt;'</span>
            <span style="color: #000088;">$parent</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$level</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$current</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#41;</span> or <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">,</span> <span style="color: #990000;">array_keys</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//Insert New tag</span>
                <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes_data</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'_attr'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attributes_data</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #000088;">$current</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//There was another element with the same tag name</span>
&nbsp;
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//If there is a 0th element it is already an array</span>
                    <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//This section will make the value an array if multiple tags with the same name appear together</span>
                    <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//This will combine the existing item and the new item together to make an array</span>
                    <span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
&nbsp;
                    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_attr'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//The attribute of the last(0th) tag must be moved as well</span>
                        <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'0_attr'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_attr'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                        <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_attr'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000088;">$last_item_index</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$current</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$last_item_index</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;complete&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//Tags that ends in 1 line '&amp;lt;tag /&gt;'</span>
            <span style="color: #666666; font-style: italic;">//See if the key is already taken.</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//New Key</span>
                <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$priority</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'tag'</span> and <span style="color: #000088;">$attributes_data</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'_attr'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attributes_data</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//If taken, put all things inside a list(array)</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> and <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//If it is already an array...</span>
&nbsp;
                    <span style="color: #666666; font-style: italic;">// ...push the new element into that array.</span>
                    <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
&nbsp;
                    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$priority</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'tag'</span> and <span style="color: #000088;">$get_attributes</span> and <span style="color: #000088;">$attributes_data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_attr'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attributes_data</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span>
&nbsp;
                <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//If it is not an array...</span>
                    <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//...Make it an array using using the existing value and the new value</span>
                    <span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$priority</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'tag'</span> and <span style="color: #000088;">$get_attributes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_attr'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//The attribute of the last(0th) tag must be moved as well</span>
&nbsp;
                            <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'0_attr'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_attr'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                            <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_attr'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
&nbsp;
                        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes_data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #000088;">$current</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_attr'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attributes_data</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #000088;">$repeated_tag_index</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span> <span style="color: #666666; font-style: italic;">//0 and 1 index is already taken</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'close'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//End of tag '&amp;lt;/tag&gt;'</span>
            <span style="color: #000088;">$current</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$parent</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$level</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml_array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>code<span style="color: #339933;">&gt;</span></pre></div></div>

<p></font></p>
<p>An example of how to use it:</p>
<p>Suppose you have an XML file like:<br />
<font size="2pt"><br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Objeto3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>003<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;referenceNumber<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/referenceNumber<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;groupIdentifier<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/groupIdentifier<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;persistentIdentifier<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/persistentIdentifier<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;masterCreationDate</span> <span style="color: #000066;">locale</span>=<span style="color: #ff0000;">&quot;CEST&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;date</span> <span style="color: #000066;">format</span>=<span style="color: #ff0000;">&quot;yyyyMMdd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>20090612<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/date<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;time</span> <span style="color: #000066;">format</span>=<span style="color: #ff0000;">&quot;HHmmssSSS&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>103530703<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/time<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/masterCreationDate<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;objectComposition<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>simple<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/objectComposition<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;structuralType<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;extension<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/extension<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/structuralType<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;hardwareEnvironment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>x86<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hardwareEnvironment<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;softwareEnvironment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>OS: Windows XP 5.1, JVM:Sun Microsystems Inc. 1.6.0_13<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/softwareEnvironment<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;installationRequirements<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/installationRequirements<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;accessInhibitors<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/accessInhibitors<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;accessFacilitators<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/accessFacilitators<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;quirks<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/quirks<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;metadataRecordCreator<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/metadataRecordCreator<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;metadataCreationDate</span> <span style="color: #000066;">locale</span>=<span style="color: #ff0000;">&quot;CEST&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;date</span> <span style="color: #000066;">format</span>=<span style="color: #ff0000;">&quot;yyyyMMdd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>20090612<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/date<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;time</span> <span style="color: #000066;">format</span>=<span style="color: #ff0000;">&quot;HHmmssSSS&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>103530734<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/time<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/metadataCreationDate<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;comments<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/comments<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;files<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">xmlns:nz_govt_natlib_xsl_XSLTFunctions</span>=<span style="color: #ff0000;">&quot;nz.govt.natlib.xsl.XSLTFunctions&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileIdentifier</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>D:\00077-70\00077-70_0001.jpg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/path<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filename<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>00077-70_0001.jpg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;extension<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jpg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/extension<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filename<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>162096<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileDateTime<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;date</span> <span style="color: #000066;">format</span>=<span style="color: #ff0000;">&quot;yyyyMMdd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>20090303<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/date<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;time</span> <span style="color: #000066;">format</span>=<span style="color: #ff0000;">&quot;HHmmssSSS&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>133008000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/time<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileDateTime<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mimetype<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>image/jpeg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mimetype<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileFormat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;format<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>JPEG<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/format<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileFormat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;imageResolution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;samplingFrequencyUnit<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/samplingFrequencyUnit<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsamplingFrequency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>150<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsamplingFrequency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ysamplingFrequency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>150<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ysamplingFrequency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/imageResolution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;imageDimension<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;width<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>998<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/width<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;length<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1321<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/length<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/imageDimension<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bitsPerSample<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bitsPerSample<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;photometricInterpretation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>YCbCr<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/photometricInterpretation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;iccprofileName</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;colorMap</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;orientation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0degrees<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/orientation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;compression<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scheme<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scheme<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;level</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/compression<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/files<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

</pre>
<p></font></p>
<p>Then you'll parse it like:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>code<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>strong<span style="color: #339933;">&gt;</span><span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> xml2array<span style="color: #009900;">&#40;</span><span style="color: #000088;">$contents</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;&lt;/</span>strong<span style="color: #339933;">&gt;</span>
<span style="color: #000088;">$query1</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT into `master` values (&quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$ultimoID</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;, &quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #339933;">&lt;</span>strong<span style="color: #339933;">&gt;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Size<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;, '&quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Filename<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Extension<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;', '&quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Mimetype<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;', '&quot;</span> <span style="color: #339933;">.&lt;/</span>strong<span style="color: #339933;">&gt;</span>
 		<span style="color: #990000;">md5_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$listado</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;', &quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>FileDateTime<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">Date</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;, &quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>FileDateTime<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">Time</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;, '&quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Filename<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Name<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;', '&quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #990000;">addslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Path<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;', &quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Image<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>ImageResolution<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>XSamplingFrequency<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;, &quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Image<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>ImageResolution<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>YSamplingFrequency<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;, &quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Image<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>ImageDimension<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Width<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;, &quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Image<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>ImageDimension<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Length<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;, '&quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>FileFormat<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Format<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;', '&quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>FileFormat<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Version<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;', &quot;</span> <span style="color: #339933;">.</span>
 		<span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span>Object<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Files<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">File</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>Image<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>BitsPerSample<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>code<span style="color: #339933;">&gt;</span></pre></div></div>

<p></font></p>
<p>Related posts:<ol>
<li><a href='http://www.leccionespracticas.com/informatica-web/smarty-templates-print_r-an-array-solved/' rel='bookmark' title='Smarty templates: print_r an array [SOLVED]'>Smarty templates: print_r an array [SOLVED]</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-web/php-check-if-url-exists-or-file-via-url/' rel='bookmark' title='PHP: check if url exists (or file via url)'>PHP: check if url exists (or file via url)</a></li>
<li><a href='http://www.leccionespracticas.com/informatica-sistemas-y-servidores/solved-apache-error-client-xxx-file-does-not-exist/' rel='bookmark' title='[SOLVED] Apache: &#8216;[error] [client ::XXX] File does not exist:&#8217;'>[SOLVED] Apache: &#8216;[error] [client ::XXX] File does not exist:&#8217;</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leccionespracticas.com/informatica-web/parse-xml-file-into-array-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

