<?xml version="1.0" encoding="UTF-8"?>
<rss 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/" version="2.0">

<channel>
	<title>Nutsmuggling</title>
	
	<link>http://davidebenini.it</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 29 Apr 2010 10:34:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Nutsmuggling" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="nutsmuggling" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>How to allow tags in Wordpress comments unobtrusively</title>
		<link>http://davidebenini.it/2010/04/29/how-to-allow-tags-in-wordpress-comments-unobtrusively/</link>
		<comments>http://davidebenini.it/2010/04/29/how-to-allow-tags-in-wordpress-comments-unobtrusively/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 10:31:08 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[allowed]]></category>
		<category><![CDATA[allowedtags]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[core]]></category>
		<category><![CDATA[span]]></category>
		<category><![CDATA[tags]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=580</guid>
		<description><![CDATA[How to allow tags in comments without touching the wp core]]></description>
			<content:encoded><![CDATA[<p>Scenario: I am using the <a href="http://wordpress.org/extend/plugins/tinymcecomments/">tinymcecomments</a> plugin to give some formatting capabilities to commenters.<br />
With the latest WP update I realised the <code>span</code> tag was removed from comments; colors attributes are filtered by the kses filter.</p>
<p>Hum.</p>
<p>After investigating I come across <a href="http://codex.wordpress.org/FAQ_Working_with_WordPress#How_do_I_stop_people_from_posting_HTML_in_comments.3F">this suggestion</a> in the Codex:</p>
<blockquote>
<p>Acceptance of HTML tags in the comments field is managed in the file kses.php, located in the wp-includes folder.</p>
<p>Open this file in a text editor, and locate the list of HTML tags near the top of the file. Each HTML tag is listed on a separate line, in the construction of a PHP array of allowed tags. Lines which begin with // are commented-out, or disabled, so lines which begin with // designate HTML tags that are not allowed in comments.</p>
<p>To stop people from posting HTML in comments, edit your kses.php file as desired to allow or disallow specific HTML tags in comments, by adding // to the very beginning of the appropriate lines of the list. To exclude all HTML tags, comment out all lines which allow HTML tags. Be sure to save your file when done.</p>
</blockquote>
<p>That&#8217;s a start but hey, is the Codex really suggesting that I alter the WP core? Next update my all precious settings will go away. C&#8217;mon, we can do better than that!</p>
<p>In the kses source code I find this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CUSTOM_TAGS'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CUSTOM_TAGS'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</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>CUSTOM_TAGS<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>     
	etc</pre></div></div>

<p>So basically I can redefine all the allowed tags structure in a constant. Not bad. But hey, do I really want to redefine  both the $allowedposttags and the $allowedtags variables? Naaah&#8230;</p>
<p>So I scavenged in the source code and I came across a fit filter. I wrote a little function for my functions.php file; needless to say, this could have gone into a plugin.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'preprocess_comment'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'fa_allow_tags_in_comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> fa_allow_tags_in_comments<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$allowedtags</span><span style="color: #339933;">;</span> 
	<span style="color: #000088;">$allowedtags</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'span'</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: #0000ff;">'style'</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$allowedtags</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'p'</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: #009900;">&#41;</span><span style="color: #339933;">;</span>   
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>See? Much more concise than overwriting the variables. And more future-proof: if subsequent versions of Wordpress change the variable there is no constant barring the changes.</p>
<p>Cheers,<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/04/29/how-to-allow-tags-in-wordpress-comments-unobtrusively/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Events Manager 2.2, security hole closed</title>
		<link>http://davidebenini.it/2010/04/10/events-manager-2-2-security-hole-closed/</link>
		<comments>http://davidebenini.it/2010/04/10/events-manager-2-2-security-hole-closed/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 15:26:00 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Events Manager]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[events manager eventsmanager wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=578</guid>
		<description><![CDATA[Security release of Events mMnager]]></description>
			<content:encoded><![CDATA[<p>Hello folks,<br />
I just released Events Manager 2.2. It&#8217;s a minor upgrade, here is the changelog:</p>
<ul>
<li>Added a option to get events through a select            </li>
<li>Closed many bugs causing a notices/warning visible only in debug mode</li>
<li>Closed a critical security hole discovered by Danilo Massa (to be released on May 10th)     </li>
</ul>
<p>The first point is the only proper feature, it allows you to use a select for the events venue. It&#8217;s something that comes in handy for people/organizations whose events take place in the same venues all the times.</p>
<p>The second point is something I should have done AGES ago. I put Worpress in debug mode and thus could see all the stuff that&#8217;s usually spitted directly into the error log. There were many small bugs, caused mainly by the lack of <code>isset</code> here and there. I believe there are still minor notice/warnings, but I got rid of most of them.</p>
<p>Point three is what urged me to release ASAP. <a href="http://www.danilomassa.info/dmportal/">Danilo Massa</a> kindly notified me of a security hole in Events Manager, providing a simple one-liner to fix it. Since the vulnerability is pretty serious I hurried to apply Danilo&#8217;s patch and release 2.2.</p>
<p>This release is quite stable, it&#8217;s employed in a client portal, so you should have no problem with the upgrade.</p>
<p>Enjoy,<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/04/10/events-manager-2-2-security-hole-closed/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Atrio – Gestione Condomini</title>
		<link>http://davidebenini.it/2010/04/06/atrio-gestione-condomini/</link>
		<comments>http://davidebenini.it/2010/04/06/atrio-gestione-condomini/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 07:55:03 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Portfolio Entry]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=555</guid>
		<description><![CDATA[Atrio is a a team of professional focused on condominium management.
The Website has a fresh look, built upon the palette of teh Atrio logo.
The website is built with Webby; the end user is served a pure HTML version of the website, while ruby allows fast editing during the development.
]]></description>
			<content:encoded><![CDATA[<p>Atrio is a a team of professional focused on condominium management.<br />
The Website has a fresh look, built upon the palette of teh Atrio logo.<br />
The website is built with Webby; the end user is served a pure HTML version of the website, while ruby allows fast editing during the development.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/04/06/atrio-gestione-condomini/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Events Manager 2.1</title>
		<link>http://davidebenini.it/2010/03/04/events-manager-2-1/</link>
		<comments>http://davidebenini.it/2010/03/04/events-manager-2-1/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 18:54:59 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Events Manager]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[haircut]]></category>
		<category><![CDATA[manager]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=548</guid>
		<description><![CDATA[Hello folks,
just a short note to announce the release of Events Manager 2.1.
It&#8217;s probably not as stable as the lack of a or b would suggest, but it is definitely much stabler than the previous version. Also, I got tired of letters.
Here&#8217;s the changelog:

Properly added Marcus Sykes as a contributor  
Added a full calendar [...]]]></description>
			<content:encoded><![CDATA[<p>Hello folks,<br />
just a short note to announce the release of <a href="http://davidebenini.it/wordpress-plugins/events-manager/">Events Manager 2.1</a>.<br />
It&#8217;s probably not as stable as the lack of <code>a</code> or <code>b</code> would suggest, but it is definitely much stabler than the previous version. Also, I got tired of letters.</p>
<p>Here&#8217;s the changelog:</p>
<ul>
<li>Properly added Marcus Sykes as a contributor  </li>
<li>Added a full calendar  </li>
<li>Added an #_EDITEVENT placeholder  </li>
<li>Added Brazialian Portuguese localization and some translatable strings</li>
<li>Added a today scope for events lists</li>
<li>Increased to 3 te default lists limit</li>
<li>Categories are now displayed in the events table                        </li>
<li>Now weeks starts according to WP settings       </li>
<li>Moved the hide page option up for better access  </li>
<li>Attributes column was not created when the plugin was upgraded, fixed</li>
<li>Added comment field to the RSVP form and #_COMMENT placeholder in RSVP email templates </li>
<li>Added customizable title to small calendar      </li>
<li>Removed php short tags                        </li>
<li>Changed RVSP &#8216;no seats available message&#8217; for better English</li>
<li>Bugfix: there was a time bug</li>
<li>Bugfix: event_time not taken into consideration in ordering events, fixed</li>
<li>Bugfix: on calendar for days after 28  on the event calendar view</li>
<li>Bugfix: for events in days with single digit</li>
<li>Bugfix: events link in the calendar now work with permalink</li>
<li>Bugfix: today in next mont was not matched in the calendar </li>
<li>Bugfix: _RESPPHONE was not matched in emails</li>
<li>Bugfix: fixed security vulnerability, which could lead to sql inject attacks      </li>
<li>Bugfix: locations with apostrophe were duplicated</li>
<li>Bugfix: bloginfo(&#8216;wpurl&#8217;) instead of bloginfo(&#8216;url&#8217;)  </li>
<li>Bugfix: now loading textdomain in the new (not deprecated) way</li>
</ul>
<p>Most of the bugfixes, and some of the features, were sponsored by Sara of <a href="http://www.paperlantern.com/">Paperlantern</a>, to whom I am most grateful.</p>
<p>Also, I just got a haircut:</p>
<p><img src="http://davidebenini.it/wp-content/uploads/2010/03/Foto-del-61365666-03-2455260-alle-1702-300x225.jpg" alt="" title="Foto-del-61365666-03-2455260-alle-1702.jpg" width="300" height="225" class="aligncenter size-medium wp-image-547" /></p>
<p>Cheers,<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/03/04/events-manager-2-1/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Wordpress: disable moderation for a single comment</title>
		<link>http://davidebenini.it/2009/12/16/wordpress-disable-moderation-for-a-single-comment/</link>
		<comments>http://davidebenini.it/2009/12/16/wordpress-disable-moderation-for-a-single-comment/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 11:47:13 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[moderation]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=531</guid>
		<description><![CDATA[I am working an very complex portal based on Wordpress. The more I code, the more I befriend the functions.php file, where all my small tweaks reside. Last in the list (pun!) a super simple action to automatically approve comments belonging to a specific post (which I use as a guestbook):

function approve_guestbook_comments&#40;$comment_ID&#41; &#123;
	$comment = get_comment&#40;$comment_ID&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>I am working an very complex portal based on Wordpress. The more I code, the more I befriend the <code>functions.php</code> file, where all my small tweaks reside. Last in the list (pun!) a super simple action to automatically approve comments belonging to a specific post (which I use as a guestbook):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> approve_guestbook_comments<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_ID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$comment</span> <span style="color: #339933;">=</span> get_comment<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_post_ID</span> <span style="color: #339933;">==</span> guestbook_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		wp_set_comment_status<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_ID</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'approve'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment_post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'approve_guestbook_comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As you see it&#8217;s a super-simple tweak, but it&#8217;s quite effective.</p>
<p>Enjoy,<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2009/12/16/wordpress-disable-moderation-for-a-single-comment/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mass import users into WP</title>
		<link>http://davidebenini.it/2009/11/30/mass-import-users-into-wp/</link>
		<comments>http://davidebenini.it/2009/11/30/mass-import-users-into-wp/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 18:04:09 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wordpress users import]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=522</guid>
		<description><![CDATA[How to import a huge number of users into Wordpress]]></description>
			<content:encoded><![CDATA[<p>I am working on a complex blog/e-commerce system together with my colleagues at @ntw. I had to import some 10.000 users into WP. The task was easier than expected. The basic idea is leveraging on the <code>wp_insert_user($userdata)</code> function, defined in <code>wp-includes/registration.php</code>. If you look at the source, you&#8217;ll see that <code>$userdata</code> is an array containing a number of keys:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #339933;">*</span> The <span style="color: #000088;">$userdata</span> <span style="color: #990000;">array</span> can contain the following fields<span style="color: #339933;">:</span>
	<span style="color: #339933;">*</span> <span style="color: #0000ff;">'ID'</span> <span style="color: #339933;">-</span> An integer that will be used <span style="color: #b1b100;">for</span> updating an existing user<span style="color: #339933;">.</span>
	<span style="color: #339933;">*</span> <span style="color: #0000ff;">'user_pass'</span> <span style="color: #339933;">-</span> A string that contains the plain text password <span style="color: #b1b100;">for</span> the user<span style="color: #339933;">.</span>
	<span style="color: #339933;">*</span> <span style="color: #0000ff;">'user_login'</span> <span style="color: #339933;">-</span> A string that contains the user<span style="color: #0000ff;">'s username for logging in.
	* '</span>user_nicename<span style="color: #0000ff;">' - A string that contains a nicer looking name for the user.
	*		The default is the user'</span>s username<span style="color: #339933;">.</span></pre></div></div>

<p>The other keys are <code>user_url</code>,<code>user_email</code>, <code>display_name</code>, <code>nickname</code>, <code>first_name</code>, <code>last_name</code>, <code>description</code>, <code>rich_editing</code>, <code>user_registered</code>, <code>role</code>, <code>jabber</code>, <code>aim</code>, <code>yim</code>; for more detal consult the source itself.</p>
<p>My script goes like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'wp-blog-header.php'</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'wp-includes/registration.php'</span><span style="color: #339933;">;</span>   
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'wp-includes/pluggable.php'</span><span style="color: #339933;">;</span> 
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;memory_limit&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;1024M&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;max_execution_time&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;240&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;h1&gt;Importazione utenti EC&lt;/h1&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$connection</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;host&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;user&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unable to connect to MySQL&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;database&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unable to connect to the database&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM source_users ;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;strong&gt;ID:&lt;/strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt;strong&gt;login:&lt;/strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt;strong&gt;password:&lt;/strong&gt; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt;strong&gt;e-mail:&lt;/strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email_address</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt;strong&gt;name:&lt;/strong&gt; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt;strong&gt;surname:&lt;/strong&gt; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">surname</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>  
		<span style="color: #666666; font-style: italic;">// Add the ID to trick WP</span>
		<span style="color: #000088;">$add_id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">users</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; (id, user_login) VALUES (&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,'&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$row-&gt;user_name</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' ); &quot;</span><span style="color: #339933;">;</span>
		 <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$add_id</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Add the rest</span>
		<span style="color: #000088;">$userdata</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		 <span style="color: #0000ff;">'ID'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">,</span>  
		 <span style="color: #0000ff;">'user_login'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_name</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'user_pass'</span> <span style="color: #339933;">=&gt;</span> wp_hash_password<span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'user_nicename'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_name</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'user_email'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email_address</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'first_name'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'last_name'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">surname</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'role'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'subscriber'</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                          
		wp_insert_user<span style="color: #009900;">&#40;</span><span style="color: #000088;">$userdata</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Some highlights:</p>
<ul>
<li>Import all the WP files you need </li>
<li>Change PHP memory and time limits if you have many records</li>
<li>Explicitly encrypt the password with <code>wp_hash_password</code>. I have no idea why this is necessary, the WP code should do this by itself; but trust me, it is.</li>
</ul>
<p>Since we are using the <code>wp_insert_user()</code> function, WP will crate records both in the users and in the usermeta tables.</p>
<p>A last warning. This huge amount of users could conflict with your php settings. To get WP working properly I had to add this line to <code>wp-config.php</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_MEMORY_LIMIT'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'64M'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Without it I could not get the users list in the admin session. I also <a href="http://core.trac.wordpress.org/ticket/11151">filed a bug</a>, but this last line should keep you on the safe side.<br />
Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2009/11/30/mass-import-users-into-wp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Faking an IP with Webrat</title>
		<link>http://davidebenini.it/2009/08/29/faking-an-ip-with-webrat/</link>
		<comments>http://davidebenini.it/2009/08/29/faking-an-ip-with-webrat/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 10:42:37 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[remote_ip]]></category>
		<category><![CDATA[webrat]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=520</guid>
		<description><![CDATA[Lately I have been diving into TDD, and more specifically BDD, thanks to the wonderful Cucumber testing framework.
Today I have had to test a specifical IP based feature. Simply put, I get the user IP and store it into the database. 
The simple rails way to get a visitor IP address is
request.remote_ip

If you do this [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I have been diving into <a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a>, and more specifically <a href="http://en.wikipedia.org/wiki/Behavior_Driven_Development">BDD</a>, thanks to the wonderful <a href="http://en.wikipedia.org/wiki/Behavior_Driven_Development">Cucumber</a> testing framework.</p>
<p>Today I have had to test a specifical IP based feature. Simply put, I get the user IP and store it into the database. </p>
<p>The simple rails way to get a visitor IP address is</p>
<pre><code>request.remote_ip
</code></pre>
<p>If you do this while developing you&#8217;ll usually get a predictable</p>
<pre><code>127.0.0.1
</code></pre>
<p>How do I test that my controller puts a correct IP in the database?<br />
At first I thought about creating a mock request object. But this way I would be testing only the saving portion of the method, not the part detecting the IP. In other words, I needed to simulate an IP address at a lower layer.</p>
<p>Webrat to the rescue! Thanks to the nice folks at the webrat irc channel I got an answer. Simply:</p>
<pre><code>header('REMOTE_ADDR', ip_address)
</code></pre>
<p>The Webrat <code>header</code>method lets you set all the header variable of you session. Handy, isn&#8217;t it?</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2009/08/29/faking-an-ip-with-webrat/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Events Manager comments disabled</title>
		<link>http://davidebenini.it/2009/08/10/events-manager-comments-disabled/</link>
		<comments>http://davidebenini.it/2009/08/10/events-manager-comments-disabled/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 13:06:56 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Events Manager]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=515</guid>
		<description><![CDATA[Events Manager, Wordpress]]></description>
			<content:encoded><![CDATA[<p>Hi folks,<br />
just a quick note for warning that comments on EM are going to be disabled for a while.<br />
Why?<br />
Despite a disclaimer at the beginning of the post and a huge banner people is posting support problems as comments, instead that on the forum. I guess I should increase the banner size of make it flashy with JS.<br />
As soon as I have some time (not that sooinish) I&#8217;ll clean the thread and leave only relevant comments (pre-forum tweak suggestions and release announcements). And re-enable commenting.<br />
For now comments are closed. Use the forum, PLEASE!<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2009/08/10/events-manager-comments-disabled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Say hello to Marcus AKA netweblogic</title>
		<link>http://davidebenini.it/2009/08/06/say-hello-to-marcus-aka-netweblogic/</link>
		<comments>http://davidebenini.it/2009/08/06/say-hello-to-marcus-aka-netweblogic/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 15:21:09 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Events Manager]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[em]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=510</guid>
		<description><![CDATA[There's a new co-author for Events Manager]]></description>
			<content:encoded><![CDATA[<p>Great news for all ye Events Manager fans. Let us all say hello to Marcus Skyes that jumped on board, and is now co-authoring Events Manager.</p>
<p>Marcus contacted me a few weeks ago, sending a modded version of Events Manager. As soon as I gave it a try I realised that Marcus had done a wonderful job patching and integrating new features into EM. </p>
<p>Thanks to Marcus&#8217;s work now we have a number of frequently requested features:</p>
<ul>
<li>WP 2.8 support</li>
<li>Events Categories</li>
<li>WYSIWYG editor for events description (and you can add pictures too!)</li>
<li>multi-day events, kinda</li>
</ul>
<p>And much more.<sup>1</sup></p>
<p>Since Marcus is expanding the plugin for some of his gigs, I invited him to co-author Events Manager, and I am glad he accepted. </p>
<p>I just tagged EM 2.0rc2 with Marcus&#8217;s integration, hope you&#8217;ll enjoy it as much as I did.</p>
<p><a href="http://downloads.wordpress.org/plugin/events-manager.2.0rc2.zip">Download EM 2.0rc2<br />
</a></p>
<p>Davide</p>
<h4>Notes</h4>
<ol class="footnotes">
<li id="footnote_0_510" class="footnote">Since these features are not yet fully documented, I suggest you take a look at the change log in the readme for instructions.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2009/08/06/say-hello-to-marcus-aka-netweblogic/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rails 2.3.3 + Ruby 1.8.7 + Gmail SMTP settings</title>
		<link>http://davidebenini.it/2009/06/25/rails-233-ruby-187-gmail-smtp-settings/</link>
		<comments>http://davidebenini.it/2009/06/25/rails-233-ruby-187-gmail-smtp-settings/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 07:11:45 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Technolalia]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[1.8.7]]></category>
		<category><![CDATA[2.3.2]]></category>
		<category><![CDATA[actionmailer]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=506</guid>
		<description><![CDATA[How to setup Rails to use you gmail smtp without installing any plugin]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not rocket science, but since I took a while to figure this out I thought I&#8217;d share:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">ActionMailer::Base</span>.<span style="color:#9900CC;">smtp_settings</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
  <span style="color:#ff3333; font-weight:bold;">:enable_starttls_auto</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>,
  <span style="color:#ff3333; font-weight:bold;">:address</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;smtp.gmail.com&quot;</span>,
  <span style="color:#ff3333; font-weight:bold;">:port</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">587</span>,
  <span style="color:#ff3333; font-weight:bold;">:domain</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;your-google-apps-domain&quot;</span>,
  <span style="color:#ff3333; font-weight:bold;">:authentication</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:plain</span>,
  <span style="color:#ff3333; font-weight:bold;">:user_name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;username&quot;</span>,
  <span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;password&quot;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>The most important line is <code>enable_starttls_auto =&gt; true</code>.</p>
<p>Unlike pre 2.2 Rails, no plugin is required. Not sure this setup works with Rails 2.2 though, never tried it.</p>
<p>Via <a href="http://www.railsforum.com/viewtopic.php?id=28480">this forum discussion</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2009/06/25/rails-233-ruby-187-gmail-smtp-settings/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
