_binary From dc8ec60710f6b2876f108acd17abf87480d008a6 Mon Sep 17 00:00:00 2001
From: Sreenidhi <sreenidhimuralidharan@gmail.com>
Date: Fri, 30 May 2014 23:48:18 -0700
Subject: [PATCH 1/4] Captcha Fully Working - Commit

---
 configs/config.php                          |   25 +-
 configs/createdb.php                        |  713 +++++++++++++++++-
 controllers/components/system_component.php |  124 ++++
 controllers/register_controller.php         |  358 +++++----
 css/search.css                              |   15 +
 models/profile_model.php                    |   11 +-
 models/textcaptchasettings_model.php        | 1057 +++++++++++++++++++++++++++
 views/elements/captchasettings_element.php  |  208 ++++++
 views/elements/graphicalcaptcha_element.php |   87 +++
 views/register_view.php                     |   24 +-
 views/suggest_view.php                      |   77 +-
 11 files changed, 2514 insertions(+), 185 deletions(-)
 mode change 100644 => 100755 controllers/components/system_component.php
 create mode 100755 models/textcaptchasettings_model.php
 create mode 100755 views/elements/captchasettings_element.php
 create mode 100755 views/elements/graphicalcaptcha_element.php

diff --git a/configs/config.php b/configs/config.php
index f58aaec..7242987 100755
--- a/configs/config.php
+++ b/configs/config.php
@@ -82,9 +82,9 @@ $COMPONENT_ACTIVITIES = array(
         "manageRoles"),
     "crawl" => array("manageCrawls", "manageClassifiers", "pageOptions",
         "resultsEditor", "searchSources"),
-    "social" => array("manageGroups", "groupFeeds", "mixCrawls", "wiki"),
+    "social" => array("manageGroups", "groupFeeds", "mixCrawls"),
     "system" => array("manageMachines", "manageLocales",
-        "serverSettings", "configure")
+        "serverSettings", "captchaSettings", "configure")
 );
 
 /** setting profile.php to something else in loac_config.php allows one to have
@@ -104,9 +104,9 @@ if(MAINTENANCE_MODE && $_SERVER["SERVER_ADDR"] != $_SERVER["REMOTE_ADDR"]) {
 }
 
 if(!defined('WORK_DIRECTORY')) {
-/*+++ The next block of code is machine edited, change at
+/*+++ The next block of code is machine edited, change at 
 your own risk, please use configure web page instead +++*/
-define('WORK_DIRECTORY', '');
+define('WORK_DIRECTORY', '/Library/WebServer/Documents/yioop_data200');
 /*++++++*/
 // end machine edited code
 }
@@ -122,15 +122,21 @@ define('FALLBACK_LOCALE_DIR', BASE_DIR."/locale");
 define ('SESSION_NAME', "yioopbiscuit");
 define('CSRF_TOKEN', "YIOOP_TOKEN");
 
-/** Captcha Mode Possibility*/
+/** Captcha Mode*/
 define('TEXT_CAPTCHA', 1);
-
-/** Captcha Mode Possibility*/
 define('HASH_CAPTCHA', 2);
+define('GRAPHICAL_CAPTCHA', 3);
+
+//Captcha Type
+define('CAPTCHA', 1);
+define('RECOVERY', 2);
+
+//Captcha Possibilities
+define('MOST', 1);
+define('LEAST', 2);
 
 /** Authentication Mode Possibility*/
 define('NORMAL_AUTHENTICATION', 1);
-
 /** Authentication Mode Possibility*/
 define('ZKP_AUTHENTICATION', 2);
 
@@ -168,7 +174,8 @@ if(file_exists(WORK_DIRECTORY.PROFILE_FILE_NAME)) {
     /** @ignore */
     define('PROFILE', false);
     define('DBMS', 'sqlite3');
-    define('CAPTCHA_MODE', HASH_CAPTCHA);
+    define('CAPTCHA_TYPE', CAPTCHA);
+    define('CAPTCHA_POSSIBILITIES', MOST);
     define('AUTHENTICATION_MODE', NORMAL_AUTHENTICATION);
     define('DEBUG_LEVEL', NO_DEBUG_INFO);
     define('USE_FILECACHE', false);
diff --git a/configs/createdb.php b/configs/createdb.php
index b409493..a828d22 100755
--- a/configs/createdb.php
+++ b/configs/createdb.php
@@ -115,7 +115,7 @@ $sql ="INSERT INTO USERS VALUES (".ROOT_ID.", 'admin', 'admin','root',
         0, 0, '$zkp_password')";
 $db->execute($sql);
 /* public account is an inactive account for used for public permissions
-   default account is root without a password 
+   default account is root without a password
  */
 $sql ="INSERT INTO USERS VALUES (".PUBLIC_USER_ID.", 'all', 'all','public',
         'public@dev.null', '".crawlCrypt('')."', '".INACTIVE_STATUS.
@@ -202,7 +202,7 @@ $public_pages["Syntax"] = <<<EOD
 
 Wiki syntax is a lightweight way to markup a text document so that
 it can be formatted and drawn nicely by Yioop.
-This page briefly describes the wiki syntax supported by Yioop. 
+This page briefly describes the wiki syntax supported by Yioop.
 
 ==Headings==
 In wiki syntax headings of documents and sections are written as follows:
@@ -277,11 +277,11 @@ Yioop also supports several html tags such as:
 |-
 |<nowiki><ins>insert</ins></nowiki>|<ins>insert</ins>
 |-
-|<nowiki><s>strike through</s> or 
+|<nowiki><s>strike through</s> or
 <strike>strike through</strike> </nowiki>|<s>strike through</s>
 |-
-|<nowiki><sup>superscript</sup> and 
-<sub>subscript</sub></nowiki>|<sup>superscript</sup> and 
+|<nowiki><sup>superscript</sup> and
+<sub>subscript</sub></nowiki>|<sup>superscript</sup> and
 <sub>subscript</sub>
 |-
 |<nowiki><tt>typewriter</tt></nowiki>|<tt>typewriter</tt>
@@ -291,7 +291,7 @@ Yioop also supports several html tags such as:
 
 ===Spacing within Paragraphs===
 The HTML entity
-<nowiki> </nowiki> 
+<nowiki> </nowiki>
 can be used to create a non-breaking space. The tag
 <nowiki><br></nowiki>
 can be used to produce a line break.
@@ -484,8 +484,7 @@ $locales = array(
     array('hi', 'हिन्दी', 'lr-tb'),
     array('tr', 'Türkçe', 'lr-tb'),
     array('fa', 'فارسی', 'rl-tb'),
-    array('te',
-    'తెలుగు', 'lr-tb'),
+    array('te', 'తెలుగు', 'lr-tb'),
 );
 
 $i = 1;
@@ -594,6 +593,12 @@ $activities = array(
             "en-US" => 'Server Settings',
             "fr-FR" => 'Serveurs',
         )),
