<?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>Jamie&#039;s Blog &#187; url shortener</title>
	<atom:link href="http://www.angelforge.org/wordpress/tags/url-shortener/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.angelforge.org/wordpress</link>
	<description>My life is words.</description>
	<lastBuildDate>Sat, 28 Jan 2012 04:35:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Stikked Patch</title>
		<link>http://www.angelforge.org/wordpress/programming/software/stikked-patch/</link>
		<comments>http://www.angelforge.org/wordpress/programming/software/stikked-patch/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 02:27:52 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[pastebin]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snipr]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[stikked]]></category>
		<category><![CDATA[url shortener]]></category>

		<guid isPermaLink="false">http://www.angelforge.org/wordpress/?p=2280</guid>
		<description><![CDATA[We&#8217;ve been using Stikked for an internal pastebin. The current version on Google Code has a few bugs. I modified this code to fix two problems specifically: The Download Code link was not working properly The Short URL functionality was not working, as Snipr had deprecated the version of the API that the program was [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been using Stikked for an internal pastebin. The current version on Google Code has a few bugs. I modified this code to fix two problems specifically:</p>
<ol>
<li>The Download Code link was not working properly</li>
<li>The Short URL functionality was not working, as Snipr had deprecated the version of the API that the program was using</li>
</ol>
<p>Below is a consolidated diff of the changes. You should be able to use it to apply a patch to 0.5.4 if you are having these issues.</p>
<p><a title="Diff" href="http://www.angelforge.org/wordpress/wp-content/uploads/2010/02/stikked.diff_.txt" target="_blank">stikked.diff</a></p>
<pre class="brush: diff; collapse: true; highlight: [16,80,99,113]; light: false; title: ; toolbar: true; notranslate">
Index: trunk/system/application/models/pastes.php
===================================================================
--- trunk/system/application/models/pastes.php	(revision 1)
+++ trunk/system/application/models/pastes.php	(revision 2)
@@ -156,14 +156,55 @@
 			$data['snipurl'] = false;
 		}
 		else
-		{
-			$target = 'http://snipr.com/site/snip?r=simple&amp;link='.site_url('view/'.$data['pid']);
+		{
+			// this next blob just copied from snipr's examples,
+			// with some modifications of course
+
+			// REQUIRED FIELDS
+			$sniplink  = site_url('view/'.$data['pid']);
+			$snipuser  = $this-&gt;config-&gt;item('snipr_user');            // YOUR USER ID REQUIRED
+			$snipapi   = $this-&gt;config-&gt;item('snipr_apikey');               // FIND IN YOUR &quot;SETTINGS&quot; PAGE
+
+			// OPTIONAL FIELDS
+			$snipnick   = '';            // MEANINGFUL NICKNAME FOR SNIPURL
+			$sniptitle  = $data['title'];  // TITLE IF ANY
+			$snippk     = '';                      // PRIVATE KEY IF ANY
+			$snipowner  = '';                      // IF THE SNIP OWNER IS SOMEONE ELSE
+			$snipformat = 'simple';                      // DEFAULT RESPONSE IS IN XML, SEND &quot;simple&quot;
+			                                       // FOR JUST THE SNIPURL
+			$snipformat_includepk = &quot;&quot;;            // SET TO &quot;Y&quot; IF YOU WANT THE PRIVATE KEY
+			                                       // RETURNED IN THE SNIPURL ALONG WITH THE ALIAS
+
+			//----------------------------------
+			// NO NEED TO EDIT BEYOND THIS POINT
+			//----------------------------------
+			$URL        = 'http://snipr.com/site/getsnip';
+			$sniplink   = rawurlencode($sniplink);
+			$snipnick   = rawurlencode($snipnick);
+			$sniptitle  = rawurlencode($sniptitle);
+
+
+			$post_data =  'sniplink='  . $sniplink  . '&amp;' .
+			              'snipnick='  . $snipnick  . '&amp;' .
+			              'snipuser='  . $snipuser  . '&amp;' .
+			              'snipapi='   . $snipapi   . '&amp;' .
+			              'sniptitle=' . $sniptitle . '&amp;' .
+			              'snipowner=' . $snipowner . '&amp;' .
+			              'snipformat='. $snipformat. '&amp;' .
+			              'snippk='    . $snippk
+			  ;
+
+
+			$target = $this-&gt;config-&gt;item('snipr_link');
 			$ch = curl_init();
 			curl_setopt($ch, CURLOPT_URL, $target);
+			curl_setopt($ch, CURLOPT_POST, true);
+			curl_setopt($ch, CURLOPT_HEADER, 0);
+			curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

 			$data['snipurl'] = curl_exec($ch);
-
+
 			curl_close($ch);

 			if(empty($data['snipurl']))
@@ -189,6 +230,7 @@

 	function checkPaste($seg=2)
 	{
+
 		if($this-&gt;uri-&gt;segment($seg) == &quot;&quot;)
 		{
 			return false;
Index: trunk/system/application/config/routes.php
===================================================================
--- trunk/system/application/config/routes.php	(revision 1)
+++ trunk/system/application/config/routes.php	(revision 2)
@@ -46,6 +46,7 @@
 $route['cron/:any'] = &quot;main/cron&quot;;

 $route['view/raw/:any'] = 'main/raw/';
+$route['view/download/:any'] = 'main/download/';
 $route['view/options'] = 'main/view_options';
 $route['view/:any'] = 'main/view';
 $route['lists'] = 'main/lists';
Index: trunk/system/application/config/config.php
===================================================================
--- trunk/system/application/config/config.php	(revision 1)
+++ trunk/system/application/config/config.php	(revision 2)
@@ -308,4 +308,16 @@
 $config['rewrite_short_tags'] = FALSE;

+/*
+|--------------------------------------------------------------------------
+| Snipr Settings - Used for short URL
+|--------------------------------------------------------------------------
+|
+| Settings for Snipr API
+|
+*/
+$config['snipr_link'] = 'http://snipurl.com/site/getsnip';
+$config['snipr_user'] = ''; // snipr user name
+$config['snipr_apikey'] = '';
+
 ?&gt;
\ No newline at end of file
Index: trunk/system/application/views/view/download.php
===================================================================
--- trunk/system/application/views/view/download.php	(revision 1)
+++ trunk/system/application/views/view/download.php	(revision 2)
@@ -1,6 +1,6 @@
 &lt;?php

-header('Content-disposition: attachment');
+header('Content-disposition: attachment;filename='.$title.'.'.$lang_code);
 echo html_entity_decode($raw);

 ?&gt;
\ No newline at end of file
Index: trunk/system/libraries/URI.php
===================================================================
--- trunk/system/libraries/URI.php	(revision 1)
+++ trunk/system/libraries/URI.php	(revision 2)
@@ -186,8 +186,15 @@
 	{
 		if ($str != '' AND $this-&gt;config-&gt;item('permitted_uri_chars') != '')
 		{
-			if ( ! preg_match(&quot;|^[&quot;.preg_quote($this-&gt;config-&gt;item('permitted_uri_chars')).&quot;]+$|i&quot;, $str))
+			$matches = array();
+			$pattern = &quot;|^[&quot;.preg_quote($this-&gt;config-&gt;item('permitted_uri_chars')).&quot;]+$|i&quot;;
+			if ( ! preg_match($pattern, $str, $matches))
 			{
+				echo '&lt;pre&gt;*'.$str.'*&lt;br&gt;';
+				echo 'allowed: '.$pattern.'&lt;br&gt;';
+				var_dump($matches);
+				var_dump(debug_backtrace());
+				echo '&lt;/pre&gt;';
 				exit('The URI you submitted has disallowed characters.');
 			}
 		}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.angelforge.org/wordpress/programming/software/stikked-patch/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

