<?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>Never Use This Font &#187; Internet</title>
	<atom:link href="http://neverusethisfont.com/blog/topics/internet/feed/" rel="self" type="application/rss+xml" />
	<link>http://neverusethisfont.com/blog</link>
	<description>Ramblings of a Designer/Programmer</description>
	<lastBuildDate>Fri, 09 Jul 2010 21:50:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Workaround for Comcast blocking port 25</title>
		<link>http://neverusethisfont.com/blog/2009/07/workaround-for-comcast-blocking-port-25/</link>
		<comments>http://neverusethisfont.com/blog/2009/07/workaround-for-comcast-blocking-port-25/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 14:01:32 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://neverusethisfont.com/blog/?p=71</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Comcast just started blocking port 25 outgoing. I have several computers at home configured to send email reports of cron jobs. Of course they do this by trying to send mail on port 25 from inside the house to my mail server outside. Now that Comcast is blocking that, I need some other way for my emails to be delivered.</p>
<p>The easiest solution I could come up with was to tell my mail server to listen on another port such as 587, and have my firewall route requests for port 25 to port 587. Here is the iptables rule to do that!</p>
<p><code>iptables -t nat -A PREROUTING -p tcp -i eth0 -d xx.xx.xx.xx --dport 25 -j DNAT --to-destination :587</code></p>
<p>Where xx.xx.xx.xx is the IP address of my mail server. Now all the computers inside think they are communicating with my mail server on port 25, but the firewall secretly passes the request on to port 587 instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2009/07/workaround-for-comcast-blocking-port-25/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Am I really the only one who knows what street I grew up on?</title>
		<link>http://neverusethisfont.com/blog/2009/05/am-i-really-the-only-one-who-knows-what-street-i-grew-up-on/</link>
		<comments>http://neverusethisfont.com/blog/2009/05/am-i-really-the-only-one-who-knows-what-street-i-grew-up-on/#comments</comments>
		<pubDate>Wed, 13 May 2009 01:46:01 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://neverusethisfont.com/blog/2009/05/am-i-really-the-only-one-who-knows-what-street-i-grew-up-on/</guid>
		<description><![CDATA[The top trending topic on Twitter the other day was #twitterpornname. This seemingly innocent meme prompts you to find your Twitter porn name by combining the name of your first pet with the street you grew up on, or some variation. Thousands of people began shouting out this information on their Twitter profiles.
At this point, [...]]]></description>
			<content:encoded><![CDATA[<p>The top trending topic on Twitter the other day was <a href="http://search.twitter.com/search?q=%23twitterpornname">#twitterpornname</a>. This seemingly innocent meme prompts you to find your Twitter porn name by combining the name of your first pet with the street you grew up on, or some variation. Thousands of people began shouting out this information on their Twitter profiles.</p>
<p><img class="alignright size-full wp-image-57" style="float: right;" title="twitter_logo" src="http://neverusethisfont.com/blog/wp-content/uploads/2008/10/twitter_logo_s.png" alt="" width="175" height="41" />At this point, little red flags may be going off in your head if you realize that another place you may have seen these questions is&#8230; the <strong>security questions</strong> for your online bank account! &#8220;The name of your first pet&#8221; and &#8220;the street you grew up on&#8221; are common security questions asked by many websites, and probably you&#8217;ve signed up on a few websites that have asked you these.</p>
<p>This meme quickly caused people to seriously think about online security. On one hand, you have people freely giving out the answers to their security questions for their online banking accounts, their student email accounts, etc.</p>
<p><strong>On the other hand,</strong> you have businesses treating this information as if you are the only one who could possibly know it. The whole point of a password is that nobody knows it except you. If I log in to a website and provide my password, the website can be reasonably sure that it is really me logging in. When security questions can be used to reset a password, you&#8217;d better be sure that nobody else knows the answers to the security questions.</p>
<p>Why, then, do businesses assume that you are the only one who knows the answers to &#8220;what street did you grow up on&#8221; or &#8220;what is your mother&#8217;s maiden name&#8221;? Surely you can think of a few other people in your life who know the answers, because they grew up with you, or they are related to you.</p>
<p>So while it&#8217;s generally a bad idea to give out the answers to your security questions on Twitter, there is really a bigger issue here.</p>
<p>Note: You may have arrived at this post because you saw <a href=" http://pin13.net/3f2">my tweet which included my SSN and credit card number</a>. Be assured: this was not my actual SSN or CC#. I was making fun of the fact that people give up personal information so easily.</p>
]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2009/05/am-i-really-the-only-one-who-knows-what-street-i-grew-up-on/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IMAP Authentication for Wordpress 2.7.1</title>
		<link>http://neverusethisfont.com/blog/2009/02/imap-authentication-for-wordpress-271/</link>
		<comments>http://neverusethisfont.com/blog/2009/02/imap-authentication-for-wordpress-271/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 18:36:59 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Server Software]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://neverusethisfont.com/blog/?p=69</guid>
		<description><![CDATA[Due to some significant changes to the Wordpress authentication mechanism, my original IMAP Authentication plugin stopped working in version 2.7.1. I have updated the plugin to work in 2.7.1. The only difference is that users are no longer automatically created in Wordpress if they have a valid IMAP account. I will try to add that [...]]]></description>
			<content:encoded><![CDATA[<p>Due to some significant changes to the Wordpress authentication mechanism, my original <a href="/blog/2008/08/imap-authentication-for-wordpress/">IMAP Authentication plugin</a> stopped working in version 2.7.1. I have updated the plugin to work in 2.7.1. The only difference is that users are no longer automatically created in Wordpress if they have a valid IMAP account. I will try to add that back in soon, but for now this will do. </p>
<p>Download <a href="http://aaronpk.net/wp-imap-authentication/imap-authentication1.2.php">imap-authentication1.2.php</a></p>
<p><span id="more-69"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #808080; font-style: italic;">/*
Plugin Name: IMAP Authentication 2
Version: 1.2
Plugin URI: http://blog.neverusethisfont.com/2009/02/imap-authentication-for-wordpress-271/
Description: Authenticate users using IMAP authentication. For Wordpress 2.7.1
Author: Aaron Parecki
Author URI: http://www.aaronparecki.com
&nbsp;
&nbsp;
Copyright 2009 by Aaron Parecki  (email : aaron@parecki.com)
&nbsp;
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.
&nbsp;
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
&nbsp;
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/</span>
&nbsp;
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'admin_menu'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'admin_menu'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'lost_password'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'disable_password'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'retrieve_password'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'disable_password'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'password_reset'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'disable_password'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
add_filter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'show_password_fields'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'show_password_fields'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'wp_authenticate_user'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'authenticate_user'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
add_filter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'check_password'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'check_password'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> is_plugin_page<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #ff0000">$mailbox</span> <span style="color: #66cc66;">=</span> IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">get_mailbox</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff0000">$user_suffix</span> <span style="color: #66cc66;">=</span> IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">get_user_suffix</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #66cc66;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrap&quot;</span><span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>h2<span style="color: #66cc66;">&gt;</span>IMAP Authentication Options<span style="color: #66cc66;">&lt;/</span>h2<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>form name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imapauthenticationoptions&quot;</span> method<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span> action<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;options.php&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_nonce_field<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'update-options'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    <span style="color: #66cc66;">&lt;</span>input type<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;action&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;update&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>input type<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;page_options&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_mailbox,imap_authentication_user_suffix&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>fieldset <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;options&quot;</span><span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>table width<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;100%&quot;</span> cellspacing<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span> cellpadding<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;form-table&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>tr valign<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>th width<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;33%&quot;</span> scope<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;row&quot;</span><span style="color: #66cc66;">&gt;&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_mailbox&quot;</span><span style="color: #66cc66;">&gt;</span>Mailbox<span style="color: #66cc66;">&lt;/</span>label<span style="color: #66cc66;">&gt;&lt;/</span>th<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;&lt;</span>input name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_mailbox&quot;</span> type<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> id<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_mailbox&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php echo htmlspecialchars($mailbox) ?&gt;&quot;</span> size<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #66cc66;">/&gt;&lt;</span>br <span style="color: #66cc66;">/&gt;</span>eg<span style="color: #66cc66;">:</span> <span style="color: #66cc66;">&#123;</span><span style="color: #000066;">mail</span><span style="color: #66cc66;">.</span>example<span style="color: #66cc66;">.</span>com<span style="color: #66cc66;">/</span>readonly<span style="color: #66cc66;">&#125;</span>INBOX or <span style="color: #66cc66;">&#123;</span><span style="color: #000066;">mail</span><span style="color: #66cc66;">.</span>example<span style="color: #66cc66;">.</span>com<span style="color: #66cc66;">:</span><span style="color: #cc66cc;">993</span><span style="color: #66cc66;">/</span>ssl<span style="color: #66cc66;">/</span>novalidate<span style="color: #66cc66;">-</span>cert<span style="color: #66cc66;">/</span>readonly<span style="color: #66cc66;">&#125;</span>INBOX<span style="color: #66cc66;">&lt;/</span>td<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>tr<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>tr valign<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>th scope<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;row&quot;</span><span style="color: #66cc66;">&gt;&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_user_suffix&quot;</span><span style="color: #66cc66;">&gt;</span>User Suffix<span style="color: #66cc66;">&lt;/</span>label<span style="color: #66cc66;">&gt;&lt;/</span>th<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;&lt;</span>input name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_user_suffix&quot;</span> type<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> id<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_user_suffix&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php echo htmlspecialchars($user_suffix) ?&gt;&quot;</span> size<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #66cc66;">/&gt;&lt;</span>br <span style="color: #66cc66;">/&gt;</span>A suffix to add to usernames <span style="color: #66cc66;">&#40;</span>typically used to automatically add the domain part of the login<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">.&lt;</span>br <span style="color: #66cc66;">/&gt;</span>eg<span style="color: #66cc66;">:</span> <span style="color: #66cc66;">@</span>example<span style="color: #66cc66;">.</span>com<span style="color: #66cc66;">&lt;/</span>td<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>tr<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;/</span>table<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>fieldset<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>p <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span><span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>input type<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php _e('Save Changes') ?&gt;&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>p<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;/</span>form<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>div<span style="color: #66cc66;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">!</span><span style="color: #000066;">class_exists</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">class</span> IMAPAuthentication <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">/*
         * Add an options pane for this plugin.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> admin_menu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            add_options_page<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAP Authentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'IMAP Authentication'</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">,</span> <span style="color: #000000; font-weight: bold;">__FILE__</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Return the mailbox option from the database, creating the option if it doesn't exist.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> get_mailbox<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #000066;">global</span> <span style="color: #ff0000">$cache_nonexistantoptions</span><span style="color: #66cc66;">;</span>
&nbsp;
            <span style="color: #ff0000">$mailbox</span> <span style="color: #66cc66;">=</span> get_settings<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'imap_authentication_mailbox'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span> <span style="color: #ff0000">$mailbox</span> or <span style="color: #ff0000">$cache_nonexistantoptions</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'imap_authentication_mailbox'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #ff0000">$mailbox</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'{localhost:143}INBOX'</span><span style="color: #66cc66;">;</span>
                IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">add_mailbox_option</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$mailbox</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$mailbox</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Add the mailbox option to the database.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> add_mailbox_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$mailbox</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            add_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'imap_authentication_mailbox'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$mailbox</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'The mailbox to try and log into.'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Return the user_suffix option from the database, creating the option if it doesn't exist.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> get_user_suffix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #000066;">global</span> <span style="color: #ff0000">$cache_nonexistantoptions</span><span style="color: #66cc66;">;</span>
&nbsp;
            <span style="color: #ff0000">$user_suffix</span> <span style="color: #66cc66;">=</span> get_settings<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'imap_authentication_user_suffix'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span> <span style="color: #ff0000">$user_suffix</span> or <span style="color: #ff0000">$cache_nonexistantoptions</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'imap_authentication_user_suffix'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #ff0000">$user_suffix</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">;</span>
                IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">add_user_suffix_option</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$user_suffix</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$user_suffix</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Add the user_suffix option to the database.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> add_user_suffix_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$user_suffix</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            add_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'imap_authentication_user_suffix'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$user_suffix</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'A suffix to add to usernames (typically used to automatically add the domain part of the login).'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// custom error handler</span>
        <span style="color: #000000; font-weight: bold;">function</span> eh<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$type</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$msg</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$file</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$line</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$context</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #ff0000">$error</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$error</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$msg</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> authenticate_user<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&amp;</span><span style="color: #ff0000">$user</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$password</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        	<span style="color: #000066;">global</span> <span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">;</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">// Apparently this method is no longer called for users who are not in the WP database</span>
&nbsp;
			<span style="color: #ff0000">$mbox</span> <span style="color: #66cc66;">=</span> imap_open<span style="color: #66cc66;">&#40;</span>IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">get_mailbox</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$user</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">user_login</span><span style="color: #66cc66;">.</span>IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">get_user_suffix</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$password</span><span style="color: #66cc66;">,</span> OP_HALFOPEN<span style="color: #66cc66;">|</span>OP_READONLY<span style="color: #66cc66;">&#41;</span> or <span style="color: #ff0000">$error</span> <span style="color: #66cc66;">=</span> imap_last_error<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$mbox</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #ff0000">$userInfo</span> <span style="color: #66cc66;">=</span> get_userdatabylogin<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$user</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">user_login</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
				imap_close<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$mbox</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> WP_User<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$userInfo</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">ID</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
				do_action<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'wp_login_failed'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$user</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">user_login</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Error<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'incorrect_password'</span><span style="color: #66cc66;">,</span> __<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'&lt;strong&gt;ERROR&lt;/strong&gt;: Incorrect password. '</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$error</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> check_password<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$unknown</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$enteredPassword</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$storedPassword</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$userID</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #ff0000">$user</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_User<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$userID</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #b1b100;">return</span> IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">authenticate_user</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$user</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$enteredPassword</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Used to disable certain login functions, e.g. retrieving a
         * user's password.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> disable_password<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            login_header<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Login'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'&lt;p class=&quot;message&quot;&gt;&lt;strong&gt;ERROR&lt;/strong&gt;: You can<span style="color: #000099; font-weight: bold;">\'</span>t do that here. This blog uses the IMAP login mechanism. Your password is set with your email account.&lt;/p&gt;'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'error'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #000066;">die</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Used to disable certain display elements, e.g. password
         * fields on profile screen.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> show_password_fields<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$username</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2009/02/imap-authentication-for-wordpress-271/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IMAP Authentication for Wordpress</title>
		<link>http://neverusethisfont.com/blog/2008/08/imap-authentication-for-wordpress/</link>
		<comments>http://neverusethisfont.com/blog/2008/08/imap-authentication-for-wordpress/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 08:00:16 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Server Software]]></category>

		<guid isPermaLink="false">http://blog.neverusethisfont.com/2008/08/imap-authentication-for-wordpress/</guid>
		<description><![CDATA[UPDATE 2/13/09: There is a newer version of the IMAP Authentication plugin for Wordpress 2.7.1.
It seems like IMAP authentication would be a pretty basic plugin to find for Wordpress. A google search doesn&#8217;t turn up much. I found this one which was apparently written for an older version of Wordpress. Never having written a Wordpress [...]]]></description>
			<content:encoded><![CDATA[<p><b>UPDATE 2/13/09: There is a newer version of the <a href="/blog/2009/02/imap-authentication-for-wordpress-271/">IMAP Authentication plugin</a> for Wordpress 2.7.1.</b></p>
<p>It seems like IMAP authentication would be a pretty basic plugin to find for Wordpress. A google search doesn&#8217;t turn up much. I found <a href="http://norman.rasmussen.co.za/77/imap-authentication-plugin/">this one</a> which was apparently written for an older version of Wordpress. Never having written a Wordpress plugin before, naturally I decided to fix it to work with version 2.6.</p>
<p>Below is the result of my efforts. I started with Norman&#8217;s code, and modified it until it worked with version 2.6. I apologize if it is written poorly or if I missed something terribly obvious; I&#8217;ve never written a Wordpress plugin before. </p>
<p>Download <a href="http://aaronpk.net/wp-imap-authentication/imap-authentication2.php">imap-authentication2.php</a></p>
<p><span id="more-52"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #808080; font-style: italic;">/*
Plugin Name: IMAP Authentication
Version: 0.1
Plugin URI: http://blog.neverusethisfont.com/2008/08/imap-authentication-for-wordpress/
Description: Authenticate users using IMAP authentication.
Author: Aaron Parecki
Author URI: http://www.aaronparecki.com
&nbsp;
Assumes a successful login against the IMAP server is a valid user, and auto-creates
the user in Wordpress if they don't already exist.
&nbsp;
&nbsp;
&nbsp;
Copyright 2007 by Aaron Parecki  (email : aaron@parecki.com)
&nbsp;
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
&nbsp;
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
&nbsp;
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
&nbsp;
*/</span>
&nbsp;
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'admin_menu'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'admin_menu'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'lost_password'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'disable_password'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'retrieve_password'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'disable_password'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
add_action<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'password_reset'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'disable_password'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
add_filter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'show_password_fields'</span><span style="color: #66cc66;">,</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'show_password_fields'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> is_plugin_page<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #ff0000">$mailbox</span> <span style="color: #66cc66;">=</span> IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">get_mailbox</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff0000">$user_suffix</span> <span style="color: #66cc66;">=</span> IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">get_user_suffix</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #66cc66;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrap&quot;</span><span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>h2<span style="color: #66cc66;">&gt;</span>IMAP Authentication Options<span style="color: #66cc66;">&lt;/</span>h2<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;</span>form name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imapauthenticationoptions&quot;</span> method<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span> action<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;options.php&quot;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_nonce_field<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'update-options'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    <span style="color: #66cc66;">&lt;</span>input type<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;action&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;update&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>input type<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;page_options&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_mailbox,imap_authentication_user_suffix&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;</span>fieldset <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;options&quot;</span><span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>table width<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;100%&quot;</span> cellspacing<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span> cellpadding<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;form-table&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>tr valign<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>th width<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;33%&quot;</span> scope<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;row&quot;</span><span style="color: #66cc66;">&gt;&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_mailbox&quot;</span><span style="color: #66cc66;">&gt;</span>Mailbox<span style="color: #66cc66;">&lt;/</span>label<span style="color: #66cc66;">&gt;&lt;/</span>th<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;&lt;</span>input name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_mailbox&quot;</span> type<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> id<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_mailbox&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php echo htmlspecialchars($mailbox) ?&gt;&quot;</span> size<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #66cc66;">/&gt;&lt;</span>br <span style="color: #66cc66;">/&gt;</span>eg<span style="color: #66cc66;">:</span> <span style="color: #66cc66;">&#123;</span><span style="color: #000066;">mail</span><span style="color: #66cc66;">.</span>example<span style="color: #66cc66;">.</span>com<span style="color: #66cc66;">/</span>readonly<span style="color: #66cc66;">&#125;</span>INBOX or <span style="color: #66cc66;">&#123;</span><span style="color: #000066;">mail</span><span style="color: #66cc66;">.</span>example<span style="color: #66cc66;">.</span>com<span style="color: #66cc66;">:</span><span style="color: #cc66cc;">993</span><span style="color: #66cc66;">/</span>ssl<span style="color: #66cc66;">/</span>novalidate<span style="color: #66cc66;">-</span>cert<span style="color: #66cc66;">/</span>readonly<span style="color: #66cc66;">&#125;</span>INBOX<span style="color: #66cc66;">&lt;/</span>td<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>tr<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>tr valign<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span><span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>th scope<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;row&quot;</span><span style="color: #66cc66;">&gt;&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_user_suffix&quot;</span><span style="color: #66cc66;">&gt;</span>User Suffix<span style="color: #66cc66;">&lt;/</span>label<span style="color: #66cc66;">&gt;&lt;/</span>th<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;&lt;</span>input name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_user_suffix&quot;</span> type<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> id<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imap_authentication_user_suffix&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php echo htmlspecialchars($user_suffix) ?&gt;&quot;</span> size<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #66cc66;">/&gt;&lt;</span>br <span style="color: #66cc66;">/&gt;</span>A suffix to add to usernames <span style="color: #66cc66;">&#40;</span>typically used to automatically add the domain part of the login<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">.&lt;</span>br <span style="color: #66cc66;">/&gt;</span>eg<span style="color: #66cc66;">:</span> <span style="color: #66cc66;">@</span>example<span style="color: #66cc66;">.</span>com<span style="color: #66cc66;">&lt;/</span>td<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;/</span>tr<span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;/</span>table<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>fieldset<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>p <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span><span style="color: #66cc66;">&gt;</span>
      <span style="color: #66cc66;">&lt;</span>input type<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit&quot;</span> value<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php _e('Save Changes') ?&gt;&quot;</span> <span style="color: #66cc66;">/&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>p<span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;/</span>form<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>div<span style="color: #66cc66;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">!</span><span style="color: #000066;">class_exists</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAPAuthentication'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">class</span> IMAPAuthentication <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">/*
         * Add an options pane for this plugin.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> admin_menu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            add_options_page<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'IMAP Authentication'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'IMAP Authentication'</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">,</span> <span style="color: #000000; font-weight: bold;">__FILE__</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Return the mailbox option from the database, creating the option if it doesn't exist.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> get_mailbox<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #000066;">global</span> <span style="color: #ff0000">$cache_nonexistantoptions</span><span style="color: #66cc66;">;</span>
&nbsp;
            <span style="color: #ff0000">$mailbox</span> <span style="color: #66cc66;">=</span> get_settings<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'imap_authentication_mailbox'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span> <span style="color: #ff0000">$mailbox</span> or <span style="color: #ff0000">$cache_nonexistantoptions</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'imap_authentication_mailbox'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #ff0000">$mailbox</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'{localhost:143}INBOX'</span><span style="color: #66cc66;">;</span>
                IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">add_mailbox_option</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$mailbox</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$mailbox</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Add the mailbox option to the database.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> add_mailbox_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$mailbox</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            add_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'imap_authentication_mailbox'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$mailbox</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'The mailbox to try and log into.'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Return the user_suffix option from the database, creating the option if it doesn't exist.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> get_user_suffix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #000066;">global</span> <span style="color: #ff0000">$cache_nonexistantoptions</span><span style="color: #66cc66;">;</span>
&nbsp;
            <span style="color: #ff0000">$user_suffix</span> <span style="color: #66cc66;">=</span> get_settings<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'imap_authentication_user_suffix'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span> <span style="color: #ff0000">$user_suffix</span> or <span style="color: #ff0000">$cache_nonexistantoptions</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'imap_authentication_user_suffix'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #ff0000">$user_suffix</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">;</span>
                IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">add_user_suffix_option</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$user_suffix</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$user_suffix</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Add the user_suffix option to the database.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> add_user_suffix_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$user_suffix</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            add_option<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'imap_authentication_user_suffix'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$user_suffix</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'A suffix to add to usernames (typically used to automatically add the domain part of the login).'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">// custom error handler</span>
        <span style="color: #000000; font-weight: bold;">function</span> eh<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$type</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$msg</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$file</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$line</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$context</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #ff0000">$error</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$error</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$msg</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> login<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$username</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$password</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        	<span style="color: #000066;">global</span> <span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">;</span>
&nbsp;
			<span style="color: #ff0000">$mbox</span> <span style="color: #66cc66;">=</span> imap_open<span style="color: #66cc66;">&#40;</span>IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">get_mailbox</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$username</span><span style="color: #66cc66;">.</span>IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">get_user_suffix</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$password</span><span style="color: #66cc66;">,</span> OP_HALFOPEN<span style="color: #66cc66;">&#41;</span> or <span style="color: #ff0000">$error</span> <span style="color: #66cc66;">=</span> imap_last_error<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$mbox</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #ff0000">$user</span> <span style="color: #66cc66;">=</span> get_userdatabylogin<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$username</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000">$user</span> <span style="color: #66cc66;">===</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
					<span style="color: #808080; font-style: italic;">// the user checked out on the IMAP server, but there was no record in the database. Automatically add it now.</span>
					<span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;INSERT INTO $wpdb-&gt;users (user_login, user_nicename, user_email, display_name) VALUES(%s, %s, %s, %s)&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$username</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$username</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$username</span><span style="color: #66cc66;">.</span>IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">get_user_suffix</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$username</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
					<span style="color: #ff0000">$user</span> <span style="color: #66cc66;">=</span> get_userdatabylogin<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$username</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
					<span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;INSERT INTO $wpdb-&gt;usermeta (user_id, meta_key, meta_value) VALUES(%d, %s, %s)&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$user</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">ID</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'nickname'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$username</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
					<span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;INSERT INTO $wpdb-&gt;usermeta (user_id, meta_key, meta_value) VALUES(%d, %s, %s)&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$user</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">ID</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'rich_editing'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'true'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
					<span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;INSERT INTO $wpdb-&gt;usermeta (user_id, meta_key, meta_value) VALUES(%d, %s, %s)&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$user</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">ID</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'wp_capabilities'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'a:1:{s:6:&quot;author&quot;;b:1;}'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
					<span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000">$wpdb</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;INSERT INTO $wpdb-&gt;usermeta (user_id, meta_key, meta_value) VALUES(%d, %s, %s)&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$user</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">ID</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'wp_user_level'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'2'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
				<span style="color: #66cc66;">&#125;</span>
&nbsp;
				imap_close<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$mbox</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> WP_User<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$user</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">ID</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
				do_action<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'wp_login_failed'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$username</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Error<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'incorrect_password'</span><span style="color: #66cc66;">,</span> __<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'&lt;strong&gt;ERROR&lt;/strong&gt;: Incorrect password.'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Used to disable certain login functions, e.g. retrieving a
         * user's password.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> disable_password<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            login_header<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Login'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'&lt;p class=&quot;message&quot;&gt;&lt;strong&gt;ERROR&lt;/strong&gt;: You can<span style="color: #000099; font-weight: bold;">\'</span>t do that here. This blog uses the IMAP login mechanism. Your password is set with your email account.&lt;/p&gt;'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'error'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			<span style="color: #000066;">die</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">/*
         * Used to disable certain display elements, e.g. password
         * fields on profile screen.
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> show_password_fields<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$username</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">!</span>is_plugin_page<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wp_authenticate<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$username</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$password</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">return</span> IMAPAuthentication<span style="color: #66cc66;">::</span><span style="color: #006600;">login</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$username</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$password</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">endif</span><span style="color: #66cc66;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2008/08/imap-authentication-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google Treasure Hunt &#8211; Question 2</title>
		<link>http://neverusethisfont.com/blog/2008/05/google-treasure-hunt/</link>
		<comments>http://neverusethisfont.com/blog/2008/05/google-treasure-hunt/#comments</comments>
		<pubDate>Tue, 20 May 2008 03:35:12 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[google cis programming bash]]></category>

		<guid isPermaLink="false">http://blog.neverusethisfont.com/2008/05/google-treasure-hunt/</guid>
		<description><![CDATA[I just stumbled across Google&#8217;s Treasure Hunt. They&#8217;re always doing neat things, so I checked it out. It&#8217;s a series of four problem-solving puzzles released one week at a time. I found out about it after the first question was already over, so I jumped in starting with the second question.
Question 2: File sum and [...]]]></description>
			<content:encoded><![CDATA[<p>I just stumbled across Google&#8217;s <a href="http://google-au.blogspot.com/2008/05/google-treasure-hunt.html">Treasure Hunt</a>. They&#8217;re always doing neat things, so I checked it out. It&#8217;s a series of four problem-solving puzzles released one week at a time. I found out about it after the first question was already over, so I jumped in starting with the second question.</p>
<p><strong>Question 2</strong>: File sum and multiplication problem</p>
<p>In this problem you are given a zip folder with hundreds of text files nested in folders an arbitrary number of levels deep. The question asks to find the sum of the nth line of all files with abc in their path, ending in .xyz. You do this twice, then calculate the product of the two sums. You can download the file I got from them at the link below.<br />
<a href="http://blog.neverusethisfont.com/wp-content/uploads/2008/05/googletreasurehunt08_9334957515161249657.zip">googletreasurehunt.zip</a></p>
<p>My question is below:</p>
<blockquote><p>Sum of line 3 for all files with path or name containing jkl and ending in .rtf<br />
Sum of line 5 for all files with path or name containing stu and ending in .rtf<br />
Multiply all the above sums together and enter the product below.</p></blockquote>
<p>I thought this would be a good chance to practice my bash scripting, so I decided to give it a shot.</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">find</span> . -<span style="color: #7a0874; font-weight: bold;">type</span> f -wholename <span style="color: #ff0000;">&quot;*jkl*<span style="color: #000099; font-weight: bold;">\.</span>rtf&quot;</span></pre></div></div>

<p>-type f restricts the search to files, not directories. -wholename searches for files matching that pattern. Once we run this, we get a list of all the files we&#8217;ll need to process. Now we need to create a running total of the values in the nth line in each file. This is where a bash &#8216;for&#8217; loop and &#8216;awk&#8217; come in handy.</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #000000; font-weight: bold;">for</span> x <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> . -<span style="color: #7a0874; font-weight: bold;">type</span> f -wholename <span style="color: #ff0000;">&quot;*jkl*<span style="color: #000099; font-weight: bold;">\.</span>rtf&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>The &#8216;$&#8217; tells bash to execute that command and return the result. The &#8216;for&#8217; loop looks at the output line by line, and the variable x will contain each filename.</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'NR==3'</span> filename.txt</pre></div></div>

<p>This is an awk command that prints the 3rd line of filename.txt. If we can stick this into the &#8216;for&#8217; loop, we can get a running total.</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #007800;">sum1=</span><span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">for</span> x <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> . -<span style="color: #7a0874; font-weight: bold;">type</span> f -wholename <span style="color: #ff0000;">&quot;*jkl*<span style="color: #000099; font-weight: bold;">\.</span>rtf&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">sum1=</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> `<span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'NR==3'</span> <span style="color: #007800;">$x</span>` + <span style="color: #007800;">$sum1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$sum1</span></pre></div></div>

<p>Now we just repeat for the other pattern, and we end up with our sum in two variables. Calculating the product is simple.</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #7a0874; font-weight: bold;">echo</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #007800;">$sum1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #007800;">$sum2</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Personally, I thought this puzzle was a little bit simplistic. I would have expected them to throw in some tricks, so that a poorly written search command would return some other files that would mess with your result. Now that I&#8217;ve said that, I hope I got it right! I find out in 10 hours if my answer is correct.</p>
<p>Feel free to comment if you have a different and/or better solution to this problem!</p>
]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2008/05/google-treasure-hunt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Phone as a Wifi access point!</title>
		<link>http://neverusethisfont.com/blog/2008/04/phone-as-a-wifi-access-point/</link>
		<comments>http://neverusethisfont.com/blog/2008/04/phone-as-a-wifi-access-point/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 21:34:57 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[cell phone]]></category>
		<category><![CDATA[Mogul]]></category>
		<category><![CDATA[sprint]]></category>
		<category><![CDATA[Wifi]]></category>

		<guid isPermaLink="false">http://blog.neverusethisfont.com/?p=42</guid>
		<description><![CDATA[This is pretty much the coolest thing in the world! I am posting from my laptop which is connected to my cell phone&#8217;s wifi connection, using Sprint&#8217;s EVDO connection to the internet. The software that enables me to do this is called wmwifirouter. Earlier this month they released their first final version of the software, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="border: 2px solid black; margin: 5px; float: right;" src="http://www.wmwifirouter.com/images/consumer-requirements-picture.jpg" alt="" width="210" height="210" />This is pretty much the coolest thing in the world! I am posting from my laptop which is connected to my cell phone&#8217;s wifi connection, using Sprint&#8217;s EVDO connection to the internet. The software that enables me to do this is called <a href="http://www.wmwifirouter.com/">wmwifirouter</a>. Earlier this month they released their first final version of the software, and started charging for it. It&#8217;s not outrageously priced, but you can still find the earlier free versions on the internet if you search for versions 0.90 or 0.89.</p>
<p>Sprint&#8217;s EVDO connection is actually pretty speedy. Of course it&#8217;s not like having a cable connection, but it&#8217;s definitely faster than dialup. I downloaded a 2mb file at a solid 85kb/s. Also see below for a traceroute to this server.</p>
<p><span id="more-42"></span></p>

<div class="wp_syntax"><div class="code"><pre class="winbatch">C<span style="color: #FF1010; font-weight: bold;">:\Documents and Settings\Aaron Parecki&gt;tracert blog.neverusethisfont.com</span>
&nbsp;
Tracing route <span style="color: #800080;">to</span> blog.neverusethisfont.com <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">67.18</span><span style="color: #cc66cc;">.176</span><span style="color: #cc66cc;">.91</span><span style="color: #66cc66;">&#93;</span>
over a maximum of <span style="color: #cc66cc;">30</span> hops<span style="color: #FF1010; font-weight: bold;">:</span>
&nbsp;
  <span style="color: #cc66cc;">1</span>     <span style="color: #cc66cc;">6</span> ms     <span style="color: #cc66cc;">2</span> ms     <span style="color: #cc66cc;">3</span> ms  <span style="color: #cc66cc;">192.168</span><span style="color: #cc66cc;">.0</span><span style="color: #cc66cc;">.1</span>
  <span style="color: #cc66cc;">2</span>   <span style="color: #cc66cc;">141</span> ms   <span style="color: #cc66cc;">124</span> ms   <span style="color: #cc66cc;">124</span> ms  <span style="color: #cc66cc;">68.28</span><span style="color: #cc66cc;">.57</span><span style="color: #cc66cc;">.69</span>
  <span style="color: #cc66cc;">3</span>     <span style="color: #66cc66;">*</span>        <span style="color: #66cc66;">*</span>        <span style="color: #66cc66;">*</span>     Request timed out.
  <span style="color: #cc66cc;">4</span>   <span style="color: #cc66cc;">131</span> ms   <span style="color: #cc66cc;">132</span> ms   <span style="color: #cc66cc;">134</span> ms  <span style="color: #cc66cc;">68.28</span><span style="color: #cc66cc;">.59</span><span style="color: #cc66cc;">.55</span>
  <span style="color: #cc66cc;">5</span>     <span style="color: #66cc66;">*</span>        <span style="color: #66cc66;">*</span>        <span style="color: #66cc66;">*</span>     Request timed out.
  <span style="color: #cc66cc;">6</span>   <span style="color: #cc66cc;">121</span> ms   <span style="color: #cc66cc;">120</span> ms   <span style="color: #cc66cc;">121</span> ms  <span style="color: #cc66cc;">68.28</span><span style="color: #cc66cc;">.63</span><span style="color: #cc66cc;">.5</span>
  <span style="color: #cc66cc;">7</span>     <span style="color: #66cc66;">*</span>        <span style="color: #66cc66;">*</span>        <span style="color: #66cc66;">*</span>     Request timed out.
  <span style="color: #cc66cc;">8</span>   <span style="color: #cc66cc;">135</span> ms   <span style="color: #cc66cc;">129</span> ms   <span style="color: #cc66cc;">128</span> ms  <span style="color: #cc66cc;">68.28</span><span style="color: #cc66cc;">.59</span><span style="color: #cc66cc;">.18</span>
  <span style="color: #cc66cc;">9</span>   <span style="color: #cc66cc;">136</span> ms   <span style="color: #cc66cc;">123</span> ms   <span style="color: #cc66cc;">128</span> ms  sl<span style="color: #66cc66;">-</span>gw20<span style="color: #66cc66;">-</span>phx<span style="color: #cc66cc;">-0</span><span style="color: #cc66cc;">-0</span><span style="color: #cc66cc;">-0</span>.sprintlink.net <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">144.224</span><span style="color: #cc66cc;">.27</span><span style="color: #cc66cc;">.5</span><span style="color: #66cc66;">&#93;</span>
 <span style="color: #cc66cc;">10</span>   <span style="color: #cc66cc;">143</span> ms   <span style="color: #cc66cc;">130</span> ms   <span style="color: #cc66cc;">243</span> ms  sl<span style="color: #66cc66;">-</span>bb21<span style="color: #66cc66;">-</span>phx<span style="color: #cc66cc;">-11</span><span style="color: #cc66cc;">-0</span><span style="color: #cc66cc;">-0</span>.sprintlink.net <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">144.232</span><span style="color: #cc66cc;">.23</span><span style="color: #cc66cc;">.199</span><span style="color: #66cc66;">&#93;</span>
 <span style="color: #cc66cc;">11</span>   <span style="color: #cc66cc;">141</span> ms   <span style="color: #cc66cc;">142</span> ms   <span style="color: #cc66cc;">138</span> ms  sl<span style="color: #66cc66;">-</span>bb25<span style="color: #66cc66;">-</span>ana<span style="color: #cc66cc;">-6</span><span style="color: #cc66cc;">-0</span><span style="color: #cc66cc;">-0</span>.sprintlink.net <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">144.232</span><span style="color: #cc66cc;">.8</span><span style="color: #cc66cc;">.74</span><span style="color: #66cc66;">&#93;</span>
 <span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">169</span> ms   <span style="color: #cc66cc;">131</span> ms   <span style="color: #cc66cc;">138</span> ms  ggr3<span style="color: #66cc66;">-</span>p330.la2ca.ip.att.net <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">192.205</span><span style="color: #cc66cc;">.33</span><span style="color: #cc66cc;">.189</span><span style="color: #66cc66;">&#93;</span>
 <span style="color: #cc66cc;">13</span>   <span style="color: #cc66cc;">156</span> ms   <span style="color: #cc66cc;">154</span> ms   <span style="color: #cc66cc;">156</span> ms  <span style="color: #cc66cc;">12.127</span><span style="color: #cc66cc;">.3</span><span style="color: #cc66cc;">.210</span>
 <span style="color: #cc66cc;">14</span>   <span style="color: #cc66cc;">154</span> ms   <span style="color: #cc66cc;">151</span> ms   <span style="color: #cc66cc;">151</span> ms  tbr1.dlstx.ip.att.net <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">12.122</span><span style="color: #cc66cc;">.10</span><span style="color: #cc66cc;">.49</span><span style="color: #66cc66;">&#93;</span>
 <span style="color: #cc66cc;">15</span>   <span style="color: #cc66cc;">153</span> ms   <span style="color: #cc66cc;">151</span> ms   <span style="color: #cc66cc;">154</span> ms  <span style="color: #cc66cc;">12.122</span><span style="color: #cc66cc;">.100</span><span style="color: #cc66cc;">.49</span>
 <span style="color: #cc66cc;">16</span>   <span style="color: #cc66cc;">150</span> ms   <span style="color: #cc66cc;">151</span> ms   <span style="color: #cc66cc;">152</span> ms  <span style="color: #cc66cc;">12.87</span><span style="color: #cc66cc;">.41</span><span style="color: #cc66cc;">.150</span>
 <span style="color: #cc66cc;">17</span>   <span style="color: #cc66cc;">324</span> ms   <span style="color: #cc66cc;">207</span> ms   <span style="color: #cc66cc;">203</span> ms  te7<span style="color: #cc66cc;">-2</span>.dsr01.dllstx3.theplanet.com <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">70.87</span><span style="color: #cc66cc;">.253</span><span style="color: #cc66cc;">.10</span><span style="color: #66cc66;">&#93;</span>
 <span style="color: #cc66cc;">18</span>   <span style="color: #cc66cc;">160</span> ms   <span style="color: #cc66cc;">155</span> ms   <span style="color: #cc66cc;">151</span> ms  7e.fd<span style="color: #cc66cc;">.5746</span>.static.theplanet.com <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">70.87</span><span style="color: #cc66cc;">.253</span><span style="color: #cc66cc;">.126</span><span style="color: #66cc66;">&#93;</span>
 <span style="color: #cc66cc;">19</span>   <span style="color: #cc66cc;">163</span> ms   <span style="color: #cc66cc;">154</span> ms   <span style="color: #cc66cc;">154</span> ms  vl1.car02.dllstx2.theplanet.com <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">12.96</span><span style="color: #cc66cc;">.160</span><span style="color: #cc66cc;">.12</span><span style="color: #66cc66;">&#93;</span>
 <span style="color: #cc66cc;">20</span>   <span style="color: #cc66cc;">154</span> ms   <span style="color: #cc66cc;">153</span> ms   <span style="color: #cc66cc;">150</span> ms  theia.parecki.com <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">67.18</span><span style="color: #cc66cc;">.176</span><span style="color: #cc66cc;">.91</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
Trace complete.
C<span style="color: #FF1010; font-weight: bold;">:\Documents and Settings\Aaron Parecki&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2008/04/phone-as-a-wifi-access-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
