<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>mysiteonline™ - PHP</title>
    <link>http://life.mysiteonline.org/</link>
    <description>Brendon Kozlowski's Home on the Web.</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.4 - http://www.s9y.org/</generator>
    <pubDate>Mon, 17 Oct 2011 15:08:05 GMT</pubDate>

    <image>
        <url>http://life.mysiteonline.org/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: mysiteonline™ - PHP - Brendon Kozlowski's Home on the Web.</title>
        <link>http://life.mysiteonline.org/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>htmlentities() in PHP is Your Friend</title>
    <link>http://life.mysiteonline.org/archives/204-htmlentities-in-PHP-is-Your-Friend.html</link>
            <category>PHP</category>
    
    <comments>http://life.mysiteonline.org/archives/204-htmlentities-in-PHP-is-Your-Friend.html#comments</comments>
    <wfw:comment>http://life.mysiteonline.org/wfwcomment.php?cid=204</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://life.mysiteonline.org/rss.php?version=2.0&amp;type=comments&amp;cid=204</wfw:commentRss>
    

    <author>nospam@example.com (Brendon Kozlowski)</author>
    <content:encoded>
    After constantly badgering a certain library calendar vendor over 2 years to fix his software&#039;s RSS feed charset issues. Personally I don&#039;t think getting raw text describing times in the form of &quot;6:30â€“8:30 p.m.&quot; is all that valuable...that&#039;s just a single example. The calendar website declared no charset information. I have no idea what charset the database is in, and the RSS feed was declared as ISO-8859-1. Our website, database, and everything else was declared as UTF-8, not that it really mattered though since the raw incoming text from the RSS feed was all garbled to begin with.&lt;br /&gt;
&lt;br /&gt;
Every once and awhile I&#039;d randomly try to find an answer to the problem. I&#039;ve been through using all sorts of different algorithms to solve the problem. None of them seemed to work, until one day I saw someone mention on StackOverflow (unfortunately I&#039;ve lost the link) that he tried using htmlentities() to solve his problem and it worked. I thought, &quot;It couldn&#039;t be that simple...&quot; However, I had nothing to lose and tested it. It worked. (What???) I still don&#039;t know why or how htmlentities managed to run a translation table on the garbled input to output the appropriate values, but I&#039;m happy! Even my attempts at REGEX were unsuccessful, though I probably was just unable to find ALL the right bit-level character code sequences needed. Apparently the translation table that htmlentities uses is pretty darn thorough! Thanks, PHP team!&lt;br /&gt;
&lt;br /&gt;
Okay, so that was the first use of htmlentities(). The second one?&lt;br /&gt;
&lt;br /&gt;
I realized I overlooked a severe security hole in my forms. When users did not provide correct details in their forms, I was simply reinserting the values they provided back in to the HTML form&#039;s VALUE tag (or in the case of a textarea, just rendering the value between the tags). For some reason this didn&#039;t strike me as being severely stupid at the time. I don&#039;t know why. I guess the &quot;never reprint what your users submit to you&quot; only made me think of &quot;back to the DOM&quot; - but only outside form elements. Who knows why. This let someone who actually put some (minimal) thought into it to run whatever PHP code they wanted simply by submitting a form without all required data. Escape the form element by using a standard HTML closing tag, then start writing the PHP. If you wanted valid HTML, just make sure to also include a dummy HTML input or textarea field once done. Simple. (Note: I am also in the process of re-examining CHMOD values of files and folders.)&lt;br /&gt;
&lt;br /&gt;
When I went back to &quot;fix&quot; my stupidity, I also initially thought of using PHP&#039;s filter functions. Although they worked, they also would sometimes (depending on user input) remove certain characters. Like a bolt of lightning (while I was eating lunch) it came to me. I just used htmlentities(), why not just use it again? ...so I did. Now my forms are a bit more protected &lt;strong&gt;and&lt;/strong&gt; our RSS feed is no longer displaying obnoxious characters to visitors due to the encoding mishaps of an external developer.&lt;br /&gt;
&lt;br /&gt;
Sometimes PHP&#039;s little gems are so awesome... 
    </content:encoded>

    <pubDate>Fri, 14 Oct 2011 12:11:40 -0700</pubDate>
    <guid isPermaLink="false">http://life.mysiteonline.org/archives/204-guid.html</guid>
    
