<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/antispam.rb</filename>
    </added>
    <added>
      <filename>public/images/guess0.jpg</filename>
    </added>
    <added>
      <filename>public/images/guess1.jpg</filename>
    </added>
    <added>
      <filename>public/images/guess2.jpg</filename>
    </added>
    <added>
      <filename>public/images/guess3.jpg</filename>
    </added>
    <added>
      <filename>public/images/guess4.jpg</filename>
    </added>
    <added>
      <filename>public/uploads/0000/0013/Aishwarya.jpg</filename>
    </added>
    <added>
      <filename>public/uploads/0000/0013/Aishwarya_thumb.jpg</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,7 @@
 class ArticlesController &lt; ApplicationController
   
+  include Antispam
+  
   before_filter :login_required, :except =&gt; :show
   before_filter :load_logged_in_user, :only =&gt; [:index, :edit, :create, :update, :destroy]
   before_filter :load_categories, :only =&gt; [:new, :edit]
@@ -37,8 +39,7 @@ class ArticlesController &lt; ApplicationController
     @latest_articles = author.articles.recent_articles
     @tagz            = author.tagz
     # anti spam for comment posting
-    @antispam1       = rand(10)
-    @antispam2       = rand(10) 
+    @antispam        = random_antispam_question
     
     respond_to do |format|
       format.html</diff>
      <filename>app/controllers/articles_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,7 @@
 class CommentsController &lt; ApplicationController
 
+  include Antispam
+
   before_filter :is_owner_of_commented_article?,  :only =&gt; :destroy
   before_filter :load_article
 
@@ -14,10 +16,14 @@ class CommentsController &lt; ApplicationController
       @comment.author = logged_in_user.username
       @comment.email  = logged_in_user.email
       @comment.url    = blog_url_from_username(logged_in_user.username)
+    # the user posting the comment is not logged in. check the antispam response
+    elsif !valid?(params[:comment][:antispam], params[:antispam_result])
+      flash[:error] = _('invalid_antispam_response')
+      redirect_to article_path and return
     end  
     # now chech that we have both the comment author name and the comment
     if @comment.author.blank? or @comment.body.blank?
-      flash[:notice] = _('comment_incomplete')
+      flash[:error] = _('comment_incomplete')
       redirect_to article_path and return
     end
 </diff>
      <filename>app/controllers/comments_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,9 @@
 module ApplicationHelper
   
   include DomainManager
-
+  include Antispam
+  
+  # subdomains
   def current_subdomain
     self.request.subdomains.join('.')
   end
@@ -72,8 +74,11 @@ module ApplicationHelper
     User.find(session[:user_id])
   end
   
-  # localization helpers
+  def method_name
+    
+  end
   
+  # localization helpers  
   def confirm_comment_deletion
     _('confirm_comment_deletion')
   end
@@ -90,7 +95,11 @@ module ApplicationHelper
     _('homepage_magazine')    
   end
   
-  def global_menu_caffee
+  def homepage_theme
+    _('homepage_theme')    
+  end
+  
+  def homepage_caffee
     _('homepage_caffee')    
   end
   </diff>
      <filename>app/helpers/application_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@ module HomeHelper
   def profile_picture(user)
     upload = Upload.find_by_filename(user.profiles.find(:first).avatar)
     avatar_picture = upload.nil? ? nil : upload.public_filename(:thumb).to_s
-     unless avatar_picture.blank?
+     unless avatar_picture.blank? or !File.exists?(&quot;public&quot; + avatar_picture)
        &quot;&lt;img src='#{avatar_picture}' alt='#{user.username}' /&gt;&quot;
      else
       &quot;&lt;img src='/images/user#{rand(10).to_s}.png' alt=#{user.username} /&gt;&quot;</diff>
      <filename>app/helpers/home_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,9 @@
 class Comment &lt; ActiveRecord::Base
 
   belongs_to :article, :counter_cache =&gt; true
+  
+  def antispam=(value)
+    # we only need this to send the antispam back to the controller
+  end
 
 end</diff>
      <filename>app/models/comment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,6 @@
 &lt;% form_for( Comment.new, :url =&gt; user_article_comments_path(@article.user, @article), 
                 :html =&gt; {
-                :id =&gt; 'new_comment_form',
-                :onsubmit =&gt; &quot;return #{session[:id].blank?} || (parseInt($('op_1').innerHTML) + parseInt($('op_2').innerHTML) == parseInt($('antispam_result').value));&quot;
+                :id =&gt; 'new_comment_form'
                 }) do |f| -%&gt;
 
   &lt;% unless session[:user_id] -%&gt;
@@ -30,11 +29,18 @@
   &lt;p&gt; 
     &lt;%= f.text_area :body, :rows =&gt; 20, :cols =&gt; 53 %&gt;
   &lt;/p&gt;
