<?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>seoxys.com&#187; Programming</title>
	<atom:link href="http://www.seoxys.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.seoxys.com</link>
	<description></description>
	<lastBuildDate>Mon, 17 Jan 2011 00:49:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>ATTemplate: Simple Templating System in PHP</title>
		<link>http://www.seoxys.com/attemplate-simple-templating-system-in-php/</link>
		<comments>http://www.seoxys.com/attemplate-simple-templating-system-in-php/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 10:13:42 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/?p=203</guid>
		<description><![CDATA[Let me say this first: I do not believe in big bloated MVC PHP frameworks. I believe in having custom code that runs as fast as possible. For recurring useful functionality, such as templates, I believe in using simple, efficient and flexible dedicated standalone&#160;modules. For the past several years, I have been using a home-grown [...]]]></description>
			<content:encoded><![CDATA[<p>Let me say this first: I do not believe in big bloated MVC PHP frameworks. I believe in having custom code that runs as fast as possible. For recurring useful functionality, such as templates, I believe in using simple, efficient and flexible dedicated standalone&nbsp;modules.</p>
<p>For the past several years, I have been using a home-grown templating system that functioned by parsing template files which would have a dedicated / invented syntax. It would replace, for example, %TAG%, with a value. It had several more advanced features too, such as conditionals, recursion, embedded PHP, and&nbsp;more.</p>
<p>And while it functioned just fine, it implemented a custom parser, and required templates to be written using a non-standard syntax. But, after having used Ruby on Rails, I was inspired to design something&nbsp;better.</p>
<p>ATTemplate is the result of this. The main idea behind ATTemplate is that PHP in itself is already a parser, so why reinvent the&nbsp;wheel?</p>
<p>ATTemplate is very lightweight and relatively simple, but it&#8217;s very powerful without being bulky. It allows for everything the other templating systems can do, including loops, nested templates, recursion, conditionals,&nbsp;etc.</p>
<h1>How to&nbsp;use</h1>
<p>Here&#8217;s how you&#8217;d use&nbsp;ATTemplate:</p>
<pre class="textmate-source"><span class="text text_html text_html_basic"><span class="source source_php source_php_embedded source_php_embedded_block source_php_embedded_block_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span>

<span class="comment comment_line comment_line_double-slash comment_line_double-slash_php"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_php">//</span> Include the ATTemplate class
</span><span class="meta meta_include meta_include_php"><span class="keyword keyword_control keyword_control_import keyword_control_import_include keyword_control_import_include_php">require_once</span> <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">attemplate.inc.php</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span></span><span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>

<span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>template</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_php">=</span> <span class="keyword keyword_other keyword_other_new keyword_other_new_php">new</span> <span class="support support_class support_class_php">ATTemplate</span>()<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>

<span class="comment comment_line comment_line_double-slash comment_line_double-slash_php"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_php">//</span> Optionally, you can give it properties, like so:
</span><span class="comment comment_line comment_line_double-slash comment_line_double-slash_php"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_php">//</span> $template = new ATTemplate($property_array);
</span>
<span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>unread_messages</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_php">=</span> <span class="support support_function support_function_rand support_function_rand_php">rand</span>(<span class="constant constant_numeric constant_numeric_php">0</span>, <span class="constant constant_numeric constant_numeric_php">20</span>)<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>

<span class="comment comment_line comment_line_double-slash comment_line_double-slash_php"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_php">//</span> Sets property 'unread_messages' to 10.
</span><span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>template</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">-&gt;</span><span class="meta meta_function-call meta_function-call_object meta_function-call_object_php">set</span>(<span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">unread_messages</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>, <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>unread_messages</span>)<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>

<span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>template</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">-&gt;</span><span class="meta meta_function-call meta_function-call_object meta_function-call_object_php">set</span>(<span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">title</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>, <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">ATTemplate Test</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>)<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>

<span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>property_array</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_php">=</span> <span class="meta meta_array meta_array_php"><span class="support support_function support_function_construct support_function_construct_php">array</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_begin punctuation_definition_array_begin_php">(</span>
    <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">first_name</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span> <span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span> <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">John</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>,
    <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">time</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span> <span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span> <span class="support support_function support_function_php_date support_function_php_date_php">date</span>(<span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">H:i:s</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_end punctuation_definition_array_end_php">)</span></span>,
    <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">friend_requests</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span> <span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span> <span class="meta meta_array meta_array_php"><span class="support support_function support_function_construct support_function_construct_php">array</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_begin punctuation_definition_array_begin_php">(</span>
        <span class="meta meta_array meta_array_php"><span class="support support_function support_function_construct support_function_construct_php">array</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_begin punctuation_definition_array_begin_php">(</span><span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">name</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span><span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">James</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>, <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">followers</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span><span class="support support_function support_function_rand support_function_rand_php">rand</span>(<span class="constant constant_numeric constant_numeric_php">0</span>, <span class="constant constant_numeric constant_numeric_php">200</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_end punctuation_definition_array_end_php">)</span></span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_end punctuation_definition_array_end_php">)</span></span>,
        <span class="meta meta_array meta_array_php"><span class="support support_function support_function_construct support_function_construct_php">array</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_begin punctuation_definition_array_begin_php">(</span><span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">name</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span><span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">Josh</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>, <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">followers</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span><span class="support support_function support_function_rand support_function_rand_php">rand</span>(<span class="constant constant_numeric constant_numeric_php">0</span>, <span class="constant constant_numeric constant_numeric_php">200</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_end punctuation_definition_array_end_php">)</span></span>),
        <span class="meta meta_array meta_array_php"><span class="support support_function support_function_construct support_function_construct_php">array</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_begin punctuation_definition_array_begin_php">(</span><span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">name</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span><span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">Aaron</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>, <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">followers</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span><span class="support support_function support_function_rand support_function_rand_php">rand</span>(<span class="constant constant_numeric constant_numeric_php">0</span>, <span class="constant constant_numeric constant_numeric_php">200</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_end punctuation_definition_array_end_php">)</span></span>),
        <span class="meta meta_array meta_array_php"><span class="support support_function support_function_construct support_function_construct_php">array</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_begin punctuation_definition_array_begin_php">(</span><span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">name</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span><span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">Eric</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>, <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">followers</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span><span class="support support_function support_function_rand support_function_rand_php">rand</span>(<span class="constant constant_numeric constant_numeric_php">0</span>, <span class="constant constant_numeric constant_numeric_php">200</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_end punctuation_definition_array_end_php">)</span></span>),
        <span class="meta meta_array meta_array_php"><span class="support support_function support_function_construct support_function_construct_php">array</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_begin punctuation_definition_array_begin_php">(</span><span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">name</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span><span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">Mike</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>, <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">followers</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span><span class="keyword keyword_operator keyword_operator_key keyword_operator_key_php">=&gt;</span><span class="support support_function support_function_rand support_function_rand_php">rand</span>(<span class="constant constant_numeric constant_numeric_php">0</span>, <span class="constant constant_numeric constant_numeric_php">200</span><span class="punctuation punctuation_definition punctuation_definition_array punctuation_definition_array_end punctuation_definition_array_end_php">)</span></span>)
    )
)<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>

<span class="comment comment_line comment_line_double-slash comment_line_double-slash_php"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_php">//</span> This pushes the content of $property_array into the properties
</span><span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>template</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">-&gt;</span><span class="meta meta_function-call meta_function-call_object meta_function-call_object_php">push</span>(<span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>property_array</span>)<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>

<span class="comment comment_line comment_line_double-slash comment_line_double-slash_php"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_php">//</span> Prints the parsed template
</span><span class="support support_function support_function_construct support_function_construct_php">echo</span> <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>template</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">-&gt;</span><span class="meta meta_function-call meta_function-call_object meta_function-call_object_php">parse</span>(<span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">index.phtml</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>)

<span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span></span></pre>
<p>And here&#8217;s what your template could look&nbsp;like:</p>
<pre class="textmate-source"><span class="text text_html text_html_basic"><span class="meta meta_tag meta_tag_sgml meta_tag_sgml_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;!</span><span class="meta meta_tag meta_tag_sgml meta_tag_sgml_doctype meta_tag_sgml_doctype_html"><span class="entity entity_name entity_name_tag entity_name_tag_doctype entity_name_tag_doctype_html">DOCTYPE</span> html PUBLIC <span class="string string_quoted string_quoted_double string_quoted_double_doctype string_quoted_double_doctype_identifiers-and-DTDs string_quoted_double_doctype_identifiers-and-DTDs_html">"-//W3C//DTD XHTML 1.0 Transitional//EN"</span>
    <span class="string string_quoted string_quoted_double string_quoted_double_doctype string_quoted_double_doctype_identifiers-and-DTDs string_quoted_double_doctype_identifiers-and-DTDs_html">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>

<span class="meta meta_tag meta_tag_structure meta_tag_structure_any meta_tag_structure_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_structure entity_name_tag_structure_any entity_name_tag_structure_any_html">html</span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_html">xmlns</span>=<span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span>http://www.w3.org/1999/xhtml<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_html">xml:lang</span>=<span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span>en<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_html">lang</span>=<span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span>en<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>
<span class="meta meta_tag meta_tag_structure meta_tag_structure_any meta_tag_structure_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_structure entity_name_tag_structure_any entity_name_tag_structure_any_html">head</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>
    <span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">meta</span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_html">http-equiv</span>=<span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span>Content-Type<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_html">content</span>=<span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span>text/html; charset=utf-8<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">/&gt;</span></span>

    <span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">title</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span><span class="source source_php source_php_embedded source_php_embedded_line source_php_embedded_line_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span> <span class="support support_function support_function_construct support_function_construct_php">echo</span> <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>title</span><span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span> <span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span><span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">title</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>

<span class="meta meta_tag meta_tag_structure meta_tag_structure_any meta_tag_structure_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_structure entity_name_tag_structure_any entity_name_tag_structure_any_html">head</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>

<span class="meta meta_tag meta_tag_structure meta_tag_structure_any meta_tag_structure_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_structure entity_name_tag_structure_any entity_name_tag_structure_any_html">body</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>

<span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">h1</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>Welcome, <span class="source source_php source_php_embedded source_php_embedded_line source_php_embedded_line_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span> <span class="support support_function support_function_construct support_function_construct_php">echo</span> <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>first_name</span><span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span> <span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span><span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">h1</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>

<span class="source source_php source_php_embedded source_php_embedded_block source_php_embedded_block_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span> <span class="keyword keyword_control keyword_control_php">if</span>(<span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>unread_messages</span><span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_php">&gt;</span><span class="constant constant_numeric constant_numeric_php">0</span>): <span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span><span class="punctuation punctuation_whitespace punctuation_whitespace_embedded punctuation_whitespace_embedded_trailing punctuation_whitespace_embedded_trailing_php">
</span><span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">h2</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>You have <span class="source source_php source_php_embedded source_php_embedded_line source_php_embedded_line_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span> <span class="support support_function support_function_construct support_function_construct_php">echo</span> <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>unread_messages</span><span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span> <span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span> unread messages!<span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">h2</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>
<span class="source source_php source_php_embedded source_php_embedded_block source_php_embedded_block_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span> <span class="keyword keyword_control keyword_control_php">endif</span><span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span> <span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span><span class="punctuation punctuation_whitespace punctuation_whitespace_embedded punctuation_whitespace_embedded_trailing punctuation_whitespace_embedded_trailing_php">
</span>
<span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">p</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>You have received friend requests from the following people:<span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">p</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>
<span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">ol</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>
<span class="source source_php source_php_embedded source_php_embedded_block source_php_embedded_block_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span> <span class="keyword keyword_control keyword_control_php">foreach</span>(<span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>friend_requests</span> <span class="keyword keyword_operator keyword_operator_logical keyword_operator_logical_php">as</span> <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>friend_request</span>): <span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span><span class="punctuation punctuation_whitespace punctuation_whitespace_embedded punctuation_whitespace_embedded_trailing punctuation_whitespace_embedded_trailing_php">
</span>    <span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">li</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span><span class="source source_php source_php_embedded source_php_embedded_line source_php_embedded_line_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span> <span class="support support_function support_function_construct support_function_construct_php">echo</span> <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>friend_request</span>[<span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">name</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>]<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span> <span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span> (has <span class="source source_php source_php_embedded source_php_embedded_line source_php_embedded_line_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span> <span class="support support_function support_function_construct support_function_construct_php">echo</span> <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>friend_request</span>[<span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">followers</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>]<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span> <span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span> followers)<span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">li</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>
<span class="source source_php source_php_embedded source_php_embedded_block source_php_embedded_block_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span> <span class="keyword keyword_control keyword_control_php">endforeach</span><span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span> <span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span><span class="punctuation punctuation_whitespace punctuation_whitespace_embedded punctuation_whitespace_embedded_trailing punctuation_whitespace_embedded_trailing_php">
</span><span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">ol</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>

<span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">p</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>The time is <span class="source source_php source_php_embedded source_php_embedded_line source_php_embedded_line_html"><span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_begin punctuation_definition_embedded_begin_php">&lt;?php</span> <span class="support support_function support_function_construct support_function_construct_php">echo</span> <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>time</span><span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span> <span class="punctuation punctuation_definition punctuation_definition_embedded punctuation_definition_embedded_end punctuation_definition_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span>&#8230;<span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">p</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>

<span class="meta meta_tag meta_tag_structure meta_tag_structure_any meta_tag_structure_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_structure entity_name_tag_structure_any entity_name_tag_structure_any_html">body</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>
<span class="meta meta_tag meta_tag_structure meta_tag_structure_any meta_tag_structure_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_structure entity_name_tag_structure_any entity_name_tag_structure_any_html">html</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_html">&gt;</span></span>
</span></pre>
<h1>License</h1>
<p>You&#8217;re free to use the code in whatever you want, commercial or not. Modify it, redistribute it, do whatever you want with&nbsp;it.</p>
<p>The only requirement is that you need to give me&nbsp;credit.</p>
<p>Also, please do <a href="mailto:kenneth@ballenegger.com">shoot me an email</a> if you use this in your&nbsp;project.</p>
<p>ATTemplate by <a href="http://www.seoxys.com">Kenneth Ballenegger</a> is licensed under the <a href="http://www.seoxys.com/azure-license">Azure&nbsp;License</a>.</p>
<h1>Download</h1>
<p><a href="http://dl.azuretalon.com/attemplate.zip">Download&nbsp;ATTemplate!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/attemplate-simple-templating-system-in-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Dynamic mass vhost with Apache and mod_rewrite</title>
		<link>http://www.seoxys.com/dynamic-mass-vhost-with-apache-and-mod_rewrite/</link>
		<comments>http://www.seoxys.com/dynamic-mass-vhost-with-apache-and-mod_rewrite/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 15:57:14 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/?p=185</guid>
		<description><![CDATA[In the process of setting up a new web-server with Mosso&#8217;s CloudServer, I came up across an interesting problem that took be the better part of the day to figure&#160;out. The new server is completely unmanaged, which means that I have no web control panel to manage things. But worry not, that&#8217;s actually a good [...]]]></description>
			<content:encoded><![CDATA[<p>In the process of setting up a new web-server with Mosso&#8217;s CloudServer, I came up across an interesting problem that took be the better part of the day to figure&nbsp;out.</p>
<p>The new server is completely unmanaged, which means that I have no web control panel to manage things. But worry not, that&#8217;s actually a good thing, because it means I have no web control panel to complicate and fuck up things&nbsp;either.</p>
<p>But it meant I had to setup Apache manually, including the vhosts so that my domain get mapped to the correct content. The problem is I have north of ten domains, each with their own subdomains. I could do it the standard and documented way of adding a VirtualHost for each domain, or I can be clever and have it do the work for&nbsp;me.</p>
<p>My first idea was to go with&nbsp;<i>mod_vhost_alias</i>:</p>
<pre class="textmate-source"><span class="source source_apache-config"><span class="support support_constant support_constant_apache-config">UseCanonicalName</span> Off

<span class="support support_constant support_constant_apache-config">LogFormat</span> <span class="string string_quoted string_quoted_double string_quoted_double_apache-config"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_apache-config">"</span>%V %h %l %u %t \<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_apache-config">"</span></span>%r\<span class="string string_quoted string_quoted_double string_quoted_double_apache-config"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_apache-config">"</span> %s %b<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_apache-config">"</span></span> vcommon
<span class="support support_constant support_constant_apache-config">CustomLog</span> logs/access_log vcommon

<span class="support support_constant support_constant_apache-config">VirtualDocumentRoot</span> /home/kenneth/www/%0/public
<span class="support support_constant support_constant_apache-config">VirtualScriptAlias</span> /home/kenneth/www/%0/cgi-bin
</span></pre>
<p>This worked like magic, automatically translating the domain requested to the path. http://domain.com/* would translate to /home/kenneth/www/domain.com/public/*. But, www.domain.com would translate to a folder named www.domain.com. This meant one of two things: either I had to create dirty symlinks in my www folder, or anybody accessing my domain from the www. subdomain would get a 404 error, both of which are&nbsp;unacceptable.</p>
<p>Another option would be to change that code like&nbsp;such:</p>
<p><code> VirtualDocumentRoot /home/kenneth/www/%-2.0.%-1.0/public<br />
VirtualScriptAlias&nbsp;/home/kenneth/www/%-2.0.%-1.0/cgi-bin</code></p>
<p>This works by taking the last two parts of a domain, but it has two big flaws. Firstly, it completely ignores any subdomains. Secondly, it doesn&#8217;t work with multiple-tld domains, such as .co.uk&nbsp;domains.</p>
<p>After a whole afternoon of trying different things, I came to the optimal solution, through URL&nbsp;rewriting.</p>
<p>With this solution, domains, whether they have www. or not, map to the same domain.tld folder, and subdomains also map to folders in the same root folder (www, in my&nbsp;case).</p>
<pre class="textmate-source"><span class="source source_apache-config"><span class="support support_constant support_constant_apache-config">UseCanonicalName</span> Off

<span class="meta meta_directory meta_directory_apache-config"><span class="meta meta_tag meta_tag_apache-config"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_apache-config">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_apache-config">Directory</span> <span class="meta meta_toc-list meta_toc-list_directory meta_toc-list_directory_apache-config">/home</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_apache-config">&gt;</span></span>
<span class="support support_constant support_constant_apache-config">Options</span> FollowSymLinks ExecCGIAllowOverride All
<span class="meta meta_tag meta_tag_apache-config"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_apache-config">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_apache-config">Directory</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_apache-config">&gt;</span></span></span>

<span class="support support_constant support_constant_apache-config">RewriteEngine</span> On

<span class="support support_constant support_constant_rewritecond support_constant_rewritecond_apache-config">RewriteCond</span> <span class="support support_variable support_variable_apache-config"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_apache-config">%{</span>REQUEST_URI}</span> <span class="string string_other string_other_rewrite-condition string_other_rewrite-condition_apache-config">!/home/kenneth/www</span>
<span class="support support_constant support_constant_rewritecond support_constant_rewritecond_apache-config">RewriteCond</span> <span class="support support_variable support_variable_apache-config"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_apache-config">%{</span>REQUEST_URI}</span> <span class="string string_other string_other_rewrite-condition string_other_rewrite-condition_apache-config">!^/icons/</span>
<span class="support support_constant support_constant_rewritecond support_constant_rewritecond_apache-config">RewriteCond</span> <span class="support support_variable support_variable_apache-config"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_apache-config">%{</span>REQUEST_URI}</span> <span class="string string_other string_other_rewrite-condition string_other_rewrite-condition_apache-config">!^/cgi-bin/</span>
<span class="support support_constant support_constant_rewritecond support_constant_rewritecond_apache-config">RewriteCond</span> <span class="support support_variable support_variable_apache-config"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_apache-config">%{</span>HTTP_HOST}</span> <span class="string string_other string_other_rewrite-condition string_other_rewrite-condition_apache-config">^(?:www\.)?(.*)$</span> <span class="string string_regexp string_regexp_rewrite-operator string_regexp_rewrite-operator_apache-config">[NC]</span>
<span class="support support_constant support_constant_rewriterule support_constant_rewriterule_apache-config">RewriteRule</span> <span class="string string_regexp string_regexp_rewrite-pattern string_regexp_rewrite-pattern_apache-config">^/(.*)$</span> <span class="string string_other string_other_rewrite-substitution string_other_rewrite-substitution_apache-config">/home/kenneth/www/</span>%<span class="string string_other string_other_rewrite-substitution string_other_rewrite-substitution_apache-config">1/public/$1</span>

<span class="support support_constant support_constant_rewritecond support_constant_rewritecond_apache-config">RewriteCond</span> <span class="support support_variable support_variable_apache-config"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_apache-config">%{</span>REQUEST_URI}</span> <span class="string string_other string_other_rewrite-condition string_other_rewrite-condition_apache-config">!/home/kenneth/www</span>
<span class="support support_constant support_constant_rewritecond support_constant_rewritecond_apache-config">RewriteCond</span> <span class="support support_variable support_variable_apache-config"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_apache-config">%{</span>REQUEST_URI}</span> <span class="string string_other string_other_rewrite-condition string_other_rewrite-condition_apache-config">^/cgi-bin/</span>
<span class="support support_constant support_constant_rewritecond support_constant_rewritecond_apache-config">RewriteCond</span> <span class="support support_variable support_variable_apache-config"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_apache-config">%{</span>HTTP_HOST}</span> <span class="string string_other string_other_rewrite-condition string_other_rewrite-condition_apache-config">^(?:www\.)?(.*)$</span> <span class="string string_regexp string_regexp_rewrite-operator string_regexp_rewrite-operator_apache-config">[NC]</span>
<span class="support support_constant support_constant_rewriterule support_constant_rewriterule_apache-config">RewriteRule</span> <span class="string string_regexp string_regexp_rewrite-pattern string_regexp_rewrite-pattern_apache-config">^/(.*)$</span> <span class="string string_other string_other_rewrite-substitution string_other_rewrite-substitution_apache-config">/home/kenneth/www/</span>%<span class="string string_other string_other_rewrite-substitution string_other_rewrite-substitution_apache-config">1/cgi-bin/$1</span> <span class="string string_regexp string_regexp_rewrite-operator string_regexp_rewrite-operator_apache-config">[T=application/x-httpd-cgi]</span></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/dynamic-mass-vhost-with-apache-and-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Registration Schemes: Asymmetrical Cryptography</title>
		<link>http://www.seoxys.com/registration-schemes-asymmetrical-cryptography/</link>
		<comments>http://www.seoxys.com/registration-schemes-asymmetrical-cryptography/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 22:13:05 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/?p=86</guid>
		<description><![CDATA[One challenge that most developers face when nearing release of their first application is how to implement registration and piracy protection. This three-part article will describe three common types of registration schemes: Serial Numbers, Asymmetrical Cryptographic Keys and Product&#160;Activation. Part Two: Asymmetrical&#160;Cryptography Asymmetrical Cryptographic Keys are a great way to secure you app, because the [...]]]></description>
			<content:encoded><![CDATA[<p>One challenge that most developers face when nearing release of their first application is how to implement registration and piracy protection. This three-part article will describe three common types of registration schemes: <b>Serial Numbers</b>, <b>Asymmetrical Cryptographic Keys</b> and <b>Product&nbsp;Activation</b>.</p>
<hr />
<h1>Part Two: Asymmetrical&nbsp;Cryptography</h1>
<p>Asymmetrical Cryptographic Keys are a great way to secure you app, because the code used to generate serials is not included in your app, thus removing the risk of a keygen. Using a private key, you sign (or encrypt) some of the user&#8217;s details. You then use this singed data as the key to your software, either in the form of a serial, a file, or even <a href="http://switchersblog.com/2007/04/05/license-keys-mac-style-1passwd-introduces-new-license-cards.html">an image with the data embedded</a>. You then verify that the signature is valid using the public key in your&nbsp;app.</p>
<p><b>Example</b></p>
<p>Start off by generating a set of private and public RSA keys. You can do this by using the following in&nbsp;Terminal.app:</p>
<p><code>openssl genrsa -out private.pem 2048<br />
openssl rsa -in private.pem -out public.pem -outform PEM&nbsp;-pubout</code></p>
<p>You can use different size keys. Using a shorter key, such as 512 will make your software more vulnerable to brute-force attack, but has the advantage of making the signature smaller (Which is useful if you wish to display it in the form of a Serial&nbsp;Number).</p>
<p>I believe I used the following set of keys. The keys are also included as files in the source code of this example (available at the bottom of this&nbsp;article).</p>
<p><code>-----BEGIN RSA PRIVATE KEY-----<br />
MIIEpAIBAAKCAQEAwKhjrkHmaupDGERSHdgZuSwBWBr4kufBGz0Dk5sn3PR3ZtaP<br />
Vrv6+5Mdz1gAEBYbUVH3m+4+dHcwol5xNckKBT8M5Zy6GPoV9dBUS/1wQBzgdTzf<br />
jvV4uE9S0pofQWw3faZ904tTOjbM0qUko2nd7yyjYBhh/m1ABEFHuL62BvRp13na<br />
vv6534OqqeExEb9VD3K9+Rr4+YQVRUpqZSz2xwhqfLgAzFVQ9bmSG8yTVKmF/vQA<br />
t+N8ThN2WO5qYtCbPawkmIpwvUCTXkxAiiTPNOiU3G1vwtzBoma9TL6dgGmhq6P7<br />
0KBcQNGUEpA2PFC7MEBeNyVyiMIOAvrkHjY/VQIDAQABAoIBABUNET9EMiIykLxB<br />
Etvx9fWWylrPL6QVsLMCOrbROEzbZYSWIzlt9uGwVIyIaBFZ6Qg8tZqTML3XHDhR<br />
q3seCXtDRWx9cJQ0F1wxtFRNUAuhXCFTUnYzekphWIJslse2RGX1YEBSM/jjbgQC<br />
SXuVoMt2jC9+2o5Lb7hHTcfxBsDBmZpghArT5seTOwDOOhTULqoh2wgZYB2IpgTI<br />
UV2CPpAqRVECRnPNdE5UcNIeHc7g4aji5BO0G0u8uM4RUffuRcLaPymuxpU9vwd1<br />
gjVaG6BF/2odW7GEBU3FNLUtvr9MxT+HC+hwOJUuk8NWxU7DqMdyiwSs7W3Nnx7R<br />
5RPvj8ECgYEA34DZjy5EMm7QyPZA6DvAZv6RIecFEwEkwFG+mQgoCy4VfLikkwzC<br />
bI8M8fc6Xiix7ZTjSmvuHt1D4HSRHMOVYgDzY0A5+F+8X657mN5TwNlYMOUkDX3I<br />
rNwc3cRVqtLZYGX0H7cR6eEomGJ7fA9gKuTpaXI0IJz5DsqsgTaGvfECgYEA3Ktr<br />
Q53i52jnssL9c3JsxQO+I/2fWKgo3bZeBI/5zLsz3itVjFjMVldrIK1QZWXI4z7l<br />
dPYwh6qCa1unsizuuzeAhW6NcuUjGPBlBqlo/a9WfOo16ExPXBoH3PH2DXz/YS+D<br />
DOp4Wl8ePhO7C46t3zmGahchysx3kCGkAmNkA6UCgYEA0upvZNUOemFlGiB5RC8O<br />
9KMLJukyOqr7mZoKubOexl4o3NgKRtLlrziXyMe8Bxt0PXYhwBt2TR4Vbf3S60gO<br />
8rte86yqiB8gT1MDRFGazATPWuUCTtECzU2y1/ztsxTjGjtcU4mZmBJpEtTtHzgL<br />
Uq9PLbkeRCCeUD0m6ZEhOqECgYB85jFyNh1F6aSrE56tB2j1Iicu69CTN6rZwuz4<br />
HB3BeXvkFhb3txMBE7244yAMJE5OAT2Ss/3H7AShi2EhgjklkkaWP3qkO3lgFkC4<br />
Qo8Ad4u2bEJS105bzQgCUJl6DPPnKCM+3j98tzXA4R4PbpSPMloYFju0M4LA+6l/<br />
CI6FWQKBgQCWr4Py/GBhgoYOlY/f41NzOfsttwcCBum3uPbiPq6gM/AQQRjzdUmK<br />
QRgG9XXs/33KUMiU+/15hK8ShrOWRSx+zHdgeMhVmuYJdEeygANI9dkonJ3+Olth<br />
77beMQrKIY9kw4bVRFtLWhxfAHXvnksnBg79PX05joVvoHFgVxuwlg==<br />
-----END RSA PRIVATE KEY-----<br />
-----BEGIN PUBLIC KEY-----<br />
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwKhjrkHmaupDGERSHdgZ<br />
uSwBWBr4kufBGz0Dk5sn3PR3ZtaPVrv6+5Mdz1gAEBYbUVH3m+4+dHcwol5xNckK<br />
BT8M5Zy6GPoV9dBUS/1wQBzgdTzfjvV4uE9S0pofQWw3faZ904tTOjbM0qUko2nd<br />
7yyjYBhh/m1ABEFHuL62BvRp13navv6534OqqeExEb9VD3K9+Rr4+YQVRUpqZSz2<br />
xwhqfLgAzFVQ9bmSG8yTVKmF/vQAt+N8ThN2WO5qYtCbPawkmIpwvUCTXkxAiiTP<br />
NOiU3G1vwtzBoma9TL6dgGmhq6P70KBcQNGUEpA2PFC7MEBeNyVyiMIOAvrkHjY/<br />
VQIDAQAB<br />
-----END PUBLIC KEY-----<br />
</code></p>
<p>Next, we will create the generator. We will start by concatenating the details (full name and email address) into a single&nbsp;string:</p>
<p><code>First&nbsp;Last+email@address.com</code></p>
<p>Then, we will use RSA to sign this string using the private key generated&nbsp;above:</p>
<p><code>lFZpwJ6GPLXz8sDez033RIxJsN072lOEa0qF+8hQ5KCcZEPQqSBU4MKbW+UJxIfSmKMOBYnVfy/wwAoSxTtqn2JIuAPEJvsTlb0mGH5u7mpxH+FDj2TicoBKephWv7UXP9k10OPA45247+j/u4yKT1UZcq7WjChQ3JoE3wBtEoFucQm8vLk/VqvNaBM1TyNEgwT8FmrKlbK1FNUI8nQ0QOEJ9P8oMAblkWE5kALZZqWnAs6xE7c73sex73t5FvxYRqRDzRDzkjTwK0anXCv8dmeLvnaaHAFcfD5llx09oa89q+wzWucE7V1TsPRYKH1sZsSz5G2xTt2pZrjIoTw5ew==</code></p>
<p><b>Note</b>: for this sample app, I explicitly turned off creating newlines in the base64&nbsp;signature.</p>
<p>The code used for this generator&nbsp;is:</p>
<pre class="textmate-source"><span class="source source_objc"><span class="meta meta_implementation meta_implementation_objc"><span class="meta meta_scope meta_scope_implementation meta_scope_implementation_objc"><span class="meta meta_function meta_function_objc">-<span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">IBAction</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">generate</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">sender</span></span>
</span>{
    <span class="support support_class support_class_cocoa">NSData</span> *privateKeyData = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSData</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">dataWithContentsOfURL<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSURL</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">fileURLWithPath<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSBundle</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">mainBundle</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">pathForResource<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>private<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span> <span class="support support_function support_function_any-method support_function_any-method_name-of-parameter support_function_any-method_name-of-parameter_objc">ofType<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>pem<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="support support_class support_class_cocoa">NSData</span> *publicKeyData = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSData</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">dataWithContentsOfURL<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSURL</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">fileURLWithPath<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSBundle</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">mainBundle</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">pathForResource<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>public<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span> <span class="support support_function support_function_any-method support_function_any-method_name-of-parameter support_function_any-method_name-of-parameter_objc">ofType<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>pem<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="support support_class support_class_cocoa">NSString</span> *details = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSString</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringWithFormat<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>%@+%@<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>name <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringValue</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>, <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>email <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringValue</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    SSCrypto *crypto = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>SSCrypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">alloc</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">initWithPublicKey<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>publicKeyData <span class="support support_function support_function_any-method support_function_any-method_name-of-parameter support_function_any-method_name-of-parameter_objc">privateKey<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>privateKeyData</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">setClearTextWithString<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>details</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    <span class="support support_class support_class_cocoa">NSData</span> *signedTextData = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">sign</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="support support_class support_class_cocoa">NSString</span> *string = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>signedTextData <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">encodeBase64WithNewlines<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="constant constant_language constant_language_objc">NO</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>serial <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">setStringValue<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>string</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">release</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
}
</span></span></span></pre>
<p>As you can see, I used Septicus Software&#8217;s great <a href="http://septicus.com/products/opensource/">SSCrypto</a> framework for this task&#8230; It makes things so much easier&#8230; Unfortunately it doesn&#8217;t support base32 or DSA, which would both have helped make more human-friendly&nbsp;keys.</p>
<p>The other piece needed is the validator, used in your software to validate serial numbers. Include only the public key in your app, and use RSA to verify the&nbsp;key.</p>
<pre class="textmate-source"><span class="source source_objc"><span class="meta meta_implementation meta_implementation_objc"><span class="meta meta_scope meta_scope_implementation meta_scope_implementation_objc"><span class="meta meta_function meta_function_objc">-<span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">IBAction</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">validate</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">sender</span></span>
</span>{
    <span class="support support_class support_class_cocoa">NSData</span> *publicKeyData = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSData</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">dataWithContentsOfURL<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSURL</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">fileURLWithPath<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSBundle</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">mainBundle</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">pathForResource<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>public<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span> <span class="support support_function support_function_any-method support_function_any-method_name-of-parameter support_function_any-method_name-of-parameter_objc">ofType<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>pem<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="support support_class support_class_cocoa">NSString</span> *details = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSString</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringWithFormat<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>%@+%@<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>name <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringValue</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>, <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>email <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringValue</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="support support_class support_class_cocoa">NSData</span> *number = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>serial <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringValue</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">dataUsingEncoding<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="support support_constant support_constant_cocoa">NSUTF8StringEncoding</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">decodeBase64WithNewLines<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="constant constant_language constant_language_objc">NO</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    SSCrypto *crypto = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>SSCrypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">alloc</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">initWithPublicKey<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>publicKeyData</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">setCipherText<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>number</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">verify</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    <span class="keyword keyword_control keyword_control_c">if</span>(<span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">clearTextAsString</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">isEqualToString<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>details</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>)
        <span class="support support_function support_function_cocoa">NSRunAlertPanel</span>(<span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>Result<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>Good serial!<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>OK<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="constant constant_language constant_language_objc">nil</span>, <span class="constant constant_language constant_language_objc">nil</span>);
    <span class="keyword keyword_control keyword_control_c">else</span>
        <span class="support support_function support_function_cocoa">NSRunAlertPanel</span>(<span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>Result<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>Wrong serial!<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>OK<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="constant constant_language constant_language_objc">nil</span>, <span class="constant constant_language constant_language_objc">nil</span>);

    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">release</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
}
</span></span></span></pre>
<p><b>Important Note</b>: In this sample code, I included both the generator and the validator in the same application. I included the private.pem file in the bundle. You should <b>never</b> do this. If the private key is ever leaked, it compromises the whole security of your&nbsp;application.</p>
<p><b>Making it&nbsp;safer</b></p>
<p>You can easily make it more secure by combining this technique with the technique explained in Part One. Instead of simple concatenating the details as I did here, you could use all the techniques applied in Part One, such as using a hash instead, or doing ROT13 on it, or rearranging the order of the&nbsp;characters.</p>
<p>Another thing you should do is to hardcode and obfuscate your public key. Having it as a file in the bundle makes you vulnerable to key substitution. (Basically, a cracker would replace the public key in your app by a different key they created using a private key they know, thus making their licenses valid instead of&nbsp;yours.) </p>
<p><b>Form&nbsp;Factors</b></p>
<p>While you may not realize it at first sight, this has become one of the most common methods in Mac shareware, thanks to the open-source framework <a href="http://aquaticmac.com">AquaticPrime</a>. AquaticPrime uses this technique behind the scenes, by embedding the signature in a plist file. AquaticPrime is a very easy way to use this. Unfortunately, if you decide to use AquaticPrime.framework in your app, it is very easy to replace the .framework file with a malicious one that will always claim your licenses are&nbsp;valid.</p>
<p>To date, as far as I know, there isn&#8217;t any HackuaticPrime.framework yet, but this might one day become a problem with AquaticPrime gaining popularity thanks to it&#8217;s extreme simplicity of&nbsp;implementation.</p>
<p><b>Update</b>: <b>Devon</b> in the comments suggests implementing a hash check of the framework, which is a simple way of checking the framework&#8217;s integrity. Of course, there are still ways to get around it, but this makes it one step more&nbsp;difficult.</p>
<p>Another common form factor for Asymmetrical Cryptographic Keys is custom URL schemes. That&#8217;s actually a very clever and convenient way of doing it. To register, the users get to simple click on a link which looks like this: (All the user sees is a nice &#8220;Click here to register&#8221;&nbsp;link)</p>
<p><code>myapp://name:email:key</code> </p>
<p>Another clever, but controversial form factor is Agile Web Solution&#8217;s 1Password <a href="http://switchersblog.com/2007/04/05/license-keys-mac-style-1passwd-introduces-new-license-cards.html">License&nbsp;&#8220;Cards&#8221;</a>.</p>
<p>And of course, if you find a way to make short base32 signatures (I hear DSA makes short signatures), you can even use longer Serial&nbsp;Numbers.</p>
<p><code>AHJ53-5HGJZ-8DG8R-284DF-56FJB-74FH4-FJUEH</code></p>
<hr />
<p><b>Sample&nbsp;Code</b></p>
<p>The code used in this article can be downloaded <a href="http://dl.azuretalon.com/async.zip">here</a>.<br />
As always, licensed under MIT license. If you do use it, mention it in the About Box or&nbsp;readme.txt.</p>
<hr />
<p><a href="http://www.seoxys.com/registration-schemes-serial-numers/">Part One: Serial Numbers</a><br />
The next part will be coming&nbsp;soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/registration-schemes-asymmetrical-cryptography/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Registration Schemes: Serial Numbers</title>
		<link>http://www.seoxys.com/registration-schemes-serial-numers/</link>
		<comments>http://www.seoxys.com/registration-schemes-serial-numers/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 21:26:56 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/?p=85</guid>
		<description><![CDATA[One challenge that most developers face when nearing release of their first application is how to implement registration and piracy protection. This three-part article will describe three common types of registration schemes: Serial Numbers, Asymmetrical Cryptographic Keys and Product&#160;Activation. Part One: Serial&#160;Numbers Serial numbers are the simplest, most practical option. However, they are also the [...]]]></description>
			<content:encoded><![CDATA[<p>One challenge that most developers face when nearing release of their first application is how to implement registration and piracy protection. This three-part article will describe three common types of registration schemes: <b>Serial Numbers</b>, <b>Asymmetrical Cryptographic Keys</b> and <b>Product&nbsp;Activation</b>.</p>
<hr />
<h1>Part One: Serial&nbsp;Numbers</h1>
<p>Serial numbers are the simplest, most practical option. However, they are also the least secure. It consists of taking at least one of the customers&#8217; details, and creating a serial number from it. The serial number is usually tied to either the customer&#8217;s name, or his email address, preferably&nbsp;both.</p>
<p>For example, let&#8217;s say the customer&#8217;s name &#8220;First Last&#8221; and his email address is &#8220;email@address.com&#8221;. The first step would be to strip his name and email address of any non-alphabetical characters, concatenate it and convert it to uppercase. (I put the email address first, because it&#8217;s less recognizable) Here&#8217;s what we&nbsp;get:</p>
<p><code>EMAILADDRESSCOMFIRSTLAST</code></p>
<p>Now map this string onto a XXXX-XXXX-XXXX-XXXX-XXXX key. If there are any character leftovers, just discard them. If there aren&#8217;t enough characters to fill all the Xs in, leave them as something constant. (they don&#8217;t have to be all the same, but they have to be the same for each position all the time. You could for example say you&#8217;re mapping it onto an QRST-ABCD-IJLK-EFGH-MNOP key, and leave unfilled spaces as&nbsp;is)</p>
<p><code>EMAI-LADD-RESS-COMF-IRST</code></p>
<p>Then, we&#8217;d apply ROT13 on&nbsp;it.</p>
<p><code>RZNV-YNQQ-ERFF-PBZS-VEFG</code></p>
<p>Lastly, we could replace any swearwords in the key by some random other constant text, <a href="http://www.rogueamoeba.com/utm/posts/Random/RASN2-Swears-2007-10-16-15-00.html">just in&nbsp;case</a>.</p>
<p>Another example, using a similar method: Using the same customer, here&#8217;s what we&#8217;d do. Take his details, concatenate and salt&nbsp;them:</p>
<p><code>First Last+random&nbsp;salt+email@address.com</code></p>
<p>Then, MD5 the result and add another&nbsp;salt:</p>
<p><code>salt+0fb61d4a0f894c63d3ddbd8388404b6c</code></p>
<p>Next, SHA1 the&nbsp;result:</p>
<p><code>28a8275bdcbca542f567efef9cc4db2150c38900</code></p>
<p>And finally, uppercase it and map it onto a XXXX-XXXX-XXXX-XXXX-XXXX&nbsp;serial:</p>
<p><code>28A8-275B-DCBC-A542-F567</code></p>
<p>When you have decided on a serial scheme, implementing it is easy. Upon registration, you take the buyer&#8217;s name and email address, and generate a serial from it. He then has to input this serial into you app, along with his name and email address. All you have to do in you app is take the name and email address he gave you, generate a serial from it, and check it against the serial he gave&nbsp;you.</p>
<p><b>Making it more&nbsp;secure</b></p>
<p>For security reasons, one important step to take is obfuscating how you create those serials, in case anyone tries to create a keygen for you app. The easiest way is adding dummy maths code in the middle of the code where you work out your serial. It will not affect your serial, but it will show up in the assembly code in case anyone tries to gdb your app (more on that in another blog post I have&nbsp;planned).</p>
<p>Another quick thing you could do is shuffle the characters a bit on a set pattern to make them less&nbsp;obvious.</p>
<p>For example you could use this&nbsp;pattern:</p>
<p><code>ABCD-EFGH-IJKL-MNOP-QRST</code></p>
<p>becomes</p>
<p><code>TMLN-DQGA-ISPC-BEOK-FJRH</code></p>
<p><b>Stand-alone&nbsp;serials</b></p>
<p>Sometimes, your serials cannot be tied to any of the customer&#8217;s data, for example for retail sales. In that case, you&#8217;d need a different serial scheme. You need to choose certain characteristics / rules that make a serial valid. It could be as simple as checking that the 19th character is a&nbsp;W.</p>
<p>Here&#8217;s a set of example rules you could&nbsp;use:</p>
<ul>
<li>The ASCII value of the first character of all five blocks of four characters have to add up to&nbsp;100.</li>
<li>The last character of all five blocks of four characters have to be&nbsp;vowels.</li>
<li>The first character of either block 3 or 4 has to be&nbsp;E.</li>
<li>The ASCII value to the third character of every block have to be even&nbsp;numbers.</li>
</ul>
<p>In your apps, just check the serial against the rules, and if it&#8217;s correct, you can assume it is a correct&nbsp;serial.</p>
<p>For your generator, you can have a pre-made list of valid serials, and assign them to a customer or print them on a retail copy when needed. The problem with this method is that you can eventually run out of valid serials. In which case you would have to generate a new batch of serials, or reassign already used serials to a second&nbsp;customer.</p>
<p>Another (better) way of doing stand-alone serial numbers is splitting the serial number in two, and basing the second part on the first part. [thanks to <b>tomasf</b> from the <a href="irc://irc.freenode.net/#macsb">#macsb</a> IRC channel for this&nbsp;method]</p>
<p>For example, in a serial number ABCD-EFGH-D07A-A959-F269, separate the first eight characters from the rest of the&nbsp;serial:</p>
<p><code>ABCDEFGH</code> </p>
<p>Salt&nbsp;it:</p>
<p><code>saltyABCDEFGH+123</code></p>
<p>MD5:</p>
<p><code>d07aa959f269104ab28e2a748c415c5c</code></p>
<p>Map it onto&nbsp;XXXX-XXXX-XXXX:</p>
<p><code>D07A-A959-F269</code></p>
<p>And check it against the second part of the serial. In this example, the serial is&nbsp;correct.</p>
<hr />
<p><a href="http://www.seoxys.com/registration-schemes-asymmetrical-cryptography/">Part Two: Asymmetrical Cryptographic Keys</a><br />
The last parts will be coming&nbsp;soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/registration-schemes-serial-numers/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Interviews and Podcasts</title>
		<link>http://www.seoxys.com/interviews-and-podcasts/</link>
		<comments>http://www.seoxys.com/interviews-and-podcasts/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 09:58:13 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/interviews-and-podcasts/</guid>
		<description><![CDATA[iAppblog recently interviewed me on the new iPhone SDK, Apple&#8217;s business model, and whether we will see Exces for iPhone. It&#8217;s an interesting read, so be sure to go have a&#160;look Last week, I also participated in the MacSB podcst episode 4. It was really interesting and instructive to have a chat with some really [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://iappblog.com/">iAppblog</a> recently interviewed me on the new iPhone SDK, Apple&#8217;s business model, and whether we will see Exces for iPhone. It&#8217;s an interesting read, so be sure to go <a href="http://iappblog.com/interview-with-kenneth-ballenegger-on-the-iphone-sdk">have a&nbsp;look</a></p>
<p>Last week, I also participated in the <a href="http://www.macdevnet.com/index.php/shows/macsoftwarebusiness">MacSB podcst</a> <a href="http://www.macdevnet.com/index.php/shows/macsoftwarebusiness/40-macsoftwarebusiness/229-macsb004-software-bundles">episode 4</a>. It was really interesting and instructive to have a chat with some really cool other developers: <a href="http://atomicwang.org/motherfucker/">Mike Lee</a>, <a href="http://www.memoryminer.com/blog/">John Fox</a>, <a href="http://dannygreg.com">Danny Greg</a>, and our host, <a href="">Steve&nbsp;Scotty</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/interviews-and-podcasts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Design!</title>
		<link>http://www.seoxys.com/new-design/</link>
		<comments>http://www.seoxys.com/new-design/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 19:53:32 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/new-design/</guid>
		<description><![CDATA[Here&#8217;s a fresh new look for my&#160;blog! I&#8217;m hoping this will look slick and&#160;professional. I&#8217;m aware it isn&#8217;t totally finished: it brings IE down to its knees, and some parts don&#8217;t look quite right in Opera. I will do my best to fix these issues ASAP. If this is the case for you, I suggest [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a fresh new look for my&nbsp;blog!</p>
<p><img src="http://akhun.com/seo/skitch/seoxys.com-20080310-214420.jpg" /></p>
<p><img src="http://akhun.com/seo/skitch/seoxys.com_%C2%BB_Blog_Archive_%C2%BB_Tutorial__Warcraft_III_Autorefresh_for_Mac_OS_X-20080310-214654.jpg" /></p>
<p>I&#8217;m hoping this will look slick and&nbsp;professional.</p>
<p>I&#8217;m aware it isn&#8217;t totally finished: it brings IE down to its knees, and some parts don&#8217;t look quite right in Opera. I will do my best to fix these issues ASAP. If this is the case for you, I suggest you upgrade to a <a href="http://apple.com/safari/">more modern</a>&nbsp;<a href="http://getfirefox.com">browser</a>.</p>
<p>Feedback is welcome! Tune in in the comments to see how much they rock. My comments show up purple, while the rest are yellow. It also uses a speaking verb at random from a hardcoded list, because it&#8217;s&nbsp;cool!</p>
<p>And be sure to click on the photo that sticks out.<br />
It&#8217;s free, good-looking&nbsp;self-promotion.</p>
<p>This was mostly designed by <a href="http://pixelsage.com/">Ernest Liu</a>. Check him out, he&nbsp;<strong>rocks</strong>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/new-design/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NanoLifeSaver</title>
		<link>http://www.seoxys.com/nanolifesaver/</link>
		<comments>http://www.seoxys.com/nanolifesaver/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 23:06:43 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Art]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/nanolifesaver/</guid>
		<description><![CDATA[I bring to you,&#160;NanoLifeSaver. NanoLifeSaver is a slick Core Animation&#160;screensaver. (This last one is a movie, Click to&#160;Play) Download&#160;NanoLifeSaver Credit goes to Scott Stevenson for coming up with the original animation&#160;code.]]></description>
			<content:encoded><![CDATA[<p>I bring to you,&nbsp;NanoLifeSaver.</p>
<p>NanoLifeSaver is a slick Core Animation&nbsp;screensaver.</p>
<p><img src="http://rsrc.azuretalon.com/nano/nano_screen1.png" /></p>
<p><img src="http://rsrc.azuretalon.com/nano/nano_screen2.png" />  	<object width="347" height="266" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="http://rsrc.azuretalon.com/nano/nano-poster.jpg" /><param name="href" value="nano.mov" /><param name="target" value="myself" /><param name="controller" value="false" /><param name="autoplay" value="false" /><param name="scale" value="aspect" /><embed width="347" height="266" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/" 			src="http://rsrc.azuretalon.com/nano/nano-poster.jpg" 			href="http://rsrc.azuretalon.com/nano/nano.mov" 			target="myself" 			controller="false" 			autoplay="false" 			scale="aspect"></embed></object><br />
(This last one is a movie, Click to&nbsp;Play)</p>
<p><a href="http://dl.azuretalon.com/nano.zip">Download&nbsp;NanoLifeSaver</a></p>
<p>Credit goes to <a href="http://theocacao.com">Scott Stevenson</a> for coming up with the <a href="http://theocacao.com/document.page/555/">original animation&nbsp;code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/nanolifesaver/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
<enclosure url="http://rsrc.azuretalon.com/nano/nano.mov" length="78" type="video/quicktime" />
		</item>
		<item>
		<title>R.I.P. Hijack</title>
		<link>http://www.seoxys.com/rip-hijack/</link>
		<comments>http://www.seoxys.com/rip-hijack/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 14:27:05 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/rip-hijack/</guid>
		<description><![CDATA[Disappointingly, codename: Hijack / Spool is no&#160;more. I have posted about this project before, and it was really something I was excited&#160;about. Back in the day where I actually had time, I was a forum freak and was active in more than 10 forums&#8230; This would have been the dream app for&#160;me. Unfortunately, Hijack has [...]]]></description>
			<content:encoded><![CDATA[<p>Disappointingly, codename: Hijack / Spool <a href="http://hijackapp.com/2008/02/04/welcome-to-codename-hijack/">is no&nbsp;more</a>.</p>
<p><img src="http://goodcomics.com/end/spool/spool_reveal.jpg" /></p>
<p>I have <a href="http://www.seoxys.com/everything-about-nothing/">posted about this project before</a>, and it was really something I was excited&nbsp;about.</p>
<p>Back in the day where I actually had time, I was a forum freak and was active in more than 10 forums&#8230; This would have been the dream app for&nbsp;me.</p>
<p>Unfortunately, Hijack has just been open-sourced. Which means that the project is essentially&nbsp;dead.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/rip-hijack/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An introduction to Sean Collins</title>
		<link>http://www.seoxys.com/an-introduction-to-sean-collins/</link>
		<comments>http://www.seoxys.com/an-introduction-to-sean-collins/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 08:59:12 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seosoft.info/seolog/2007/11/22/an-introduction-to-sean-collins/</guid>
		<description><![CDATA[From: Sean Collins Date: July 23, 2007 4:32:35 PM EDT To: [anonymous@gmail.com] Subject: Aquatic&#160;Prime I recently read your blog post about Aquatic prime, after I was hunting around inside another&#160;application. I would like to perhaps exchange some notes, because I think I might have found at least an individual application that uses the PHP authentication [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
<b>From</b>: Sean Collins <sean@seanmcollins.com><br />
<b>Date</b>: July 23, 2007 4:32:35 PM EDT<br />
<b>To</b>: [anonymous@gmail.com]<br />
<b>Subject</b>: Aquatic&nbsp;Prime</p>
<p>I recently read your blog post about Aquatic prime, after I was hunting around inside another&nbsp;application.</p>
<p>I would like to perhaps exchange some notes, because I think I might have found at least an individual application that uses the PHP authentication of the AquaticPrime framework, and I suspect that it would be vulnerable to SQL Injection attacks, as well as using what I believe to be, a cookie that never expires that is baked into the executable, which could lead to some other interesting&nbsp;things.</p>
<p>Let me know if you&#8217;d be interested in a&nbsp;chat!</p>
<p>Thank You,<br />
Sean&nbsp;Collins
</p></blockquote>
<blockquote><p>
1:42:24 PM <span style="color:red;">seanwdp</span>: [Hey], it&#8217;s Sean C<br />
1:42:48 PM <span style="color:blue;">anonymous</span>: hey sean.<br />
1:43:10 PM <span style="color:red;">seanwdp</span>: The app in question is called Exces<br />
1:43:22 PM <span style="color:red;">seanwdp</span>: part of that MacHeist deal they were doing a week ago<br />
1:43:35 PM <span style="color:blue;">anonymous</span>: ok<br />
1:43:58 PM <span style="color:blue;">anonymous</span>: and what can you do exactly? (re-reading your email)<br />
1:44:13 PM <span style="color:red;">seanwdp</span>: I don&#8217;t have any POC just yet, just some leads.<br />
1:44:41 PM <span style="color:red;">seanwdp</span>: just looking through the executable, found some little things<br />
1:45:04 PM <span style="color:red;">seanwdp</span>: the app uses the PHP part of the AP framework<br />
1:45:14 PM <span style="color:red;">seanwdp</span>: to do registration keys and such<br />
1:45:20 PM <span style="color:blue;">anonymous</span>: k<br />
1:45:44 PM <span style="color:red;">seanwdp</span>: let me give you the executable dump<br />
1:45:55 PM <span style="color:blue;">anonymous</span>: k<br />
1:47:27 PM <span style="color:blue;">anonymous</span>: can i just strings it?<br />
1:47:57 PM <span style="color:red;">seanwdp</span>: yeah, already did and sent it to you as a txt<br />
1:48:52 PM <span style="color:red;">seanwdp</span>: one of the stings contains his license check<br />
1:48:53 PM <span style="color:blue;">anonymous</span>: ok<br />
1:48:59 PM <span style="color:red;">seanwdp</span>: it&#8217;s a PHP script<br />
1:49:09 PM <span style="color:red;">seanwdp</span>: if you connect to it with just a browser you get a bunch of mysql errors<br />
1:49:10 PM <span style="color:blue;">anonymous</span>: http://www.seosoft.info/app_rsrc/exces_licence_check.plist.php<br />
1:49:13 PM <span style="color:blue;">anonymous</span>: yeah i see<br />
1:49:14 PM <span style="color:red;">seanwdp</span>: exactly<br />
1:49:23 PM <span style="color:red;">seanwdp</span>: so I think that the cookie is a few lines below<br />
1:49:25 PM <span style="color:red;">seanwdp</span>: that has the login data<br />
1:49:43 PM <span style="color:blue;">anonymous</span>: and that is based on the AP sample code you think?<br />
1:49:52 PM <span style="color:red;">seanwdp</span>: I&#8217;m not entirely sure<br />
1:49:59 PM <span style="color:red;">seanwdp</span>: If it is the AP sample code<br />
1:50:02 PM <span style="color:red;">seanwdp</span>: that&#8217;s pretty bad<br />
1:50:11 PM <span style="color:red;">seanwdp</span>: I was going from the thinking that he tried to extend the AP<br />
1:50:18 PM <span style="color:blue;">anonymous</span>: so have you actually tried to inject anything?<br />
1:50:32 PM <span style="color:red;">seanwdp</span>: I&#8217;ve been looking for a way to feed it some bad data<br />
1:50:38 PM <span style="color:red;">seanwdp</span>: I was doing some pretty simple stuff<br />
1:50:47 PM <span style="color:red;">seanwdp</span>: the license key I think is through stenography<br />
1:50:57 PM <span style="color:red;">seanwdp</span>: so I was trying to see what it takes as a dragging source<br />
1:51:12 PM <span style="color:red;">seanwdp</span>: see if I could craft some bad data, then capture the packets<br />
1:51:22 PM <span style="color:blue;">anonymous</span>: heh ok<br />
1:51:30 PM <span style="color:red;">seanwdp</span>: What makes me wonder, is the fact that he has another part, his bug reporting<br />
1:51:39 PM <span style="color:blue;">anonymous</span>: ap uses real encryption though<br />
1:51:51 PM <span style="color:red;">seanwdp</span>: right<br />
1:51:52 PM <span style="color:blue;">anonymous</span>: no stenagraphy no faking<br />
1:52:13 PM <span style="color:red;">seanwdp</span>: but my thinking is that the app will send a user/pass<br />
1:52:30 PM <span style="color:red;">seanwdp</span>: since you get the error about not having a user or database selected<br />
1:52:35 PM <span style="color:red;">seanwdp</span>: when you visit that register page<br />
1:53:22 PM <span style="color:blue;">anonymous</span>: what user/pass?<br />
1:53:28 PM <span style="color:blue;">anonymous</span>: a bit confused<br />
1:53:44 PM <span style="color:red;">seanwdp</span>: okay. Know how you visit that registration page with a regular browser?<br />
1:53:53 PM <span style="color:blue;">anonymous</span>: y<br />
1:54:10 PM <span style="color:red;">seanwdp</span>: notice those mysql errors<br />
1:54:16 PM <span style="color:blue;">anonymous</span>: right right<br />
1:54:22 PM <span style="color:red;">seanwdp</span>: Line 2 is the host<br />
1:54:27 PM <span style="color:red;">seanwdp</span>: line 3 is the database<br />
1:54:46 PM <span style="color:blue;">anonymous</span>: looks like he&#8217;s on a dreamhost box<br />
1:54:50 PM <span style="color:red;">seanwdp</span>: right<br />
1:54:59 PM <span style="color:red;">seanwdp</span>: I&#8217;m thinking those variables<br />
1:55:02 PM <span style="color:red;">seanwdp</span>: the PHP ones<br />
1:55:22 PM <span style="color:red;">seanwdp</span>: that set the host, database name, and possibly user/password combo are in the app<br />
1:55:26 PM <span style="color:blue;">anonymous</span>: ok<br />
1:55:32 PM <span style="color:blue;">anonymous</span>: i&#8217;d be real surprised<br />
1:55:36 PM <span style="color:red;">seanwdp</span>: as would I<br />
1:55:48 PM <span style="color:blue;">anonymous</span>: in fact i doubt its likely at all<br />
1:56:05 PM <span style="color:blue;">anonymous</span>: knowing dreamhost (used to be a customer) they firewall off the mysql server<br />
1:56:24 PM <span style="color:blue;">anonymous</span>: the info would be embedded in the php<br />
1:56:33 PM <span style="color:blue;">anonymous</span>: it looks to me as if the guy has a f-ed up php<br />
1:56:45 PM <span style="color:blue;">anonymous</span>: either the mysql server is down, or something is misconfigured<br />
1:56:52 PM <span style="color:blue;">anonymous</span>: i dont think the username password are in the app<br />
1:56:56 PM <span style="color:blue;">anonymous</span>: unless you&#8217;ve found them?<br />
1:57:08 PM <span style="color:red;">seanwdp</span>: only guesses at this point, nothing jumped out in the strings<br />
1:57:14 PM <span style="color:blue;">anonymous</span>: what happens when you packet sniff?<br />
1:57:23 PM <span style="color:red;">seanwdp</span>: still trying to get that running<br />
1:57:27 PM <span style="color:blue;">anonymous</span>: ok<br />
1:57:29 PM <span style="color:red;">seanwdp</span>: I might have to do what you did<br />
1:57:33 PM <span style="color:red;">seanwdp</span>: with the code injection<br />
1:57:37 PM <span style="color:red;">seanwdp</span>: just force it to connect<br />
1:57:43 PM <span style="color:blue;">anonymous</span>: ah<br />
1:57:54 PM <span style="color:blue;">anonymous</span>: so it doesn&#8217;t connect to that url normally?<br />
1:58:02 PM <span style="color:blue;">anonymous</span>: until you register it perhaps?<br />
1:58:05 PM <span style="color:red;">seanwdp</span>: yeah<br />
1:58:08 PM <span style="color:red;">seanwdp</span>: and there&#8217;s a cookie<br />
1:58:13 PM <span style="color:red;">seanwdp</span>: expires never<br />
1:58:27 PM <span style="color:red;">seanwdp</span>: I wondered if that might be a good lead.<br />
1:58:33 PM <span style="color:blue;">anonymous</span>: AP is designed for client side validation<br />
1:58:39 PM <span style="color:blue;">anonymous</span>: he&#8217;s doing it server side too perhaps<br />
1:59:03 PM <span style="color:red;">seanwdp</span>: I mean the guy just sold like 100k licenses or something<br />
1:59:09 PM <span style="color:blue;">anonymous</span>: no shit?<br />
1:59:11 PM <span style="color:red;">seanwdp</span>: yeah<br />
1:59:12 PM <span style="color:red;">seanwdp</span>: macheist<br />
1:59:16 PM <span style="color:red;">seanwdp</span>: so I mean, it&#8217;s gotta work<br />
1:59:19 PM <span style="color:blue;">anonymous</span>: heh<br />
1:59:20 PM <span style="color:blue;">anonymous</span>: yeha<br />
1:59:24 PM <span style="color:blue;">anonymous</span>: unless it is a dead url<br />
1:59:29 PM <span style="color:blue;">anonymous</span>: isn&#8217;t used any more<br />
1:59:33 PM <span style="color:blue;">anonymous</span>: or is in there to throw you off <img src='http://www.seoxys.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> <br />
1:59:34 PM <span style="color:red;">seanwdp</span>: true, maybe he baked a new version for macheist<br />
1:59:39 PM <span style="color:blue;">anonymous</span>: maybe<br />
1:59:53 PM <span style="color:red;">seanwdp</span>: I dunno, I can&#8217;t imagine him being too smart<br />
2:00:06 PM <span style="color:red;">seanwdp</span>: his app just hands off the dirty work to disk utility<br />
2:00:09 PM <span style="color:blue;">anonymous</span>: i&#8217;d _hope_ he is if he&#8217;s releasing an encryption app<br />
2:00:11 PM <span style="color:blue;">anonymous</span>: ah<br />
2:00:12 PM <span style="color:blue;">anonymous</span>: haha<br />
2:00:19 PM <span style="color:red;">seanwdp</span>: yet still manages to have a &#8220;limit&#8221; of 10gb<br />
2:00:26 PM <span style="color:red;">seanwdp</span>: for his &#8220;vaults&#8221;<br />
2:00:48 PM <span style="color:red;">seanwdp</span>: it&#8217;s right in the code, he calls hdiutil<br />
2:01:03 PM <span style="color:red;">seanwdp</span>: all he&#8217;s got is a pretty GUI<br />
2:01:31 PM <span style="color:blue;">anonymous</span>: yeah<br />
2:01:35 PM <span style="color:blue;">anonymous</span>: another Disco app<br />
2:01:38 PM <span style="color:red;">seanwdp</span>: yep.<br />
2:02:00 PM <span style="color:red;">seanwdp</span>: At least Disco has &#8220;ismoke&#8221;<br />
2:02:05 PM <span style="color:red;">seanwdp</span>: <img src='http://www.seoxys.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> <br />
2:03:30 PM <span style="color:red;">seanwdp</span>: so what are your thoughts?<br />
2:04:17 PM <span style="color:blue;">anonymous</span>: i dunno. i&#8217;d be really surprised if the app relies on it for registration<br />
2:04:30 PM <span style="color:blue;">anonymous</span>: AP is vulnerable once you have it in your hands.<br />
2:04:44 PM <span style="color:blue;">anonymous</span>: it just depends on how much work the guy has done to obfuscate it<br />
2:04:56 PM <span style="color:blue;">anonymous</span>: and even then you can always find (and then replace) the public key used<br />
2:05:04 PM <span style="color:red;">seanwdp</span>: right<br />
2:05:11 PM <span style="color:red;">seanwdp</span>: but what about the risks to his website<br />
2:05:20 PM <span style="color:blue;">anonymous</span>: i&#8217;d be surprised if there are any<br />
2:05:28 PM <span style="color:blue;">anonymous</span>: it could just be the mysql server is fubared<br />
2:05:32 PM <span style="color:blue;">anonymous</span>: something is misconfigured<br />
2:05:41 PM <span style="color:blue;">anonymous</span>: hard to say<br />
2:05:50 PM <span style="color:blue;">anonymous</span>: any badly written php could be vulnerable<br />
2:05:54 PM <span style="color:red;">seanwdp</span>: right<br />
2:06:04 PM <span style="color:blue;">anonymous</span>: to find out for sure you need to sniff the packets and find out what it sends<br />
2:06:07 PM <span style="color:red;">seanwdp</span>: well I mean he has a bug reporter, where all the stuff is sent using the $_GET array<br />
2:06:19 PM <span style="color:blue;">anonymous</span>: any suspicious looking printf style strings?<br />
2:06:32 PM <span style="color:blue;">anonymous</span>: stuff that could be a http url request?<br />
2:06:47 PM <span style="color:blue;">anonymous</span>: &#8220;%@&#038;%@&#038;%@&#8221; type stuff?<br />
2:07:01 PM <span style="color:red;">seanwdp</span>: lemme see<br />
2:07:09 PM <span style="color:blue;">anonymous</span>: you could try hacking the bug reporter<br />
2:07:11 PM <span style="color:red;">seanwdp</span>: I swear I saw some<br />
2:07:22 PM <span style="color:blue;">anonymous</span>: if that is vulnerable then the license check  probably is too<br />
2:07:27 PM <span style="color:red;">seanwdp</span>: yeah<br />
2:07:40 PM <span style="color:red;">seanwdp</span>: I mean, it&#8217;s much easier to crack the bug reporter<br />
2:07:52 PM <span style="color:red;">seanwdp</span>: since I guess the database connection info is in the script<br />
2:07:56 PM <span style="color:red;">seanwdp</span>: *not guess<br />
2:07:59 PM <span style="color:red;">seanwdp</span>: it is<br />
2:08:07 PM <span style="color:blue;">anonymous</span>: that makes no sense<br />
2:08:08 PM <span style="color:blue;">anonymous</span>: why do that?<br />
2:08:16 PM <span style="color:red;">seanwdp</span>: pulled it out of a php book<br />
2:08:16 PM <span style="color:blue;">anonymous</span>: easier for it to be server side<br />
2:08:24 PM <span style="color:blue;">anonymous</span>: if he has to change the password he&#8217;d be fucked<br />
2:08:26 PM <span style="color:red;">seanwdp</span>: right, that&#8217;s what I&#8217;m saying<br />
2:08:27 PM <span style="color:blue;">anonymous</span>: or whatever<br />
2:08:34 PM <span style="color:red;">seanwdp</span>: he&#8217;s probably got a mysql_connect.php<br />
2:08:46 PM <span style="color:red;">seanwdp</span>: that has a username, password, host, and all that<br />
2:08:54 PM <span style="color:blue;">anonymous</span>: but even then he&#8217;d have to jump through hoops to expose his mysql server to the world<br />
2:08:59 PM <span style="color:blue;">anonymous</span>: by default DH firewalls it<br />
2:09:07 PM <span style="color:blue;">anonymous</span>: so you have to assume he knows how to do that at least<br />
2:09:12 PM <span style="color:red;">seanwdp</span>: yeah<br />
2:09:21 PM <span style="color:blue;">anonymous</span>: which is inconsistent with him putting his password in the client<br />
2:09:31 PM <span style="color:red;">seanwdp</span>: it would be<br />
2:09:46 PM <span style="color:red;">seanwdp</span>: it&#8217;s just that you don&#8217;t get the same error reporting on the bug page as the license page<br />
2:10:15 PM <span style="color:red;">seanwdp</span>: but that could be because someone wrote the bug script better<br />
2:10:24 PM <span style="color:red;">seanwdp</span>: and it doesn&#8217;t give out those errors to the user<br />
2:10:38 PM <span style="color:red;">seanwdp</span>: meanwhile someone far dumber left the error reporting on, for the license script<br />
2:11:59 PM <span style="color:blue;">anonymous</span>: well focus on the bug reporter see if you can capture what it sends<br />
2:12:05 PM <span style="color:blue;">anonymous</span>: i&#8217;d be interested to see that<br />
2:15:46 PM <span style="color:red;">seanwdp</span>: yeah<br />
2:15:58 PM <span style="color:red;">seanwdp</span>: I&#8217;m pretty sure it just sends three or four variables<br />
2:16:06 PM <span style="color:red;">seanwdp</span>: the PHP script gets them and off they go into the database<br />
2:16:12 PM <span style="color:red;">seanwdp</span>: since they&#8217;re right in the url<br />
2:16:23 PM <span style="color:red;">seanwdp</span>: http://www.seosoft.info/app_rsrc/bug_send.php?<br />lang=%@&#038;product=Exces&#038;name=%@&#038;email=<br />%@&#038;description=%@&#038;explanation=%@<br />
2:16:52 PM <span style="color:blue;">anonymous</span>: yeah<br />
2:17:15 PM <span style="color:blue;">anonymous</span>: so do some injection <img src='http://www.seoxys.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <br />
2:24:07 PM <span style="color:red;">seanwdp</span>: I&#8217;ll let you know what I come up with<br />
2:24:20 PM <span style="color:blue;">anonymous</span>: cool<br />
2:24:26 PM <span style="color:red;">seanwdp</span>: work finally threw up their hands and let me run our stuff on Apache<br />
2:24:39 PM <span style="color:red;">seanwdp</span>: the guy running the server (win2003) has NFC<br />
2:24:47 PM <span style="color:red;">seanwdp</span>: and i don&#8217;t like or care about IIS<br />
2:24:56 PM <span style="color:red;">seanwdp</span>: thing spent more time broken then up and&nbsp;running
</p></blockquote>
<p>&#8216;Nuff&nbsp;said.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/an-introduction-to-sean-collins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Trail-ware limitation</title>
		<link>http://www.seoxys.com/trail-ware-limitation/</link>
		<comments>http://www.seoxys.com/trail-ware-limitation/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 12:04:59 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seosoft.info/seolog/2007/08/08/trail-ware-limitation/</guid>
		<description><![CDATA[A topic I feel strongly about is trial-ware limitation. The most used solution these day is time limitation, and I hate&#160;it. On the MacSB mailing&#160;list: Hi&#160;all, I&#8217;ve got a client who really wants me to work up an expiring trial-ware system for one of their&#160;apps. However, I have to say that I&#8217;m always really wary [...]]]></description>
			<content:encoded><![CDATA[<p>A topic I feel strongly about is trial-ware limitation. The most used solution these day is time limitation, and I <b>hate</b>&nbsp;it.</p>
<p>On the MacSB mailing&nbsp;list:</p>
<blockquote><p>Hi&nbsp;all,</p>
<p>I&#8217;ve got a client who really wants me to work up an expiring trial-ware system<br />
for one of their<br />&nbsp;apps.</p>
<p>However, I have to say that I&#8217;m always really wary of such solutions. I regard<br />
them as easily<br />
hacked (vs., say, a build that just doesn&#8217;t contain certain features) and<br />
bypassable; therefore,<br />
I usually try to steer clients away from them, and don&#8217;t use them in my own<br />&nbsp;stuff.</p>
<p>But, I&#8217;ve known these people a long time, and don&#8217;t want to just give them a<br />
&#8220;gut reaction&#8221;<br />
answer. I thought I&#8217;d ask here first to see if anyone has any real-world<br />
experience in favor of<br />
either&nbsp;solution.</p>
<p>For that matter, if anyone is willing to discuss how they created a good<br />
expire-ware solution,<br />
I&#8217;d love to hear about&nbsp;it.</p>
<p>Many&nbsp;thanks,</p>
<p>B
</p></blockquote>
<p>My&nbsp;reply:</p>
<blockquote><p>I don&#8217;t like either expiring demos nor feature limitation because of the following&nbsp;reasons:</p>
<p>Expiring demos: Easily hackable (easiest to hack, infinite demos). Say a user tries out V1.0, but doesn&#8217;t like it. When V2.0 comes out, he hears good about it, but can&#8217;t try it and therefore will not buy&nbsp;it.</p>
<p>Feature-limited demos: Can&#8217;t try out the full&nbsp;product.</p>
<p>What I prefer, and what I do is&nbsp;Nagging.</p>
<p>It works surprisingly well. It&#8217;s timeless, and annoys the hell out of the future customer without impairing&nbsp;functionality.</p>
<p>There&#8217;s different kind of&nbsp;nagging:</p>
<p>-iGetter/Ambrosia-style nagging. You gotta wait for a minute or so before being able to use the software.<br />
-<a href="http://excesapp.com">Exces</a>-style nagging. A nag comes up periodically. The user can immediately close it, but it comes up in front-most ever so often.<br />
-The 3rd nagging style is where a window is constantly open (user can&#8217;t close it) reminding the user to register. That&#8217;s IMHO the most annoying&nbsp;one.</p>
<p>Cheers,<br />&nbsp;Kenneth
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/trail-ware-limitation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

