<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Sveggiani's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 11:45:20 GMT</pubDate>
    <description>DZone Snippets: Sveggiani's Code Snippets</description>
    <item>
      <title>Loop de X elementos por fila</title>
      <link>http://snippets.dzone.com/posts/show/4665</link>
      <description>// Genera una estructura que va colocando un resultset en filas de X elementos.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;// Cat&#225;logos&lt;br /&gt;$catalogos_query = 'SELECT catalogos.* FROM catalogos WHERE catalogos.estado = 1 ORDER BY catalogos.id_catalogo DESC';&lt;br /&gt;$catalogos_rs = mysql_query( $catalogos_query );&lt;br /&gt;$catalogos_num = mysql_num_rows( $catalogos_rs );&lt;br /&gt;&lt;br /&gt;// inicia looper&lt;br /&gt;$elem_count = 0;&lt;br /&gt;$elem_total_count = 0;&lt;br /&gt;$elem_per_row = 6; // Configurar esto!&lt;br /&gt;// bucle entre todas los elementos a mostrar&lt;br /&gt;while( $row = mysql_fetch_assoc( $catalogos_rs ) ) :&lt;br /&gt;	$elem_count++;&lt;br /&gt;	$elem_total_count++;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;	&lt;?php if ( $elem_count == 1 ) : // si es el primer elemento de la fila.... ?&gt;&lt;br /&gt;&lt;br /&gt;	&lt;div class="catalogoRow"&gt;&lt;br /&gt;&lt;br /&gt;	&lt;?php endif; ?&gt;	&lt;br /&gt;&lt;br /&gt;	&lt;?php if ( $elem_count == $elem_per_row ) : // si es el &#250;ltimo elemento de la fila...&lt;br /&gt;		$class = "catalogoContainer ultimo";&lt;br /&gt;	else:&lt;br /&gt;		$class = "catalogoContainer";&lt;br /&gt;	endif; ?&gt;&lt;br /&gt;&lt;br /&gt;		&lt;div class="&lt;?php echo $class ?&gt;"&gt;&lt;br /&gt;&lt;br /&gt;			&lt;div class="catalogoImagen"&gt;&lt;br /&gt;				&lt;a target="_blank" href="/arxius/catalogos/&lt;?php echo $row['archivo']; ?&gt;"&gt;&lt;img src="../arxius/catalogos/&lt;?php echo $row['imagen']; ?&gt;" alt="&lt;?php echo $row['titulo_'.$idioma]; ?&gt;" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;			&lt;/div&gt;&lt;br /&gt;			&lt;div class="catalogoTitulo"&gt;&lt;br /&gt;				&lt;p&gt;&lt;?php echo $row['titulo_'.$idioma]; ?&gt;&lt;/p&gt;&lt;br /&gt;			&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;		&lt;/div&gt;&lt;!-- end .container --&gt;&lt;br /&gt;&lt;br /&gt;	&lt;?php if ( $elem_count == $elem_per_row || $catalogos_num == $elem_total_count ) : // elem_db_total es el total de reg. a mostrar de la bbdd ?&gt;&lt;br /&gt;		&lt;div class="clear"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;	&lt;/div&gt;&lt;!-- end .row --&gt;&lt;br /&gt;&lt;br /&gt;	&lt;?php $elem_count = 0; endif; ?&gt;&lt;br /&gt;&lt;br /&gt;&lt;?php endwhile; ?&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 17 Oct 2007 12:46:19 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4665</guid>
      <author>sveggiani (Sebasti&#225;n)</author>
    </item>
    <item>
      <title>Devuelve el Referer limpio</title>
      <link>http://snippets.dzone.com/posts/show/4611</link>
      <description>// Limpia y devuelve el REFERER&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;	function getReferer(){&lt;br /&gt;		// limpia el referer &lt;br /&gt;		$ref = $_SERVER['HTTP_REFERER'];&lt;br /&gt;		$web = str_replace(array('http://','www.'),'',$ref);&lt;br /&gt;		$web = substr($web,0,strpos ($web, '/'));&lt;br /&gt;		if(!empty($web)):&lt;br /&gt;			// retorna el referer limpio&lt;br /&gt;			return $web;&lt;br /&gt;		else:&lt;br /&gt;			// sin referer&lt;br /&gt;			return 'jane.es';&lt;br /&gt;		endif;&lt;br /&gt;	}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 03 Oct 2007 16:14:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4611</guid>
      <author>sveggiani (Sebasti&#225;n)</author>
    </item>
    <item>
      <title>recupera datos del visitante</title>
      <link>http://snippets.dzone.com/posts/show/4610</link>
      <description>&lt;code&gt;&lt;br /&gt;	function getLocation( $ip ) {&lt;br /&gt;		&lt;br /&gt;		static $location = array();&lt;br /&gt;		&lt;br /&gt;		if( !isset( $location[$ip] ) ) {&lt;br /&gt;			$url = "http://www.hostip.info/api/get.html?ip=" . $ip . "&amp;position=true&amp;raandom=" . rand(0,500);&lt;br /&gt;			/* cURL */&lt;br /&gt;			$ch = curl_init();&lt;br /&gt;			curl_setopt($ch, CURLOPT_URL, $url);&lt;br /&gt;			curl_setopt($ch, CURLOPT_HEADER, 0);&lt;br /&gt;			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);&lt;br /&gt;			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;			$data = curl_exec($ch);&lt;br /&gt;&lt;br /&gt;			if ( curl_errno( $ch ) ) {&lt;br /&gt;				print "Error: ".curl_error($ch);&lt;br /&gt;			} else {&lt;br /&gt;				curl_close($ch);&lt;br /&gt;				$lines = split ("\n", $data);&lt;br /&gt;				foreach($lines as $l):&lt;br /&gt;					$prop = split(':',$l);&lt;br /&gt;					$location[$ip][trim($prop[0])] = addslashes(trim($prop[1]));&lt;br /&gt;				endforeach;&lt;br /&gt;		   }&lt;br /&gt;			&lt;br /&gt;		}&lt;br /&gt;		return $location[$ip];&lt;br /&gt;	}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 03 Oct 2007 16:12:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4610</guid>
      <author>sveggiani (Sebasti&#225;n)</author>
    </item>
  </channel>
</rss>
