<?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>Alex Cook &#187; wordpress</title>
	<atom:link href="http://www.propellingsolutions.com/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.propellingsolutions.com</link>
	<description>User Experience Design, Flex Development, &#38; Entreprenuership</description>
	<lastBuildDate>Mon, 06 Sep 2010 01:48:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Pull All Categories out of a WordPress Database</title>
		<link>http://www.propellingsolutions.com/2010/09/how-to-pull-all-categories-out-of-a-wordpress-database/</link>
		<comments>http://www.propellingsolutions.com/2010/09/how-to-pull-all-categories-out-of-a-wordpress-database/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 01:48:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[flex]]></category>
		<category><![CDATA[geekery]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.propellingsolutions.com/?p=470</guid>
		<description><![CDATA[Sample code for selecting all categories out of the WordPress database.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some pretty neat stuff with WordPress lately, specifically querying and displaying categories and their heirarchy in Flex/Air.  For now, though, I just wanted to post this one simple query which selects all of the categories in WordPress&#8230; maybe you&#8217;ll find it useful.</p>
<p><code>SELECT wp_terms.term_id, wp_terms.name, wp_terms.slug FROM wp_terms,wp_term_taxonomy WHERE wp_terms.term_id = wp_term_taxonomy.term_id AND wp_term_taxonomy.taxonomy = 'category' AND wp_terms.term_id != 1 ORDER BY name ASC</code></p>
<p>In this example, I&#8217;m getting all categories that are not &#8220;uncategorized&#8221; from WordPress.</p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.propellingsolutions.com/2010/09/how-to-pull-all-categories-out-of-a-wordpress-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securing a WordPress page with https</title>
		<link>http://www.propellingsolutions.com/2009/12/securing-a-wordpress-page-with-https/</link>
		<comments>http://www.propellingsolutions.com/2009/12/securing-a-wordpress-page-with-https/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 21:48:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.propellingsolutions.com/?p=132</guid>
		<description><![CDATA[What I needed
I needed a way to secure a single page.  This could be an order page or a page where I want to protect user information.  The problem is, even if you simply try to go to &#8220;https://mysite.com/page&#8221;, you&#8217;ll be re-directed to the http page by WordPress.  Furthermore, even if you [...]]]></description>
			<content:encoded><![CDATA[<h1><strong>What I needed</strong></h1>
<p>I needed a way to secure a single page.  This could be an order page or a page where I want to protect user information.  The problem is, even if you simply try to go to &#8220;https://mysite.com/page&#8221;, you&#8217;ll be re-directed to the http page by WordPress.  Furthermore, even if you use htaccess to force the content over https, you&#8217;ll still get &#8220;partially encrypted&#8221; errors.</p>
<h1><strong>What is out there</strong></h1>
<p>There was <a href="http://wordpress.org/extend/plugins/admin-ssl-secure-admin/">Admin SSL,</a> which has a 4-star rating&#8230; but did not work for me; I think the developer stopped working on it and newer versions of WP don&#8217;t work with the plugin.  I also tried <a href="http://wordpress.org/extend/plugins/https-for-wordpress/">HTTPS for WordPress</a>, and that didn&#8217;t work either.</p>
<p>Because I couldn&#8217;t find anything&#8230; I put together this hack.  I guess I could make it into a plugin, but I&#8217;m lazy.</p>
<h1><strong>How to do it<br />
</strong></h1>
<p>Required knowledge/tools:</p>
<ul>
<li>Installation of CURL on your server</li>
<li>Basic knowledge of .htaccess, and how to edit the file</li>
<li>Basic php knowledge</li>
<li>A working SSL certificate</li>
</ul>
<h1>1.  Modify your .htaccess file</h1>
<p>Figure out what page you wan to secure.  For example, you might want to secure /contact-us.  Add the following lines to your .htacccess file, before the normal wordpress lines:</p>
<pre>&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteRule ^contact-us/ /secure-page.php [QSA,L]
RewriteRule ^contact-us /secure-page.php [QSA,L]
&lt;/IfModule&gt;
# normal WordPress stuff:
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
&lt;/IfModule&gt;</pre>
<p>Here we&#8217;re checking to see if the visitor is requesting the &#8220;contact-us&#8221; page, and if so, we&#8217;re rewriting the request to a file called secure-page.php, instead of loading WordPress (step 2).</p>
<h1>2.  Rename /contact-us &amp; modify menu</h1>
<p><img class="alignnone size-full wp-image-148" title="Untitled-1" src="http://www.propellingsolutions.com/wp-content/uploads/2009/12/Untitled-1.jpg" alt="Untitled-1" width="579" height="150" /></p>
<p>Next, you&#8217;ll need to get rid of the old /contact-us page you had, and rename it to contact-page-content &#8211; you can do this using WordPress&#8230; edit the Premalink, and set it to /contact-page-content.</p>
<p>You&#8217;ll need to exclude the page from your navigation, and then put an absolute link to /contact-us in your menu. I suggest the &#8220;Exclude Pages&#8221; plugin, found at <a href="http://wordpress.org/extend/plugins/exclude-pages/">http://wordpress.org/extend/plugins/exclude-pages/</a></p>
<h1>2.  Create secure-page.php</h1>
<p>Create a file called secure-page.php and add it to your base directory (in the same location as your .htaccess file):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$domain</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;www.mydomain.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>  <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'on'</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$url</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;https://<span style="color: #006699; font-weight: bold;">$domain</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location:<span style="color: #006699; font-weight: bold;">$url</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$curl_handle</span><span style="color: #339933;">=</span>curl_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span>CURLOPT_URL<span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$domain</span>/contact-page-content&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// assuming pretty urls are setup this way...</span>
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span>CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span>CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> curl_exec<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
curl_close<span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #990000;">print</span> <span style="color: #0000ff;">&quot;Timed Out&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;src=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://<span style="color: #006699; font-weight: bold;">$domain</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'src=&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;src='<span style="color: #006699; font-weight: bold;">$domain</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;src='&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;url(<span style="color: #000099; font-weight: bold;">\&quot;</span>http://<span style="color: #006699; font-weight: bold;">$domain</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'url(&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/http:\/\/.*?(\/.*?\.css)/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$1</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/http:\/\/.*?(\/.*?\.js)/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$1</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/http:\/\/.*?(\/.*?\.xml)/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$1</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print</span> <span style="color: #000088;">$buffer</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>OK, here&#8217;s an explanation:</strong></p>
<p>You renamed /contact-us to /contact-page-content, and then excluded it from your navigation.  Note that the page still exists &#8211; you can enter /contact-page-content into your browser, and it will show the page, right?  But, you hid it from navigation, and you provided the user with a link to /contact-us.  Some people might say this solution is still not &#8220;secure&#8221;, but I could honestly care less if the user can still go to /contact-page-content&#8230; if they do, who cares?</p>
<p><strong>As for what secure-page.php is doing:</strong></p>
<p>The first part checks to make sure the page is served over https.  If not, it forwards to the https version, and exits.</p>
<p>Next, we use CURL to request another page (contact-page-content).  Remember that you can still navigate to /contact-page-content, and CURL is doing just that.  CURL then downloads the entire content of the page into a buffer/string.</p>
<p>Next, we replace all references to http assets to https&#8230; or just &#8220;/&#8221;.   We do this because WordPress uses absolute URLs to assets (&#8221;http://mysite.com/image.jpg&#8221;), and we want it to be relative (&#8221;/image.jpg&#8221;).  We then echo out the buffer, and voila, your page is now secured.</p>
<h1>Conclusion</h1>
<p>I should turn this into a plugin, but I&#8217;m lazy and I just don&#8217;t have the time&#8230;</p>
<p>If you have problems just comment on this post and I&#8217;ll get back to you!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.propellingsolutions.com/2009/12/securing-a-wordpress-page-with-https/feed/</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
	</channel>
</rss>