+    "captchaSettings" => array('db_activity_captcha_settings',
+        array(
+            "en-US" => 'Captcha Settings',
+            "fr-FR" => 'Paramètres Captcha',
+        )),
+
     "configure" => array('db_activity_configure',
         array(
             "en-US" => 'Configure',
@@ -603,8 +608,557 @@ $activities = array(
             "ko" => '구성',
             "vi-VN" => 'Sắp xếp hoạt động dựa theo hoạch định',
         ))
+
+);
+
+$captcha_questions_and_choices = array(
+    // Captcha-Most Questions
+
+    $question_choice_most_pair01 = array(
+       'question' => array('identifier_string' =>'db_most_question01',
+            'method_name' => 'captcha_question_most01',
+            'values' => array('en-US' => "Which lives or lasts the longest?",
+                'fr-FR' => "Qui vit ou dure le plus longtemps?"
+                    )),
+       'choices' => array('identifier_string' => 'db_most_captcha_choices01',
+            'method_name' => 'captcha_choices_most01',
+            'values' => array('en-US' => "lightning, bacteria, ant, dog, ". 
+                "horse, person, oak tree, planet, star, galaxy",
+                'fr-FR' => "la foudre, les bactéries, une fourmi, un chien, ".
+                 "un cheval, une personne, un chêne, une planète, ".
+                 "une étoile, une galaxie"
+                    ))
+
+    ),
+    $question_choice_most_pair02 = array(
+       'question' => array('identifier_string' => 'db_most_question02',
+            'method_name' => 'captcha_question_most02',
+            'values' => array('en-US' => "Which is more abundant?",
+                'fr-FR' => "Quel est le plus abondant?",
+                    )),
+
+       'choices' => array('identifier_string' => 'db_most_captcha_choices02',
+            'method_name' => 'captcha_choices_most02',
+            'values' => array('en-US' => "continents, countries, subways, ".
+                 "cities, doctors, people, hands, teeth, hair, cells, ".
+                 "molecules, atoms, protons",
+                'fr-FR' => "continents, les pays, les métros, les villes, ".
+                 "les médecins, les gens, les mains, les dents, les cheveux, ".
+                 "les cellules, les molécules, les atomes, les protons",
+                    ))
+    ),
+
+
+    $question_choice_most_pair03 = array(
+       'question' => array('identifier_string' => 'db_most_question03',
+            'method_name' => 'captcha_question_most03',
+            'values' => array('en-US' => "Which is usually more pricey?",
+                'fr-FR' => "Quel est généralement plus cher?",
+                    )),
+
+       'choices' => array('identifier_string' => 'db_most_captcha_choices03',
+            'method_name' => 'captcha_choices_most03',
+            'values' => array('en-US' => "a postage stamp, cup of coffee, ".
+                 "movie ticket, shoes, bicycle, one month's rent, car, ".
+                 "house, a power plant",
+                'fr-FR' => "un timbre-poste, tasse de café, ". 
+                 "billet de cinéma, chaussures, vélos, ". 
+                 "la location d'un mois, voiture, maison, ".
+                 "d'une centrale électrique",
+                    ))
+    ),
+
+    $question_choice_most_pair04 = array(
+       'question' => array('identifier_string' => 'db_most_question04',
+            'method_name' => 'captcha_question_most04',
+            'values' => array('en-US' => "Which is more round?",
+                'fr-FR' => "Quel est le plus rond?",
+                    )),
+
+       'choices' => array('identifier_string' => 'db_most_captcha_choices04',
+            'method_name' => 'captcha_choices_most04',
+            'values' => array('en-US' => "a chair, the letter T, a banana, ".
+                 "a pear, an apple, an orange, a sphere",
+                'fr-FR' => "une chaise, la lettre T, une banane, une poire, ".
+                 "une pomme, une orange, une sphère",
+                    ))
+    ),
+
+    $question_choice_most_pair05 = array(
+       'question' => array('identifier_string' => 'db_most_question05',
+            'method_name' => 'captcha_question_most05',
+            'values' => array('en-US' => "Which is usually the largest?",
+                   'fr-FR' => "Quel est généralement le plus grand?",
+                       )),
+       'choices' => array('identifier_string' => 'db_most_captcha_choices05',
+            'method_name' => 'captcha_choices_most05',
+               'values' => array('en-US' => "a coin, a baseball, ". 
+                    "a milk gallon, shopping cart, refrigerator, ". 
+                    "giraffe, house, volcano, the Moon, the Earth",
+                'fr-FR' => "une pièce de monnaie, une balle de baseball, ".
+                 "un gallon de lait, panier, réfrigérateur, girafe, maison, ".
+                 "volcan, la Lune, la Terre",
+                       ))
+    ),
+
+    $question_choice_most_pair06 = array(
+       'question' => array('identifier_string' => 'db_most_question06',
+            'method_name' => 'captcha_question_most06',
+            'values' => array('en-US' => "Which is taller?",
+                  'fr-FR' => "Quel est le plus grand?",
+                      )),
+       'choices' => array('identifier_string' => 'db_most_captcha_choices06',
+            'method_name' => 'captcha_choices_most06',
+               'values' => array('en-US' => "ladybug, mouse, cat, toddler, ". 
+                    "man, horse, elephant, giraffe, tall building, mountain",
+                'fr-FR' => "coccinelle, souris, chat, enfant, homme, ".
+                 "cheval, éléphant, girafe, grand bâtiment, montagne",
+                       ))
+    ),
+
+    $question_choice_most_pair07 = array(
+       'question' => array('identifier_string' => 'db_most_question07',
+            'method_name' => 'captcha_question_most07',
+            'values' => array('en-US' => "Which takes longer?",
+                 'fr-FR' => "Qui prend plus de temps?",
+                     )),
+       'choices' => array('identifier_string' => 'db_most_captcha_choices07',
+            'method_name' => 'captcha_choices_most07',
+               'values' => array('en-US' => "blink, lick envelope, ". 
+                    "comb hair, apply makeup, watch a movie, run marathon, ". 
+                    "olympics, summer vacation, year",
+                'fr-FR' => "clignotement, enveloppe lécher, ".
+                 "peigner les cheveux, appliquer le maquillage, ".
+                 "regarder un film, exécuter marathon, jeux olympiques, ".
+                 "les vacances d'été, l'année",
+                        ))
+    ),
+
+    $question_choice_most_pair08 = array(
+       'question' => array('identifier_string' => 'db_most_question08',
+            'method_name' => 'captcha_question_most08',
+            'values' => array('en-US' => "Which is hotter sounding?",
+                 'fr-FR' => "Quel sondage plus chaud?",
+                     )),
+       'choices' => array('identifier_string' => 'db_most_captcha_choices08',
+            'method_name' => 'captcha_choices_most08',
+               'values' => array('en-US' => "Pluto, polar exploring, ". 
+                    "skating, swimming pool, tea, steam, molten iron, sun",
+                'fr-FR' => "Pluton, exploration polaire, patinage, piscine, ".
+                 "thé, vapeur, fer fondu, le soleil",
+                       ))
+    ),
+
+    $question_choice_most_pair09 = array(
+       'question' => array('identifier_string' => 'db_most_question09',
+            'method_name' => 'captcha_question_most09',
+            'values' => array('en-US' => "Which is the oldest?",
+                 'fr-FR' => "Quel est la plus ancienne?",
+                     )),
+       'choices' => array('identifier_string' => 'db_most_captcha_choices09',
+            'method_name' => 'captcha_choices_most09',
+               'values' => array('en-US' => "fresh milk, current president, ".
+                    "your grandparents, Flight at Kitty Hawk, ". 
+                    "the Black Death, Egyptian Pyramids, writing, ".
+                    "cave paintings, dinosaurs",
+                'fr-FR' => "lait frais, actuel président, ".
+                 "vos grands-parents, vol à Kitty Hawk, la peste noire, ".
+                 "pyramides égyptiennes,  l'écriture, ". 
+                 "les peintures rupestres, des dinosaures",
+                       ))
+    ),
+
+    $question_choice_most_pair10 = array(
+       'question' => array('identifier_string' => 'db_most_question10',
+            'method_name' => 'captcha_question_most10',
+            'values' => array('en-US'=> "Which holds more?",
+                'fr-FR'=> "Qui détient plus?",
+                    )),
+       'choices' => array('identifier_string' => 'db_most_captcha_choices10',
+            'method_name' => 'captcha_choices_most10',
+               'values' => array('en-US'=> "teaspoon, saucer, cup, bowl, ". 
+                    "teapot, wash basin, barrel, pickup truck, ". 
+                    "moving van, oil tanker",
+                'fr-FR'=> "cuillère à café, soucoupe, tasse, bol, théière, ".
+                 "lavabo, baril, camionnette, camion de déménagement, ".
+                  "pétrolier",
+                       ))
+        ),
+
+    //Captcha-Least Questions
+
+    $question_choice_least_pair01 = array(
+       'question' => array('identifier_string' => 'db_least_question01',
+            'method_name' => 'captcha_question_least01',
+               'values' => array('en-US' => "Which lives or lasts the ". 
+                   "shortest?",
+                'fr-FR' => "Qui vit ou dure le plus court?",
+                       )),
+       'choices' => array('identifier_string' => 'db_least_captcha_choices01',
+            'method_name' => 'captcha_choices_least01',
+            'values' => array('en-US' => "lightning, bacteria, ant, dog, ". 
+                 "horse, person, oak tree, planet, star, galaxy",
+                'fr-FR' => "la foudre, les bactéries, une fourmi, un chien, ".
+                  "un cheval, une personne, un chêne, une planète, ". 
+                  "une étoile, une galaxie",
+                      ))
+    ),
+
+    $question_choice_least_pair02 = array(
+       'question' => array('identifier_string' => 'db_least_question02',
+            'method_name' => 'captcha_question_least02',
+               'values' => array('en-US' => "Which is less abundant?",
+                'fr-FR' => "Quel est moins abondante?",
+                       )),
+       'choices' => array('identifier_string' => 'db_least_captcha_choices02',
+            'method_name' => 'captcha_choices_least02',
+            'values' => array('en-US' => "continents, countries, subways, ".
+                 "cities, doctors, people, hands, teeth, hair, cells, ".
+                 "molecules, atoms, protons",
+                'fr-FR' => "continents, les pays, les métros, les villes, ".
+                 "les médecins, les gens, les mains, les dents, ". 
+                 "les cheveux, les cellules, les molécules, ". 
+                 "les atomes, les protons",
+                      ))
+    ),
+
+    $question_choice_least_pair03 = array(
+       'question' => array('identifier_string' => 'db_least_question03',
+            'method_name' => 'captcha_question_least03',
+               'values' => array('en-US' => "Which is usually less pricey?",
+                'fr-FR' => "Quel est généralement moins cher?",
+                       )),
+       'choices' => array('identifier_string' => 'db_least_captcha_choices03',
+            'method_name' => 'captcha_choices_least03',
+             'values' => array('en-US' => "a postage stamp, cup of coffee, ".
+                 "movie ticket, shoes, bicycle, one month's rent, car, ".
+                 "house, a power plant",
+                'fr-FR' => "un timbre-poste, tasse de café, ".
+                 "billet de cinéma, chaussures, vélos, ". 
+                 "la location d'un mois, voiture, maison, ".
+                 "d'une centrale électrique",
+                      ))
+    ),
+
+    $question_choice_least_pair04 = array(
+       'question' => array('identifier_string' => 'db_least_question04',
+            'method_name' => 'captcha_question_least04',
+               'values' => array('en-US' => "Which is less round?",
+                'fr-FR' => "Quel est moins rond?",
+                       )),
+       'choices' => array('identifier_string' => 'db_least_captcha_choices04',
+            'method_name' => 'captcha_choices_least04',
+            'values' => array('en-US' => "a chair, the letter T, a banana, ".
+                 "a pear, an apple, an orange, a sphere",
+                'fr-FR' => "une chaise, la lettre T, une banane, une poire, ".
+                 "une pomme, une orange, une sphère",
+                      ))
+    ),
+
+    $question_choice_least_pair05 = array(
+       'question' => array('identifier_string' => 'db_least_question05',
+            'method_name' => 'captcha_question_least05',
+               'values' => array('en-US' => "Which is usually the smallest?",
+                'fr-FR' => "Quel est généralement le plus petit?",
+                       )),
+       'choices' => array('identifier_string' => 'db_least_captcha_choices05',
+            'method_name' => 'captcha_choices_least05',
+            'values' => array('en-US' => "a coin, a baseball, ". 
+                 "a milk gallon, shopping cart, refrigerator, ". 
+                 "giraffe,house, volcano, the Moon, the Earth",
+                'fr-FR' => "une pièce de monnaie, une balle de baseball, ".
+                 "un gallon de lait, panier, réfrigérateur, girafe, ".
+                 "maison, volcan, la Lune, la Terre",
+                      ))
+    ),
+
+    $question_choice_least_pair06 = array(
+       'question' => array('identifier_string' => 'db_least_question06',
+            'method_name' => 'captcha_question_least06',
+            'values' => array('en-US' => "Which is shorter?",
+                'fr-FR' => "Quel est le plus court?",
+                       )),
+       'choices' => array('identifier_string' => 'db_least_captcha_choices06',
+            'method_name' => 'captcha_choices_least06',
+            'values' => array('en-US' => "ladybug, mouse, cat, toddler, ".
+                 "man, horse, elephant, giraffe, tall building, mountain",
+                'fr-FR' => "coccinelle, souris, chat, enfant, homme, ".
+                 "cheval, éléphant, girafe, grand bâtiment, montagne",
+                      ))
+    ),
+
+    $question_choice_least_pair07 = array(
+       'question' => array('identifier_string' => 'db_least_question07',
+            'method_name' => 'captcha_question_least07',
+               'values' => array('en-US' => "Which takes less time?",
+                'fr-FR' => "Qui prend moins de temps?",
+                       )),
+       'choices' => array('identifier_string' => 'db_least_captcha_choices07',
+            'method_name' => 'captcha_choices_least07',
+            'values' => array('en-US' => "blink, lick envelope, comb hair, ".
+                 "apply makeup, watch a movie, run marathon, olympics, ".
+                 "summer vacation, year",
+                'fr-FR' => "clignotement, enveloppe lécher, ".
+                 "peigner les cheveux, appliquer le maquillage, ".
+                 "regarder un film, exécuter marathon, ".
+                 "jeux olympiques, les vacances d'été, l'année",
+                      ))
+    ),
+
+    $question_choice_least_pair08 = array(
+       'question' => array('identifier_string' => 'db_least_question08',
+            'method_name' => 'captcha_question_least08',
+            'values' => array('en-US' => "Which is colder sounding?",
+                'fr-FR' => "Quel est le sondage froid?",
+                      )),
+       'choices' => array('identifier_string' => 'db_least_captcha_choices08',
+            'method_name' => 'captcha_choices_least08',
+            'values' => array('en-US' => "Pluto, polar exploring, skating, ".
+                 "swimming pool, tea, steam, molten iron, sun",
+                'fr-FR' => "Pluton, exploration polaire, patinage, piscine, ".
+                 "thé, vapeur, fer fondu, le soleil",
+                     ))
+    ),
+
+    $question_choice_least_pair09 = array(
+       'question' => array('identifier_string' => 'db_least_question09',
+            'method_name' => 'captcha_question_least09',
+            'values' => array('en-US' => "Which is the newest?",
+                'fr-FR' => "Quel est le plus récent?",
+                     )),
+       'choices' => array('identifier_string' => 'db_least_captcha_choices09',
+            'method_name' => 'captcha_choices_least09',
+            'values' => array('en-US' => "fresh milk, current president, ".
+                 "your grandparents, Flight at Kitty Hawk, the Black Death, ".
+                 "Egyptian Pyramids, writing, cave paintings, dinosaurs",
+                'fr-FR' => "lait frais, actuel président, ". 
+                 "vos grands-parents, vol à Kitty Hawk, la peste noire, ". 
+                 "pyramides égyptiennes, l'écriture, ". 
+                 "les peintures rupestres, des dinosaures",
+                    ))
+    ),
+
+    $question_choice_least_pair10 = array(
+       'question' => array('identifier_string' => 'db_least_question10',
+            'method_name' => 'captcha_question_least10',
+            'values' => array('en-US' => "Which holds less?",
+                'fr-FR' => "Qui détient moins?",
+                    )),
+       'choices' => array('identifier_string' => 'db_least_captcha_choices10',
+            'method_name' => 'captcha_choices_least10',
+            'values' => array('en-US' => "teaspoon, saucer, cup, bowl, ". 
+                "teapot, wash basin, barrel, pickup truck, moving van, ". 
+                "oil tanker",
+                'fr-FR' => "cuillère à café, soucoupe, tasse, bol, théière, ".
+                 "lavabo, baril, camionnette, camion de déménagement, ".
+                 "pétrolier",
+                    ))
+    ),
+);
+
+
+$preferences_questions_and_choices = array(
+    //Preferences-Most Questions
+
+    $preferences_choice_most_pair01 = array(
+       'question' => array('identifier_string' => 'db_most_prefquestion01',
+            'method_name' => 'preferences_question_most01',
+            'values' => array('en-US' => "Animal you like the best:",
+                'fr-FR' => "Animal que vous aimez le mieux:",
+                     )),
+       'choices' => array('identifier_string' => 'db_most_prefchoices01',
+            'method_name' => 'preferences_choices_most01',
+            'values' => array('en-US' => "ant, bunny, cat, cockroach, ".
+                 "dog, goldfish, hamster, horse, snake, tiger, whale",
+                'fr-FR' => "fourmi, lapin, chat, cafard, chien, ". 
+                 "poisson d'or, hamster, cheval, serpent, ". 
+                 "araignée, tigre, baleine",
+                    ))
+    ),
+
+    $preferences_choice_most_pair02 = array(
+       'question' => array('identifier_string' => 'db_most_prefquestion02',
+            'method_name' => 'preferences_question_most02',
+            'values' => array('en-US' => "Color you like the most:",
+                'fr-FR' => "Couleur que vous aimez le plus:",
+                     )),
+       'choices' => array('identifier_string' => 'db_most_prefchoices02',
+            'method_name' => 'preferences_choices_most02',
+            'values' => array('en-US' => "no color, aquamarine, blue, ". 
+                 "brown, gold, green, gray, mauve, pink, periwinkle, ". 
+                 "purple, red, silver, turquoise, yellow",
+                'fr-FR' => "pas de couleur, aigue-marine, bleu, brun, or, ".
+                 "vert, gris, mauve, rose, bigorneau, pourpre, rouge, ".
+                 "argent, turquoise, jaune",
+                    ))
+    ),
+
+    $preferences_choice_most_pair03 = array(
+       'question' => array('identifier_string' => 'db_most_prefquestion03',
+            'method_name' => 'preferences_question_most03',
+            'values' => array('en-US' => "Food you like the most:",
+                'fr-FR' => "Nourriture que vous aimez le plus:",
+                     )),
+       'choices' => array('identifier_string' => 'db_most_prefchoices03',
+            'method_name' => 'preferences_choices_most03',
+            'values' => array('en-US' => "apple, banana, chicken, fish, ".
+                 "lamb, nuts, orange, pork, potato, tomato, steak",
+                'fr-FR' => "pomme, banane, poulet, poisson, agneau, ".
+                 "noix, orange, porc, pomme de terre, la tomate, le steak",
+                    ))
+    ),
+
+    $preferences_choice_most_pair04 = array(
+       'question' => array('identifier_string' => 'db_most_prefquestion04',
+            'method_name' => 'preferences_question_most04',
+            'values' => array('en-US' => "Drink you like the most:",
+                'fr-FR' => "Boisson vous aimez le plus:",
+                     )),
+       'choices' => array('identifier_string' => 'db_most_prefchoices04',
+            'method_name' => 'preferences_choices_most04',
+            'values' => array('en-US' => "apple juice, beer, coffee, ". 
+                 "hot tea, ice tea, lemonade, orange juice, soda, ". 
+                 "sparkling water, still water, wine",
+                'fr-FR' => "jus de pomme, bière, café, thé chaud, ". 
+                 "thé glacé, limonade, jus d'orange, soda, ". 
+                 "eau gazeuse, eau plate, vin",
+                    ))
+    ),
+
+    $preferences_choice_most_pair05 = array(
+       'question' => array('identifier_string' => 'db_most_prefquestion05',
+            'method_name' => 'preferences_question_most05',
+            'values' => array('en-US' => "Game you like the most:",
+                'fr-FR' => "Jeu que vous aimez le plus:",
+                     )),
+       'choices' => array('identifier_string' => 'db_most_prefchoices05',
+            'method_name' => 'preferences_choices_most05',
+            'values' => array('en-US' => "basketball, backgammon, checkers, ".
+                 "chess, football, hockey, skate, ski, tennis, volleyball",
+                'fr-FR' => "basket-ball, backgammon, dames, échecs, ".
+                 "football, hockey, patin, ski, tennis, volley-ball",
+                    ))
+    ),
+
+    $preferences_choice_most_pair06 = array(
+       'question' => array('identifier_string' => 'db_most_prefquestion06',
+            'method_name' => 'preferences_question_most06',
+            'values' => array('en-US' => "Sound you like the most:",
+                'fr-FR' => "Son que vous aimez le plus: ",
+                     )),
+       'choices' => array('identifier_string' => 'db_most_prefchoices06',
+            'method_name' => 'preferences_choices_most06',
+            'values' => array('en-US' => "accordion, drum, flute, guitar, ".
+                 "harmonica, harp, horn, oboe, piano, triangle, trumpet, ".
+                 "violin, whistle, xylophone",
+                'fr-FR' => "accordéon, tambour, flûte, guitare, harmonica, ".
+                 "harpe, cor, hautbois, piano, triangle, trompette, violon, ".
+                 "sifflet, xylophone",
+                    ))
+    ),
+
+    //Preferences-Least Questions
+
+    $preferences_choice_least_pair01 = array(
+       'question' => array('identifier_string' => 'db_least_prefquestion01',
+            'method_name' => 'preferences_question_least01',
+            'values' => array('en-US' => "Animal you like the least:",
+                'fr-FR' => "Animal que vous aimez le moins:",
+                     )),
+       'choices' => array('identifier_string' => 'db_least_prefchoices01',
+            'method_name' => 'preferences_choices_least01',
+            'values' => array('en-US' => "ant, bunny, cat, cockroach, dog, ".
+                 "goldfish, hamster, horse, snake, tiger, whale",
+                'fr-FR' => "fourmi, lapin, chat, cafard, chien, ".
+                 "poisson d'or, hamster, cheval, serpent, araignée, ".
+                 "tigre, baleine",
+                    ))
+    ),
+
+    $preferences_choice_least_pair02 = array(
+       'question' => array('identifier_string' => 'db_least_prefquestion02',
+            'method_name' => 'preferences_question_least02',
+            'values' => array('en-US' => "Color you like the least:",
+                'fr-FR' => "Couleur que vous aimez le moins:",
+                     )),
+       'choices' => array('identifier_string' => 'db_least_prefchoices02',
+            'method_name' => 'preferences_choices_least02',
+            'values' => array('en-US' => "no color, aquamarine, blue, ". 
+                 "brown, gold, green, gray, mauve, pink, periwinkle, ". 
+                 "purple, red, silver, turquoise, yellow",
+                'fr-FR' => "pas de couleur, aigue-marine, bleu,brun, or, ".
+                 "vert, gris, mauve, rose, bigorneau, pourpre, rouge, ". 
+                 "argent, turquoise, jaune",
+                    ))
+    ),
+
+    $preferences_choice_least_pair03 = array(
+       'question' => array('identifier_string' => 'db_least_prefquestion03',
+            'method_name' => 'preferences_question_least03',
+            'values' => array('en-US' => "Food you like the least:",
+                'fr-FR' => "Nourriture que vous aimez le moins:",
+                     )),
+       'choices' => array('identifier_string' => 'db_least_prefchoices03',
+            'method_name' => 'preferences_choices_least03',
+            'values' => array('en-US' => "apple, banana, chicken, fish, ".
+                 "lamb, nuts, orange, pork, potato, tomato, steak",
+                'fr-FR' => "pomme, banane, poulet, poisson, agneau, noix, ".
+                 "orange, porc, pomme de terre, la tomate, le steak",
+                    ))
+    ),
+
+    $preferences_choice_least_pair04 = array(
+       'question' => array('identifier_string' => 'db_least_prefquestion04',
+            'method_name' => 'preferences_question_least04',
+            'values' => array('en-US' => "Drink you like the least:",
+                'fr-FR' => "Boisson vous aimez le moins:",
+                     )),
+       'choices' => array('identifier_string' => 'db_least_prefchoices04',
+            'method_name' => 'preferences_choices_least04',
+            'values' => array('en-US' => "apple juice, beer, coffee, ". 
+                 "hot tea, ice tea, lemonade, orange juice, soda, ". 
+                 "sparkling water, still water, wine",
+                'fr-FR' => "jus de pomme, bière, café, thé chaud, ". 
+                 "thé glacé, limonade, jus d'orange, soda, ". 
+                 "eau gazeuse, eau plate, vin",
+                    ))
+    ),
+
+    $preferences_choice_least_pair05 = array(
+       'question' => array('identifier_string' => 'db_least_prefquestion05',
+            'method_name' => 'preferences_question_least05',
+            'values' => array('en-US' => "Game you like the least:",
+                'fr-FR' => "Jeu que vous aimez le moins:",
+                     )),
+       'choices' => array('identifier_string' => 'db_least_prefchoices05',
+            'method_name' => 'preferences_choices_least05',
+            'values' => array('en-US' => "basketball, backgammon, ". 
+                 "checkers, chess, football, hockey, skate, ski, ". 
+                 "tennis, volleyball",
+                'fr-FR' => "basket-ball, backgammon, dames, échecs, ". 
+                 "football, hockey, patin, ski, tennis, volley-ball",
+                    ))
+    ),
+
+    $preferences_choice_least_pair06 = array(
+       'question' => array('identifier_string' => 'db_least_prefquestion06',
+            'method_name' => 'preferences_question_least06',
+            'values' => array('en-US' => "Sound you like the least:",
+                'fr-FR' => "Son que vous aimez le moins: ",
+                     )),
+       'choices' => array('identifier_string' => 'db_least_prefchoices06',
+            'method_name' => 'preferences_choices_least06',
+            'values' => array('en-US' => "accordion, drum, flute, guitar, ".
+                 "harmonica, harp, horn, oboe, piano, triangle, trumpet, ".
+                 "violin, whistle, xylophone",
+                'fr-FR' => "accordéon, tambour, flûte, guitare, harmonica, ".
+                 "harpe, cor, hautbois, piano, triangle, trompette, violon, ".
+                 "sifflet, xylophone",
+                    ))
+    ),
 );
 