-  &lt;% unless session[:id].blank? %&gt;
-    &lt;p&gt;
-     &lt;label for=&quot;antispam&quot;&gt;&lt;span id=&quot;op_1&quot;&gt;&lt;%= @antispam1 %&gt;&lt;/span&gt; + &lt;span id=&quot;op_2&quot;&gt;&lt;%= @antispam2 %&gt;&lt;/span&gt; = &lt;/label&gt; &lt;%= text_field_tag :antispam_result, &quot;&quot;, :size =&gt; 2 %&gt;
+  &lt;% if session[:user_id].blank? %&gt;
+    &lt;p id=&quot;antispam&quot;&gt;
+	 &lt;table&gt;
+	   &lt;tr&gt;
+         &lt;td&gt;&lt;%= image_tag path_for_antispam(@antispam) %&gt;&lt;/td&gt;
+         &lt;td width=&quot;20%&quot;&gt; ==&gt; &lt;/td&gt;
+         &lt;td width=&quot;30%&quot;&gt;&lt;%= text_field_tag :antispam_result, &quot;&quot;, :size =&gt; 10 %&gt;&lt;/td&gt;
+       &lt;/tr&gt;
+     &lt;/table&gt;
     &lt;/p&gt;
-  &lt;% end %&gt;
+    &lt;%= f.hidden_field :antispam, :value =&gt; @antispam %&gt;
+  &lt;% end %&gt; 
 
   &lt;p&gt;
     &lt;%= f.submit save %&gt;</diff>
      <filename>app/views/articles/_new_comment.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,7 @@
     	  &lt;div id=&quot;menu&quot;&gt;
     	    &lt;ul&gt;
     	      &lt;li&gt;&lt;%= link_to homepage, blog_farm_url %&gt;&lt;/a&gt;&lt;/li&gt;
-    	      &lt;li&gt;&lt;%= link_to global_menu_caffee, cat_url(Category.find_by_name(global_menu_caffee)) %&gt;&lt;/a&gt;&lt;/li&gt;
+    	      &lt;li&gt;&lt;%= link_to homepage_theme, cat_url(Category.find_by_name(homepage_caffee)) %&gt;&lt;/a&gt;&lt;/li&gt;
     	      &lt;li&gt;&lt;%= link_to 'login', user_login_path, :id =&gt; 'last' %&gt;&lt;/li&gt;
     	    &lt;/ul&gt;
     	  &lt;/div&gt;</diff>
      <filename>app/views/layouts/application.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -17,4 +17,4 @@ config.action_view.debug_rjs                         = true
 # Don't care if the mailer can't send
 config.action_mailer.raise_delivery_errors = false
 
-ActionController::Base.session_options[:session_domain] = '.imac.dev'
\ No newline at end of file
+ActionController::Base.session_options[:session_domain] = '.macbook.dev'
\ No newline at end of file</diff>
      <filename>config/environments/development.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,7 @@ homepage_pubbers: pubbers
 homepage_articles: articles
 homepage_magazine: magazine
 homepage_caffee: morning coffee
+homepage_theme: caffee
 please_log_in: please log in
 specify_name: please fill out the username
 already_taken_username: this username is already taken. please choose another one
@@ -57,6 +58,7 @@ administer_existing_articles: modify existing articles
 administer_comments: administer comments
 administer_uploaded_files: administer uploaded files
 comments: comments
+invalid_antispam_response: invalid antispam response
 said: said
 new_comment_added: new comment added
 confirm_comment_deletion: are you sure you want to delete this comment?</diff>
      <filename>vendor/plugins/polyglot/languages/en.yml</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,7 @@ homepage_pubbers: pubberi
 homepage_articles: articole
 homepage_magazine: revista
 homepage_caffee: cafeaua de dimineata
+homepage_theme: cafea
 please_log_in: te rugam sa te loghezi
 specify_name: va rugam sa introduceti numele
 already_taken_username: acest username este deja folosit. va rugam sa alegeti altul
@@ -57,6 +58,7 @@ administer_existing_articles: modifica articolele existente
 administer_comments: administreaza comentarii
 administer_uploaded_files: administreaza fisierele uploadate
 comments: comentarii
+invalid_antispam_response: raspunsul antispam invalid
 said: a spus
 new_comment_added: a fost adaugat un nou comentariu
 confirm_comment_deletion: esti sigur ca vrei sa stergi acest comentariu?</diff>
      <filename>vendor/plugins/polyglot/languages/ro.yml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9711599eb0eaa3ce6a697bf554f38ccbc72aeeeb</id>
    </parent>
  </parents>
  <author>
    <name>sergiu truta</name>
    <email>sergiutruta@gmail.com</email>
  </author>
  <url>http://github.com/sergiutruta/blogpub/commit/6b7ae124b0967012a2f8188508bd8105848c384e</url>
  <id>6b7ae124b0967012a2f8188508bd8105848c384e</id>
  <committed-date>2008-03-21T16:03:01-07:00</committed-date>
  <authored-date>2008-03-21T16:03:01-07:00</authored-date>
  <message>changed the antispam criteria</message>
  <tree>b0b72e7d8f8aceefdfbeaeefee3afa26790f515a</tree>
  <committer>
    <name>sergiu truta</name>
    <email>sergiutruta@gmail.com</email>
  </committer>
</commit>
