<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/lemon_security.php</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -35,6 +35,7 @@ dispatch('/:page', 'wikir_page_show');
     $page_name = params('page');
     if($page = WikirPage::find($page_name))
     {
+      lemon_csrf_unset_token();
       set('page_name', $page-&gt;name());
       set('page_content', $page-&gt;content());
       return html('show.php');
@@ -55,16 +56,19 @@ dispatch('/:page/new', 'wikir_page_new');
 dispatch_post('/:page', 'wikir_page_create');
   function wikir_page_create()
   {
-    $page_name    = $_POST['page_name'];
-    $page_content = $_POST['page_content'];
-    $page = new WikirPage();
-    $page-&gt;name($page_name);
-    $page-&gt;content($page_content); 
-    if($page-&gt;save())
+    if(lemon_csrf_require_valid_token())
     {
-      redirect_to($page-&gt;name());
+      $page_name    = $_POST['page_name'];
+      $page_content = $_POST['page_content'];
+      $page = new WikirPage();
+      $page-&gt;name($page_name);
+      $page-&gt;content($page_content); 
+      if($page-&gt;save())
+      {
+        redirect_to($page-&gt;name());
+      }
+      halt('An error occured. Unable to create this page. Please check page/ dir is writable.');
     }
-    halt('An error occured. Unable to create this page. Please check page/ dir is writable.');
   }
   
 dispatch('/:page/edit', 'wikir_page_edit');
@@ -73,6 +77,7 @@ dispatch('/:page/edit', 'wikir_page_edit');
     $page_name = params('page');
     if($page = WikirPage::find($page_name))
     {
+      lemon_csrf_unset_token();
       set('page_name', $page-&gt;name());
       set('page_content', $page-&gt;content());
       return html('edit.php');
@@ -87,13 +92,16 @@ dispatch_put('/:page', 'wikir_page_update');
     $page_content = $_POST['page_content'];
     if($page = WikirPage::find($page_name))
     {
-      $page-&gt;name($page_name);
-      $page-&gt;content($page_content);
-      if($page-&gt;save() !== FALSE)
+      if(lemon_csrf_require_valid_token())
       {
-        redirect($page-&gt;name());
+        $page-&gt;name($page_name);
+        $page-&gt;content($page_content);
+        if($page-&gt;save() !== FALSE)
+        {
+          redirect($page-&gt;name());
+        }
+        halt('An error occured. Unable to update this page. Please check page/ dir is writable.');
       }
-      halt('An error occured. Unable to update this page. Please check page/ dir is writable.');
     }
     halt(NOT_FOUND);
   }</diff>
      <filename>index.php</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 &lt;h1&gt;Edit page: &lt;?=h($page_name)?&gt;&lt;/h1&gt;
 &lt;form action=&quot;&lt;?=url_for($page_name)?&gt;&quot; method=&quot;post&quot;&gt;
+  &lt;?=html_form_token_field();?&gt;
   &lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;PUT&quot; id=&quot;_method&quot;&gt;
   &lt;input type=&quot;hidden&quot; name=&quot;page_name&quot; value=&quot;&lt;?=page_name?&gt;&quot; id=&quot;page_name&quot;&gt;
   &lt;textarea name=&quot;page_content&quot; id=&quot;page_content&quot; rows=&quot;8&quot; cols=&quot;40&quot;&gt;&lt;?=$page_content;?&gt;&lt;/textarea&gt;</diff>
      <filename>views/edit.php</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 &lt;h1&gt;Create page: &lt;?=h($page_name)?&gt;&lt;/h1&gt;
 &lt;form action=&quot;&lt;?=url_for('create')?&gt;&quot; method=&quot;post&quot;&gt;
+  &lt;?=html_form_token_field();?&gt;
   &lt;input type=&quot;hidden&quot; name=&quot;page_name&quot; value=&quot;&lt;?=$page_name;?&gt;&quot; id=&quot;page_name&quot;&gt;
   &lt;textarea name=&quot;page_content&quot; id=&quot;page_content&quot; rows=&quot;8&quot; cols=&quot;40&quot;&gt;&lt;/textarea&gt;
   &lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Create &amp;rarr;&quot;&gt;&lt;/p&gt;</diff>
      <filename>views/new.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>334847920c51b712591820bab565ee0b7b37dcc6</id>
    </parent>
  </parents>
  <author>
    <name>Fabrice Luraine</name>
    <email>fabrice.luraine@sofa-design.net</email>
  </author>
  <url>http://github.com/organicweb/limonade-wiki-example/commit/5ac8b223c4e4a77939aade8ee9fbd8a9e13885c1</url>
  <id>5ac8b223c4e4a77939aade8ee9fbd8a9e13885c1</id>
  <committed-date>2009-09-19T07:19:46-07:00</committed-date>
  <authored-date>2009-09-19T07:19:46-07:00</authored-date>
  <message>Adding Cross Site Request Forgery (CSRF) protection (to avoid spam...)</message>
  <tree>ee12be647b606f67df47a51ea3cc069f974d11bb</tree>
  <committer>
    <name>Fabrice Luraine</name>
    <email>fabrice.luraine@sofa-design.net</email>
  </committer>
</commit>
