<?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>Penguinsoft &#187; Code and Servers</title>
	<atom:link href="http://penguinsoft.us/category/code-and-servers/feed/" rel="self" type="application/rss+xml" />
	<link>http://penguinsoft.us</link>
	<description>Application Development, Web Development, Innovative Software Solutions</description>
	<lastBuildDate>Mon, 23 Jan 2012 18:45:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MySQL Class for PHP</title>
		<link>http://penguinsoft.us/2010/08/mysql-class-for-php/</link>
		<comments>http://penguinsoft.us/2010/08/mysql-class-for-php/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 01:57:50 +0000</pubDate>
		<dc:creator>Tomi Lehto</dc:creator>
				<category><![CDATA[Code and Servers]]></category>
		<category><![CDATA[Awesomeness]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://penguinsoft.us/?p=553</guid>
		<description><![CDATA[This should get you started if you're looking to connect to MySQL database.]]></description>
			<content:encoded><![CDATA[<p>This should get you started if you&#8217;re looking to connect to MySQL database.<span id="more-553"></span></p>
<p>Requires a simple configuration file where you keep all your variables (user/password/etc, like SITEDB_HOSTNAME).</p>
<p>To connect, just drop these lines in the code</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysqlClass.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> mysqlClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mystuff</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStuff</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>mysqlClass source:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> mysqlClass <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$_Link</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Construct: Open SQL</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_Link <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span>SITEDB_HOSTNAME<span style="color: #339933;">,</span> SITEDB_USERNAME<span style="color: #339933;">,</span> SITEDB_PASSWORD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SET NAMES 'utf8'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span>SITEDB_DATABASE<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: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_Link<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">callError</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Server connection error: &quot;</span> <span style="color: #339933;">.</span> SITEDB_HOSTNAME <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;.&quot;</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: #339933;">!</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">callError</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Database open error: &quot;</span> <span style="color: #339933;">.</span> SITEDB_DATABASE <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Destruct: Close SQL</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __destruct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_Link<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Update sample</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> updateStuff<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stuff</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
			UPDATE 		stuff
			SET		stuff = '<span style="color: #009933; font-weight: bold;">%s</span>'
			WHERE		id = <span style="color: #009933; font-weight: bold;">%d</span>
		&quot;</span><span style="color: #339933;">,</span>
			<span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stuff</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_Link<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: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">callError</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Update Error: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//Insert Sample</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> insertStuff<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stuff</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
			INSERT INTO		stuff
						(stuff)
				VALUES		('<span style="color: #009933; font-weight: bold;">%s</span>');
		&quot;</span><span style="color: #339933;">,</span>
			<span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stuff</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span> or <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">callError</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Insert Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">mysql_insert_id</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Select Sample</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getStuff<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
                    SELECT          *
                    FROM            stuff
		&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_Link<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: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">callError</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Result error: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$queryresult</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$queryresult</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #990000;">mysql_free_result</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$queryresult</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Show SQL errors</span>
	<span style="color: #000000; font-weight: bold;">function</span> callError<span style="color: #009900;">&#40;</span><span style="color: #000088;">$details</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Database Error: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$details</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' Error: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://penguinsoft.us/2010/08/mysql-class-for-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Show Errors in PHP</title>
		<link>http://penguinsoft.us/2010/07/show-errors-in-php/</link>
		<comments>http://penguinsoft.us/2010/07/show-errors-in-php/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 03:39:57 +0000</pubDate>
		<dc:creator>Tomi Lehto</dc:creator>
				<category><![CDATA[Code and Servers]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://penguinsoft.us/?p=486</guid>
		<description><![CDATA[In the good &#8220;old&#8221; days when 99% of all websites looked horrible, PHP would by default spit out all errors. If you made a mistake in your code, you&#8217;d get gracefully &#8220;notified&#8221;. With PHP 5 we arrived to a new era of hidden rebukes &#8211; page just loads totally blank by default. If you like ...]]></description>
			<content:encoded><![CDATA[<p>In the good &#8220;old&#8221; days when 99% of all websites looked horrible, PHP would by default spit out all errors. If you made a mistake in your code, you&#8217;d get gracefully &#8220;notified&#8221;.</p>
<p>With PHP 5 we arrived to a new era of hidden rebukes &#8211; page just loads totally blank by default.</p>
<p>If you like games, you can just start searching the problem from your source code! If you have less than 100k lines you&#8217;ve got a good chance to find the issue before dawn.</p>
<p>If not, just drop these lines to the beginning of the script &#8211; should be fine&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'display_errors'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">E_ALL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://penguinsoft.us/2010/07/show-errors-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bad SSH Logins</title>
		<link>http://penguinsoft.us/2010/07/bad-ssh-logins/</link>
		<comments>http://penguinsoft.us/2010/07/bad-ssh-logins/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 02:33:00 +0000</pubDate>
		<dc:creator>Kenneth</dc:creator>
				<category><![CDATA[Code and Servers]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[bad]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[logs]]></category>
		<category><![CDATA[mc]]></category>
		<category><![CDATA[profile]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://penguinsoft.us/?p=403</guid>
		<description><![CDATA[On a linux machine all the failed ssh logins go to a log file in /var/log/btmp. So the question being, How do we see this information in a nice understandable format. We could just use the cat utility like so <code>cat /var/log/btmp</code>. After 10 minutes]]></description>
			<content:encoded><![CDATA[<p>On a linux machine all the failed ssh logins go to a log file <span id="more-403"></span>in /var/log/btmp. So the question being, How do we see this information in a nice understandable format. We could just use the cat utility like so <code>cat /var/log/btmp</code>. After 10 minutes of your linux box spewing out a bunch of junk to your terminal you&#8217;ll understand why this is a bad thing. There is a utility called <code>last</code> it is used to see the people who were last logged in. Type <code>last -10</code>. The output is useful but it isn&#8217;t useful for our purposes. We want to see the bad logins not the good logins. It just so happens the <code>last</code> utility accepts a filename parameter. Type <code>last -10 -f /var/log/btmp</code>. Voila! This is exactly what we want to see. You can change the -10 to any number you want and it will show you that number of bad logins. Let&#8217;s put this into an alias in our bash profile. You need to navigate to your bash profile, mine is in /root/.bash_profile. Use a text editor like <code>vi</code> or my favorite <code>mc</code>. Add the following line to the script <code>alias bad='last -10 -f /var/log/btmp</code>. Save it, log out and log back in. Now you can just type <code>bad</code> and it will output what you want! Please leave a comment if this helped you, or if you have a better way of doing it.</p>
]]></content:encoded>
			<wfw:commentRss>http://penguinsoft.us/2010/07/bad-ssh-logins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sanitizing Input in Flash</title>
		<link>http://penguinsoft.us/2010/06/sanitizing-input-in-flash/</link>
		<comments>http://penguinsoft.us/2010/06/sanitizing-input-in-flash/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 00:17:38 +0000</pubDate>
		<dc:creator>Kenneth</dc:creator>
				<category><![CDATA[Code and Servers]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[bbs]]></category>
		<category><![CDATA[characters]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[sanitizing]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://penguinsoft.us/?p=252</guid>
		<description><![CDATA[Let&#8217;s say for example you are creating a bulletin board system or some post system from within flash and you would like to restrict the use of any html or special characters. It turns out there is a very simple and elegant way you can strip out or replace any characters you want to. First ...]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say for example you are creating a bulletin board system or some post system from within flash and you would like to restrict the use of any html or special characters. <span id="more-252"></span>It turns out there is a very simple and elegant way you can strip out or replace any characters you want to.</p>
<p>First we want to declare an array in as3 with all the characters that we don&#8217;t want in our string.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> htmlChars:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
htmlChars<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
htmlChars<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
htmlChars<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;&amp;gt;&quot;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
htmlChars<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;&amp;lt;&quot;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;&quot;</span>;</pre></div></div>

<p>Then all we have to do is to create our function that takes a string as an argument and returns our safe sanitized string.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sanitizeInput<span style="color: #66cc66;">&#40;</span>msg:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> htmlChar:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> htmlChars<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
    	     msg = msg.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span>htmlChar<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span>htmlChars<span style="color: #66cc66;">&#91;</span>htmlChar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">return</span> msg;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Now we can call our function.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> safeString:<span style="color: #0066CC;">String</span> = sanitizeInput<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;</span></pre></div></div>

<p>What we can also do is to replace characters in the string. For example&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">htmlChars<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Bye&quot;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;CYA&quot;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> safeString:<span style="color: #0066CC;">String</span> = sanitizeInput<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Bye for now<span style="color: #000099; font-weight: bold;">\&quot;</span>);
// safeString = &quot;</span>CYA <span style="color: #b1b100;">for</span> now<span style="color: #ff0000;">&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://penguinsoft.us/2010/06/sanitizing-input-in-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Socket Policy Server</title>
		<link>http://penguinsoft.us/2010/03/flash-socket-policy-server/</link>
		<comments>http://penguinsoft.us/2010/03/flash-socket-policy-server/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 17:54:19 +0000</pubDate>
		<dc:creator>Kenneth</dc:creator>
				<category><![CDATA[Code and Servers]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[policy file]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[tcp]]></category>
		<category><![CDATA[tcplistener]]></category>

		<guid isPermaLink="false">http://penguinsoft.us/?p=208</guid>
		<description><![CDATA[We have a custom built communication server that can handle video/audio and text. Well a while back we wrote a flash client for this server. Well Adobe had just updated their flash player to include some new security enhancements one of which involved not allowing cross domain policy files to be served up via HTTP. ...]]></description>
			<content:encoded><![CDATA[<p>We have a custom built communication server that can handle video/audio and text. Well a while back we wrote a flash client for this server. Well Adobe had just updated their flash player to include some new security enhancements one of which involved not allowing cross domain policy files to be served up via HTTP. There had to be a server listening on port 843 in order to serve the policy file. So I went to task of whipping one up real fast.<span id="more-208"></span></p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> TcpListener tcl<span style="color: #008000;">;</span>
        <span style="color: #008080; font-style: italic;">//Generate policy</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">string</span> response <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span> <span style="color: #008000;">+</span>
                                    <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\0</span>&quot;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Starting up server...&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            tcl <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TcpListener<span style="color: #008000;">&#40;</span>IPAddress<span style="color: #008000;">.</span><span style="color: #0000FF;">Any</span>, <span style="color: #FF0000;">843</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            tcl<span style="color: #008000;">.</span><span style="color: #0000FF;">Start</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            tcl<span style="color: #008000;">.</span><span style="color: #0000FF;">BeginAcceptSocket</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> AsyncCallback<span style="color: #008000;">&#40;</span>AcceptCallback<span style="color: #008000;">&#41;</span>, tcl<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Hit enter/return to close&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadLine</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> AcceptCallback<span style="color: #008000;">&#40;</span>IAsyncResult ar<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">try</span>
            <span style="color: #008000;">&#123;</span>
                TcpListener listener <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
                Socket client <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
&nbsp;
                listener <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>TcpListener<span style="color: #008000;">&#41;</span>ar<span style="color: #008000;">.</span><span style="color: #0000FF;">AsyncState</span><span style="color: #008000;">;</span>
                client <span style="color: #008000;">=</span> listener<span style="color: #008000;">.</span><span style="color: #0000FF;">EndAcceptSocket</span><span style="color: #008000;">&#40;</span>ar<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                NetworkStream ns <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> NetworkStream<span style="color: #008000;">&#40;</span>client<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                StreamReader sr <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StreamReader<span style="color: #008000;">&#40;</span>ns<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                StreamWriter sw <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StreamWriter<span style="color: #008000;">&#40;</span>ns<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                sr<span style="color: #008000;">.</span><span style="color: #0000FF;">Read</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008080; font-style: italic;">//Send policy</span>
                sw<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span>response<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                sw<span style="color: #008000;">.</span><span style="color: #0000FF;">Flush</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                ns<span style="color: #008000;">.</span><span style="color: #0000FF;">Flush</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008080; font-style: italic;">//Cleanup</span>
                sw<span style="color: #008000;">.</span><span style="color: #0000FF;">Close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                sr<span style="color: #008000;">.</span><span style="color: #0000FF;">Close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                ns<span style="color: #008000;">.</span><span style="color: #0000FF;">Close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                client<span style="color: #008000;">.</span><span style="color: #0000FF;">Close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008080; font-style: italic;">//Do it again!</span>
                tcl<span style="color: #008000;">.</span><span style="color: #0000FF;">BeginAcceptSocket</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> AsyncCallback<span style="color: #008000;">&#40;</span>AcceptCallback<span style="color: #008000;">&#41;</span>, tcl<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
            <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>Exception e<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span>e<span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span></pre></div></div>

<p>So there it is. A quick and dirty flash socket policy server written in c#. You can compile/run this in windows or linux running mono. I&#8217;ve been using a modified version of this for quite some time to handle tens of thousands of users and never had a problem with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://penguinsoft.us/2010/03/flash-socket-policy-server/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Multi-language support in T-SQL</title>
		<link>http://penguinsoft.us/2010/03/multi-language-support-in-t-sql/</link>
		<comments>http://penguinsoft.us/2010/03/multi-language-support-in-t-sql/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 06:02:55 +0000</pubDate>
		<dc:creator>Tomi Lehto</dc:creator>
				<category><![CDATA[Code and Servers]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://penguinsoft.us/?p=200</guid>
		<description><![CDATA[This is brilliant, a little scary, but brilliant. (note added July 2010: OK, A LOT SCARY!) While back we built a website supporting unlimited languages and articles. For a reason unknown I decided to keep all my content in one table, index it and link my other tables to it. This concept is quite interesting, ...]]></description>
			<content:encoded><![CDATA[<p>This is brilliant, a little scary, but brilliant. (note added July 2010: OK, A LOT SCARY!)</p>
<p>While back we built a website supporting unlimited languages and articles. For a reason unknown I decided to keep all my content in one table, index it and link my other tables to it.<span id="more-200"></span></p>
<p>This concept is quite interesting, I think it&#8217;s worth a look. Check out a sample Stored Procedure:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> dbo<span style="color: #66cc66;">.</span>SPSelectArticles
	@categoryid <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">,</span>
	@languageid <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">,</span>
	@defaultlanguageid <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">,</span>
	@maxarticles <span style="color: #993333; font-weight: bold;">INT</span>
<span style="color: #993333; font-weight: bold;">AS</span>
<span style="color: #993333; font-weight: bold;">SET</span> ROWCOUNT @maxarticles
	<span style="color: #993333; font-weight: bold;">SELECT</span>
			A<span style="color: #66cc66;">.</span>id <span style="color: #993333; font-weight: bold;">AS</span> id<span style="color: #66cc66;">,</span> CT<span style="color: #66cc66;">.</span>content <span style="color: #993333; font-weight: bold;">AS</span> title<span style="color: #66cc66;">,</span> CD<span style="color: #66cc66;">.</span>content <span style="color: #993333; font-weight: bold;">AS</span> description<span style="color: #66cc66;">,</span> A<span style="color: #66cc66;">.</span>publishdate <span style="color: #993333; font-weight: bold;">AS</span> publishdate<span style="color: #66cc66;">,</span> AC<span style="color: #66cc66;">.</span>color <span style="color: #993333; font-weight: bold;">AS</span> categorycolor<span style="color: #66cc66;">,</span>
			<span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">AS</span> iscorrectlanguage
	<span style="color: #993333; font-weight: bold;">FROM</span>	articles A
	<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span>
		contentitems CT <span style="color: #993333; font-weight: bold;">ON</span> CT<span style="color: #66cc66;">.</span>cid <span style="color: #66cc66;">=</span> A<span style="color: #66cc66;">.</span>title_cid <span style="color: #993333; font-weight: bold;">AND</span> CT<span style="color: #66cc66;">.</span>languageid <span style="color: #66cc66;">=</span> @languageid
	<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span>
		contentitems CD <span style="color: #993333; font-weight: bold;">ON</span> CD<span style="color: #66cc66;">.</span>cid <span style="color: #66cc66;">=</span> A<span style="color: #66cc66;">.</span>description_cid <span style="color: #993333; font-weight: bold;">AND</span> CD<span style="color: #66cc66;">.</span>languageid <span style="color: #66cc66;">=</span> @languageid
	<span style="color: #993333; font-weight: bold;">INNER</span> <span style="color: #993333; font-weight: bold;">JOIN</span>
		articlecategories AC <span style="color: #993333; font-weight: bold;">ON</span> A<span style="color: #66cc66;">.</span>categoryid <span style="color: #66cc66;">=</span> AC<span style="color: #66cc66;">.</span>id
	<span style="color: #993333; font-weight: bold;">WHERE</span>	A<span style="color: #66cc66;">.</span>publishdate &amp;lt; GETDATE<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span>
		A<span style="color: #66cc66;">.</span>categoryid <span style="color: #66cc66;">=</span> @categoryid <span style="color: #993333; font-weight: bold;">AND</span>
		CT<span style="color: #66cc66;">.</span>content <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
<span style="color: #993333; font-weight: bold;">UNION</span> <span style="color: #993333; font-weight: bold;">ALL</span>
	<span style="color: #993333; font-weight: bold;">SELECT</span>
			A<span style="color: #66cc66;">.</span>id <span style="color: #993333; font-weight: bold;">AS</span> id<span style="color: #66cc66;">,</span> CTD<span style="color: #66cc66;">.</span>content <span style="color: #993333; font-weight: bold;">AS</span> title<span style="color: #66cc66;">,</span> CDD<span style="color: #66cc66;">.</span>content <span style="color: #993333; font-weight: bold;">AS</span> description<span style="color: #66cc66;">,</span> A<span style="color: #66cc66;">.</span>publishdate <span style="color: #993333; font-weight: bold;">AS</span> publishdate<span style="color: #66cc66;">,</span> AC<span style="color: #66cc66;">.</span>color <span style="color: #993333; font-weight: bold;">AS</span> categorycolor<span style="color: #66cc66;">,</span>
			<span style="color: #cc66cc;">0</span> <span style="color: #993333; font-weight: bold;">AS</span> iscorrectlanguage
	<span style="color: #993333; font-weight: bold;">FROM</span>	articles A
	<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span>
		contentitems CTD <span style="color: #993333; font-weight: bold;">ON</span> CTD<span style="color: #66cc66;">.</span>cid <span style="color: #66cc66;">=</span> A<span style="color: #66cc66;">.</span>title_cid <span style="color: #993333; font-weight: bold;">AND</span> CTD<span style="color: #66cc66;">.</span>languageid <span style="color: #66cc66;">=</span> @defaultlanguageid
	<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span>
		contentitems CDD <span style="color: #993333; font-weight: bold;">ON</span> CDD<span style="color: #66cc66;">.</span>cid <span style="color: #66cc66;">=</span> A<span style="color: #66cc66;">.</span>description_cid <span style="color: #993333; font-weight: bold;">AND</span> CDD<span style="color: #66cc66;">.</span>languageid <span style="color: #66cc66;">=</span> @defaultlanguageid
	<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span>
		contentitems CT <span style="color: #993333; font-weight: bold;">ON</span> CT<span style="color: #66cc66;">.</span>cid <span style="color: #66cc66;">=</span> A<span style="color: #66cc66;">.</span>title_cid <span style="color: #993333; font-weight: bold;">AND</span> CT<span style="color: #66cc66;">.</span>languageid <span style="color: #66cc66;">=</span> @languageid
	<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span>
		contentitems CD <span style="color: #993333; font-weight: bold;">ON</span> CD<span style="color: #66cc66;">.</span>cid <span style="color: #66cc66;">=</span> A<span style="color: #66cc66;">.</span>description_cid <span style="color: #993333; font-weight: bold;">AND</span> CD<span style="color: #66cc66;">.</span>languageid <span style="color: #66cc66;">=</span> @languageid
	<span style="color: #993333; font-weight: bold;">INNER</span> <span style="color: #993333; font-weight: bold;">JOIN</span>
		articlecategories AC <span style="color: #993333; font-weight: bold;">ON</span> A<span style="color: #66cc66;">.</span>categoryid <span style="color: #66cc66;">=</span> AC<span style="color: #66cc66;">.</span>id
	<span style="color: #993333; font-weight: bold;">WHERE</span>	A<span style="color: #66cc66;">.</span>publishdate &amp;lt; GETDATE<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span>
		A<span style="color: #66cc66;">.</span>categoryid <span style="color: #66cc66;">=</span> @categoryid <span style="color: #993333; font-weight: bold;">AND</span>
		CT<span style="color: #66cc66;">.</span>content <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NULL</span>
		<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> A<span style="color: #66cc66;">.</span>publishdate <span style="color: #993333; font-weight: bold;">DESC</span></pre></div></div>

<p>The big idea is to pass a language id to this SP, and it does the rest. All the content on a page just changes based on the languageid. I built SP&#8217;s like this for main content, random words here and there and this one for articles.</p>
<p>Beauty in this beast is the fact that it looks if translation exists, and returns the default language if not found &#8211; in this case English. And it&#8217;s reasonably fast, this is written around 4 years ago!</p>
<p>Site has now served almost 6 million (yes, millions) page views in the past 2 years, and is still going strong.</p>
<p>Let me know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://penguinsoft.us/2010/03/multi-language-support-in-t-sql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Updates and Joins in MySQL</title>
		<link>http://penguinsoft.us/2010/03/updates-and-joins-in-mysql/</link>
		<comments>http://penguinsoft.us/2010/03/updates-and-joins-in-mysql/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 01:08:44 +0000</pubDate>
		<dc:creator>Tomi Lehto</dc:creator>
				<category><![CDATA[Code and Servers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://penguinsoft.us/?p=183</guid>
		<description><![CDATA[Now this is supremely hot. You can update a whole set of information from one table to another without passing any data from your PHP. Not sure if this works with MS SQL, I&#8217;ll check next time I&#8217;m around those machines. Here is what I was after: Users on a website need the ability to ...]]></description>
			<content:encoded><![CDATA[<p>Now this is supremely hot. You can update a whole set of information from one table to another without passing any data from your PHP. Not sure if this works with MS SQL, I&#8217;ll check next time I&#8217;m around those machines.<span id="more-183"></span></p>
<p>Here is what I was after:</p>
<ol>
<li>Users on a website need the ability to customize their personal pages</li>
<li>We want to make it easy for them by using themes (pre-selected styles, fonts, colors)</li>
<li>Users must have the ability to adjust their theme if they so desire</li>
</ol>
<p>Here is what I did:</p>
<ol>
<li>Created a theme table to MySQL that includes all the fancy style columns, like font styles, colors, etc</li>
<li>Added columns to users page table to match those theme styles</li>
<li>I created a PHP function to apply a theme based on theme selected, and user&#8217;s id</li>
</ol>
<p>Awesomeness in this case comes to play when it&#8217;s time to change the theme. PHP is from a data object that has user id already set:</p>
<p>PHP Code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setPageTheme<span style="color: #009900;">&#40;</span><span style="color: #000088;">$themeid</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
        UPDATE userpages U
        INNER JOIN themes T ON T.themeid = <span style="color: #009933; font-weight: bold;">%d</span>
        SET U.background=T.background, U.font=T.font, U.textcolor=T.textcolor
        WHERE U.userid = <span style="color: #009933; font-weight: bold;">%d</span>
    &quot;</span><span style="color: #339933;">,</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">esc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$themeid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">userid</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_Link<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: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">callError</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So now you&#8217;ve got the theme transferred to users page, and then you just build a page where user can customize the theme further if they so desire. How cool is that? <img src='http://penguinsoft.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Hopefully this saves you some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://penguinsoft.us/2010/03/updates-and-joins-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Increasing max upload limit in WordPress</title>
		<link>http://penguinsoft.us/2010/03/max-upload-in-wordpress/</link>
		<comments>http://penguinsoft.us/2010/03/max-upload-in-wordpress/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 23:37:34 +0000</pubDate>
		<dc:creator>Tomi Lehto</dc:creator>
				<category><![CDATA[Code and Servers]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://penguinsoft.us/?p=169</guid>
		<description><![CDATA[I was working on adding some fancy media content  for one of my customers, and WordPress gave me this error: EPIC FAIL. This file is too big. The maximum upload size for your server is 2M. Ok, I added the fail. It wasn&#8217;t WordPress! Did some research and found this simple and easy solution to ...]]></description>
			<content:encoded><![CDATA[<p>I was working on adding some fancy media content  for one of my customers, and WordPress gave me this error:</p>
<pre>EPIC FAIL.
This file is too big. The maximum upload size for your server is 2M.</pre>
<p><span id="more-169"></span><br />
Ok, I added the fail. It wasn&#8217;t WordPress!</p>
<p>Did some research and found this simple and easy solution to increase the limit that should work on a shared host as well:</p>
<ol>
<li>Login to your web server</li>
<li>Find the root folder for wordpress (where all the good stuff is)</li>
<li>Edit .htaccess file (or create one if it doesn&#8217;t exist)</li>
<li>Add following lines to the file
<pre>php_value max_input_time 250
php_value max_execution_time 250
php_value upload_max_filesize 15M
php_value post_max_size 15M</pre>
</li>
<li>Save the file</li>
<li>This should allow you to post decent size files, and give you enough time for processing without server timing you out.</li>
</ol>
<p>Let me know if this works for you!</p>
]]></content:encoded>
			<wfw:commentRss>http://penguinsoft.us/2010/03/max-upload-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