</item>
<item>
    <title>Outlook Web Access (Exchange) with PHP and cURL</title>
    <link>http://life.mysiteonline.org/archives/165-Outlook-Web-Access-Exchange-with-PHP-and-cURL.html</link>
            <category>PHP</category>
    
    <comments>http://life.mysiteonline.org/archives/165-Outlook-Web-Access-Exchange-with-PHP-and-cURL.html#comments</comments>
    <wfw:comment>http://life.mysiteonline.org/wfwcomment.php?cid=165</wfw:comment>

    <slash:comments>10</slash:comments>
    <wfw:commentRss>http://life.mysiteonline.org/rss.php?version=2.0&amp;type=comments&amp;cid=165</wfw:commentRss>
    

    <author>nospam@example.com (Brendon Kozlowski)</author>
    <content:encoded>
    I needed a way to authenticate users from our library from a server &lt;em&gt;outside&lt;/em&gt; our network, and therefore also not connected to Active Directory.  At first I was thinking LDAP would be the best way...then I did my research and learned enough about LDAP to realize just how much information it gives out - WAY too much for it to be very secure.  Even if I used SSL, created an account specifically for this access, set that account to read only...all it would take would be one person to hack our server and grab that information and all our organization&#039;s data is out there.  Although it&#039;s about as much of a chance as getting hit by lightning in the middle of the desert in a sand storm, I wouldn&#039;t want to be responsible.&lt;br /&gt;
&lt;br /&gt;
The only server with any sort of external web presence that is also touching the internet is our Exchange server&#039;s web access portal.  I thought, &quot;Ah HA! I can use cURL, or streams, or fsockopen or something to fake a login to this page to verify authentication!&quot;  After searching a bit (I&#039;m terrible every time I attempt to write something using cURL to authenticate), I came across a few things.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Exchange Server 2007 uses SOAP to provide a web service...AWESOME!  We currently use 2003 though, but we will be upgrading later this year, so this may be helpful later on. &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa579187.aspx&quot;&gt;[Link]&lt;/a&gt;&lt;ol type=&quot;a&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.howtoforge.com/talking-soap-with-exchange&quot;&gt;HowToForge article on how to use PHP with 2007&#039;s SOAP Web Service&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li&gt;I found &lt;a href=&quot;http://web.archive.org/web/20090125160119/http://cadmuslabs.net/index.php?entry=entry081230-075614&quot;&gt;this PHP script&lt;/a&gt; that I tested, which successfully contacted our OWA server and authenticated.&lt;/li&gt;&lt;li&gt;I also found a PHP class on &lt;a href=&quot;http://code.google.com/p/tylerhall/source/browse/trunk/outlook-web-access/owa.php&quot;&gt;Google Code&lt;/a&gt; from Tyler Hall - it&#039;s not any particular project repository, just miscellaneous code he&#039;s hosting.  It looks like it&#039;s slightly more feature rich, allowing info from address books and a user&#039;s inbox, for example.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
I only needed to authenticate our building, so thankfully we had our own subdomain (not sure of the proper terminology) in the AD...  If your domain was example.com (DC=example,DC=com), just getting OUR office (assume &quot;Office1&quot;) was as easy as defining office1.example.com (DC=office1,DC=example,DC=com) after the @ symbol in the user&#039;s username (typically unnecessary information with OWA, but adding it explicitly was important here).  It (seemingly) worked perfectly.&lt;br /&gt;
&lt;br /&gt;
If you plan on doing something similar, just make sure that you cache (and encrypt) username/password information locally, hitting the OWA page continuously would probably make your System (or Email) Administrators a little unhappy with you. 
    </content:encoded>

    <pubDate>Fri, 13 Mar 2009 10:43:40 -0700</pubDate>
    <guid isPermaLink="false">http://life.mysiteonline.org/archives/165-guid.html</guid>
    
