<?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>Design vs. Develop &#187; javascript</title>
	<atom:link href="http://www.designvsdevelop.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.designvsdevelop.com</link>
	<description>the department of planned spontaneity</description>
	<lastBuildDate>Tue, 23 Feb 2010 14:25:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The way NOT to do JavaScript in Joomla!</title>
		<link>http://www.designvsdevelop.com/the-way-not-to-do-javascript-in-joomla/</link>
		<comments>http://www.designvsdevelop.com/the-way-not-to-do-javascript-in-joomla/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 19:01:54 +0000</pubDate>
		<dc:creator>Joe LeBlanc</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[dcphp]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[raw]]></category>

		<guid isPermaLink="false">http://www.designvsdevelop.com/?p=352</guid>
		<description><![CDATA[While doing a little Sunday afternoon browsing of Twitter, I noticed Amy Stephen warning about a bad technique for using Joomla! with AJAX-style requests. I followed the link (WARNING: don&#8217;t use this code!) and found security vulnerabilities right away. Since the blog in question doesn&#8217;t support comments, I&#8217;m forced to respond here.
First, as Amy pointed out, [...]]]></description>
			<content:encoded><![CDATA[<p>While doing a little Sunday afternoon browsing of Twitter, I noticed Amy Stephen <a href="http://twitter.com/AmyStephen/status/3088009866">warning</a> about a bad technique for using Joomla! with AJAX-style requests. I followed the <a href="http://www.prodevtips.com/2009/08/01/adding-ajax-to-joomla-15-with-jquery/">link</a> (<strong>WARNING:</strong> don&#8217;t use this code!) and found security vulnerabilities right away. Since the blog in question doesn&#8217;t support comments, I&#8217;m forced to respond here.</p>
<p>First, as Amy pointed out, the technique creates another entry point into Joomla. While this <em>can</em> be used effectively if you know what you&#8217;re doing, it&#8217;s totally unnecessary for a casual application of asynchronous JavaScript. Next, class, who can tell me what&#8217;s wrong with this piece of code?</p>
<pre>cExt( $_POST['func'] );</pre>
<p>That&#8217;s right, we&#8217;re passing data straight from our HTTP request (which can come from anywhere in the WORLD) into our application&#8217;s logic. Once we get into the the <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre; ">cExt <span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, fantasy; line-height: 19px; white-space: normal; font-size: 13px; ">function, the variable is used to execute code with <strong>no</strong> filtering whatsoever:</span></span></p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">function cExt($func = &#8221;){</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$cext = null;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if(!empty($GLOBALS['cExt']))</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$cext = $GLOBALS['cExt'];</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">else{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$GLOBALS['cExt'] = new plgCommunityExt();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$cext = $GLOBALS['cExt'];</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if(empty($func))</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">return $cext;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">else{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if($GLOBALS['ajax'] == true)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$cext-&gt;$func();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">else</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">return $cext-&gt;$func();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<pre>function cExt($func = ''){

    $cext = null;

    if(!empty($GLOBALS['cExt']))

        $cext = $GLOBALS['cExt'];

    else{

        $GLOBALS['cExt'] = new plgCommunityExt();

        $cext = $GLOBALS['cExt'];

    }

    if(empty($func))

        return $cext;

    else{

        if($GLOBALS['ajax'] == true)

            $cext-&gt;$func();

        else

            return $cext-&gt;$func();

    }

}</pre>
<p>Please, regardless of whether or not you use Joomla, don&#8217;t do this! It is a totally insecure way of writing code. Instead, if you are using Joomla, you can at least filter this variable using the following code:</p>
<pre>$func = JRequest::getCmd('func', '');</pre>
<p>This code will filter the <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre; ">func</span> variable from the request and make sure it only includes numbers, letters, or underscores. Additionally, you should filter <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre; ">$func</span> to make sure a corresponding public function in the <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre; ">plgCommunityExt<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, fantasy; line-height: 19px; white-space: normal; font-size: 13px; "> class exists <strong>before</strong> attempting to use it to actually execute that function.</span></span></p>
<p>As a side note, <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre; ">$GLOBALS</span> is being used an awful lot here. While this isn&#8217;t a security risk in and of itself, it is a bad practice that can lead to insecure coding. If the <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre; ">register_globals</span> setting in PHP (going away in PHP 6) is turned on, this becomes a huge security risk as anyone in the world can set the value of <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre; ">cExt</span> to anything.</p>
<p>The post ends with this quick jibe:</p>
<address>That was pretty easy wasn’t it, in order to get quick results you just have to find these shortcuts which will spare you the time and pain of having to read some Joomla-, or pick your favorite, CMS book.</address>
<p>I&#8217;d argue that the author of this blog post would not only benefit from reading a book about CMS development, but one on basic PHP security. The technique he describes is insecure in any PHP-based framework or CMS.</p>
<p>Fortunately, you don&#8217;t even have to run to the bookstore to find examples of the correct way of doing these things. Louis Landry has a quick example of how to return JSON formatted data simply and securely on <a href="http://groups.google.com/group/joomla-dev-cms/browse_thread/thread/5ac0b49c0f458b1a">this thread</a>, without having to create a special component view. If you do want to use a view, this <a href="http://blog.syncleon.com/2009/05/ajax-ify-your-joomla-website.html">blog post</a> will show you how to do it.</p>
<p>Finally, if you do want to learn how to add AJAX-style requests to Joomla (without necessarily using JSON), I&#8217;ll shamelessly plug <a href="http://www.packtpub.com/learning-joomla-1.5-extension-development/book">my own book</a>. But you don&#8217;t even have to buy it, because the <a href="http://www.packtpub.com/files/learning-joomla-1-5-extension-development-sample-chapter-8-using-javascript-effects.pdf">sample chapter</a> is indeed the one on JavaScript and Joomla (start on page 168 if you already know Joomla! MVC).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.designvsdevelop.com/the-way-not-to-do-javascript-in-joomla/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using MooTools and jQuery Together in Joomla!</title>
		<link>http://www.designvsdevelop.com/using-mootools-and-jquery-together-in-joomla/</link>
		<comments>http://www.designvsdevelop.com/using-mootools-and-jquery-together-in-joomla/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 16:33:17 +0000</pubDate>
		<dc:creator>Joe LeBlanc</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Joomla 1.5]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://www.designvsdevelop.com/?p=312</guid>
		<description><![CDATA[Framework conflicts are a common problem people run into when using jQuery. While jQuery provides some tricks you can use to get around this, you may still run into issues when Joomla! generates MooTools effects. While writing the second edition of Learning Joomla! Extension Development, I decided to do a chapter on JavaScript and look [...]]]></description>
			<content:encoded><![CDATA[<p>Framework conflicts are a common problem people run into when using jQuery. While jQuery provides some <a href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries">tricks you can use</a> to get around this, you may still run into issues when Joomla! generates MooTools effects. While writing the second edition of <a href="http://www.packtpub.com/learning-joomla!-1.5-extension-development/book">Learning Joomla! Extension Development</a>, I decided to do a chapter on JavaScript and look into this problem a little bit more closely. It turns out you have to make sure MooTools loads before jQuery, then use one of the tricks detailed on jquery.com.</p>
<p>Fortunately, this can be done in Joomla! consistenly, so I documented it. Packt decided to release the entire JavaScript chapter as the <a href="http://www.packtpub.com/files/learning-joomla-1-5-extension-development-sample-chapter-8-using-javascript-effects.pdf">sample PDF</a> for my book, so you can read everything you need to know about implementing this technique for free!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.designvsdevelop.com/using-mootools-and-jquery-together-in-joomla/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some software I&#8217;ve been using recently</title>
		<link>http://www.designvsdevelop.com/some-software-ive-been-using-recently/</link>
		<comments>http://www.designvsdevelop.com/some-software-ive-been-using-recently/#comments</comments>
		<pubDate>Tue, 08 Jan 2008 18:03:59 +0000</pubDate>
		<dc:creator>Joe LeBlanc</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cyberduck]]></category>
		<category><![CDATA[flot]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macfuse]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[sshfs]]></category>

		<guid isPermaLink="false">http://www.designvsdevelop.com/?p=233</guid>
		<description><![CDATA[Flot &#8211; Want to build dynamic graphs without using Flash? Flot is ready. It&#8217;s lightweight and pretty quick to pick up. I&#8217;m using it for a project where people can add and remove as many data series as they wish. Throw in some JSON calls and the results are pretty impressive. Although I can&#8217;t show [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flot</strong> &#8211; Want to build dynamic graphs without using Flash? <a href="http://code.google.com/p/flot/">Flot</a> is ready. It&#8217;s lightweight and pretty quick to pick up. I&#8217;m using it for a project where people can add and remove as many data series as they wish. Throw in some JSON calls and the results are pretty impressive. Although I can&#8217;t show off that project here, take a look at some of the posted <a href="http://people.iola.dk/olau/flot/examples/">examples</a>. It&#8217;s based on <a href="http://www.jquery.com">jQuery</a> and produced by a Danish <a href="http://www.iola.dk/english.html">firm</a>.</p>
<p><strong>MacFUSE and SSHFS</strong> &#8211; One of the biggest problems I&#8217;ve run into with using Macs is that Finder cannot mount FTP and SFTP sites as writable volumes. While you can get clients like <a href="http://cyberduck.ch/">CyberDuck</a> that will allow you to do transfers, editing the files for an entire website this way can be tedious. Using <a href="http://code.google.com/p/macfuse/">MacFUSE and SSHFS</a> together can get around this limitation. SSHFS is still in a very early release and I did run into some stability issues when mounted all day long, but the core functionality is there.</p>
<p><strong>Selenium IDE</strong> &#8211; Testing and debugging web interfaces has always been a bit of a pain, but <a href="http://www.openqa.org/selenium-ide/">Selenium IDE</a> can make the process much, much faster. Open up the IDE, click record, then start filling out forms and clicking on elements. Then you can save your test and reopen it later to run it whenever you wish. I did run into a few issues where Javascript generated DOM elements confused the debugger (might be a timing issue), but overall it is a very powerful and easy to use Firefox extension. You can also use <a href="http://www.openqa.org/selenium-core/">Selenium Core</a> on other browsers. I haven&#8217;t tried this, but it appears that you can record the test using the IDE in Firefox, then use that same test with Core with the other browsers. Thanks to <a href="http://www.laurathomson.com/">Laura Thomson</a> for mentioning this one at the <a href="http://dcphpconference.com">DC PHP Conference</a> this past fall.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.designvsdevelop.com/some-software-ive-been-using-recently/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
