<?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>nlstudio.se</title>
	<atom:link href="http://nlstudio.se/feed/" rel="self" type="application/rss+xml" />
	<link>http://nlstudio.se</link>
	<description>Grafiker, Fotograf och Programmerarer</description>
	<lastBuildDate>Fri, 28 Oct 2011 14:01:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Apple looses ALAC</title>
		<link>http://nlstudio.se/blog/apple-looses-alac/</link>
		<comments>http://nlstudio.se/blog/apple-looses-alac/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 14:01:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Alac]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[Fidelity]]></category>
		<category><![CDATA[Open]]></category>
		<category><![CDATA[Quality]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://nlstudio.se/?p=53</guid>
		<description><![CDATA[ALAC, wich stands for &#8221;Apple Lossless is a lossless audio codec that Apple developed some time ago for digital music. The codec can compress music files anywhere from 40-60% of their original size with no discernible loss in audio quality (&#8230;)</p><p><a href="http://nlstudio.se/blog/apple-looses-alac/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>ALAC, wich stands for &#8221;Apple Lossless is a lossless audio codec that Apple developed some time ago for digital music. The codec can compress music files anywhere from 40-60% of their original size with no discernible loss in audio quality or fidelity.</p>
<p>Apple&#8217;s ALAC codec is now open source.</p>
]]></content:encoded>
			<wfw:commentRss>http://nlstudio.se/blog/apple-looses-alac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress categories with descriptions</title>
		<link>http://nlstudio.se/php/wordpress-categories-with-descriptions/</link>
		<comments>http://nlstudio.se/php/wordpress-categories-with-descriptions/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 19:49:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Categories]]></category>
		<category><![CDATA[Descriptions]]></category>

		<guid isPermaLink="false">http://nlstudio.se/?p=42</guid>
		<description><![CDATA[Some WordPress-themes has the description of the category below the category name. This is not standard in WordPress. So this is how you can do it]]></description>
			<content:encoded><![CDATA[<p>Some WordPress-themes has the description of the category below the category name.<br />
This is not standard in WordPress.<br />
So this is how you can do it</p>
<pre class="brush: php; title: ; notranslate">
$args=array(
);
$categories=get_categories($args);
foreach($categories as $category) {
echo '&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;' . get_category_link( $category-&gt;term_id ) . '&quot; title=&quot;' . sprintf( __( &quot;View all posts in %s&quot; ), $category-&gt;name ) . '&quot; ' . '&gt;' . $category-&gt;name.'&lt;/a&gt;&lt;/strong&gt;';
echo '&lt;br /&gt;'. $category-&gt;description . '&lt;/li&gt;';
}
</pre>
<pre class="brush: css; title: ; notranslate">
#wpyagnav{
height: 61px;
background: #d0d0d0;
margin-left: auto;
margin-right: auto;
width: 980px;
}

ul.wpyagcat{
padding-top: 11px;
}

ul.wpyagcat li{
display: inline;
float: left;
position: relative;
margin-left: 18px;
text-align: center;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://nlstudio.se/php/wordpress-categories-with-descriptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Charset</title>
		<link>http://nlstudio.se/tips/charset/</link>
		<comments>http://nlstudio.se/tips/charset/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 10:35:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Charset]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://nlstudio.se/?p=36</guid>
		<description><![CDATA[For those of you who have troubles with Charset (it&#8217;s easy to forget!) in your code, you can add the code to your .htaccess to make sure that all your pages are shown in correct charset! Even if you forget (&#8230;)</p><p><a href="http://nlstudio.se/tips/charset/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>For those of you who have troubles with Charset (it&#8217;s easy to forget!) in your code, you can add the code to your .htaccess to make sure that all your pages are shown in correct charset! Even if you forget to add charset on your pages! </p>
<pre class="brush: php; title: ; notranslate">
&lt;FilesMatch &quot;\.(htm|html|css|js)$&quot;&gt;
AddDefaultCharset UTF-8
&lt;/FilesMatch&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://nlstudio.se/tips/charset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email validation with filter_var</title>
		<link>http://nlstudio.se/blog/email-validation-with-filter_var/</link>
		<comments>http://nlstudio.se/blog/email-validation-with-filter_var/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 10:54:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Regexp]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://nlstudio.se/?p=28</guid>
		<description><![CDATA[When having a website that allows user-registration it&#8217;s good to check that the user data inputed is valid. A lot of people use RegExp to check if an email is valid. This is generally not the best way to do (&#8230;)</p><p><a href="http://nlstudio.se/blog/email-validation-with-filter_var/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>When having a website that allows user-registration it&#8217;s good to check that the user data inputed is valid. A lot of people use RegExp to check if an email is valid. This is generally not the best way to do it. I recently came across a good way to do e-mail verification by using the php filter_var function.</p>
<p>This is how it&#8217;s done</p>
<pre class="brush: php; title: ; notranslate">
$email = &quot;someone@exa mple.com&quot;;

if(!filter_var($email, FILTER_VALIDATE_EMAIL))
  {
  echo &quot;E-mail is not valid&quot;;
  // Rest of PHP-code
  }
else
  {
  echo &quot;E-mail is valid&quot;;
  // Rest of PHP-code
  }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://nlstudio.se/blog/email-validation-with-filter_var/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Secure GET with intval</title>
		<link>http://nlstudio.se/blog/secure-get-with-intval/</link>
		<comments>http://nlstudio.se/blog/secure-get-with-intval/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 10:45:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Intval]]></category>
		<category><![CDATA[Secure]]></category>

		<guid isPermaLink="false">http://nlstudio.se/?p=24</guid>
		<description><![CDATA[A big problem, and a rather common one, is that users try to modify (read: hack) a websites to do things that the code wasen&#8217;t supposed to. Such as allow a basic user &#8211; to gain admin-access. This can easily (&#8230;)</p><p><a href="http://nlstudio.se/blog/secure-get-with-intval/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>A big problem, and a rather common one, is that users try to modify (read: hack) a websites to do things that the code wasen&#8217;t supposed to. Such as allow a basic user &#8211; to gain admin-access. This can easily be done by changing the data posted by $_GET.</p>
<p>So &#8211; how can we prevent this?<br />
By using php&#8217;s function called intval() we can check that it returns as an integer.</p>
<p>This is how it can be done:</p>
<pre class="brush: php; title: ; notranslate">
// Echo out the user-id wich we get from $_GET wich will return 1 or 1=1
echo $_GET['userId'];
// Wrap the $_GET with intval()-function and set it to the $id variable
$id=intval($_GET['userId']);
// Echoing out the id will now return '1'
echo $id; // 1

// We're now selecting som the table &quot;users&quot; with out '$id' var - wich is a clean integer variable! This is safe!
mysql_query('SELECT * FROM users WHERE id='.$id);
</pre>
<p><em>Do remember to sanitize your variables with more functions if they contain other data than just integers. Using stripslashes and mysql_real_escape_string is a good method! More on this in a later post!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://nlstudio.se/blog/secure-get-with-intval/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RegExp snippets</title>
		<link>http://nlstudio.se/blog/regexp-snippets/</link>
		<comments>http://nlstudio.se/blog/regexp-snippets/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 10:35:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Regexp]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://nlstudio.se/?p=18</guid>
		<description><![CDATA[I recently came across a webpage that shares some RegExp code for some verification-purposes. And as i use RegExp a lot in my projects to check/validate &#8211; i thought i&#8217;d share it with the rest of you. Validate username Validate (&#8230;)</p><p><a href="http://nlstudio.se/blog/regexp-snippets/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I recently came across a webpage that shares some RegExp code for some verification-purposes. And as i use RegExp a lot in my projects to check/validate &#8211; i thought i&#8217;d share it with the rest of you.</p>
<p><strong>Validate username</strong></p>
<p><em>Validate username, consist of alpha-numeric (a-z, A-Z, 0-9), underscores, and has minimum 5 character and maximum 20 character. You could change the minimum character and maximum character to any number you like.</em></p>
<pre class="brush: php; title: ; notranslate">
$username = &quot;user_name12&quot;;
if (preg_match('/^[a-z\d_]{5,20}$/i', $username)) {
    echo &quot;Your username is ok.&quot;;
} else {
    echo &quot;Wrong username format.&quot;;
}
</pre>
<p><strong>Validate IP addresses</strong></p>
<p><em>Validate Ip adresses</em></p>
<pre class="brush: php; title: ; notranslate">
$IP = &quot;198.168.1.78&quot;;
if (preg_match('/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/',$IP)) {
    echo &quot;Your IP address is ok.&quot;;
} else {
    echo &quot;Wrong IP address.&quot;;
}
</pre>
<p><strong>Validate Creditcard</strong></p>
<p><em>Validate creditcards with this regexp</em></p>
<pre class="brush: php; title: ; notranslate">
$cc = &quot;378282246310005&quot;;
if (preg_match('/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/', $cc)) {
    echo &quot;Your credit card number is ok.&quot;;
} else {
    echo &quot;Wrong credit card number.&quot;;
}
</pre>
<p><strong>Validate URL&#8217;s</strong></p>
<p><em>Used to validate the urls</em></p>
<pre class="brush: php; title: ; notranslate">
$url = &quot;http://nlstudio.se/&quot;;
if (preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $url)) {
    echo &quot;Your url is ok.&quot;;
} else {
    echo &quot;Wrong url.&quot;;
}
</pre>
<p><strong>Extract domain name from certain URL</strong></p>
<p><em>This regexp will extract the domainname from a URL</em></p>
<pre class="brush: php; title: ; notranslate">
$url = &quot;http://nlstudio.com/index.html&quot;;
preg_match('@^(?:http://)?([^/]+)@i', $url, $matches);
$host = $matches[1];

echo $host;
</pre>
<p><strong>Highlight</strong></p>
<p><em>Used to highlight certain words in a string</em></p>
<pre class="brush: php; title: ; notranslate">
$text = &quot;This is a sample text from nlstudio where you can read more about php, webdesign, photography and get to know the user behind the blog.&quot;;

$text = preg_replace(&quot;/\b(nlstudio)\b/i&quot;, '&lt;span style=&quot;background:#5fc9f6&quot;&gt;\1&lt;/span&gt;', $text);

echo $text;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://nlstudio.se/blog/regexp-snippets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filter out duplicate data from MySQL</title>
		<link>http://nlstudio.se/blog/filter-out-duplicate-data-from-mysql/</link>
		<comments>http://nlstudio.se/blog/filter-out-duplicate-data-from-mysql/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 08:53:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Duplicates]]></category>
		<category><![CDATA[Filter]]></category>
		<category><![CDATA[Rows]]></category>

		<guid isPermaLink="false">http://nlstudio.se/?p=14</guid>
		<description><![CDATA[Alright &#8211; i did this big mistake &#8211; i forgot to check and see if a user-email was registerd in the database before another user was added (i wasen&#8217;t going to allow 2 account per email!). If i had a (&#8230;)</p><p><a href="http://nlstudio.se/blog/filter-out-duplicate-data-from-mysql/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Alright &#8211; i did this big mistake &#8211; i forgot to check and see if a user-email was registerd in the database before another user was added (i wasen&#8217;t going to allow 2 account per email!). If i had a small databas with just a few users &#8211; i could go through them manually and remove those rows. But i have quite a few users on my webpage &#8211; so i went the easier way &#8211; sql!</p>
<pre class="brush: sql; title: ; notranslate">
select email,count(email) from `tbl_users`
group by email having count(email) &gt; 1
</pre>
<p>By doing this is could see wich emails where registered 2+ and simply remove them!</p>
]]></content:encoded>
			<wfw:commentRss>http://nlstudio.se/blog/filter-out-duplicate-data-from-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>censor-functions</title>
		<link>http://nlstudio.se/blog/censor-functions/</link>
		<comments>http://nlstudio.se/blog/censor-functions/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 21:00:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nlstudio.se/?p=9</guid>
		<description><![CDATA[Needed a simple function to check for bad words on my webpage &#8211; so i made a function for it. Just wrap it around your variable like this: And make sure that your functions.php file contains this code:]]></description>
			<content:encoded><![CDATA[<p>Needed a simple function to check for bad words on my webpage &#8211; so i made a function for it.<br />
Just wrap it around your variable like this:</p>
<pre class="brush: php; title: ; notranslate">
include ('includes/functions.php');
censor($userPost);
</pre>
<p>And make sure that your functions.php file contains this code:</p>
<pre class="brush: php; title: ; notranslate">

function censor($text){
// Create an array of 'badwords'
$change = array('badword1', 'badword2', 'badword3');

// Replace all the bad words
$text = str_replace($change, &quot;***&quot;, $text);

return $text;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://nlstudio.se/blog/censor-functions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