</item>
<item>
    <title>Disable the Security Component in CakePHP only for Certain Actions</title>
    <link>http://life.mysiteonline.org/archives/175-Disable-the-Security-Component-in-CakePHP-only-for-Certain-Actions.html</link>
            <category>PHP</category>
    
    <comments>http://life.mysiteonline.org/archives/175-Disable-the-Security-Component-in-CakePHP-only-for-Certain-Actions.html#comments</comments>
    <wfw:comment>http://life.mysiteonline.org/wfwcomment.php?cid=175</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://life.mysiteonline.org/rss.php?version=2.0&amp;type=comments&amp;cid=175</wfw:commentRss>
    

    <author>nospam@example.com (Brendon Kozlowski)</author>
    <content:encoded>
    As I&#039;m working on a desktop application that needs to connect to the database backend, and CakePHP provides an awesome mechanism for REST or AJAX communication (as well as data validation), I decided to have my desktop application talk directly through the Cake interface to do its magic.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, I was also using CakePHP&#039;s rather secure Security component to prevent XSS/CSRF attacks.  The problem is that because the desktop application was directly accessing the method with data and bypassing CakePHP&#039;s FormHelper automatically created (and Security Component friendly) rendered HTML, it was failing (and because it wouldn&#039;t even get to the action since the Security Component was set in the AppController, I couldn&#039;t even use $this-&gt;log($this, LOG_DEBUG) to see what was happening).&lt;br /&gt;