+
 $i = 1;
 foreach($activities as $activity => $translation_info) {
     // set-up activity
@@ -612,20 +1166,157 @@ foreach($activities as $activity => $translation_info) {
     //give admin role the ability to have that activity
     $db->execute("INSERT INTO ROLE_ACTIVITY VALUES (".ADMIN_ROLE.", $i)");
     $db->execute("INSERT INTO TRANSLATION
-            VALUES($i,'{$translation_info[0]}')");
+            VALUES($i, '{$translation_info[0]}')");
     foreach($translation_info[1] as $locale_tag => $translation) {
         $index = $locale_index[$locale_tag];
         $db->execute("INSERT INTO TRANSLATION_LOCALE VALUES ($i, $index,
             '$translation')");
+
     }
+
     $i++;
 }
 
+foreach($captcha_questions_and_choices as $captcha_question_and_choice) {
+    $question_data = $captcha_question_and_choice['question'];
+    $choices_data = $captcha_question_and_choice['choices'];
+    $identifier_string_question = $question_data['identifier_string'];
+    $identifier_string_choices = $choices_data['identifier_string'];
+    $method_name_question = $question_data['method_name'];
+    $method_name_choices = $choices_data['method_name'];
+    $values_question = $question_data['values'];
+    $values_choices = $choices_data['values'];
+
+    $sql_question_translation =  "INSERT INTO TRANSLATION ". 
+            "(IDENTIFIER_STRING) VALUES(?)";
+    $question_translation_result = $db->execute($sql_question_translation,
+            array($identifier_string_question));
+    if($question_translation_result) {
+        $translation_id_question = $db->insertID();
+    }
+    $sql_choices_translation =  "INSERT INTO TRANSLATION ". 
+            "(IDENTIFIER_STRING) VALUES(?)";
+    $choices_translation_result = $db->execute($sql_choices_translation,
+            array($identifier_string_choices));
+    if($choices_translation_result) {
+        $translation_id_choices = $db->insertID();
+    }
+    $sql_mapping = "INSERT INTO QUESTION_CHOICE_MAPPING ".
+            "(TRANSLATION_ID_QUESTION, TRANSLATION_ID_CHOICES) ".
+            "VALUES (?,?)";
+    $result_mapping = $db->execute($sql_mapping,
+            array($translation_id_question, $translation_id_choices));
+    if(!$result_mapping) {
+        return false;
+    }
+
+    $sql_question = "INSERT INTO CAPTCHA (TRANSLATION_ID, METHOD_NAME) ".
+            "VALUES (?,?)";
+    $result_question = $db->execute($sql_question,
+            array($translation_id_question, $method_name_question));
+    if((!$result_question)) {
+        return false;
+    }
+
+    foreach($question_data['values'] as $locale_tag => $translation_question) {
+        $index_captcha_question_and_choices = $locale_index[$locale_tag];
+        $db->execute("INSERT INTO TRANSLATION_LOCALE
+            VALUES ($translation_id_question,
+            $index_captcha_question_and_choices,
+            '".$db->escapeString($translation_question)."')");
+     }
+     foreach($choices_data['values'] as $locale_tag => $translation_choices) {
+         $index_captcha_question_and_choices = $locale_index[$locale_tag];
+         $db->execute("INSERT INTO TRANSLATION_LOCALE
+             VALUES ($translation_id_choices,
+             $index_captcha_question_and_choices,
+             '".$db->escapeString($translation_choices)."')");
+    }
+    $sql_choices = "INSERT INTO CAPTCHA (TRANSLATION_ID, METHOD_NAME) VALUES (?,?)";
+       $result_choices = $db->execute($sql_choices,
+            array($translation_id_choices, $method_name_choices));
+       if((!$result_choices)) {
+           return false;
+       }
+
+}
+
+foreach($preferences_questions_and_choices as
+            $preferences_question_and_choice) {
+
+    $questionpref_data = $preferences_question_and_choice['question'];
+    $choicespref_data = $preferences_question_and_choice['choices'];
+    $identifierpref_string_question = $questionpref_data['identifier_string'];
+    $identifierpref_string_choices = $choicespref_data['identifier_string'];
+    $methodpref_name_question = $questionpref_data['method_name'];
+    $methodpref_name_choices = $choicespref_data['method_name'];
+    $valuespref_question = $questionpref_data['values'];
+    $valuespref_choices = $choicespref_data['values'];
+
+    $sqlpref_question_translation =  "INSERT INTO TRANSLATION ". 
+            "(IDENTIFIER_STRING) VALUES(?)";
+    $questionpref_translation_result =
+            $db->execute($sqlpref_question_translation,
+            array($identifierpref_string_question));
+    if($questionpref_translation_result) {
+        $translation_id_questionpref = $db->insertID();
+    }
+    $sqlpref_choices_translation =  "INSERT INTO TRANSLATION ".
+            "(IDENTIFIER_STRING) VALUES(?)";
+    $choicespref_translation_result =
+            $db->execute($sqlpref_choices_translation,
+            array($identifierpref_string_choices));
+    if($choicespref_translation_result) {
+        $translation_id_choicespref = $db->insertID();
+    }
+
+    $sql_mapping = "INSERT INTO QUESTION_CHOICE_MAPPING ".
+            "(TRANSLATION_ID_QUESTION, TRANSLATION_ID_CHOICES) ".
+            "VALUES (?,?)";
+    $result_mapping = $db->execute($sql_mapping,
+            array($translation_id_questionpref, $translation_id_choicespref));
+    if(!$result_mapping) {
+        return false;
+    }
+
+    $sqlpref_question = "INSERT INTO PREFERENCES ". 
+            "(TRANSLATION_ID, METHOD_NAME) VALUES (?,?)";
+    $resultpref_question = $db->execute($sqlpref_question,
+            array($translation_id_questionpref, $methodpref_name_question));
+    if((!$resultpref_question)) {
+        return false;
+    }
+
+     foreach($questionpref_data['values'] as $locale_tag =>
+            $translation_questionpref) {
+       $index_preferences_question_and_choices = $locale_index[$locale_tag];
+       $db->execute("INSERT INTO TRANSLATION_LOCALE VALUES
+            ($translation_id_questionpref,
+            $index_preferences_question_and_choices,
+           '".$db->escapeString($translation_questionpref)."')");
+    }
+    foreach($choicespref_data['values'] as $locale_tag =>
+            $translation_choicespref) {
+         $index_captcha_question_and_choices = $locale_index[$locale_tag];
+         $db->execute("INSERT INTO TRANSLATION_LOCALE VALUES
+             ($translation_id_choicespref, $index_captcha_question_and_choices,
+             '".$db->escapeString($translation_choicespref)."')");
+    }
+    $sqlpref_choices = "INSERT INTO PREFERENCES ". 
+            "(TRANSLATION_ID, METHOD_NAME) VALUES (?,?)";
+    $resultpref_choices = $db->execute($sqlpref_choices,
+            array($translation_id_choicespref, $methodpref_name_choices));
+    if((!$resultpref_choices)){
+        return false;
+    }
+}
+
 $new_user_activities = array(
     "manageAccount",
     "manageGroups",
     "mixCrawls",
-    "groupFeeds"
+    "groupFeeds",
+    "captchaSettings"
 );
 
 foreach($new_user_activities as $new_activity) {
@@ -720,6 +1411,8 @@ $db->execute("INSERT INTO TRANSLATION_LOCALE VALUES
 $db->execute("INSERT INTO TRANSLATION_LOCALE VALUES
         (1004, 20, 'اخبار' )");
 
+
+
 $db->disconnect();
 if(in_array(DBMS, array('sqlite','sqlite3' ))){
     chmod(CRAWL_DIR."/data/".DB_NAME.".db", 0666);
diff --git a/controllers/components/system_component.php b/controllers/components/system_component.php
old mode 100644
new mode 100755
index e53568e..56f39a5
--- a/controllers/components/system_component.php
+++ b/controllers/components/system_component.php
@@ -342,6 +342,11 @@ class SystemComponent extends Component
         $search_array = array(array("tag", "", "", "ASC"));
         $data['SCRIPT'] = "";
         $data["ELEMENT"] = "managelocales";
+        $locales = $parent->model("locale")->getLocaleList();
+        $data["LANGUAGES"] = array();
+        foreach($locales as $locale) {
+            $data["LANGUAGES"][$locale['LOCALE_TAG']] = $locale['LOCALE_NAME'];
+        }
         $data['CURRENT_LOCALE'] = array("localename" => "",
             'localetag' => "", 'writingmode' => '-1');
         $data['WRITING_MODES'] = array(
@@ -658,6 +663,125 @@ EOD;
         return $data;
     }
 
+	/**
+     * Responsible for the Captcha settings.
+     * Allows users(and admin) to add/delete captcha questions 
+     * to/from the database.
+     */
+	function captchaSettings()
+    {
+        $parent = $this->parent;        
+        $textcaptchasettings_model = $parent->model("textcaptchasettings");
+        $possible_arguments = array("addtextcaptcha", "savetextcaptcha", 
+            "updatetextcaptcha", "setcaptchamode");
+        $data = array();
+        $profile_model = $parent->model("profile");
+        $profile =  $profile_model->getProfile(WORK_DIRECTORY);
+        $arg = "";
+        if(isset($_REQUEST['arg'])) {
+            $arg = $_REQUEST['arg'];
+        }
+        $data['SCRIPT'] = "";
+        $data["ELEMENT"] = "captchasettings";
+        $locales = $parent->model("locale")->getLocaleList();
+        $data["LANGUAGES"] = array();
+        foreach($locales as $locale) {
+            $data["LANGUAGES"][$locale['LOCALE_TAG']] = $locale['LOCALE_NAME'];
+        }
+
+        if(isset($_REQUEST['arg']) &&
+                    in_array($_REQUEST['arg'], $possible_arguments)) {
+            switch($_REQUEST['arg'])
+            {   
+                case "setcaptchamode":
+                    $captcha_mode = $_REQUEST['CAPTCHA_MODE'];
+                    if($captcha_mode) {
+                        $profile["CAPTCHA_MODE"] = $captcha_mode;
+                        $profile_model->updateProfile(WORK_DIRECTORY, 
+                            array(), $profile);
+                    }
+                    break;
+                case "addtextcaptcha": 
+                    
+                    $text_captcha_add_to_database = isset(
+                        $_REQUEST["text_captcha_add_to_database"]);
+                    if($text_captcha_add_to_database) {
+                        // Call the captcha model to insert questions to DB.
+                        $captcha_type = $_REQUEST["CAPTCHA_TYPE"];
+                        $question_type = $_REQUEST["CAPTCHA_POSSIBILITIES"];
+                        $captcha_locale = $_REQUEST["CAPTCHA_LOCALE"];
+                        $captcha_question = 
+                            $_REQUEST["CAPTCHA_QUESTION_INPUT"];
+                        $captcha_choices = $_REQUEST["CAPTCHA_CHOICES_INPUT"];
+                        if($captcha_type && $question_type && $captcha_locale 
+                            && $captcha_question && $captcha_choices) {
+                          $captcha_add = 
+                          $textcaptchasettings_model->addCaptchaDataToDatabase(
+                                $captcha_type, $question_type, $captcha_locale, 
+                                $captcha_question, $captcha_choices);
+                        }   
+
+                   } 
+                   break;
+                
+                case "updatetextcaptcha":
+                    if(isset($_REQUEST['actiondelete'])) {
+                        if(isset($_REQUEST["text_captcha_delete_questions"])) {
+                          $text_captcha_delete_questions = 
+                                $_REQUEST["text_captcha_delete_questions"];   
+                          $captcha_delete = 
+                            $textcaptchasettings_model->
+                                deleteCaptchaDataFromDatabase(
+                                $text_captcha_delete_questions);
+                        }
+                    }
+                    if(isset($_REQUEST['actionedit'])) {
+                        if(isset($_REQUEST["text_captcha_delete_questions"])) {
+                            $text_captcha_delete_questions = 
+                                $_REQUEST["text_captcha_delete_questions"];
+                            $data['EDIT_CAPTCHA_MAPS'] = 
+                                $textcaptchasettings_model->editCaptchaData(
+                                    $text_captcha_delete_questions);      
+                        }   
+                    }
+                    break;
+                case "savetextcaptcha":
+                    if(isset($_REQUEST['updateField'])) {
+                        $textcaptchasettings_model->
+                            updateCaptchaStringInTranslationLocale(
+                                $_REQUEST['updateField']);
+                    }
+                    break;
+                default:
+                    break; 
+            }   
+        }
+        $translation_locale = 
+            $textcaptchasettings_model->fetchCaptchaPrefQuestionChoices();
+        $data["translation_locale"] = $translation_locale;
+        $data['CAPTCHA_MODES'] = array (
+               TEXT_CAPTCHA =>
+                   tl('captchasettings_element_text_captcha'),
+               HASH_CAPTCHA =>
+                   tl('captchasettings_element_hash_captcha'),
+               GRAPHICAL_CAPTCHA =>
+                   tl('captchasettings_element_graphical_captcha'),
+                   );
+
+        $data['CAPTCHA_TYPE'] = array(
+               CAPTCHA => tl('captchasettings_element_captcha'),
+               RECOVERY => tl('captchasettings_element_recovery'),
+
+               );
+        $data['CAPTCHA_POSSIBILITIES'] = array(
+               MOST => tl('captchasettings_element_possibility_most'),
+               LEAST => tl('captchasettings_element_possibility_least'),    
+               );
+        $data["CAPTCHA_MODE"] = $profile["CAPTCHA_MODE"];
+        return $data;
+    }
+
+
 
     /**
      * Responsible for handling admin request related to the configure activity
diff --git a/controllers/register_controller.php b/controllers/register_controller.php
index 79ade27..d21b289 100755
--- a/controllers/register_controller.php
+++ b/controllers/register_controller.php
@@ -126,65 +126,50 @@ class RegisterController extends Controller implements CrawlConstants
      */
     function __construct()
     {
+        $locale = $this->model("locale");
+        $textcaptchasettings_model = $this->model("textcaptchasettings");
+        $tid_data = $textcaptchasettings_model->getTranslationIdMethodNameMap(
+            $locale->getLocaleTag());
+        $recovery_tid_list = $tid_data['recovery_tids'];
+        $captcha_tid_list = $tid_data['captcha_tids'];
+        $least_tid_list = $tid_data['least_tids'];
+        $most_tid_list = $tid_data['most_tids'];
+        $tid_method_name_map = $tid_data['map'];
+        $question_choices_map = 
+            $textcaptchasettings_model->getQuestionChoicesMap();
         $this->captchas_qa = array(
-            array(tl('register_controller_question0_most'),
-                tl('register_controller_question0_least'),
-                tl('register_controller_question0_choices')),
-            array(tl('register_controller_question1_most'),
-                tl('register_controller_question1_least'),
-                tl('register_controller_question1_choices')),
-            array(tl('register_controller_question2_most'),
-                tl('register_controller_question2_least'),
-                tl('register_controller_question2_choices')),
-            array(tl('register_controller_question3_most'),
-                tl('register_controller_question3_least'),
-                tl('register_controller_question3_choices')),
-            array(tl('register_controller_question4_most'),
-                tl('register_controller_question4_least'),
-                tl('register_controller_question4_choices')),
-            array(tl('register_controller_question5_most'),
-                tl('register_controller_question5_least'),
-                tl('register_controller_question5_choices')),
-            array(tl('register_controller_question6_most'),
-                tl('register_controller_question6_least'),
-                tl('register_controller_question6_choices')),
-            array(tl('register_controller_question7_most'),
-                tl('register_controller_question7_least'),
-                tl('register_controller_question7_choices')),
-            array(tl('register_controller_question8_most'),
-                tl('register_controller_question8_least'),
-                tl('register_controller_question8_choices')),
-            array(tl('register_controller_question9_most'),
-                tl('register_controller_question9_least'),
-                tl('register_controller_question9_choices')),
-            );
+            'least' => array(),
+            'most' => array()
+        );
         $this->recovery_qa = array(
-            array(tl('register_controller_recovery1_more'),
-                tl('register_controller_recovery1_less'),
-                tl('register_controller_recovery1_choices')),
-            array(tl('register_controller_recovery2_more'),
-                tl('register_controller_recovery2_less'),
-                tl('register_controller_recovery2_choices')),
-            array(tl('register_controller_recovery3_more'),
-                tl('register_controller_recovery3_less'),
-                tl('register_controller_recovery3_choices')),
-            array(tl('register_controller_recovery4_more'),
-                tl('register_controller_recovery4_less'),
-                tl('register_controller_recovery4_choices')),
-            array(tl('register_controller_recovery5_more'),
-                tl('register_controller_recovery5_less'),
-                tl('register_controller_recovery5_choices')),
-            array(tl('register_controller_recovery6_more'),
-                tl('register_controller_recovery6_less'),
-                tl('register_controller_recovery6_choices'))
-            );
+            LEAST => array(),
+            MOST => array()
+        );
+        foreach($question_choices_map as $question_translation_id => 
+            $choices_translation_id) {
+            $question_method_name = 
+                $tid_method_name_map[$question_translation_id];
+            $choices_method_name = 
+                $tid_method_name_map[$choices_translation_id];
+            $least_or_most = (in_array($question_translation_id, 
+                $least_tid_list))? LEAST: MOST;
+            if(in_array($question_translation_id, $recovery_tid_list)) {
+                $this->recovery_qa[$least_or_most][] = array(
+                    'question' => $question_method_name, 'choices' => 
+                        $choices_method_name);
+            } else {
+                $this->captchas_qa[$least_or_most][] = array(
+                    'question' => $question_method_name, 'choices' => 
+                        $choices_method_name);           
+            }
+        }
         parent::__construct();
     }
 
     /**
      *  Main entry method for this controller. Determine which account
      *  creation/recovery activity needs to be performed. Calls the
-     *  appropriate method, then sends the return $data to aview
+     *  appropriate method, then sends the return $data to a view
      *  determined by that activity. $this->displayView then renders that
      *  view
      */
@@ -196,18 +181,6 @@ class RegisterController extends Controller implements CrawlConstants
         } else {
             $user = $_SERVER['REMOTE_ADDR'];
         }
-        $visitor_check_names = array('captcha_time_out',
-            'suggest_day_exceeded');
-        foreach($visitor_check_names as $name) {
-            $visitor = $visitor_model->getVisitor($_SERVER['REMOTE_ADDR'],
-                $name);
-            if(isset($visitor['END_TIME']) && $visitor['END_TIME'] > time()) {
-                $_SESSION['value'] = date('Y-m-d H:i:s', $visitor['END_TIME']);
-                $url = BASE_URL."?c=static&p=".$visitor['PAGE_NAME'];
-                header("Location:".$url);
-                exit();
-            }
-        }
         $data = array();
         $data['REFRESH'] = "register";
         $activity = isset($_REQUEST['a']) ?
@@ -224,6 +197,10 @@ class RegisterController extends Controller implements CrawlConstants
             'processAccountData', 'createAccount', $data);
         $data["check_fields"] = array("user");
         unset($data["check_user"]);
+        if(CAPTCHA_MODE != GRAPHICAL_CAPTCHA && 
+                isset($_SESSION["graphical_captcha_string"])) {
+            unset($_SESSION["graphical_captcha_string"]);
+        }
         if(CAPTCHA_MODE == TEXT_CAPTCHA) {
             for($i = 0; $i < self::NUM_CAPTCHA_QUESTIONS; $i++) {
                 $data["check_fields"][] = "question_$i";
@@ -387,7 +364,7 @@ class RegisterController extends Controller implements CrawlConstants
             $user_model->setUserSession($user['USER_ID'], $_SESSION);
         }
         unset($_SESSION['CAPTCHA_ANSWERS']);
-        unset($_SESSION['CAPTCHAS']);
+        unset($_SESSION['CAPTCHA']);
         unset($_SESSION['RECOVERY_ANSWERS']);
         unset($_SESSION['RECOVERY']);
         return $data;
@@ -445,7 +422,7 @@ class RegisterController extends Controller implements CrawlConstants
             }
         }
         unset($_SESSION['CAPTCHA_ANSWERS']);
-        unset($_SESSION['CAPTCHAS']);
+        unset($_SESSION['CAPTCHA']);
         unset($_SESSION['RECOVERY_ANSWERS']);
         unset($_SESSION['RECOVERY']);
         $_SESSION['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
@@ -518,7 +495,7 @@ class RegisterController extends Controller implements CrawlConstants
                 $user['HASH'].$time.$user['USER_NAME'].AUTH_KEY));
         $server->send($subject, MAIL_SENDER, $user['EMAIL'], $message);
         unset($_SESSION['CAPTCHA_ANSWERS']);
-        unset($_SESSION['CAPTCHAS']);
+        unset($_SESSION['CAPTCHA']);
         unset($_SESSION['RECOVERY_ANSWERS']);
         unset($_SESSION['RECOVERY']);
         return $data;
@@ -647,10 +624,14 @@ class RegisterController extends Controller implements CrawlConstants
         $data["REFRESH"] = "suggest";
         $visitor_model = $this->model("visitor");
         $clear = false;
-        if($profile['CAPTCHA_MODE'] == HASH_CAPTCHA) {
+        if(CAPTCHA_MODE != GRAPHICAL_CAPTCHA && 
+                isset($_SESSION["graphical_captcha_string"])) {
+            unset($_SESSION["graphical_captcha_string"]);
+        }
+        if(CAPTCHA_MODE == HASH_CAPTCHA) {
             $data['INCLUDE_SCRIPTS'] = array("sha1", "hash_captcha");
         }
-        if($profile['CAPTCHA_MODE'] == TEXT_CAPTCHA) {
+        if(CAPTCHA_MODE == TEXT_CAPTCHA) {
             $num_captchas = self::NUM_CAPTCHA_QUESTIONS;
             unset($_SESSION["request_time"]);
             unset($_SESSION["level"] );
@@ -686,27 +667,31 @@ class RegisterController extends Controller implements CrawlConstants
         if(isset($_REQUEST['url'])) {
             $data['url'] = $this->clean($_REQUEST['url'], "string");
         }
-        if($profile['CAPTCHA_MODE'] == TEXT_CAPTCHA) {
-            if(!isset($_SESSION['CAPTCHAS']) ||
+        if(CAPTCHA_MODE == TEXT_CAPTCHA) {
+            if(!isset($_SESSION['CAPTCHA']) ||
                !isset($_SESSION['CAPTCHA_ANSWERS'])){
                 list($captchas, $answers) = $this->selectQuestionsAnswers(
-                $this->captchas_qa, $num_captchas, self::NUM_CAPTCHA_CHOICES);
-                $data['CAPTCHAS'] = $captchas;
+                    $this->captchas_qa, $num_captchas, 
+                    self::NUM_CAPTCHA_CHOICES);
+                $data['CAPTCHA'] = $captchas;
                 $data['build_time'] = time();
                 $_SESSION['BUILD_TIME'] = $data['build_time'];
                 $_SESSION['CAPTCHA_ANSWERS'] = $answers;
-                $_SESSION['CAPTCHAS'] = $data['CAPTCHAS'];
+                $_SESSION['CAPTCHA'] = $data['CAPTCHA'];
             } else {
-                $data['CAPTCHAS'] = $_SESSION['CAPTCHAS'];
+                $data['CAPTCHA'] = $_SESSION['CAPTCHA'];
             }
         }
         $missing = array();
         $save = isset($_REQUEST['arg']) && $_REQUEST['arg'];
+        if(CAPTCHA_MODE == GRAPHICAL_CAPTCHA && !$save) {
+            $this->setupGraphicalCaptchaViewData();
+        }
         if(CAPTCHA_MODE == TEXT_CAPTCHA) {
             for($i = 0; $i < $num_captchas; $i++) {
             $field = "question_$i";
-            $captchas = isset($_SESSION['CAPTCHAS'][$i]) ?
-                $_SESSION['CAPTCHAS'][$i] : array();
+            $captchas = isset($_SESSION['CAPTCHA'][$i]) ?
+                $_SESSION['CAPTCHA'][$i] : array();
             if($save) {
                 if(!isset($_REQUEST[$field]) || $_REQUEST[$field] == "-1" ||
                     !in_array($_REQUEST[$field], $captchas)) {
@@ -719,6 +704,7 @@ class RegisterController extends Controller implements CrawlConstants
         }
         $data['MISSING'] = $missing;
         if($save && isset($_REQUEST['url'])) {
+			print("suggest url saved?");
             $url = $this->clean($_REQUEST['url'], "string");
             $url_parts = @parse_url($url);
             if(!isset($url_parts['scheme'])) {
@@ -736,7 +722,7 @@ class RegisterController extends Controller implements CrawlConstants
                     tl('register_controller_error_fields')."</h1>');";
                 return $data;
             }
-            if(CAPTCHA_MODE == HASH_CAPTCHA) {
+           if(CAPTCHA_MODE == HASH_CAPTCHA) {
                 if(!$this->validateHashCode()) {
                     $data['SCRIPT'] = "doMessage('<h1 class=\"red\" >".
                     tl('register_controller_failed_hashcode')."</h1>');";
@@ -751,14 +737,30 @@ class RegisterController extends Controller implements CrawlConstants
                     tl('register_controller_failed_human')."</h1>');";
                 for($i = 0; $i < $num_captchas; $i++) {
                     $data["question_$i"] = "-1";
-                }
-                unset($_SESSION['CAPTCHAS']);
+                
+                 }
+                unset($_SESSION['CAPTCHA']);
                 unset($_SESSION['CAPTCHA_ANSWERS']);
                 $visitor_model->updateVisitor(
                     $_SERVER['REMOTE_ADDR'], "captcha_time_out");
                 return $data;
                 }
             }
+            if(CAPTCHA_MODE == GRAPHICAL_CAPTCHA) {
+                if(isset ($_SESSION['graphical_captcha_string']) && 
+                        $_SESSION['graphical_captcha_string'] != 
+                        $_REQUEST['user_entered_graphical_captcha_string']) {
+                    $data['SCRIPT'] = "doMessage('<h1 class=\"red\" >".
+                        tl('register_controller_failed_graphical_human').
+                        "</h1>');";
+                    unset($_SESSION['graphical_captcha_string']);
+                    $this->setupGraphicalCaptchaViewData();
+                    $visitor_model->updateVisitor(
+                        $_SERVER['REMOTE_ADDR'], "captcha_time_out");
+                    return $data;
+                }
+                $this->setupGraphicalCaptchaViewData();
+            }
             if(!$this->model("crawl")->appendSuggestSites($url)) {
                 $data['SCRIPT'] = "doMessage('<h1 class=\"red\" >".
                 tl('register_controller_suggest_full')."</h1>');";
@@ -769,22 +771,23 @@ class RegisterController extends Controller implements CrawlConstants
             $visitor_model->updateVisitor(
                 $_SERVER['REMOTE_ADDR'], "suggest_day_exceeded",
                 self::ONE_DAY, self::ONE_DAY, MAX_SUGGEST_URLS_ONE_DAY);
-            if($profile['CAPTCHA_MODE'] == TEXT_CAPTCHA) {
+            if(CAPTCHA_MODE == TEXT_CAPTCHA) {
                 for($i = 0; $i < $num_captchas; $i++) {
                 $data["question_$i"] = "-1";
                 }
-                unset($_SESSION['CAPTCHAS']);
+                unset($_SESSION['CAPTCHA']);
                 unset($_SESSION['CAPTCHA_ANSWERS']);
                 list($captchas, $answers) = $this->selectQuestionsAnswers(
-                $this->captchas_qa, $num_captchas, self::NUM_CAPTCHA_CHOICES);
-                $data['CAPTCHAS'] = $captchas;
+                    $this->captchas_qa, $num_captchas, 
+                    self::NUM_CAPTCHA_CHOICES);
+                $data['CAPTCHA'] = $captchas;
                 $_SESSION['CAPTCHA_ANSWERS'] = $answers;
-                $_SESSION['CAPTCHAS'] = $data['CAPTCHAS'];
+                $_SESSION['CAPTCHA'] = $data['CAPTCHA'];
             }
             $data['build_time'] = time();
             $_SESSION['BUILD_TIME'] = $data['build_time'];
-            $data['url'] ="";
-        }
+            $data['url'] =""; 
+        } 
         return $data;
     }
 
@@ -828,16 +831,23 @@ class RegisterController extends Controller implements CrawlConstants
             unset($_SESSION["request_time"]);
             unset($_SESSION["level"] );
             unset($_SESSION["random_string"] );
-        if(!isset($_SESSION['CAPTCHAS'])||!isset($_SESSION['CAPTCHA_ANSWERS'])){
-            list($captchas, $answers) = $this->selectQuestionsAnswers(
-                $this->captchas_qa, self::NUM_CAPTCHA_QUESTIONS,
-                self::NUM_CAPTCHA_CHOICES);
-            $data['CAPTCHAS'] = $captchas;
-            $_SESSION['CAPTCHA_ANSWERS'] = $answers;
-            $_SESSION['CAPTCHAS'] = $data['CAPTCHAS'];
-        } else {
-            $data['CAPTCHAS'] = $_SESSION['CAPTCHAS'];
+            if(empty($_SESSION['CAPTCHA'])) {
+                unset($_SESSION['CAPTCHA']);
+            }
+            if(!isset($_SESSION['CAPTCHA']) || !isset(
+                    $_SESSION['CAPTCHA_ANSWERS'])){
+                list($captchas, $answers) = $this->selectQuestionsAnswers(
+                    $this->captchas_qa, self::NUM_CAPTCHA_QUESTIONS,
+                    self::NUM_CAPTCHA_CHOICES);
+                $data['CAPTCHA'] = $captchas;
+                $_SESSION['CAPTCHA_ANSWERS'] = $answers;
+                $_SESSION['CAPTCHA'] = $data['CAPTCHA'];
+            } else {
+                $data['CAPTCHA'] = $_SESSION['CAPTCHA'];
+            }
         }
+        if(CAPTCHA_MODE == GRAPHICAL_CAPTCHA) {
+            $this->setupGraphicalCaptchaViewData();
         }
         if(!isset($_SESSION['RECOVERY'])) {
             list($data['RECOVERY'], ) = $this->selectQuestionsAnswers(
@@ -848,17 +858,67 @@ class RegisterController extends Controller implements CrawlConstants
         }
         return $data;
     }
-
+    
+    /**
+     * Sets up the graphical captcha view
+     * Draws the string for graphical captcha
+     */
+    
+    function setupGraphicalCaptchaViewData() {
+        unset($_SESSION["graphical_captcha_string"]);
+        // defines captcha text
+        $characters_for_captcha = '1234567890'.
+            'abcdefghijklmnopqrstuvwxyz'.
+            'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+        $len = strlen($characters_for_captcha);
+        // selecting letters for captcha
+        $captcha_letter = $characters_for_captcha[rand(0, $len - 1)]; 
+        $word = "";
+        for ($i = 0; $i < 6; $i++) {
+            // selecting letters for captcha
+            $captcha_letter = $characters_for_captcha[rand(0, $len - 1)];
+            $word = $word.$captcha_letter;
+         }
+         // stores the captcha in a session variable 'graphical_captcha_string'
+         $_SESSION['graphical_captcha_string'] = $word;
+    }
+    
     /**
-     *  Picks $num_select most/least questions from an array of triplets of
-     *  the form a string question: Which is the most ..?, a string
-     *  question: Which is the least ..?, followed by a comma separated list
-     *  of choices ranked from least to most. For each question pick,
-     *  $num_choices many items from the last element of the triplet are
-     *  chosen.
+     *  Picks $num_select most/least questions from an associative array
+     * which contains 2 other arrays one for most and one for least.
+     * The arrays for most or least in turn contains and array of
+     * question-choices pair; question: Which is the most ..? and 
+     * choices: which contains a comma separated list of choices ranked from 
+     * least to most. For each question pick, $num_choices many items from 
+     * the choices would be selected.
+     * An example associative array would like this.
+     * $this->captchas_qa = array(
+     *  MOST => array(
+     *      array(
+     *          "question"=>"register_controller_question0_most",
+     *          "choices"=>"register_controller_question0_choices"
+     *      ),
+     *      array(
+     *          "question"=>"register_controller_question1_most",
+     *          "choices"=>"register_controller_question1_choices"
+     *      )
+     *
+     *  ),
+     *  LEAST => array(
+     *      array(
+     *          "question"=>"register_controller_question0_least",
+     *          "choices"=>"register_controller_question0_choices"
+     *      ),
+     *      array(
+     *          "question"=>"register_controller_question0_least",
+     *          "choices"=>"register_controller_question0_choices"
+     *      )
+     *    )
+     *   );
      *
      *  @param array $questions_answers an array t_1, t_2, t_3, t_4, where
-     *      each t_i is a triplet as described above
+     *      each t_i is an associative array containing the most
+     *      and least arrays as described above
      *  @param int $num_select number of triples from the list to pick
      *      for each triple pick either the most question or the least
      *      question
@@ -873,14 +933,37 @@ class RegisterController extends Controller implements CrawlConstants
     {
         $questions = array();
         $answers = array();
-        $size_qa = count($question_answers);
-        for($i = 0; $i < $num_select; $i++) {
-            do {
-                $question_choice = mt_rand(0, $size_qa - 1);
-            }while(isset($questions[$question_choice]));
-            $more_less = rand(0, 1);
+        // Clone arrays so you can unset values
+        $qa_least_arr = array_merge(array(), $question_answers[LEAST]);
+        $qa_most_arr = array_merge(array(), $question_answers[MOST]);
+
+        for($i = 0; $i < $num_select && (count($qa_most_arr) > 0 && 
+                count($qa_least_arr) > 0); $i++) {
+            $least_or_most = (rand(0, 1))?MOST:LEAST;
+            if(count($qa_most_arr) == 0 && count($qa_least_arr) > 0) {
+                $least_or_most = LEAST;
+            } elseif (count($qa_most_arr) >= 0 && count($qa_least_arr) == 0) {
+                $least_or_most = MOST;
+            }
+            
+            $selected_question_choice = Null;
+            $most_question_choice_index = -1;
+            $least_question_choice_index = -1;
+            if($least_or_most == MOST) {
+              $size_qa = count($qa_most_arr);
+              $most_question_choice_index = mt_rand(0, $size_qa - 1);
+              $selected_question_choice = 
+                  $qa_most_arr[$most_question_choice_index];
+            } else {
+              $size_qa = count($qa_least_arr);
+              $least_question_choice_index = mt_rand(0, $size_qa - 1);
+              $selected_question_choice = 
+                  $qa_least_arr[$least_question_choice_index];
+            }
+            
             $answer_possibilities =
-                explode(",", $question_answers[$question_choice][2]);
+                explode(",", 
+                    $selected_question_choice["choices"]);
             $selected_possibilities = array();
             $size_possibilities = count($answer_possibilities);
             if($num_choices < 0) {
@@ -889,27 +972,32 @@ class RegisterController extends Controller implements CrawlConstants
                 $num = $num_choices;
             }
             for($j = 0; $j < $num; $j++) {
-                do {
-                    $selected_possibility = mt_rand(0, $size_possibilities - 1);
-                } while(isset($selected_possibilities[$selected_possibility]));
-                $selected_possibilities[$selected_possibility] =
-                    $answer_possibilities[$selected_possibility];
+              do {
+                  $selected_possibility = mt_rand(0, $size_possibilities - 1);
+              } while(isset($selected_possibilities[$selected_possibility]));
+              $selected_possibilities[$selected_possibility] =
+                  $answer_possibilities[$selected_possibility];
             }
-            $questions[$question_choice] = array("-1" =>
-                    $question_answers[$question_choice][$more_less]);
+            $questions[$i] =  array("-1" =>
+                    $selected_question_choice["question"]);
             $tmp = array_values($selected_possibilities);
-            $questions[$question_choice] +=  array_combine($tmp, $tmp);
-            if($more_less) {
+            $questions[$i] +=  array_combine($tmp, $tmp);
+            if($least_or_most == MOST) {
                 ksort($selected_possibilities);
-                $selected_possibilities = array_values($selected_possibilities);
+                $selected_possibilities = 
+                    array_values($selected_possibilities);
                 $answers[$i] = $selected_possibilities[0];
+                unset($qa_most_arr[$most_question_choice_index]);
+                $qa_most_arr = array_values($qa_most_arr);
             } else {
                 krsort($selected_possibilities);
-                $selected_possibilities = array_values($selected_possibilities);
+                $selected_possibilities = 
+                    array_values($selected_possibilities);
                 $answers[$i] = $selected_possibilities[0];
+                unset($qa_least_arr[$least_question_choice_index]);
+                $qa_least_arr = array_values($qa_least_arr);
             }
         }
-        $questions = array_values($questions);
         return array($questions, $answers);
     }
 
@@ -940,7 +1028,7 @@ class RegisterController extends Controller implements CrawlConstants
                 $activity = $activity_fail;
             }
             if($activity == $activity_success) {
-                if($profile['CAPTCHA_MODE'] == TEXT_CAPTCHA) {
+                if(CAPTCHA_MODE == TEXT_CAPTCHA) {
                     if(!isset($_SESSION['CAPTCHA_ANSWERS']) ) {
                         $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >".
                         tl('register_controller_need_cookies')."</h1>');";
@@ -953,14 +1041,25 @@ class RegisterController extends Controller implements CrawlConstants
                         for($i = 0; $i < self::NUM_CAPTCHA_QUESTIONS; $i++) {
                             $data["question_$i"] = "-1";
                         }
-                    unset($_SESSION['CAPTCHAS']);
+                    unset($_SESSION['CAPTCHA']);
                     unset($_SESSION['CAPTCHA_ANSWERS']);
                     $this->model("visitor")->updateVisitor(
                         $_SERVER['REMOTE_ADDR'], "captcha_time_out");
                     $activity = $activity_fail;
                     }
-                }
-                else {
+                } elseif (CAPTCHA_MODE == GRAPHICAL_CAPTCHA) {
+                    if($_SESSION['graphical_captcha_string'] != 
+                            $_REQUEST[
+                            'user_entered_graphical_captcha_string']) {
+                        $data['SCRIPT'] = "doMessage('<h1 class=\"red\" >".
+                        tl('register_controller_failed_graphical_human')."
+                            </h1>');";
+                        unset($_SESSION['graphical_captcha_string']);
+                        $this->model("visitor")->updateVisitor(
+                            $_SERVER['REMOTE_ADDR'], "captcha_time_out");
+                        $activity = $activity_fail;
+                    }
+                } else {
                     if(!$this->validateHashCode()) {
                         $data['SCRIPT'] = "doMessage('<h1 class=\"red\" >".
                         tl('register_controller_failed_hashcode')."</h1>');";
@@ -1010,19 +1109,22 @@ class RegisterController extends Controller implements CrawlConstants
     function checkCaptchaAnswers()
     {
         $captcha_passed = true;
+        
         for($i = 0; $i < self::NUM_CAPTCHA_QUESTIONS; $i++) {
+	
             $field = "question_".$i;
             if($_REQUEST[$field] != $_SESSION['CAPTCHA_ANSWERS'][$i]) {
                 $captcha_passed = false;
                 break;
+              
             }
         }
         return $captcha_passed;
     }
 
     /**
-     *  Checks whether the answers to the account recovery questions match those
-     *  provided earlier by an account user
+     *  Checks whether the answers to the account recovery questions match 
+     * those provided earlier by an account user
      *
      *  @param array $user who to check recovery answers for
      *  @return bool true if only if all were correct
diff --git a/css/search.css b/css/search.css
index f783c8a..2a30579 100755
--- a/css/search.css
+++ b/css/search.css
@@ -2474,3 +2474,18 @@ table.wikitable > caption
     z-index: 200;
 }
 
+/* Captcha settings styles */
+
+#captcha-settings-container ul {
+    list-style-type: none;
+    padding: 0;
+}
+
+#captcha-settings-container li {
+    line-height: 40px;
+}
+
+.graphical-captcha-container {
+    width: 260px;
+    padding-top: 10px;
+}
diff --git a/models/profile_model.php b/models/profile_model.php
index 3e14201..a1d9e62 100755
--- a/models/profile_model.php
+++ b/models/profile_model.php
@@ -309,6 +309,13 @@ EOT;
             "CREATE TABLE ACTIVITY (ACTIVITY_ID $serial PRIMARY KEY
                 $auto_increment, TRANSLATION_ID INTEGER,
                 METHOD_NAME VARCHAR(256))",
+
+			"CREATE TABLE CAPTCHA (CAPTCHA_ID $serial PRIMARY KEY $auto_increment,
+	                TRANSLATION_ID INTEGER, METHOD_NAME VARCHAR(256) )",     
+	                        
+	        "CREATE TABLE QUESTION_CHOICE_MAPPING (TRANSLATION_ID_QUESTION INTEGER,
+	                TRANSLATION_ID_CHOICES INTEGER )",            
+
             "CREATE INDEX ACTIVITY_TRANSLATION_ID_INDEX ON
                  ACTIVITY (TRANSLATION_ID)",
             "CREATE TABLE CRAWL_MIXES (TIMESTAMP NUMERIC(11) PRIMARY KEY,
@@ -348,7 +355,7 @@ EOT;
                 MEMBER_ACCESS INTEGER, VOTE_ACCESS INTEGER DEFAULT ".
                 NON_VOTING_GROUP.")",
             /* NOTE: We are not using singular name GROUP for GROUPS as
-               is a reserved SQL keyword
+               GROUP is a reserved SQL keyword
              */
             "CREATE INDEX GRP_OWNER_ID_INDEX ON GROUPS (OWNER_ID)",
             "CREATE INDEX GRP_MEMBER_ACCESS_INDEX ON GROUPS(MEMBER_ACCESS)",
@@ -373,6 +380,8 @@ EOT;
                 PRIMARY KEY(TIMESTAMP, FRAGMENT_ID))",
             "CREATE TABLE ROLE (ROLE_ID $serial PRIMARY KEY $auto_increment,
                 NAME VARCHAR(512))",
+			"CREATE TABLE PREFERENCES (PREFERENCES_ID $serial PRIMARY KEY $auto_increment,
+		                TRANSLATION_ID INTEGER, METHOD_NAME VARCHAR(256))",     
             "CREATE TABLE ROLE_ACTIVITY (ROLE_ID INTEGER, ACTIVITY_ID INTEGER,
                 PRIMARY KEY(ROLE_ID, ACTIVITY_ID))",
             "CREATE TABLE SUBSEARCH (LOCALE_STRING VARCHAR(32) PRIMARY KEY,
diff --git a/models/textcaptchasettings_model.php b/models/textcaptchasettings_model.php
new file mode 100755
index 0000000..3a4fa20
--- /dev/null
+++ b/models/textcaptchasettings_model.php
@@ -0,0 +1,1057 @@
+<?php
+/**
+ *  SeekQuarry/Yioop --
+ *  Open Source Pure PHP Search Engine, Crawler, and Indexer
+ *
+ *  Copyright (C) 2009 - 2014  Chris Pollett chris@pollett.org
+ *
+ *  LICENSE:
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *  END LICENSE
+ *
+ * @author Chris Pollett chris@pollett.org
+ * @package seek_quarry
+ * @subpackage model
+ * @license http://www.gnu.org/licenses/ GPL3
+ * @link http://www.seekquarry.com/
+ * @copyright 2009 - 2014
+ * @filesource
+ */
+
+if(!defined('BASE_DIR')) {echo "BAD REQUEST"; exit();}
+
+/** Loads base model class if necessary */
+require_once BASE_DIR."/models/model.php";
+/**
+ * This is class is used to handle the
+ * captcha settings for Yioop
+ *
+ * @author Chris Pollett
+ *
+ * @package seek_quarry
+ * @subpackage model
+ */
+class TextcaptchasettingsModel extends Model
+{
+    /**
+     * Given the identifier string for the question, return the translation_id
+     * of a string given the identifier_string, for the captcha question
+     *
+     * @param string $identifier_string which is the identifier string for
+     * a captcha question
+     * @return string the identifier string for a captcha question
+     */
+
+    function getTranslationId($identifier_string)
+    {
+
+         $sql = "SELECT DISTINCT(TRANSLATION_ID) FROM TRANSLATION ". 
+             "WHERE IDENTIFIER_STRING = :identifier_string";
+         $result = $this->db->execute($sql,
+            array(":identifier_string" => $identifier_string));
+         if($result){
+             $row = $this->db->fetchArray($result);
+         }
+         return $row['TRANSLATION_ID'];
+    }
+
+    /**
+     * Computes and returns identifier_string for a captcha question
+     * given captcha_locale and captcha_type
+     *
+     * @param string captcha_type either captcha or recovery which is a part of
+     * the identifier string for a question
+     * @param string question_type either most or least which is a
+     * part of the identifier string for a captcha/recovery question
+     *
+     * @return string the identifier_string for a captcha question
+     */
+
+    function getIdentifierStringQuestion($captcha_type, $question_type)
+    {
+        $identifier_string_question = "";
+        $row = "";
+
+        // Most Captcha questions
+         if($captcha_type == CAPTCHA && $question_type == MOST) {
+            $identifier_string_filter = "db_most_question%";
+            $most_captcha_sql = "SELECT TRANSLATION_ID, ".
+                "MAX(IDENTIFIER_STRING) AS IDENTIFIER_STRING ".
+                "FROM TRANSLATION WHERE IDENTIFIER_STRING ".
+                "LIKE :identifier_string_filter ".
+                "ORDER BY IDENTIFIER_STRING DESC";
+            $result = $this->db->execute($most_captcha_sql,
+                array(":identifier_string_filter" =>
+                $identifier_string_filter));
+            if($result) {
+                $row = $this->db->fetchArray($result);
+            }
+            $identifier_string_index = str_replace("db_most_question", "",
+                $row['IDENTIFIER_STRING']);
+            /*
+                Converts $identifier_index to Integer
+                Checks if $identifier_index is an integer.
+                If yes, adds 1 to it
+              */
+            if(!is_numeric($identifier_string_index)) {
+                return false;
+            } else {
+                $identifier_index = (int)$identifier_string_index;
+                $identifier_index += 1;
+            }
+            $identifier_string_question = str_replace("db_most_question%",
+                "db_most_question", $identifier_string_filter);
+            $identifier_string_question =
+                $identifier_string_question.$identifier_index;
+
+
+         // Least Captcha Questions
+         } else if($captcha_type == CAPTCHA && $question_type == LEAST) {
+             $identifier_string_filter = "db_least_question%";
+            $least_captcha_sql = "SELECT TRANSLATION_ID, ". 
+                "MAX(IDENTIFIER_STRING) AS IDENTIFIER_STRING ". 
+                "FROM TRANSLATION WHERE IDENTIFIER_STRING ".
+                "LIKE :identifier_string_filter ". 
+                "ORDER BY IDENTIFIER_STRING DESC";
+            $result = $this->db->execute($least_captcha_sql,
+                array(":identifier_string_filter" =>
+                $identifier_string_filter));
+            if($result) {
+                $row = $this->db->fetchArray($result);
+            }
+            $identifier_string_index = str_replace("db_least_question", "",
+                $row['IDENTIFIER_STRING']);
+            /*
+               Converts $identifier_index to Integer
+               Checks if $identifier_index is an integer.
+               If yes, adds 1 to it
+             */
+            if(!is_numeric($identifier_string_index)) {
+               return false;
+            } else {
+               $identifier_index = (int)$identifier_string_index;
+               $identifier_index += 1;
+            }
+            $identifier_string_question = str_replace("db_least_question%",
+                "db_least_question", $identifier_string_filter);
+            $identifier_string_question =
+                $identifier_string_question.$identifier_index;
+
+        // Most Preferences Questions
+        } else if($captcha_type == RECOVERY && $question_type == MOST) {
+             $identifier_string_filter = "db_most_prefquestion%";
+            $most_preferences_sql = "SELECT TRANSLATION_ID, ".
+                "MAX(IDENTIFIER_STRING) AS IDENTIFIER_STRING ". 
+                "FROM TRANSLATION WHERE IDENTIFIER_STRING ". 
+                "LIKE :identifier_string_filter ". 
+                "ORDER BY IDENTIFIER_STRING DESC";
+            $result = $this->db->execute($most_preferences_sql,
+                array(":identifier_string_filter" =>
+                $identifier_string_filter));
+            if($result) {
+                $row = $this->db->fetchArray($result);
+            }
+           $identifier_string_index = str_replace("db_most_prefquestion", "",
+                $row['IDENTIFIER_STRING']);
+            /*
+               Converts $identifier_index to Integer
+               Checks if $identifier_index is an integer.
+               If yes, adds 1 to it
+             */
+           if(!is_numeric($identifier_string_index)) {
+               return false;
+           } else {
+               $identifier_index = (int)$identifier_string_index;
+               $identifier_index += 1;
+           }
+           $identifier_string_question = str_replace("db_most_prefquestion%",
+                "db_most_prefquestion", $identifier_string_filter);
+           $identifier_string_question =
+               $identifier_string_question.$identifier_index;
+
+          // Least Preferences Questions
+          } else if($captcha_type == RECOVERY && $question_type == LEAST) {
+              $identifier_string_filter = "db_least_prefquestion%";
+            $least_preferences_sql = "SELECT TRANSLATION_ID, ".
+                "MAX(IDENTIFIER_STRING) AS IDENTIFIER_STRING ". 
+                "FROM TRANSLATION WHERE IDENTIFIER_STRING ". 
+                "LIKE :identifier_string_filter ". 
+                "ORDER BY IDENTIFIER_STRING DESC";
+            $result = $this->db->execute($least_preferences_sql,
+                array(":identifier_string_filter" =>
+                $identifier_string_filter));
+             if($result) {
+                 $row = $this->db->fetchArray($result);
+             }
+            $identifier_string_index = str_replace("db_least_prefquestion", "",
+                $row['IDENTIFIER_STRING']);
+            /*
+               Converts $identifier_index to Integer
+               Checks if $identifier_index is an integer.
+               If yes, adds 1 to it
+             */
+            if(!is_numeric($identifier_string_index)) {
+                return false;
+            } else {
+                $identifier_index = (int)$identifier_string_index;
+                $identifier_index += 1;
+            }
+            $identifier_string_question = str_replace("db_least_prefquestion%",
+                "db_least_prefquestion", $identifier_string_filter);
+            $identifier_string_question =
+                $identifier_string_question.$identifier_index;
+
+        }
+         return $identifier_string_question;
+    }
+
+    /**
+     * Computes and returns identifier_string for a captcha choice list
+     * given captcha_locale and captcha_type
+     *
+     * @param string captcha_type either captcha or recovery which is a part of
+     * the identifier string for a question
+     * @param string question_type either most or least which is a
+     * part of the identifier string for a captcha/recovery question
+     *
+     * @return string the identifier_string for a captcha choice list
+     */
+
+    function getIdentifierStringChoices($captcha_type, $question_type)
+    {
+        $identifier_string_choices = "";
+        $row = "";
+
+        // Most Captcha choices
+         if($captcha_type == CAPTCHA && $question_type == MOST) {
+            $identifier_string_filter_choices = "db_most_captcha_choices%";
+            $most_captcha_sql_choices = "SELECT TRANSLATION_ID, ".
+                "MAX(IDENTIFIER_STRING) AS IDENTIFIER_STRING ". 
+                "FROM TRANSLATION WHERE IDENTIFIER_STRING ". 
+                "LIKE :identifier_string_filter_choices ".
+                "ORDER BY IDENTIFIER_STRING DESC";
+            $result_choices = $this->db->execute($most_captcha_sql_choices,
+                array(":identifier_string_filter_choices" =>
+                $identifier_string_filter_choices));
+            if($result_choices) {
+                $row = $this->db->fetchArray($result_choices);
+            }
+            $identifier_string_index_choices =
+                str_replace("db_most_captcha_choices", "",
+                $row['IDENTIFIER_STRING']);
+            /*
+               Converts $identifier_index_choices to Integer
+               Checks if $identifier_index_choices is an integer.
+               If yes, adds 1 to it
+             */
+            if(!is_numeric($identifier_string_index_choices)){
+                return false;
+            } else {
+                $identifier_index_choices =
+                    (int)$identifier_string_index_choices;
+                $identifier_index_choices += 1;
+            }
+            $identifier_string_choices =
+                str_replace("db_most_captcha_choices%",
+                "db_most_captcha_choices", $identifier_string_filter_choices);
+            $identifier_string_choices =
+                $identifier_string_choices.$identifier_index_choices;
+
+         // Least Captcha choices
+         } else if($captcha_type == CAPTCHA && $question_type == LEAST) {
+             $identifier_string_filter_choices = "db_least_captcha_choices%";
+            $least_captcha_sql_choices = "SELECT TRANSLATION_ID, ".
+                "MAX(IDENTIFIER_STRING) AS IDENTIFIER_STRING ". 
+                "FROM TRANSLATION WHERE IDENTIFIER_STRING ". 
+                "LIKE :identifier_string_filter_choices ".
+                "ORDER BY IDENTIFIER_STRING DESC";
+            $result_choices = $this->db->execute($least_captcha_sql_choices,
+                array(":identifier_string_filter_choices" =>
+                $identifier_string_filter_choices));
+            if($result_choices) {
+                $row = $this->db->fetchArray($result_choices);
+            }
+           $identifier_string_index_choices =
+               str_replace("db_least_captcha_choices", "",
+               $row['IDENTIFIER_STRING']);
+           /*
+              Converts $identifier_index_choices to Integer
+              Checks if $identifier_index_choices is an integer.
+              If yes, adds 1 to it
+            */
+           if(!is_numeric($identifier_string_index_choices)) {
+               return false;
+           } else {
+               $identifier_index_choices =
+                   (int)$identifier_string_index_choices;
+               $identifier_index_choices += 1;
+           }
+           $identifier_string_choices =
+               str_replace("db_least_captcha_choices%",
+               "db_least_captcha_choices", $identifier_string_filter_choices);
+           $identifier_string_choices =
+               $identifier_string_choices.$identifier_index_choices;
+
+        // Most Preferences choices
+        } else if($captcha_type == RECOVERY && $question_type == MOST) {
+             $identifier_string_filter_choices = "db_most_prefchoices%";
+            $most_preferences_sql_choices = "SELECT TRANSLATION_ID, ".
+                "MAX(IDENTIFIER_STRING) AS IDENTIFIER_STRING ". 
+                "FROM TRANSLATION WHERE IDENTIFIER_STRING ". 
+                "LIKE :identifier_string_filter_choices ".
+                "ORDER BY IDENTIFIER_STRING DESC";
+            $result_choices = $this->db->execute($most_preferences_sql_choices,
+                array(":identifier_string_filter_choices" =>
+                $identifier_string_filter_choices));
+            if($result_choices) {
+                $row = $this->db->fetchArray($result_choices);
+            }
+           $identifier_string_index_choices =
+               str_replace("db_most_prefchoices", "",
+               $row['IDENTIFIER_STRING']);
+            /*
+               Converts $identifier_index_choices to Integer
+               Checks if $identifier_index_choices is an integer.
+               If yes, adds 1 to it
+             */
+           if(!is_numeric($identifier_string_index_choices)) {
+               return false;
+           } else {
+               $identifier_index_choices =
+                   (int)$identifier_string_index_choices;
+               $identifier_index_choices += 1;
+           }
+           $identifier_string_choices = str_replace("db_most_prefchoices%",
+               "db_most_prefchoices", $identifier_string_filter_choices);
+           $identifier_string_choices =
+               $identifier_string_choices.$identifier_index_choices;
+
+          // Least Preferences choices
+          } else if($captcha_type == RECOVERY && $question_type == LEAST) {
+              $identifier_string_filter_choices = "db_least_prefchoices%";
+            $least_preferences_sql_choices = "SELECT TRANSLATION_ID, ".
+                "MAX(IDENTIFIER_STRING) AS IDENTIFIER_STRING ". 
+                "FROM TRANSLATION WHERE IDENTIFIER_STRING ". 
+                "LIKE :identifier_string_filter_choices ".
+                "ORDER BY IDENTIFIER_STRING DESC";
+            $result_choices =
+                $this->db->execute($least_preferences_sql_choices,
+                array(":identifier_string_filter_choices" =>
+                $identifier_string_filter_choices));
+            if($result_choices) {
+                 $row = $this->db->fetchArray($result_choices);
+            }
+            $identifier_string_index_choices =
+                str_replace("db_least_prefchoices", "",
+                $row['IDENTIFIER_STRING']);
+            /*
+               Converts $identifier_index_choices to Integer
+               Checks if $identifier_index_choices is an integer.
+               If yes, adds 1 to it
+             */
+            if(!is_numeric($identifier_string_index_choices)) {
+                return false;
+            } else {
+                $identifier_index_choices =
+                    (int)$identifier_string_index_choices;
+                $identifier_index_choices += 1;
+            }
+            $identifier_string_choices = str_replace("db_least_prefchoices%",
+                "db_least_prefchoices", $identifier_string_filter_choices);
+            $identifier_string_choices =
+                $identifier_string_choices.$identifier_index_choices;
+
+        } 
+         return $identifier_string_choices;
+    }
+
+    /**
+     * Computes and returns method_name for a captcha/recovery question
+     * given captcha_locale and captcha_type
+     *
+     * @param string captcha_type either captcha or recovery which is a part of
+     * the identifier string for a question
+     * @param string question_type either most or least which is a
+     * part of the identifier string for a captcha/recovery question
+     *
+     * @return string the method name for a captcha/recovery question
+     */
+
+    function getMethodNameQuestion($captcha_type, $question_type)
+    {
+        $method_name_question = "";
+        $row = "";
+
+        // Most Captcha questions
+         if($captcha_type == CAPTCHA && $question_type == MOST) {
+            $method_name_filter = "captcha_question_most%";
+            $most_captcha_sql = "SELECT TRANSLATION_ID, MAX(METHOD_NAME) ".
+                "AS METHOD_NAME FROM CAPTCHA WHERE METHOD_NAME ". 
+                "LIKE :method_name_filter ORDER BY METHOD_NAME DESC";
+            $result = $this->db->execute($most_captcha_sql,
+                array(":method_name_filter" => $method_name_filter));
+            if($result) {
+                $row = $this->db->fetchArray($result);
+            }
+            $method_name_index = str_replace("captcha_question_most", "",
+                $row['METHOD_NAME']);
+            /*
+                Converts $method_index to Integer
+                Checks if $method_index is an integer.
+                If yes, adds 1 to it
+              */
+            if(!is_numeric($method_name_index)) {
+                return false;
+            } else {
+                $method_index = (int)$method_name_index;
+                $method_index += 1;
+            }
+            $method_name_question = str_replace("captcha_question_most%",
+                "captcha_question_most", $method_name_filter);
+            $method_name_question = $method_name_question.$method_index;
+
+        // Least Captcha questions
+         } else if($captcha_type == CAPTCHA && $question_type == LEAST) {
+             $method_name_filter = "captcha_question_least%";
+            $least_captcha_sql = "SELECT TRANSLATION_ID, MAX(METHOD_NAME) ".
+                "AS METHOD_NAME FROM CAPTCHA WHERE METHOD_NAME ". 
+                "LIKE :method_name_filter ORDER BY METHOD_NAME DESC";
+            $result = $this->db->execute($least_captcha_sql,
+                array(":method_name_filter" => $method_name_filter));
+            if($result) {
+                $row = $this->db->fetchArray($result);
+            }
+           $method_name_index = str_replace("captcha_question_least", "",
+                $row['METHOD_NAME']);
+            /*
+                Converts $method_index to Integer
+                Checks if $method_index is an integer.
+                If yes, adds 1 to it
+              */
+           if(!is_numeric($method_name_index)) {
+                return false;
+           } else {
+                $method_index = (int)$method_name_index;
+                $method_index += 1;
+           }
+           $method_name_question = str_replace("captcha_question_least%",
+                "captcha_question_least", $method_name_filter);
+           $method_name_question = $method_name_question.$method_index;
+
+        // Most Preferences Questions
+        } else if($captcha_type == RECOVERY && $question_type == MOST) {
+             $method_name_filter = "preferences_question_most%";
+            $most_preferences_sql = "SELECT TRANSLATION_ID, MAX(METHOD_NAME) ".
+                "AS METHOD_NAME FROM PREFERENCES WHERE METHOD_NAME ". 
+                "LIKE :method_name_filter ORDER BY METHOD_NAME DESC";
+            $result = $this->db->execute($most_preferences_sql,
+                array(":method_name_filter" => $method_name_filter));
+            if($result) {
+                $row = $this->db->fetchArray($result);
+            }
+           $method_name_index = str_replace("preferences_question_most", "",
+                $row['METHOD_NAME']);
+            /*
+                Converts $method_index to Integer
+                Checks if $method_index is an integer.
+                If yes, adds 1 to it
+              */
+           if(!is_numeric($method_name_index)) {
+               return false;
+           } else {
+               $method_index = (int)$method_name_index;
+               $method_index += 1;
+           }
+           $method_name_question = str_replace("preferences_question_most%",
+                "preferences_question_most", $method_name_filter);
+           $method_name_question = $method_name_question.$method_index;
+
+         // Least Preferences Questions
+          } else if($captcha_type == RECOVERY && $question_type == LEAST) {
+              $method_name_filter = "preferences_question_least%";
+            $least_preferences_sql = "SELECT TRANSLATION_ID, ". 
+                "MAX(METHOD_NAME) AS METHOD_NAME FROM PREFERENCES WHERE ". 
+                "METHOD_NAME LIKE :method_name_filter ". 
+                "ORDER BY METHOD_NAME DESC";
+             $result = $this->db->execute($least_preferences_sql,
+                array(":method_name_filter" => $method_name_filter));
+             if($result) {
+                 $row = $this->db->fetchArray($result);
+             }
+            $method_name_index = str_replace("preferences_question_least", "",
+                $row['METHOD_NAME']);
+            /*
+               Converts $method_index to Integer
+               Checks if $method_index is an integer.
+               If yes, adds 1 to it
+             */
+            if(!is_numeric($method_name_index)) {
+                return false;
+            } else {
+                $method_index = (int)$method_name_index;
+                $method_index += 1;
+            }
+            $method_name_question = str_replace("preferences_question_least%",
+                "preferences_question_least", $method_name_filter);
+            $method_name_question = $method_name_question.$method_index;
+
+        } 
+         return $method_name_question;
+    }
+
+    /**
+     * Computes and returns method_name for a captcha/recovery choice list
+     * given captchaLocale and captchaType
+     *
+     * @param string captcha_type either captcha or recovery which is a part of
+     * the identifier string for a question
+     * @param string question_type either most or least which is a
+     * part of the identifier string for a captcha/recovery question
+     *
+     * @return string the method_name for a captcha/preference choice list
+     */
+
+    function getMethodNameChoices($captcha_type, $question_type)
+    {
+        $method_name_choices = "";
+        $row = "";
+
+        // Most Captcha choices
+         if($captcha_type == CAPTCHA && $question_type = MOST) {
+            $method_name_filter_choices = "captcha_choices_most%";
+            $most_captcha_sql_choices = "SELECT TRANSLATION_ID, ".
+                "MAX(METHOD_NAME) AS METHOD_NAME FROM CAPTCHA WHERE ".
+                "METHOD_NAME LIKE :method_name_filter_choices ".
+                "ORDER BY METHOD_NAME DESC";
+            $result_choices = $this->db->execute($most_captcha_sql_choices,
+                array(":method_name_filter_choices" =>
+                $method_name_filter_choices));
+            if($result_choices) {
+                $row = $this->db->fetchArray($result_choices);
+            }
+            $method_name_index_choices = str_replace("captcha_choices_most",
+                "", $row['METHOD_NAME']);
+            /*
+               Converts $method_index_choices to Integer
+               Checks if $method_index_choices is an integer.
+               If yes, adds 1 to it
+             */
+            if(!is_numeric($method_name_index_choices)) {
+                return false;
+            } else {
+            $method_index_choices = (int)$method_name_index_choices;
+            $method_index_choices += 1;
+            }
+            $method_name_choices = str_replace("captcha_choices_most%",
+                "captcha_choices_most", $method_name_filter_choices);
+            $method_name_choices = $method_name_choices.$method_index_choices;
+
+        // Least Captcha choices
+         } else if($captcha_type == CAPTCHA && $question_type == LEAST) {
+             $method_name_filter_choices = "captcha_choices_least%";
+            $least_captcha_sql_choices = "SELECT TRANSLATION_ID, ".
+                "MAX(METHOD_NAME) AS METHOD_NAME FROM CAPTCHA WHERE ".
+                "METHOD_NAME LIKE :method_name_filter_choices ".
+                "ORDER BY METHOD_NAME DESC";
+            $result_choices = $this->db->execute($least_captcha_sql_choices,
+                array(":method_name_filter_choices" =>
+                $method_name_filter_choices));
+            if($result_choices) {
+                $row = $this->db->fetchArray($result_choices);
+            }
+           $method_name_index_choices = str_replace("captcha_choices_least",
+                "", $row['METHOD_NAME']);
+            /*
+               Converts $method_index_choices to Integer
+               Checks if $method_index_choices is an integer.
+               If yes, adds 1 to it
+             */
+           if(!is_numeric($method_name_index_choices)) {
+                return false;
+           } else {
+                $method_index_choices = (int)$method_name_index_choices;
+                $method_index_choices += 1;
+           }
+           $method_name_choices = str_replace("captcha_choices_least%",
+                "captcha_choices_least", $method_name_filter_choices);
+           $method_name_choices = $method_name_choices.$method_index_choices;
+
+        // Most Preferences choices
+        } else if($captcha_type == RECOVERY && $question_type == MOST) {
+             $method_name_filter_choices = "preferences_choices_most%";
+            $most_preferences_sql_choices = "SELECT TRANSLATION_ID, ".
+                "MAX(METHOD_NAME) AS METHOD_NAME FROM PREFERENCES WHERE ".
+                "METHOD_NAME LIKE :method_name_filter_choices ".
+                "ORDER BY METHOD_NAME DESC";
+            $result_choices = $this->db->execute($most_preferences_sql_choices,
+                array(":method_name_filter_choices" =>
+                $method_name_filter_choices));
+            if($result_choices){
+                $row = $this->db->fetchArray($result_choices);
+            }
+           $method_name_index_choices = str_replace("preferences_choices_most",
+                "", $row['METHOD_NAME']);
+            /*
+               Converts $method_index_choices to Integer
+               Checks if $method_index_choices is an integer.
+               If yes, adds 1 to it
+             */
+           if(!is_numeric($method_name_index_choices)) {
+                return false;
+           } else {
+               $method_index_choices = (int)$method_name_index_choices;
+               $method_index_choices += 1;
+           }
+           $method_name_choices = str_replace("preferences_choices_most%",
+                "preferences_choices_most", $method_name_filter_choices);
+           $method_name_choices = $method_name_choices.$method_index_choices;
+
+         // Least Preferences choices
+          } else if($captcha_type == RECOVERY && $question_type == LEAST) {
+              $method_name_filter_choices = "preferences_choices_least%";
+            $least_preferences_sql_choices = "SELECT TRANSLATION_ID, ".
+                "MAX(METHOD_NAME) AS METHOD_NAME FROM PREFERENCES WHERE ".
+                "METHOD_NAME LIKE :method_name_filter_choices ".
+                "ORDER BY METHOD_NAME DESC";
+            $result_choices = $this->db->execute($least_preferences_sql_choices,
+                array(":method_name_filter_choices" =>
+                $method_name_filter_choices));
+            if($result_choices) {
+                $row = $this->db->fetchArray($result_choices);
+            }
+            $method_name_index_choices = str_replace("preferences_choices_least",
+                "", $row['METHOD_NAME']);
+            /*
+               Converts $method_index_choices to Integer
+               Checks if $method_index_choices is an integer.
+               If yes, adds 1 to it
+             */
+            if(!is_numeric($method_name_index_choices)) {
+                return false;
+            } else {
+                $method_index_choices = (int)$method_name_index_choices;
+                $method_index_choices += 1;
+            }
+            $method_name_choices = str_replace("preferences_choices_least%",
+                "preferences_choices_least", $method_name_filter_choices);
+            $method_name_choices = $method_name_choices.$method_index_choices;
+
+        }
+         return $method_name_choices;
+    }
+
+    /**
+     * Computes and returns locale_id for a given captcha_locale
+     *
+     * @param string $captcha_locale
+     * @return string the locale_id for a given captcha_locale
+     */
+
+    function getLocaleId($captcha_locale)
+    {
+        $sql = "SELECT DISTINCT(LOCALE_ID) from LOCALE WHERE
+            LOCALE_TAG = :captcha_locale";
+        $result = $this->db->execute($sql,
+            array(":captcha_locale" => $captcha_locale));
+         if($result) {
+             $row = $this->db->fetchArray($result);
+         }
+        return $row['LOCALE_ID'];
+    }
+
+    /**
+     * Function for adding captcha/recovery question to the database
+     *
+     * @param string captcha_type which is either captcha/recovery
+     * @param string question_type which is either most/least
+     * @param string captcha_locale which is a list of locales to choose from
+     * @param string captcha_question which is a captcha/recovery
+     *      question to be added
+     * @param string captcha_choices which is a list of captcha/recovery choices
+     * @return bool value; returns true if the question-choice pair
+     *      is added to the database
+     */
+
+    function addCaptchaDataToDatabase($captcha_type, $question_type,
+                $captcha_locale, $captcha_question, $captcha_choices)
+    {
+        $db = $this->db;
+        // Gets identifier string for insertion into the TRANSLATION table
+        $identifier_string_question =
+            $this->getIdentifierStringQuestion($captcha_type, $question_type);
+        $identifier_string_choices =
+            $this->getIdentifierStringChoices($captcha_type, $question_type);
+        /*
+           Gets method name for insertion into the CAPTCHA and
+           PREFERENCES tables
+         */
+        $method_name_question =
+            $this->getMethodNameQuestion($captcha_type, $question_type);
+        $method_name_choices =
+            $this->getMethodNameChoices($captcha_type, $question_type);
+
+        // Insert into TRANSLATION table
+        $sql_translation = "INSERT INTO TRANSLATION (IDENTIFIER_STRING) ".
+            "VALUES(?)";
+        $result_translation = $db->execute($sql_translation,
+            array($identifier_string_question));
+        if(!$result_translation) {
+           return false;
+        }
+        $sql_translation = "INSERT INTO TRANSLATION (IDENTIFIER_STRING) ".
+            "VALUES(?)";
+        $result_translation = $db->execute($sql_translation,
+            array($identifier_string_choices));
+        if(!$result_translation) {
+           return false;
+        }
+        $locale_id = $this->getLocaleId($captcha_locale);
+        $translation_id_question =
+            $this->getTranslationId($identifier_string_question);
+        $translation_id_choices =
+            $this->getTranslationId($identifier_string_choices);
+
+        /*
+           Insert into CAPTCHA and PREFERENCES tables
+           Captcha and Preferences Questions
+         */
+        if($captcha_type == CAPTCHA) {
+            $sql_captcha = "INSERT INTO CAPTCHA (TRANSLATION_ID, METHOD_NAME) ".
+                "VALUES(?,?)";
+            $sql_captcha_choices = "INSERT INTO CAPTCHA (TRANSLATION_ID, ".
+                "METHOD_NAME) VALUES(?,?)";
+            $result_captcha = $db->execute($sql_captcha,
+                array($translation_id_question, $method_name_question));
+            $result_captcha_choices = $db->execute($sql_captcha_choices,
+                array($translation_id_choices, $method_name_choices));
+            if(!$result_captcha) {
+                return false;
+            }
+            if(!$result_captcha_choices) {
+                return false;
+            }
+        } else if($captcha_type == RECOVERY) {
+            $sql_recov = "INSERT INTO PREFERENCES (TRANSLATION_ID, METHOD_NAME) ".
+                "VALUES(?,?)";
+            $sql_recov_choices = "INSERT INTO PREFERENCES (TRANSLATION_ID, ".
+                "METHOD_NAME) VALUES(?,?)";
+            $result_recov = $db->execute($sql_recov,
+                array($translation_id_question, $method_name_question));
+            $result_recov_choices = $db->execute($sql_recov_choices,
+                array($translation_id_choices, $method_name_choices));
+            if(!$result_recov) {
+                return false;
+            }
+            if(!$result_recov_choices) {
+                return false;
+            }
+        } else {
+            print_r("Not the right question type!");
+        }
+
+        // Insert into QUESTION_CHOICES_MAPPING table
+        $sql_captcha = "INSERT INTO QUESTION_CHOICE_MAPPING ".
+            "(TRANSLATION_ID_QUESTION, TRANSLATION_ID_CHOICES) VALUES(?,?)";
+        $result_captcha = $db->execute($sql_captcha,
+            array($translation_id_question, $translation_id_choices));
+        if(!$result_captcha) {
+            return false;
+        }
+
+        // Insert into TRANSLATION_LOCALE table
+        $sql_translation_locale = "INSERT INTO TRANSLATION_LOCALE ".
+            "(TRANSLATION_ID, LOCALE_ID, TRANSLATION) VALUES(?,?,?) ";
+        $result = $db->execute($sql_translation_locale,
+            array($translation_id_question, $locale_id, $captcha_question));
+        if(!$result) {
+            return false;
+        }
+        $result = $db->execute($sql_translation_locale,
+            array($translation_id_choices, $locale_id, $captcha_choices));
+        if(!$result) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Function for fetching captcha/recovery question from the database
+     *
+     * @return string returns the captcha/recovery questions from the database
+     */
+
+    function fetchCaptchaPrefQuestionChoices()
+    {
+      $db = $this->db;
+      $sql = "SELECT rowid as translation_locale_id, TRANSLATION_ID, ".
+        "TRANSLATION AS questionChoices FROM TRANSLATION_LOCALE WHERE ".
+        "TRANSLATION_ID IN (SELECT DISTINCT TRANSLATION_ID_QUESTION ".
+        "FROM QUESTION_CHOICE_MAPPING)";
+      $result = $db->execute($sql);
+      $data = array();
+      if($result) {
+          $rows = array();
+          while($row = $this->db->fetchArray($result)) {
+             $data['translation_locale'][]= $row;
+          }
+      }
+      return ($data['translation_locale']);
+    }
+
+    /**
+     * Function for deleting captcha/recovery questions and their corresponding
+     * choices from the database
+     *
+     * @param string the captcha questions text_captcha_delete_questions
+     */
+
+    function deleteCaptchaDataFromDatabase($text_captcha_delete_questions)
+    {
+      $db = $this->db;
+      if($text_captcha_delete_questions) {
+        $translation_locale_ids = implode(",", $text_captcha_delete_questions);
+        /*
+           Append CHOICES rowids to the set of QUESTION rowids that have to be
+           deleted from TRANSLATION_LOCALE
+         */
+        $sql_get_choice_row_ids = "SELECT TL.ROWID AS rowid FROM ".
+            "TRANSLATION_LOCALE AS TL, (SELECT QCM.TRANSLATION_ID_CHOICES ".
+            "AS TRANSLATION_ID, TL.LOCALE_ID AS LOCALE_ID FROM ".
+            "QUESTION_CHOICE_MAPPING AS QCM, (SELECT TRANSLATION_ID, ".
+            "LOCALE_ID FROM TRANSLATION_LOCALE WHERE ROWID ".
+            "IN (".$translation_locale_ids.")) AS TL WHERE ".
+            "QCM.TRANSLATION_ID_QUESTION = TL.TRANSLATION_ID) AS ". 
+            "CHOICES_LOCALE WHERE TL.TRANSLATION_ID = ". 
+            "CHOICES_LOCALE.TRANSLATION_ID AND ".
+            "TL.LOCALE_ID = CHOICES_LOCALE.LOCALE_ID";
+        $result = $db->execute($sql_get_choice_row_ids);
+        if($result) {
+            while($row = $this->db->fetchArray($result)) {
+               $translation_locale_ids .= ",".$row['rowid'];
+            }
+        }
+        // DELETE QUESTIONS & CHOICES FROM TRANSLATION_LOCALE
+        $sql_question_delete = "DELETE FROM TRANSLATION_LOCALE WHERE ".
+            "ROWID IN ($translation_locale_ids)";
+        $result = $db->execute($sql_question_delete);
+        $purge_translation_id_arr = array();
+        $sql_purge_translation_ids = "SELECT TRANSLATION_ID FROM TRANSLATION ".
+            "WHERE TRANSLATION_ID NOT IN (SELECT DISTINCT TRANSLATION_ID ".
+            "FROM TRANSLATION_LOCALE)";
+        $result = $db->execute($sql_purge_translation_ids);
+        if($result) {
+            while($row = $this->db->fetchArray($result)){
+               $purge_translation_id_arr[]= $row['TRANSLATION_ID'];
+            }
+        }
+        $purge_translation_ids = implode(",", $purge_translation_id_arr);
+        if($purge_translation_ids) {
+            /*
+               Delete from other tables if the translation_id of the row that is
+               being deleted in translation_locale is not present in any other
+               row (other than the row being deleted).
+             */
+            // DELETE FROM PREFERENCES
+            $sql_delete_preferences = "DELETE FROM PREFERENCES WHERE ".
+                "TRANSLATION_ID IN ($purge_translation_ids)";
+            $result = $db->execute($sql_delete_preferences);
+            // DELETE FROM CAPTCHA
+            $sql_delete_captcha = "DELETE FROM CAPTCHA WHERE ".
+                "TRANSLATION_ID IN ($purge_translation_ids)";
+            $result = $db->execute($sql_delete_captcha);
+            // DELETE FROM QUESTION_CHOICE_MAPPING
+            $sql_delete_QCM = "DELETE FROM QUESTION_CHOICE_MAPPING WHERE ".
+                "TRANSLATION_ID_QUESTION IN ($purge_translation_ids) OR ".
+                "TRANSLATION_ID_CHOICES IN (".$purge_translation_ids.")";
+            $result = $db->execute($sql_delete_QCM);
+            // DELETE FROM TRANSLATION
+            $sql_delete_translation = "DELETE FROM TRANSLATION WHERE ".
+                "TRANSLATION_ID IN ($purge_translation_ids)";
+            $result = $db->execute($sql_delete_translation);
+
+        }
+      }
+    }
+
+    /**
+     * Function for getting the translation id for the method names
+     * for the selected locale.
+     * Gives the corresponding translated question-choice pair for the chosen
+     * method name from the CAPTCHA/PREFERENCES table, for the locale id and
+     * translation id.
+     * @param a string locale_tag that is the locale tag for the chosen locale
+     *
+     * @return returns a boolean value
+     */
+
+    function getTranslationIdMethodNameMap($locale_tag){
+        if(!$locale_tag) {
+            $locale_tag = DEFAULT_LOCALE;
+        }
+        $db = $this->db;
+        $sql = "SELECT LOCALE_ID FROM LOCALE WHERE LOCALE_TAG = ? ".
+            $db->limitOffset(1);
+        $result = $db->execute($sql, array($locale_tag));
+        $row = $db->fetchArray($result);
+        $locale_id = $row['LOCALE_ID'];
+        $translated_values = array();
+        $sql = "SELECT TRANSLATION, TRANSLATION_ID FROM TRANSLATION_LOCALE ".
+            "WHERE LOCALE_ID = $locale_id AND TRANSLATION_ID IN (SELECT ".
+            "TRANSLATION_ID FROM CAPTCHA UNION SELECT TRANSLATION_ID ".
+            "FROM PREFERENCES)";
+        $result = $db->execute($sql);
+        if(!$result) {
+            return false;
+        }
+        while($row = $this->db->fetchArray($result)) {
+             $translated_values[$row['TRANSLATION_ID']] = $row['TRANSLATION'];
+        }
+        $sql = "SELECT TRANSLATION_ID, METHOD_NAME, 'CAPTCHA' AS TYPE FROM ".
+            "CAPTCHA UNION SELECT TRANSLATION_ID, METHOD_NAME, 'RECOVERY' ".
+            "AS TYPE FROM PREFERENCES";
+        $result = $db->execute($sql);
+        if($result) {
+            $data = array(
+                'recovery_tids' => array(),
+                'captcha_tids' => array(),
+                'least_tids' => array(),
+                'most_tids' => array(),
+                'map' => array()
+            );
+            while($row = $this->db->fetchArray($result)) {
+               $data['map'][$row['TRANSLATION_ID']] =
+                   $translated_values[$row['TRANSLATION_ID']];
+               if($row['TYPE'] == 'CAPTCHA') {
+                   $data['captcha_tids'][] = $row['TRANSLATION_ID'];
+               }
+               if($row['TYPE'] == 'RECOVERY') {
+                   $data['recovery_tids'][] = $row['TRANSLATION_ID'];
+               }
+               $least_or_most = (strpos($row['METHOD_NAME'],
+                   'least') !== FALSE)? 'least_tids': 'most_tids';
+               $data[$least_or_most][] = $row['TRANSLATION_ID'];
+            }
+            return $data;
+        }
+        return false;
+    }
+
+    /**
+     * Function for getting the translation id map for question choices
+     */
+
+    function getQuestionChoicesMap(){
+        $db = $this->db;
+        $sql = "SELECT * FROM QUESTION_CHOICE_MAPPING";
+        $result = $db->execute($sql);
+        if($result){
+            $question_choice_map = array();
+            while($row = $this->db->fetchArray($result)){
+                $question_choice_map[$row['TRANSLATION_ID_QUESTION']]
+                    = $row['TRANSLATION_ID_CHOICES'];
+            }
+            return $question_choice_map;
+        }
+        return false;
+    }
+
+    /**
+     * Function for editing the selected question choices
+     * The selected question-choice pair(s) are populated in a newly created
+     * textbox.
+     *
+     * @param string text_captcha_edit_questions, the question selected
+     *        to be edited
+     */
+
+    function editCaptchaData($text_captcha_edit_questions){
+        if(!$text_captcha_edit_questions){
+            return;
+        }
+        $db = $this->db;
+        $rowid_tid_map = array();
+        $question_choice_tid_map = array();
+        $question_choice_rowid_map = array();
+        $rowid_translation_map = array();
+        $tid_lid_rowid_map = array();
+        $rowid_localeid_map = array();
+
+        $translation_locale_ids = implode(",", $text_captcha_edit_questions);
+        $sql = "SELECT rowid, TRANSLATION_ID, LOCALE_ID, TRANSLATION ".
+            "FROM TRANSLATION_LOCALE WHERE rowid ". 
+            "IN (".$translation_locale_ids.")";
+        $result = $db->execute($sql);
+        if($result) {
+           while($row = $this->db->fetchArray($result)) {
+               $rowid_tid_map[$row['rowid']] = $row['TRANSLATION_ID'];
+               $rowid_translation_map[$row['rowid']] = $row['TRANSLATION'];
+               $rowid_localeid_map[$row['rowid']] = $row['LOCALE_ID'];
+           }
+        }
+        $sql = "SELECT * FROM QUESTION_CHOICE_MAPPING WHERE ".
+            "TRANSLATION_ID_QUESTION in (".implode(",", $rowid_tid_map).")";
+        $result = $db->execute($sql);
+        if($result) {
+           while($row = $this->db->fetchArray($result)) {
+               $question_choice_tid_map[$row['TRANSLATION_ID_QUESTION']] =
+                   $row['TRANSLATION_ID_CHOICES'];
+           }
+        }
+        $sql = "SELECT rowid, TRANSLATION_ID, TRANSLATION, LOCALE_ID ".
+            "FROM TRANSLATION_LOCALE WHERE TRANSLATION_ID ". 
+            "IN (".implode(",", $question_choice_tid_map).")";
+        $result = $db->execute($sql);
+        if($result) {
+           while($row = $this->db->fetchArray($result)) {
+               $rowid_translation_map[$row['rowid']] = $row['TRANSLATION'];
+               $tid_lid_rowid_map[$row['TRANSLATION_ID']][$row['LOCALE_ID']] =
+                   $row['rowid'];
+           }
+        }
+        foreach($text_captcha_edit_questions as $question_rowid) {
+            $question_locale_id = $rowid_localeid_map[$question_rowid];
+            $question_tid = $rowid_tid_map[$question_rowid];
+            $choices_tid = $question_choice_tid_map[$question_tid];
+            $choices_rowid =
+                $tid_lid_rowid_map[$choices_tid][$question_locale_id];
+            $question_choice_rowid_map[$question_rowid] = $choices_rowid;
+        }
+        $data = array("question_choice_rowid_map" =>
+            $question_choice_rowid_map, "rowid_translation_map" =>
+            $rowid_translation_map);
+        return $data;
+    }
+
+    /**
+     * Function for updating the selected question choices
+     * The selected question-choice pair(s) are updated in the database
+     *
+     * @param rowid_translation_map which is the map for the translation id
+     *        and its corresponding rowid
+     */
+
+    function updateCaptchaStringInTranslationLocale($rowid_translation_map) {
+        foreach($rowid_translation_map as $rowid => $translation) {
+            $sql = "UPDATE TRANSLATION_LOCALE SET TRANSLATION = :translation ".
+                "WHERE rowid = :rowid";
+            $this->db->execute($sql,
+                array(":translation"=>$translation, ":rowid"=>$rowid));
+        }
+    }
+}
+
+ ?>
+
diff --git a/views/elements/captchasettings_element.php b/views/elements/captchasettings_element.php
new file mode 100755
index 0000000..48e079e
--- /dev/null
+++ b/views/elements/captchasettings_element.php
@@ -0,0 +1,208 @@
+<?php
+/**
+ *  SeekQuarry/Yioop --
+ *  Open Source Pure PHP Search Engine, Crawler, and Indexer
+ *
+ *  Copyright (C) 2009 - 2014 Chris Pollett chris@pollett.org
+ *
+ *  LICENSE:
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *  END LICENSE
+ *
+ * @author Sreenidhi Muralidharan sreenidhimuralidharan@gmail.com
+ * @package seek_quarry
+ * @subpackage element
+ * @license http://www.gnu.org/licenses/ GPL3
+ * @link http://www.seekquarry.com/
+ * @copyright 2009 - 2014
+ * @filesource
+ */
+
+
+if(!defined('BASE_DIR')) {echo "BAD REQUEST"; exit();}
+
+/**
+ * Element used to draw forms to select either among a text or a 
+ * graphical captcha
+ *
+ * @author Chris Pollett
+ * @package seek_quarry
+ * @subpackage element
+ */
+ require_once BASE_DIR."/models/model.php";
+ require_once BASE_DIR."/models/textcaptchasettings_model.php";
+  
+ 
+class CaptchasettingsElement extends Element
+{
+    /**
+     * Method that draws forms to to select either among a text or a 
+     * graphical captcha
+     *
+     * @param array $data holds data on the profile elements which have been
+     *      filled in as well as data about which form fields to display
+     */
+    function render($data)
+    {
+       
+    
+?>
+<div class = "current-activity">
+    <div>
+        <div id ="captcha-settings-container">
+            <form class="top-margin" method="post" action="">
+                <label for="captcha-settings">
+                    <?php e(tl('captchasettings_element_captcha_setting'));?>
+                </label>
+                <?php 
+                    $selected_value = $data["CAPTCHA_MODE"];
+                    $this->view->helper("options")->render("captcha-settings", 
+                        "CAPTCHA_MODE", $data['CAPTCHA_MODES'], 
+                        $selected_value, true);
+                ?>
+                <input type="hidden" name="arg" value="setcaptchamode"/>
+            </form>
+            <?php
+                if ($selected_value == TEXT_CAPTCHA) {
+            ?>
+                <div id="text-captcha-container">
+                    <h4>Add Captcha/Recovery Question:</h4>
+                    <form id="text-captcha-container-add" 
+                        class="text-captcha-container-add" 
+                        method="post" action="">
+                        <ul><li><label id="captcha-type" 
+                            for="captcha-type"><?php 
+                            e(tl('captchasettings_element_captcha_type')); 
+                            ?></label>
+                            <?php $this->view->helper("options")->render(
+                                "captcha-type", "CAPTCHA_TYPE", 
+                                $data['CAPTCHA_TYPE'], 
+                                $data['CAPTCHA_TYPE']);?>
+                            </li>
+                            <li><label id="captcha-possibilities" 
+                            for="captcha-possibilities">
+                            <?php 
+                            e(tl(
+                            'captchasettings_element_captcha_possibilities')); 
+                            ?></label>
+                            <?php $this->view->helper("options")->render(
+                                "captcha-possibilities", "CAPTCHA_POSSIBILITIES", 
+                                $data['CAPTCHA_POSSIBILITIES'], 
+                                $data['CAPTCHA_POSSIBILITIES']);?>
+                            </li>
+                            <li><label id="locale-selection">
+                            <?php 
+                            e(tl('captchasettings_element_captcha_language')); 
+                            ?></label>
+                            <?php $this->view->helper("options")->render(
+                                "captcha-locale", "CAPTCHA_LOCALE", 
+                                $data['LANGUAGES'], "en-US");?>
+                            </li>
+                            <li><label id="captcha-question-input-label"><?php
+                                e(tl(
+                                'captchasettings_element_captcha_question'));
+                                ?></label>
+                                <input type="text" 
+                                    id="captcha-question-input" 
+                                    name="CAPTCHA_QUESTION_INPUT">
+                            </li>
+                            <li><label id="captcha-choices-input-label"><?php
+                                e(tl(
+                                'captchasettings_element_captcha_choices'));
+                                ?></label>
+                                <input type="text" 
+                                    id="captcha-choices-input" 
+                                    name="CAPTCHA_CHOICES_INPUT"></li>
+                            <li><input type="hidden" name="arg" 
+                                    value="addtextcaptcha" />
+             				    <input type="submit" value= 
+             				        'Add To Database' 
+             				        id="text-captcha-add-to-database" 
+             				        name="text_captcha_add_to_database">
+             				</li>
+                        </ul>
+                        <input type="hidden" name="CAPTCHA_MODE" 
+                                    value="text_captcha"/></form>
+                        <form name="updateTextCaptchaForm" method="post" 
+                                action =""> 
+         		    	    <h4>Current Question:</h4>
+                            <select multiple="multiple" 
+                                class="text-captcha-input" 
+                                name="text_captcha_delete_questions[]">    	    	     
+         		     	        <?php 
+         		     	        if($data['translation_locale']) {
+                                    foreach($data['translation_locale'] as 
+                                        $translation_locale) {
+                                        e('<option value
+                                            = "'.$translation_locale[
+                                            'translation_locale_id'].'">'.
+                                            $translation_locale[
+                                                'questionChoices'].
+                                        '</option>');  
+                                    }
+                                }               
+                                ?>
+                        </select>
+                        <input type="hidden" name="arg" 
+                            value="updatetextcaptcha" />
+         				<input type="submit" value='Delete From Database' 
+         				    name="actiondelete"/>
+                        <input type="submit" value='Edit'  
+                            name="actionedit"/>
+                       </form> 
+                    <?php if(isset($data['EDIT_CAPTCHA_MAPS'])) {
+                        $question_choice_rowid_map = 
+                            $data['EDIT_CAPTCHA_MAPS']
+                            ['question_choice_rowid_map'];
+                        $rowid_translation_map = $data['EDIT_CAPTCHA_MAPS']
+                            ['rowid_translation_map'];
+                        e('<form method="post">');
+                        foreach($question_choice_rowid_map as 
+                            $question_rowid => $choices_rowid) {
+                            e('<div>');
+                            e('<div>');
+                            e('Question:<input name="updateField['.
+                                $question_rowid.']" value="'.
+                                $rowid_translation_map[$question_rowid].'" 
+                                style="width:80%">');
+                            e('</div>');
+                            e('<div>');
+                            e('Choices:<input name="updateField['.
+                                $choices_rowid.']" value="'.
+                                $rowid_translation_map[$choices_rowid].'" 
+                                style="width:80%">');
+                            e('</div>');
+                            e('</div>');
+                        }
+                        e('<input type="hidden" name="arg" 
+                            value="savetextcaptcha" />');
+                        e('<input type="submit" value ="Save" />');
+                        e('</form>');
+                    }
+                    ?>
+                </div>                
+            <?
+                } // END TEXT CAPTCHA
+            ?>
+        </div><!-- End of div: captcha-settings-container-->
+    </div>
+</div><!-- End of div: current-activity -->
+
+<?php
+    }
+}
+
+?>
diff --git a/views/elements/graphicalcaptcha_element.php b/views/elements/graphicalcaptcha_element.php
new file mode 100755
index 0000000..b0cdcdb
--- /dev/null
+++ b/views/elements/graphicalcaptcha_element.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ *  SeekQuarry/Yioop --
+ *  Open Source Pure PHP Search Engine, Crawler, and Indexer
+ *
+ *  Copyright (C) 2009 - 2014  Chris Pollett chris@pollett.org
+ *
+ *  LICENSE:
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ *  END LICENSE
+ *
+ * @author Chris Pollett chris@pollett.org
+ * @package seek_quarry
+ * @subpackage model
+ * @license http://www.gnu.org/licenses/ GPL3
+ * @link http://www.seekquarry.com/
+ * @copyright 2009 - 2014
+ * @filesource
+ */
+
+if(!defined('BASE_DIR')) {echo "BAD REQUEST"; exit();}
+
+/**
+ * This is class is used to handle the 
+ * graphical captcha settings for Yioop
+ * 
+ * @param string the captcha string as $data
+ * @author Chris Pollett
+ *
+ * @package seek_quarry
+ * @subpackage element
+ */
+ 
+class GraphicalcaptchaElement extends Element
+{
+    function render($data) 
+    {
+        if(isset($data['captcha_string'])) {
+            $captcha_word = $data['captcha_string'];
+            $image = @imagecreatetruecolor(195, 35);
+            // defines background color, random lines color and text color
+            $bg_color = imagecolorallocate($image, mt_rand(0,255), 255, 0);
+            imagefill($image, 0, 0, $bg_color);
+            $lines_color = imagecolorallocate($image, 0x99, 0xCC, 0x99);
+            $text_color = imagecolorallocate($image, mt_rand(0,255), 0, 255);
+            // draws random lines
+            for($i = 0; $i < 4; $i++){
+                imageline($image, 0, rand(0,35), 195, rand(0,35), 
+                    $lines_color);
+            }
+            $captcha_letter_array = str_split($captcha_word);
+            foreach($captcha_letter_array as $i => $captcha_letter) { 
+                imagesetthickness($image, 1);
+                imagestring($image, 5, 5 + ($i * 35), rand(2,14), 
+                    $captcha_letter, $text_color); 
+            }
+            // creates image
+            ob_start (); 
+            imagepng ($image);
+            $image_data = ob_get_contents ();
+            ob_end_clean ();
+            $image_data_base64 = base64_encode($image_data);
+            e('<div class="graphical-captcha-container">');
+            e('<img src="data:image/png;base64,'.$image_data_base64.'" 
+                width="260" height="70" border="1" alt="CAPTCHA">');
+            e('<input type="text" maxlength = "6"
+                name="user_entered_graphical_captcha_string"/>');
+            e('</div>');
+            imagedestroy($image);
+            
+        }
+    }
+}
+?>
\ No newline at end of file
diff --git a/views/register_view.php b/views/register_view.php
index f17b288..3252b68 100755
--- a/views/register_view.php
+++ b/views/register_view.php
@@ -183,16 +183,16 @@ class RegisterView extends View
                                 <?php echo in_array("repassword", $missing)
                                     ?'<span class="red">*</span>':''; ?></td>
                         </tr>
-                        <?php
-                        if(isset($_SESSION["random_string"])) {
+                        <?php                        
+                        if(isset($_SESSION["random_string"]) || 
+                            isset($_SESSION["graphical_captcha_string"])) {
                             $question_sets = array(
-                                tl('register_view_account_recovery')=>
+                                tl('register_view_account_recovery') =>
                                 $data['RECOVERY']);
-                        }
-                        else {
+                        } else {
                             $question_sets = array(
-                                tl('register_view_human_check')=>
-                                $data['CAPTCHAS'],
+                                tl('register_view_human_check') =>
+                                $data['CAPTCHA'],
                                 tl('register_view_account_recovery')
                                 =>$data['RECOVERY']);
                         }
@@ -222,6 +222,16 @@ class RegisterView extends View
                                 }
                                 $i++;
                             }
+                        }                        
+                        if (isset($_SESSION["graphical_captcha_string"])) {
+                            $graphical_element_data = array();
+                            $graphical_element_data["captcha_string"] = 
+                                $_SESSION["graphical_captcha_string"];
+                            e('<tr><th class="table-label">'.
+                                tl('register_view_human_check').'</th><td>');
+                            $this->element("graphicalcaptcha")->render(
+                                $graphical_element_data);
+                            e("</td></tr>");
                         }
                         ?>
                         <tr>
diff --git a/views/suggest_view.php b/views/suggest_view.php
index 163e5d0..8030d16 100644
--- a/views/suggest_view.php
+++ b/views/suggest_view.php
@@ -90,8 +90,8 @@ class SuggestView extends View
             <input type="hidden" name="c" value="register" />
             <input type="hidden" name="a" value="suggestUrl" />
             <input type="hidden" name="arg" value="save" />
-            <input type="hidden" name="build_time" value="<?php
-                e($data['build_time']); ?>" />
+            <input type="hidden" name="build_time" value=" <?php 
+                e($data['build_time']); ?>" /> 
                 <div class="register">
                     <table>
                         <tr>
@@ -109,34 +109,51 @@ class SuggestView extends View
                         </tr>
                         <tr>
                         <?php
-                        if(!isset($_SESSION["random_string"])) {
-                        $question_sets = array(tl('register_view_human_check')
-                            => $data['CAPTCHAS']);
-                        $i = 0;
-                        foreach($question_sets as $name => $set) {
-                            $first = true;
-                            $num = count($set);
-                            foreach($set as $question) {
-                                if($first) { ?>
-                                    <tr><th class="table-label"
-                                        rowspan='<?php e($num); ?>'><?php
-                                        e($name);
-                                      ?></th><td class="table-input border-top">
-                                <?php
-                                } else { ?>
-                                    <tr><td class="table-input">
-                                <?php
+                        if(!isset($_SESSION["random_string"]) && 
+                            !isset($_SESSION["graphical_captcha_string"])) {
+                                $question_sets = 
+                                    array(tl('register_view_human_check') => 
+                                    $data['CAPTCHA']);
+                                $i = 0;
+                                foreach($question_sets as $name => $set) {
+                                    $first = true;
+                                    $num = count($set);
+                                        foreach($set as $question) {
+                                            if($first) { ?>
+                                                <tr><th class="table-label"
+                                                    rowspan='<?php e($num); 
+                                                        ?>'>
+                                                    <?php e($name); ?>
+                                                </th><td 
+                                                class="table-input border-top">
+                                                <?php
+                                            } else { ?>
+                                                <tr><td class="table-input">
+                                                    <?php
+                                            }
+                                            $this->helper("options")->render(
+                                            "question-$i", "question_$i",
+                                            $question, $data["question_$i"]);
+                                
+                                            $first = false;
+                                            e(in_array("question_$i", $missing)
+                                                ?'<span class="red">*
+                                                    </span>':'');
+                                            e("</td></tr>");
+                                            $i++;
+                                        }
                                 }
-                                $this->helper("options")->render(
-                                    "question-$i", "question_$i",
-                                    $question, $data["question_$i"]);
-                                $first = false;
-                                e(in_array("question_$i", $missing)
-                                    ?'<span class="red">*</span>':'');
-                                e("</td></tr>");
-                                $i++;
-                            }
-                          }
+                        }
+                        if (isset($_SESSION["graphical_captcha_string"])) {
+                            $graphical_element_data = array();
+                            $graphical_element_data["captcha_string"] = 
+                                $_SESSION["graphical_captcha_string"];
+                            e('<tr><th class="table-label">'.
+                                tl('register_view_human_check').
+                                '</th><td>');
+                            $this->element("graphicalcaptcha")->render(
+                                $graphical_element_data);
+                            e("</td></tr>");
                         }
                         ?>
                         <tr>
@@ -176,4 +193,4 @@ class SuggestView extends View
         <?php
         }
     }
-?>
\ No newline at end of file
+?>
-- 
1.7.12.4 (Apple Git-37)


From b838b004ae006c71f3990732c6222ab8a379861d Mon Sep 17 00:00:00 2001
From: Sreenidhi <sreenidhimuralidharan@gmail.com>
Date: Sat, 31 May 2014 11:14:14 -0700
Subject: [PATCH 2/4] Captcha - working

---
 configs/config.php                         |  4 +--
 css/search.css                             |  9 ++++++
 locale/en-US/configure.ini                 | 18 ++++++++++++
 views/elements/captchasettings_element.php | 44 +++++++++++++++---------------
 4 files changed, 51 insertions(+), 24 deletions(-)

diff --git a/configs/config.php b/configs/config.php
index 7242987..b72dca6 100755
--- a/configs/config.php
+++ b/configs/config.php
@@ -82,7 +82,7 @@ $COMPONENT_ACTIVITIES = array(
         "manageRoles"),
     "crawl" => array("manageCrawls", "manageClassifiers", "pageOptions",
         "resultsEditor", "searchSources"),
-    "social" => array("manageGroups", "groupFeeds", "mixCrawls"),
+    "social" => array("manageGroups", "groupFeeds", "mixCrawls", "wiki"),
     "system" => array("manageMachines", "manageLocales",
         "serverSettings", "captchaSettings", "configure")
 );
@@ -106,7 +106,7 @@ if(MAINTENANCE_MODE && $_SERVER["SERVER_ADDR"] != $_SERVER["REMOTE_ADDR"]) {
 if(!defined('WORK_DIRECTORY')) {
 /*+++ The next block of code is machine edited, change at 
 your own risk, please use configure web page instead +++*/
-define('WORK_DIRECTORY', '/Library/WebServer/Documents/yioop_data200');
+define('WORK_DIRECTORY', '');
 /*++++++*/
 // end machine edited code
 }
diff --git a/css/search.css b/css/search.css
index 2a30579..07976f6 100755
--- a/css/search.css
+++ b/css/search.css
@@ -2489,3 +2489,12 @@ table.wikitable > caption
     width: 260px;
     padding-top: 10px;
 }
+
+.text-captcha-container .question-update-input {
+    width: 50%;
+}
+
+.text-captcha-container .choices-update-input {
+    width: 50%;
+}
+
diff --git a/locale/en-US/configure.ini b/locale/en-US/configure.ini
index b3e44de..3d4d468 100755
--- a/locale/en-US/configure.ini
+++ b/locale/en-US/configure.ini
@@ -1618,6 +1618,24 @@ crawlstatus_view_no_previous_crawl = "No Previous Crawls"
 ; activity_element.php line: 62
 activity_element_activities = "Activities"
 ;
+; captchasettings_element.php line: 68
+captchasettings_element_captcha_setting = "Select a Captcha Mode:"
+;
+; captchasettings_element.php line: 89
+captchasettings_element_captcha_type = "Type:"
+;
+; captchasettings_element.php line: 100
+captchasettings_element_captcha_possibilities = "Possibilities:"
+;
+; captchasettings_element.php line: 109
+captchasettings_element_captcha_language = "Locale Preference:"
+;
+; captchasettings_element.php line: 117
+captchasettings_element_captcha_question = "Question:"
+;
+; captchasettings_element.php line: 125
+captchasettings_element_captcha_choices = "Choices:"
+;
 ; configure_element.php line: 82
 configure_element_work_directory = "Search Engine Work Directory"
 ;
diff --git a/views/elements/captchasettings_element.php b/views/elements/captchasettings_element.php
index 48e079e..0aaad9f 100755
--- a/views/elements/captchasettings_element.php
+++ b/views/elements/captchasettings_element.php
@@ -78,13 +78,13 @@ class CaptchasettingsElement extends Element
             <?php
                 if ($selected_value == TEXT_CAPTCHA) {
             ?>
-                <div id="text-captcha-container">
-                    <h4>Add Captcha/Recovery Question:</h4>
+                <div id="text-captcha-container"
+                    class="text-captcha-container" >
+                    <h2>Add Captcha/Recovery Question:</h2>
                     <form id="text-captcha-container-add" 
                         class="text-captcha-container-add" 
                         method="post" action="">
-                        <ul><li><label id="captcha-type" 
-                            for="captcha-type"><?php 
+                        <ul><li><label for="captcha-type"><?php 
                             e(tl('captchasettings_element_captcha_type')); 
                             ?></label>
                             <?php $this->view->helper("options")->render(
@@ -92,8 +92,7 @@ class CaptchasettingsElement extends Element
                                 $data['CAPTCHA_TYPE'], 
                                 $data['CAPTCHA_TYPE']);?>
                             </li>
-                            <li><label id="captcha-possibilities" 
-                            for="captcha-possibilities">
+                            <li><label for="captcha-possibilities">
                             <?php 
                             e(tl(
                             'captchasettings_element_captcha_possibilities')); 
@@ -103,7 +102,7 @@ class CaptchasettingsElement extends Element
                                 $data['CAPTCHA_POSSIBILITIES'], 
                                 $data['CAPTCHA_POSSIBILITIES']);?>
                             </li>
-                            <li><label id="locale-selection">
+                            <li><label for="locale-selection">
                             <?php 
                             e(tl('captchasettings_element_captcha_language')); 
                             ?></label>
@@ -111,7 +110,7 @@ class CaptchasettingsElement extends Element
                                 "captcha-locale", "CAPTCHA_LOCALE", 
                                 $data['LANGUAGES'], "en-US");?>
                             </li>
-                            <li><label id="captcha-question-input-label"><?php
+                            <li><label for="captcha-question-input-label"><?php
                                 e(tl(
                                 'captchasettings_element_captcha_question'));
                                 ?></label>
@@ -119,7 +118,7 @@ class CaptchasettingsElement extends Element
                                     id="captcha-question-input" 
                                     name="CAPTCHA_QUESTION_INPUT">
                             </li>
-                            <li><label id="captcha-choices-input-label"><?php
+                            <li><label for="captcha-choices-input-label"><?php
                                 e(tl(
                                 'captchasettings_element_captcha_choices'));
                                 ?></label>
@@ -138,7 +137,7 @@ class CaptchasettingsElement extends Element
                                     value="text_captcha"/></form>
                         <form name="updateTextCaptchaForm" method="post" 
                                 action =""> 
-         		    	    <h4>Current Question:</h4>
+         		    	    <h2>Current Question:</h2>
                             <select multiple="multiple" 
                                 class="text-captcha-input" 
                                 name="text_captcha_delete_questions[]">    	    	     
@@ -155,15 +154,16 @@ class CaptchasettingsElement extends Element
                                     }
                                 }               
                                 ?>
-                        </select>
-                        <input type="hidden" name="arg" 
-                            value="updatetextcaptcha" />
-         				<input type="submit" value='Delete From Database' 
-         				    name="actiondelete"/>
-                        <input type="submit" value='Edit'  
-                            name="actionedit"/>
+                            </select>
+                            <input type="hidden" name="arg" 
+                                value="updatetextcaptcha" />
+         				    <input type="submit" value='Delete From Database' 
+         				        name="actiondelete"/>
+                            <input type="submit" value='Edit'  
+                                name="actionedit"/>
                        </form> 
-                    <?php if(isset($data['EDIT_CAPTCHA_MAPS'])) {
+                       <?php 
+                       if(isset($data['EDIT_CAPTCHA_MAPS'])) {
                         $question_choice_rowid_map = 
                             $data['EDIT_CAPTCHA_MAPS']
                             ['question_choice_rowid_map'];
@@ -174,16 +174,16 @@ class CaptchasettingsElement extends Element
                             $question_rowid => $choices_rowid) {
                             e('<div>');
                             e('<div>');
-                            e('Question:<input name="updateField['.
+                            e('Question <input name="updateField['.
                                 $question_rowid.']" value="'.
                                 $rowid_translation_map[$question_rowid].'" 
-                                style="width:80%">');
+                                class="question-update-input">');
                             e('</div>');
                             e('<div>');
-                            e('Choices:<input name="updateField['.
+                            e('Choices <input name="updateField['.
                                 $choices_rowid.']" value="'.
                                 $rowid_translation_map[$choices_rowid].'" 
-                                style="width:80%">');
+                                class="choices-update-input">');
                             e('</div>');
                             e('</div>');
                         }
-- 
1.7.12.4 (Apple Git-37)


From 6a33ddd4b665f8c2b520de2a04c88fb0c5ee03a9 Mon Sep 17 00:00:00 2001
From: Sreenidhi <sreenidhimuralidharan@gmail.com>
Date: Sat, 31 May 2014 15:49:35 -0700
Subject: [PATCH 3/4] Captcha commit working

---
 configs/config.php                         |  2 +-
 locale/en-US/configure.ini                 | 15 +++++++++++++
 views/elements/captchasettings_element.php | 34 +++++++++++++++++++++---------
 3 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/configs/config.php b/configs/config.php
index b72dca6..5f0a0db 100755
--- a/configs/config.php
+++ b/configs/config.php
@@ -106,7 +106,7 @@ if(MAINTENANCE_MODE && $_SERVER["SERVER_ADDR"] != $_SERVER["REMOTE_ADDR"]) {
 if(!defined('WORK_DIRECTORY')) {
 /*+++ The next block of code is machine edited, change at 
 your own risk, please use configure web page instead +++*/
-define('WORK_DIRECTORY', '');
+define('WORK_DIRECTORY', '/Library/WebServer/Documents/yioop_data200');
 /*++++++*/
 // end machine edited code
 }
diff --git a/locale/en-US/configure.ini b/locale/en-US/configure.ini
index 3d4d468..3d78f67 100755
--- a/locale/en-US/configure.ini
+++ b/locale/en-US/configure.ini
@@ -1621,6 +1621,9 @@ activity_element_activities = "Activities"
 ; captchasettings_element.php line: 68
 captchasettings_element_captcha_setting = "Select a Captcha Mode:"
 ;
+; captchasettings_element.php line: 84
+captchasettings_element_add_captcha_recovery = "Add Captcha/Recovery Question:"
+;
 ; captchasettings_element.php line: 89
 captchasettings_element_captcha_type = "Type:"
 ;
@@ -1636,6 +1639,18 @@ captchasettings_element_captcha_question = "Question:"
 ; captchasettings_element.php line: 125
 captchasettings_element_captcha_choices = "Choices:"
 ;
+; captchasettings_element.php line: 135
+captchasettings_element_add_to_database = "Add To Database"
+;
+; captchasettings_element.php line: 144
+captchasettings_element_current_question = "Current Question:"
+;
+; captchasettings_element.php line: 170
+captchasettings_element_delete_from_database = "Delete From Database"
+;
+; captchasettings_element.php line: 175
+captchasettings_element_edit_database = "Edit"
+;
 ; configure_element.php line: 82
 configure_element_work_directory = "Search Engine Work Directory"
 ;
diff --git a/views/elements/captchasettings_element.php b/views/elements/captchasettings_element.php
index 0aaad9f..8e95584 100755
--- a/views/elements/captchasettings_element.php
+++ b/views/elements/captchasettings_element.php
@@ -80,7 +80,9 @@ class CaptchasettingsElement extends Element
             ?>
                 <div id="text-captcha-container"
                     class="text-captcha-container" >
-                    <h2>Add Captcha/Recovery Question:</h2>
+                    <h2><?php 
+                        e(tl('captchasettings_element_add_captcha_recovery')); 
+                    ?></h2>
                     <form id="text-captcha-container-add" 
                         class="text-captcha-container-add" 
                         method="post" action="">
@@ -102,7 +104,7 @@ class CaptchasettingsElement extends Element
                                 $data['CAPTCHA_POSSIBILITIES'], 
                                 $data['CAPTCHA_POSSIBILITIES']);?>
                             </li>
-                            <li><label for="locale-selection">
+                            <li><label for="captcha-locale">
                             <?php 
                             e(tl('captchasettings_element_captcha_language')); 
                             ?></label>
@@ -127,17 +129,23 @@ class CaptchasettingsElement extends Element
                                     name="CAPTCHA_CHOICES_INPUT"></li>
                             <li><input type="hidden" name="arg" 
                                     value="addtextcaptcha" />
-             				    <input type="submit" value= 
-             				        'Add To Database' 
+             				    <input type="submit"   
              				        id="text-captcha-add-to-database" 
-             				        name="text_captcha_add_to_database">
+             				        name="text_captcha_add_to_database" 
+             				        value="<?php
+             				        e(tl(
+             				       'captchasettings_element_add_to_database'));
+             				        ?>"/>
              				</li>
                         </ul>
                         <input type="hidden" name="CAPTCHA_MODE" 
                                     value="text_captcha"/></form>
                         <form name="updateTextCaptchaForm" method="post" 
                                 action =""> 
-         		    	    <h2>Current Question:</h2>
+         		    	    <h2>
+         		    	    <?php 
+                            e(tl('captchasettings_element_current_question')); 
+                            ?></h2>
                             <select multiple="multiple" 
                                 class="text-captcha-input" 
                                 name="text_captcha_delete_questions[]">    	    	     
@@ -157,10 +165,16 @@ class CaptchasettingsElement extends Element
                             </select>
                             <input type="hidden" name="arg" 
                                 value="updatetextcaptcha" />
-         				    <input type="submit" value='Delete From Database' 
-         				        name="actiondelete"/>
-                            <input type="submit" value='Edit'  
-                                name="actionedit"/>
+         				    <input type="submit" value="<?php
+         				       e(tl(
+         				      'captchasettings_element_delete_from_database'));
+         				       ?>" 
+         				       name="actiondelete"/>
+                            <input type="submit" value="<?php
+            				    e(tl(
+            				  'captchasettings_element_edit_database'));
+            				    ?>"  
+                               name="actionedit"/>
                        </form> 
                        <?php 
                        if(isset($data['EDIT_CAPTCHA_MAPS'])) {
-- 
1.7.12.4 (Apple Git-37)


From 7b4c0fea6d24dfb36f940d7ad889750d49eec3d4 Mon Sep 17 00:00:00 2001
From: Sreenidhi <sreenidhimuralidharan@gmail.com>
Date: Sat, 31 May 2014 16:12:29 -0700
Subject: [PATCH 4/4] Captcha latest commit

---
 configs/config.php                         |  2 +-
 locale/en-US/configure.ini                 | 18 +++++-----
 views/elements/captchasettings_element.php | 57 +++++++++++++++---------------
 3 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/configs/config.php b/configs/config.php
index 5f0a0db..b72dca6 100755
--- a/configs/config.php
+++ b/configs/config.php
@@ -106,7 +106,7 @@ if(MAINTENANCE_MODE && $_SERVER["SERVER_ADDR"] != $_SERVER["REMOTE_ADDR"]) {
 if(!defined('WORK_DIRECTORY')) {
 /*+++ The next block of code is machine edited, change at 
 your own risk, please use configure web page instead +++*/
-define('WORK_DIRECTORY', '/Library/WebServer/Documents/yioop_data200');
+define('WORK_DIRECTORY', '');
 /*++++++*/
 // end machine edited code
 }
diff --git a/locale/en-US/configure.ini b/locale/en-US/configure.ini
index 3d78f67..0885300 100755
--- a/locale/en-US/configure.ini
+++ b/locale/en-US/configure.ini
@@ -1627,11 +1627,11 @@ captchasettings_element_add_captcha_recovery = "Add Captcha/Recovery Question:"
 ; captchasettings_element.php line: 89
 captchasettings_element_captcha_type = "Type:"
 ;
-; captchasettings_element.php line: 100
-captchasettings_element_captcha_possibilities = "Possibilities:"
+; captchasettings_element.php line: 99
+captchasettings_element_captcha_possible = "Possibilities:"
 ;
 ; captchasettings_element.php line: 109
-captchasettings_element_captcha_language = "Locale Preference:"
+captchasettings_element_captcha_locale = "Locale Preference:"
 ;
 ; captchasettings_element.php line: 117
 captchasettings_element_captcha_question = "Question:"
@@ -1639,17 +1639,17 @@ captchasettings_element_captcha_question = "Question:"
 ; captchasettings_element.php line: 125
 captchasettings_element_captcha_choices = "Choices:"
 ;
-; captchasettings_element.php line: 135
-captchasettings_element_add_to_database = "Add To Database"
+; captchasettings_element.php line: 140
+captchasettings_element_captcha_add = "Add To Database"
 ;
 ; captchasettings_element.php line: 144
 captchasettings_element_current_question = "Current Question:"
 ;
-; captchasettings_element.php line: 170
-captchasettings_element_delete_from_database = "Delete From Database"
+; captchasettings_element.php line: 173
+captchasettings_element_captcha_delete = "Delete From Database"
 ;
-; captchasettings_element.php line: 175
-captchasettings_element_edit_database = "Edit"
+; captchasettings_element.php line: 177
+captchasettings_element_captcha_edit = "Edit"
 ;
 ; configure_element.php line: 82
 configure_element_work_directory = "Search Engine Work Directory"
diff --git a/views/elements/captchasettings_element.php b/views/elements/captchasettings_element.php
index 8e95584..f77df5c 100755
--- a/views/elements/captchasettings_element.php
+++ b/views/elements/captchasettings_element.php
@@ -96,46 +96,49 @@ class CaptchasettingsElement extends Element
                             </li>
                             <li><label for="captcha-possibilities">
                             <?php 
-                            e(tl(
-                            'captchasettings_element_captcha_possibilities')); 
-                            ?></label>
+                             e(tl('captchasettings_element_captcha_possible')); 
+                            ?>
+                            </label>
                             <?php $this->view->helper("options")->render(
-                                "captcha-possibilities", "CAPTCHA_POSSIBILITIES", 
+                                "captcha-possibilities", 
+                                "CAPTCHA_POSSIBILITIES", 
                                 $data['CAPTCHA_POSSIBILITIES'], 
                                 $data['CAPTCHA_POSSIBILITIES']);?>
                             </li>
                             <li><label for="captcha-locale">
                             <?php 
-                            e(tl('captchasettings_element_captcha_language')); 
-                            ?></label>
+                              e(tl('captchasettings_element_captcha_locale')); 
+                            ?>
+                            </label>
                             <?php $this->view->helper("options")->render(
                                 "captcha-locale", "CAPTCHA_LOCALE", 
                                 $data['LANGUAGES'], "en-US");?>
                             </li>
-                            <li><label for="captcha-question-input-label"><?php
-                                e(tl(
-                                'captchasettings_element_captcha_question'));
-                                ?></label>
+                            <li><label for="captcha-question-input-label">
+                            <?php 
+                             e(tl('captchasettings_element_captcha_question')); 
+                            ?>
+                            </label>
                                 <input type="text" 
                                     id="captcha-question-input" 
                                     name="CAPTCHA_QUESTION_INPUT">
                             </li>
-                            <li><label for="captcha-choices-input-label"><?php
-                                e(tl(
-                                'captchasettings_element_captcha_choices'));
-                                ?></label>
+                            <li><label for="captcha-choices-input-label">
+                            <?php 
+                              e(tl('captchasettings_element_captcha_choices')); 
+                            ?>
+                            </label>
                                 <input type="text" 
                                     id="captcha-choices-input" 
                                     name="CAPTCHA_CHOICES_INPUT"></li>
                             <li><input type="hidden" name="arg" 
                                     value="addtextcaptcha" />
              				    <input type="submit"   
-             				        id="text-captcha-add-to-database" 
-             				        name="text_captcha_add_to_database" 
-             				        value="<?php
-             				        e(tl(
-             				       'captchasettings_element_add_to_database'));
-             				        ?>"/>
+             				      id="text-captcha-add-to-database" 
+             				      name="text_captcha_add_to_database" 
+             				      value="<?php 
+                                  e(tl('captchasettings_element_captcha_add')); 
+                                  ?>"/>
              				</li>
                         </ul>
                         <input type="hidden" name="CAPTCHA_MODE" 
@@ -165,15 +168,13 @@ class CaptchasettingsElement extends Element
                             </select>
                             <input type="hidden" name="arg" 
                                 value="updatetextcaptcha" />
-         				    <input type="submit" value="<?php
-         				       e(tl(
-         				      'captchasettings_element_delete_from_database'));
-         				       ?>" 
+         				    <input type="submit" value="<?php 
+                               e(tl('captchasettings_element_captcha_delete')); 
+                               ?>" 
          				       name="actiondelete"/>
-                            <input type="submit" value="<?php
-            				    e(tl(
-            				  'captchasettings_element_edit_database'));
-            				    ?>"  
+                            <input type="submit" value="<?php 
+                                e(tl('captchasettings_element_captcha_edit')); 
+                                ?>"  
                                name="actionedit"/>
                        </form> 
                        <?php 
-- 
1.7.12.4 (Apple Git-37)