&lt;br /&gt;
After searching for a good 30 minutes or so, I came across &lt;a href=&quot;http://n2.nabble.com/how-to-disable-security-component-for-a-single-action-td682715.html&quot;&gt;this archived Google Group post&lt;/a&gt; by franky06l:&lt;br /&gt;
&lt;textarea name=&quot;code&quot; class=&quot;php&quot;&gt;if(isset($this-&gt;Security) &amp;&amp;amp; $this-&gt;action == &#039;myaction&#039;))
     $this-&gt;Security-&gt;enabled = false;&lt;/textarea&gt;I updated this to only be used in my specific controller&#039;s action, as so:&lt;br /&gt;
&lt;textarea name=&quot;code&quot; class=&quot;php&quot;&gt;function beforeFilter(){
	parent::beforeFilter();
	if(isset($this-&gt;Security) &amp;&amp;amp; $this-&gt;RequestHandler-&gt;isAjax() &amp;&amp;amp; $this-&gt;action == &#039;add&#039;){
 		$this-&gt;Security-&gt;enabled = false; 
	}
}&lt;/textarea&gt;Voila!  It now works as expected.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Note:&lt;/strong&gt; One will need to be extra cautious when disabling the Security Component.  The Security Component takes care of a lot of issues for us automatically, by disabling it, you&#039;re opening yourself up to some possible troubles.  Extra precaution is recommended, and I relinquish myself from any use of the above code that may cause harm - use at your own peril (or absolute need)!  :D 
    </content:encoded>

    <pubDate>Wed, 26 Aug 2009 12:58:35 -0700</pubDate>
    <guid isPermaLink="false">http://life.mysiteonline.org/archives/175-guid.html</guid>
    
</item>
<item>
    <title>Finding all application Controllers in CakePHP (v1.3.x)</title>
    <link>http://life.mysiteonline.org/archives/201-Finding-all-application-Controllers-in-CakePHP-v1.3.x.html</link>
            <category>PHP</category>
    
    <comments>http://life.mysiteonline.org/archives/201-Finding-all-application-Controllers-in-CakePHP-v1.3.x.html#comments</comments>
    <wfw:comment>http://life.mysiteonline.org/wfwcomment.php?cid=201</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://life.mysiteonline.org/rss.php?version=2.0&amp;type=comments&amp;cid=201</wfw:commentRss>
    

    <author>nospam@example.com (Brendon Kozlowski)</author>
    <content:encoded>
    At some point in time you may find the need to get a list of all of the controllers within your application. It&#039;s actually quite simple so long as you don&#039;t need controllers from any plugins.&lt;br /&gt;
&lt;textarea name=&quot;code&quot; class=&quot;php&quot;&gt;    function listControllers() {
        $controllers = App::objects(&#039;controller&#039;);
        $controllers = array_diff($controllers, array(&#039;App&#039;, &#039;Pages&#039;));

        pr($controllers);die();
    }&lt;/textarea&gt;&lt;br /&gt;
Place this code in any of your controllers and view it from the web (for instance, from the Users Controller): http://www.example.com/users/listControllers&lt;br /&gt;
&lt;br /&gt;
You&#039;ll see something similar to the following:&lt;br /&gt;
&lt;textarea name=&quot;code&quot; class=&quot;php&quot;&gt;Array
(
    [2] =&gt; Comments
    [3] =&gt; Posts
    [4] =&gt; Tags
    [5] =&gt; Users
)&lt;/textarea&gt;&lt;br /&gt;
The &lt;a href=&quot;http://api.cakephp.org/class/app#method-Appobjects&quot;&gt;App::objects()&lt;/a&gt; method returns an array of objects of the given type, such as: &#039;model&#039;, &#039;controller&#039;, &#039;helper&#039;, or &#039;plugin&#039; - it also accepts other parameters, such as &quot;path&quot; in case you do eventually need to check controllers for your plugins.&lt;br /&gt;
&lt;br /&gt;
The array_diff() is there as a much simpler method to remove the AppController and PagesController from the returned results as they would most likely exist in your application regardless and aren&#039;t normally something you&#039;d need to worry about with ACL as there are other means within Cake to handle access to them. You&#039;ll notice that array_diff doesn&#039;t return an array starting at index of 0 since it removes keys from the original array too. That shouldn&#039;t be a problem, but if it is you can always use a loop instead of array_diff() and just unset or splice the matching values.&lt;br /&gt;
&lt;br /&gt;
I used the CakePHP convenience method of pr() (print_r surrounded by PRE tags), and a die() simply to show the returned results and print them to the screen. You&#039;d probably prefer to double underscore the function name (__listControllers()) to make it a private method to the class (rather than publicly viewable via the web), and change pr() to &lt;strong&gt;return&lt;/strong&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;What&#039;s the purpose of this?&lt;/strong&gt;&lt;br /&gt;
- Maybe you&#039;d want to create a web interface for ACL and need to know which controllers to give/deny access to/from&lt;br /&gt;
- Maybe you want to create a navigation menu based on your controllers&lt;br /&gt;
...maybe you can think of something that I can&#039;t. :)&lt;br /&gt;
&lt;br /&gt;
Alter to your own tastes. This is only a starting point.&lt;br /&gt;
&lt;br /&gt;
Other useful links (check version compatibility in these resources):&lt;br /&gt;
&lt;a href=&quot;http://debuggable.com/posts/quick-dessert-list-all-controllers-of-a-cakephp-application:480f4dd6-adf4-4b18-9fe8-4b99cbdd56cb&quot;&gt;Quick dessert: List all controllers of a CakePHP application&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://bakery.cakephp.org/articles/view/automatically-load-all-controllers-and-actions-into-aco-tables-for-acl-with-a-cakephp-task&quot;&gt;Automatically load all controllers and actions into ACO tables for ACL with a CakePHP Task&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://cakebaker.42dh.com/2006/07/21/how-to-list-all-controllers/&quot;&gt;How to list all controllers&lt;/a&gt; 
    </content:encoded>

    <pubDate>Tue, 28 Sep 2010 14:08:52 -0700</pubDate>
    <guid isPermaLink="false">http://life.mysiteonline.org/archives/201-guid.html</guid>
    
</item>

</channel>
</rss>
