_binary diff --git a/configs/config.php b/configs/config.php
index 6ee8d7e..1462cc4 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
@@ -122,15 +122,23 @@ define('FALLBACK_LOCALE_DIR', BASE_DIR."/locale");
 define ('SESSION_NAME', "yioopbiscuit");
 define('CSRF_TOKEN', "YIOOP_TOKEN");
 
-/** Captcha Mode Possibility*/
-define('TEXT_CAPTCHA', 1);
+/** Captcha Mode*/
+define('TEXT_CAPTCHA', 'text_captcha');
 
-/** Captcha Mode Possibility*/
-define('HASH_CAPTCHA', 2);
+/** Captcha Mode*/
+define('HASH_CAPTCHA', 'hash_captcha');
+define('GRAPHICAL_CAPTCHA', 'graphical_captcha');
+
+//Captcha Type
+define('CAPTCHA', 'captcha');
+define('RECOVERY', 'recovery');
+
+//Captcha Possibilities
+define('MOST', 'most');
+define('LEAST', 'least');
 
 /** Authentication Mode Possibility*/
 define('NORMAL_AUTHENTICATION', 1);
-
 /** Authentication Mode Possibility*/
 define('ZKP_AUTHENTICATION', 2);
 
@@ -168,7 +176,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/configure_tool.php b/configs/configure_tool.php
old mode 100644
new mode 100755
diff --git a/configs/createdb.php b/configs/createdb.php
index 452bd06..0f380d2 100755
--- a/configs/createdb.php
+++ b/configs/createdb.php
@@ -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,380 @@ $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 +989,127 @@ 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')");
+        $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];
+       $sql = "INSERT INTO TRANSLATION_LOCALE VALUES ($translation_id_questionpref, $index_preferences_question_and_choices, 
+           '".$db->escapeString($translation_questionpref)."')";
+       $db->execute($sql);  
+    }
+    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 +1204,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/admin_controller.php b/controllers/admin_controller.php
index cf3f8cf..4bd950b 100755
--- a/controllers/admin_controller.php
+++ b/controllers/admin_controller.php
@@ -45,6 +45,9 @@ require_once BASE_DIR."/lib/page_rule_parser.php";
 require_once BASE_DIR."/lib/classifiers/classifier.php";
 /** Loads crawl_daemon to manage news_updater */
 require_once BASE_DIR."/lib/crawl_daemon.php";
+
+//require_once BASE_DIR."/models/textcaptchasettings_model.php";
+
 /** get processors for different file types */
 foreach(glob(BASE_DIR."/lib/processors/*_processor.php") as $filename) {
     require_once $filename;
@@ -200,9 +203,11 @@ class AdminController extends Controller implements CrawlConstants
                "u.focus();";
         }
         $_SESSION['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
+        
         $this->displayView($view, $data);
     }
 
+
     /**
      * If there is no profile/work directory set up then this method
      * get called to by pass any login and go to the configure screen.
diff --git a/controllers/classifier_controller.php b/controllers/classifier_controller.php
old mode 100644
new mode 100755
diff --git a/controllers/components/captchasettings_component.php b/controllers/components/captchasettings_component.php
new file mode 100755
index 0000000..e69de29
diff --git a/controllers/components/component.php b/controllers/components/component.php
old mode 100644
new mode 100755
diff --git a/controllers/components/system_component.php b/controllers/components/system_component.php
old mode 100644
new mode 100755
index e53568e..98806f8
--- 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,108 @@ 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
+                    // Check if text captcha form is posted on clicking 'Add To Database' button
+                    $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"] = CAPTCHA_MODE;
+        return $data;
+    }
+
+
 
     /**
      * Responsible for handling admin request related to the configure activity
diff --git a/controllers/controller.php b/controllers/controller.php
index 702578c..d12b230 100755
--- a/controllers/controller.php
+++ b/controllers/controller.php
@@ -210,7 +210,7 @@ abstract class Controller
     }
 
     /**
-     *  This function should be overriden to web handle requests
+     *  This function should be overridden to web handle requests
      */
     public abstract function processRequest();
 
diff --git a/controllers/crawl_controller.php b/controllers/crawl_controller.php
old mode 100644
new mode 100755
diff --git a/controllers/register_controller.php b/controllers/register_controller.php
index 79ade27..1bc82bf 100755
--- a/controllers/register_controller.php
+++ b/controllers/register_controller.php
@@ -126,65 +126,42 @@ 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 +173,18 @@ 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();
-            }
-        }
+       // $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 +201,9 @@ 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 +367,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 +425,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 +498,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 +627,13 @@ 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,18 +669,18 @@ 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;
+                $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();
@@ -705,8 +688,8 @@ class RegisterController extends Controller implements CrawlConstants
         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)) {
@@ -718,7 +701,10 @@ class RegisterController extends Controller implements CrawlConstants
           }
         }
         $data['MISSING'] = $missing;
+		print_r($_REQUEST);
+		print_r($save);
         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,25 @@ 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($_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']);
+                    $visitor_model->updateVisitor(
+                        $_SERVER['REMOTE_ADDR'], "captcha_time_out");
+                    return $data;
+                }
+            }
             if(!$this->model("crawl")->appendSuggestSites($url)) {
                 $data['SCRIPT'] = "doMessage('<h1 class=\"red\" >".
                 tl('register_controller_suggest_full')."</h1>');";
@@ -769,22 +766,22 @@ 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;
+                $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 +825,35 @@ 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) {
+            unset($_SESSION["graphical_captcha_string"]);
+            // defines captcha text
+            $charactersForCaptcha = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+            $len = strlen($charactersForCaptcha);
+            // selecting letters for captcha
+            $captchaLetter = $charactersForCaptcha[rand(0, $len - 1)];
+            $word = "";
+            for ($i = 0; $i < 6; $i++) {
+                // selecting letters for captcha
+                $captchaLetter = $charactersForCaptcha[rand(0, $len - 1)];
+                $word = $word.$captchaLetter;      
+             }
+             // stores the captcha in a session variable called 'captcha_string'
+             $_SESSION['graphical_captcha_string'] = $word;
         }
         if(!isset($_SESSION['RECOVERY'])) {
             list($data['RECOVERY'], ) = $this->selectQuestionsAnswers(
@@ -848,17 +864,43 @@ class RegisterController extends Controller implements CrawlConstants
         }
         return $data;
     }
-
+    
     /**
-     *  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 +915,34 @@ 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 +951,30 @@ 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);
                 $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);
                 $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 +1005,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 +1018,22 @@ 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,11 +1083,14 @@ 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;
diff --git a/css/search.css b/css/search.css
index 2b86795..f14f6aa 100755
--- a/css/search.css
+++ b/css/search.css
@@ -2456,3 +2456,18 @@ table.wikitable > caption
     z-index: 200;
 }
 
+/* Captcha settings styles */
+
+#captchaSettingsContainer ul {
+  list-style-type: none;
+  padding: 0;
+}
+
+#captchaSettingsContainer li {
+  line-height: 40px;
+}
+
+.textCaptchaQuestions {
+  padding: 10px;
+}
+
diff --git a/data/default.db b/data/default.db
old mode 100644
new mode 100755
diff --git a/lib/locale_functions.php b/lib/locale_functions.php
index 2d1541c..73fec13 100755
--- a/lib/locale_functions.php
+++ b/lib/locale_functions.php
@@ -102,7 +102,6 @@ function guessLocale()
  *      provided uses current locale's value
  * @param int threshold number of chars to guess a particular encoding
  * @return string IANA language tag of the guessed locale
-
  */
 function guessLocaleFromString($phrase_string, $locale_tag = NULL)
 {
diff --git a/locale/en-US/configure.ini b/locale/en-US/configure.ini
index 015b4c1..c879751 100755
--- a/locale/en-US/configure.ini
+++ b/locale/en-US/configure.ini
@@ -1068,6 +1068,27 @@ system_component_configure_email_activation = "Email Activation"
 ; system_component.php line: 601
 system_component_configure_admin_activation = "Admin Activation"
 ;
+;system_component.php line: 692
+captchasettings_element_text_captcha = "Text Captcha"
+;
+;system_component.php line: 694
+captchasettings_element_hash_captcha = "Hash Captcha"
+;
+;system_component.php line: 696
+captchasettings_element_graphical_captcha = "Graphical Captcha"
+;
+;system_component.php line: 701
+captchasettings_element_captcha = "Captcha"
+;
+;system_component.php line: 702
+captchasettings_element_recovery = "Recovery"
+;
+;system_component.php line: 706
+captchasettings_element_possibility_most = "Most"
+;
+;system_component.php line: 707
+captchasettings_element_possibility_least = "Least"
+;
 ; system_component.php line: 605
 serversettings_element_text_captcha = "Text Captcha"
 ;
@@ -1380,6 +1401,9 @@ register_controller_error_fields = "Starred fields need to be filled in correctl
 ; register_controller.php line: 741
 register_controller_failed_hashcode = "Hash Code Did Not Match!"
 ;
+;register_controller.php line: 746
+register_controller_failed_graphical_human = "Incorrect Captcha! Please try again!"
+;
 ; register_controller.php line: 750
 register_controller_failed_human = "Got human check questions wrong!"
 ;
@@ -1618,6 +1642,27 @@ crawlstatus_view_no_previous_crawl = "No Previous Crawls"
 ; activity_element.php line: 62
 activity_element_activities = "Activities"
 ;
+;captchasettings_element.php line: 72
+captchasettings_element_captcha_setting = "Select a Captcha:"
+;
+;captchasettings_element.php line: 97
+captchasettings_element_captcha_type = "Type:"
+;
+;captchasettings_element.php line: 107
+captchasettings_element_captcha_possibilities = "Possibilities:"
+;
+;captchasettings_element.php line: 140
+captchasettings_element_captcha_language = "Select your locale preference:"
+;
+;captchasettings_element.php line: 98
+captchasettings_element_captcha_question = "Question:"
+;
+;captchasettings_element.php line: 104
+captchasettings_element_captcha_choices = "Choices:"
+;
+;captchasettings_element.php line: 152
+captchasettings_element_captcha_correct_choice = "Correct choice:"
+;
 ; configure_element.php line: 82
 configure_element_work_directory = "Search Engine Work Directory"
 ;
@@ -2291,6 +2336,12 @@ managelocales_element_locale_info = "Edit Locale"
 ; managelocales_element.php line: 130
 managelocales_element_add_locale = "Add Locale"
 ;
+; managelocales_element.php line: 99
+managelocales_element_delete_locale = "Delete Locale"
+;
+; managelocales_element.php line: 109
+managelocales_element_delete_localelabel = "Locale:"
+;
 ; managelocales_element.php line: 149
 managelocales_element_localenamelabel = "Locale Name:"
 ;
diff --git a/models/crawl_model.php b/models/crawl_model.php
index 42eda1d..3eb0588 100755
--- a/models/crawl_model.php
+++ b/models/crawl_model.php
@@ -899,7 +899,7 @@ EOT;
             " CRAWL_TIMESTAMP='$timestamp'";
         $result = $this->db->execute($sql);
         $rows = array();
-        while($rows[] =  $this->db->fetchArray($result)) ;
+        while($rows[] = $this->db->fetchArray($result));
 
         foreach($rows as $row) {
             $this->deleteCrawlMix($row['TIMESTAMP']);
diff --git a/models/datasources/pdo_manager.php b/models/datasources/pdo_manager.php
index 59ca3e1..8cdf5df 100644
--- a/models/datasources/pdo_manager.php
+++ b/models/datasources/pdo_manager.php
@@ -46,7 +46,6 @@ require_once "datasource_manager.php";
  * the abstract class DatasourceManager
  * for any PDO accessible DBMS. Method explanations
  * are from the parent class.
-
  * @author Chris Pollett
  *
  * @package seek_quarry
diff --git a/models/profile_model.php b/models/profile_model.php
index 3ede1c1..5c37875 100755
--- a/models/profile_model.php
+++ b/models/profile_model.php
@@ -50,8 +50,9 @@ require_once(BASE_DIR.'/lib/url_parser.php');
 class ProfileModel extends Model
 {
      var $profile_fields = array('API_ACCESS', 'AUTH_KEY',
-        'AUTHENTICATION_MODE', 'CACHE_LINK', 'CAPTCHA_MODE','DEBUG_LEVEL',
-        'DESCRIPTION_WEIGHT', 'DB_HOST', 'DBMS', 'DB_NAME','DB_PASSWORD',
+        'AUTHENTICATION_MODE', 'CACHE_LINK', 'CAPTCHA_MODE','CAPTCHA_TYPE',
+        'CAPTCHA_POSSIBILITIES','DEBUG_LEVEL', 'DESCRIPTION_WEIGHT',
+        'DB_HOST', 'DBMS', 'DB_NAME','DB_PASSWORD',
         'DB_USER', 'DEFAULT_LOCALE', 'FIAT_SHAMIR_MODULUS', 'GROUP_ITEM',
         'IN_LINK','IP_LINK', 'LINK_WEIGHT', 'MAIL_PASSWORD', 'MAIL_SECURITY',
         'MAIL_SENDER', 'MAIL_SERVER', 'MAIL_SERVERPORT', 'MAIL_USERNAME',
@@ -298,6 +299,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,
@@ -337,7 +345,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)",
@@ -362,6 +370,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..d074305
--- /dev/null
+++ b/models/textcaptchasettings_model.php
@@ -0,0 +1,869 @@
+<?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
+ * db results related to Administration Activities
+ *
+ * @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;
+          
+          }else{
+              print_r("Not the right question type!");
+          }    
+ 	      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 = "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, 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 = "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, 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 = "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, 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;
+          
+          }else{
+              print_r("Not the right question type!");
+          }   
+ 	      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;
+          
+          }else{
+              print_r("Not the right question type!");
+          }    
+ 	      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 = "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, 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 = "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, 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 = "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, 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 $methodIndexChoices to Integer	           
+            //checks if $methodIndexChoices 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;
+          
+          }else{
+              print_r("Not the right question type!");
+          }   
+ 	      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 PREFERNCES 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/models/visitor_model.php b/models/visitor_model.php
index 80f2575..817acc1 100644
--- a/models/visitor_model.php
+++ b/models/visitor_model.php
@@ -88,7 +88,7 @@ class VisitorModel extends Model
      *
      *  @param string $ip_address the ipv4 or ipv6 address as a string
      *  @param string $page_name
-     */
+     */  
     function removeVisitor($ip_address, $page_name = 'captcha_time_out')
     {
         $sql = "DELETE FROM VISITOR WHERE ADDRESS = ? AND PAGE_NAME = ?";
@@ -112,7 +112,7 @@ class VisitorModel extends Model
      *      address should be treated as never seen before
      *  @param int string $count_till_double how many accesses before start
      *      double the delay
-     */
+     */   
     function updateVisitor($ip_address, $page_name, $start_delay = 1,
         $forget_age = self::ONE_WEEK, $count_till_double = 1)
     {
@@ -140,7 +140,7 @@ class VisitorModel extends Model
             ":delay"=>$delay, ":end_time" => $end_time,
             ":forget_age" => $forget_age, ":account_count" => $access_count,
             ":ip_address" => $ip_address, ":page_name" => $page_name));
-    }
+    }  
 }
 
  ?>
diff --git a/scripts/captchasettings.js b/scripts/captchasettings.js
new file mode 100755
index 0000000..cf0e107
--- /dev/null
+++ b/scripts/captchasettings.js
@@ -0,0 +1,12 @@
+var text_captcha_add_new = document.getElementById('text_captcha_add_new');
+text_captcha_add_new.addEventListener('click', function(event) {
+  addField();
+});
+
+function addField() {
+  var form = document.getElementById('captchaFormForText');
+  var input = document.createElement('input');
+  input.type = 'text';
+  input.name = 'CAPTCHA_CHOICES_INPUT[]';
+  form.appendChild(input);
+}
diff --git a/views/elements/captchasettings_element.php b/views/elements/captchasettings_element.php
new file mode 100755
index 0000000..fcf700d
--- /dev/null
+++ b/views/elements/captchasettings_element.php
@@ -0,0 +1,166 @@
+<?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 ="captchaSettingsContainer">
+            <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="textCaptchaContainer">
+                    <h4>Add Captcha/Recovery Question:</h4>
+                    <form id = "textCaptchaContainerAdd" class = "textCaptchaContainerAdd" 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-settings", "CAPTCHA_POSSIBILITIES", $data['CAPTCHA_POSSIBILITIES'], $data['CAPTCHA_POSSIBILITIES']);
+                                ?>
+                            </li>
+                            <li>
+                                <label id = "localeSelection"><?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 = "captchaQuestionInputLabel"><?php
+                                e(tl('captchasettings_element_captcha_question'));
+                                ?></label>
+                				<input type = "text" id = "CAPTCHA_QUESTION_INPUT" name = "CAPTCHA_QUESTION_INPUT">
+                            </li>
+                            <li>
+                                <label id = "captchaChoicesInputLabel"><?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 = "textCaptchaInput" 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>
+                    
+                    <? 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: captchaSettingsContainer-->
+    </div>
+</div><!-- End of div: current-activity -->
+
+<script type = "text/javascript" src = "./scripts/captchasettings.js" ></script>
+
+<?php
+    }
+}
+
+?>
diff --git a/views/elements/configure_element.php b/views/elements/configure_element.php
old mode 100644
new mode 100755
diff --git a/views/elements/graphicalcaptcha_element.php b/views/elements/graphicalcaptcha_element.php
new file mode 100644
index 0000000..0c83685
--- /dev/null
+++ b/views/elements/graphicalcaptcha_element.php
@@ -0,0 +1,42 @@
+<?php
+
+if(!defined('BASE_DIR')) {echo "BAD REQUEST"; exit();}
+
+
+class GraphicalcaptchaElement extends Element
+{
+    function render($data) 
+    {
+        if(isset($data['captcha_string'])) {
+            $captchaWord = $data['captcha_string'];
+            $image = @imagecreatetruecolor(195, 35);
+            // defines background color, random lines color and text color
+            $bgColor = imagecolorallocate($image, mt_rand(0,255), 255, 0);
+            imagefill($image, 0, 0, $bgColor);
+            $linesColor = imagecolorallocate($image, 0x99, 0xCC, 0x99);
+            $textColor = 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), $linesColor);
+            }
+            $captchaLetterArr = str_split($captchaWord);
+            foreach($captchaLetterArr as $i => $captchaLetter) {
+                imagesetthickness($image, 1);
+                imagestring($image, 5, 5 + ($i * 35), rand(2,14), $captchaLetter, $textColor); 
+            }
+            // creates image
+            ob_start (); 
+            imagepng ($image);
+            $image_data = ob_get_contents ();
+            ob_end_clean ();
+            $image_data_base64 = base64_encode($image_data);
+            e('<div style="width:260px;padding-top:10px;">');
+            e('<img src="data:image/png;base64,'.$image_data_base64.'" width="260" height="70" border="1" alt="CAPTCHA">');
+            e('<input type="text" name="user_entered_graphical_captcha_string"/>');
+            e('</div>');
+            imagedestroy($image);
+            
+        }
+    }
+}
+?>
\ No newline at end of file
diff --git a/views/elements/managelocales_element.php b/views/elements/managelocales_element.php
index e2b48e8..35e9dd8 100644
--- a/views/elements/managelocales_element.php
+++ b/views/elements/managelocales_element.php
@@ -57,119 +57,36 @@ class ManagelocalesElement extends Element
     {
     ?>
         <div class="current-activity">
-        <?php
-        if($data['FORM_TYPE'] == "search") {
-            $this->renderSearchForm($data);
-        } else {
-            $this->renderLocaleForm($data);
-        }
-        $data['TABLE_TITLE'] = tl('managelocales_element_locale_list');
-        $data['NO_FLOAT_TABLE'] = true;
-        $data['ACTIVITY'] = 'manageLocales';
-        $data['VIEW'] = $this->view;
-        $this->view->helper("pagingtable")->render($data);
-        ?>
-        <table class="locale-table">
-            <tr>
-            <th><?php e(tl('managelocales_element_localename')); ?></th>
-            <?php
-            if(!MOBILE) { ?>
-                <th><?php e(tl('managelocales_element_localetag'));?></th>
-                <th><?php e(tl('managelocales_element_writingmode'));
-                    ?></th>
-            <?php
-            }
-            ?>
-            <th><?php e(tl('managelocales_element_percenttranslated'));?></th>
-            <th colspan="2"><?php e(tl('managelocales_element_actions'));?></th>
-            </tr>
-        <?php
-        $base_url = '?c=admin&amp;a=manageLocales&amp;'.CSRF_TOKEN."=".
-            $data[CSRF_TOKEN];
-        foreach($data['LOCALES'] as $locale) {
-            e("<tr><td><a href='$base_url".
-                "&amp;arg=editstrings&amp;selectlocale=".$locale['LOCALE_TAG'].
-                "' >". $locale['LOCALE_NAME']."</a></td>");
-            if(!MOBILE) {
-                e("<td>".$locale['LOCALE_TAG']."</td>");
-                e("<td>".$locale['WRITING_MODE']."</td>");
-            }
-            e("<td class='align-right' >".
-                $locale['PERCENT_WITH_STRINGS']."</td>");
-            e("<td><a href='$base_url"
-                ."&amp;arg=editlocale&amp;selectlocale=".
-                $locale['LOCALE_TAG']."' >"
-                .tl('managelocales_element_edit')."</a></td>");
-            e("<td><a href='$base_url"
-                ."&amp;arg=deletelocale&amp;selectlocale=".
-                $locale['LOCALE_TAG']."' >"
-                .tl('managelocales_element_delete')."</a></td></tr>");
-        }
-        ?>
-        </table>
-        </div>
-    <?php
-    }
-
-    /**
-     *  Draws the add locale and edit locale forms
-     *
-     *  @param array $data consists of values of locale fields set
-     *      so far as well as values of the drops downs on the form
-
-     */
-    function renderLocaleForm($data)
-    {
-        $base_url = "?c=admin&amp;".CSRF_TOKEN."=".$data[CSRF_TOKEN].
-            "&amp;a=manageLocales";
-        $editlocale = ($data['FORM_TYPE'] == "editlocale") ? true: false;
-        if($editlocale) {
-            e("<div class='float-opposite'><a href='$base_url'>".
-                tl('manageloecales_element_add_locale_form')."</a></div>");
-            e("<h2>".tl('managelocales_element_locale_info'). "</h2>");
-        } else {
-            e("<h2>".tl('managelocales_element_add_locale'). "</h2>");
-        }
-        ?>
+        <h2><?php e(tl('managelocales_element_add_locale'))?></h2>
         <form id="addLocaleForm" method="post" action=''>
         <input type="hidden" name="c" value="admin" />
         <input type="hidden" name="<?php e(CSRF_TOKEN); ?>" value="<?php
             e($data[CSRF_TOKEN]); ?>" />
         <input type="hidden" name="a" value="manageLocales" />
-        <input type="hidden" name="arg" value="<?php
-            e($data['FORM_TYPE']);?>" />
-        <?php 
-        if($editlocale) {
-        ?>
-            <input type="hidden" name="selectlocale" value="<?php
-                e($data['CURRENT_LOCALE']['localetag']);?>" /><?php
-        }
-        ?>
+        <input type="hidden" name="arg" value="addlocale" />
+
         <table class="name-table">
             <tr><td><label for="locale-name"><?php
                 e(tl('managelocales_element_localenamelabel'))?></label></td>
                 <td><input type="text" id="locale-name"
-                    name="localename" maxlength="80" class="narrow-field"
-                    value="<?php e($data['CURRENT_LOCALE']['localename']); ?>"
-                    <?php
-                    if($editlocale) {
-                        e(' disabled="disabled" ');
-                    }
-                    ?> />
+                    name="localename" maxlength="80" class="narrow-field"/>
                 </td><td></td>
             </tr>
             <tr><td><label for="locale-tag"><?php
                 e(tl('managelocales_element_localetaglabel'))?></label></td>
                 <td><input type="text" id="locale-tag"
-                name="localetag"  maxlength="80"
-                value="<?php e($data['CURRENT_LOCALE']['localetag']); ?>"
-                class="narrow-field"/></td>
+                name="localetag"  maxlength="80" class="narrow-field"/></td>
             </tr>
             <tr><td><?php e(tl('managelocales_element_writingmodelabel'))?></td>
-            <td><?php $this->view->helper("options")->render(
-                        "writing-mode", "writingmode",
-                        $data['WRITING_MODES'],
-                        $data['CURRENT_LOCALE']['writingmode']); ?>
+            <td><label for="locale-lr-tb">lr-tb</label><input type="radio"
+                id="locale-lr-tb" name="writingmode"
+                value="lr-tb" checked="checked" />
+            <label for="locale-rl-tb">rl-tb</label><input type="radio"
+                id="locale-rl-tb" name="writingmode" value="rl-tb" />
+            <label for="locale-tb-rl">tb-rl</label><input type="radio"
+                id="locale-tb-rl" name="writingmode" value="tb-rl" />
+            <label for="locale-tb-lr">tb-lr</label><input type="radio"
+                id="locale-tb-lr" name="writingmode" value="tb-lr" />
             </td>
             </tr>
             <tr><td></td><td class="center"><button class="button-box"
@@ -178,34 +95,50 @@ class ManagelocalesElement extends Element
             </tr>
         </table>
         </form>
-        <?php
-    }
 
-    /**
-     *  Draws the search for locales forms
-     *
-     *  @param array $data consists of values of locale fields set
-     *      so far as well as values of the drops downs on the form
+        <h2><?php e(tl('managelocales_element_delete_locale'))?></h2>
+        <form id="deleteLocaleForm" method="post" action='#'>
+        <input type="hidden" name="c" value="admin" />
+        <input type="hidden" name="<?php e(CSRF_TOKEN); ?>" value="<?php
+            e($data[CSRF_TOKEN]); ?>" />
+        <input type="hidden" name="a" value="manageLocales" />
+        <input type="hidden" name="arg" value="deletelocale" />
 
-     */
-    function renderSearchForm($data)
-    {
-        $controller = "admin";
-        $activity = "manageLocales";
-        $view = $this->view;
-        $title = tl('managelocales_element_search_locales');
-        $return_form_name = tl('managelocales_element_addlocale_form');
-        $fields = array(
-            tl('managelocales_element_localename') => "name",
-            tl('managelocales_element_localetag') => "tag",
-            tl('managelocales_element_writingmode') => "mode"
-        );
-        $dropdowns = array(
-            "mode" => array("lr-tb" => "lr-rb", "rl-tb" => "rl-tb",
-                "tb-rl" => "tb-rl", "tb-lr" => "tb-lr")
-        );
-        $view->helper("searchform")->render($data, $controller, $activity,
-                $view, $title, $return_form_name, $fields, $dropdowns);
+        <table class="name-table" >
+        <tr><td><label for="delete-localename"><?php
+            e(tl('managelocales_element_delete_localelabel'))?></label></td>
+            <td><?php $this->view->helper("options")->render(
+                "delete-localename",
+                "selectlocale", $data['LANGUAGES'], "-1"); ?></td>
+            <td><button class="button-box" type="submit"><?php
+                e(tl('managelocales_element_submit')); ?></button></td>
+        </tr>
+        </table>
+        </form>
+
+        <h2><?php e(tl('managelocales_element_locale_list'))?></h2>
+        <table class="locale-table">
+            <tr>
+            <th><?php e(tl('managelocales_element_localename')); ?></th>
+            <th><?php e(tl('managelocales_element_localetag'));?></th>
+            <th><?php e(tl('managelocales_element_writingmode'));
+                ?></th>
+            <th><?php  e(tl('managelocales_element_percenttranslated'));?></th>
+            </tr>
+        <?php
+        foreach($data['LOCALES'] as $locale) {
+            e("<tr><td><a href='?c=admin&amp;a=manageLocales".
+                "&amp;arg=editlocale&amp;selectlocale=".$locale['LOCALE_TAG'].
+                "&amp;".CSRF_TOKEN."=".$data[CSRF_TOKEN]."'>".
+                $locale['LOCALE_NAME']."</a></td><td>".
+                $locale['LOCALE_TAG']."</td>");
+            e("<td>".$locale['WRITING_MODE']."</td><td class='align-right' >".
+                $locale['PERCENT_WITH_STRINGS']."</td></tr>");
+        }
+        ?>
+        </table>
+        </div>
+    <?php
     }
 }
 ?>
diff --git a/views/recover_view.php b/views/recover_view.php
index 2caf48c..8aa5015 100644
--- a/views/recover_view.php
+++ b/views/recover_view.php
@@ -151,12 +151,12 @@ class RecoverView extends View
                             tl('register_view_account_recovery')
                                 =>$data['RECOVERY']);
                     } else {
-                       if(isset($_SESSION["random_string"])) {
+                       if(isset($_SESSION["random_string"]) || isset($_SESSION["graphical_captcha_string"])) {
                             $question_sets = array();
                         } else {
                             $question_sets = array(
                                 tl('register_view_human_check') =>
-                                $data['CAPTCHAS'] );
+                                $data['CAPTCHA'] );
                         }
                     }
                     if(isset($_SESSION["random_string"])) {
@@ -186,6 +186,13 @@ class RecoverView extends View
                             }
                         }
                     }
+                    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>
                         <td></td>
diff --git a/views/register_view.php b/views/register_view.php
index f17b288..e3282dd 100755
--- a/views/register_view.php
+++ b/views/register_view.php
@@ -57,6 +57,17 @@ class RegisterView extends View
      */
     function renderView($data)
     {
+        // echo('<pre>');
+        // print_r($_REQUEST."<br>");
+        // echo('</pre>');
+        // echo("<br>SESSION <br>");
+        // echo('<pre>');
+        // print_r($_SESSION);
+        // echo('</pre>');
+        // echo("<br> DATA <br>");
+        // echo('<pre>');
+        // print_r($data);
+        // echo('</pre>');
         $logo = "resources/yioop.png";
         if(MOBILE) {
             $logo = "resources/m-yioop.png";
@@ -183,16 +194,15 @@ 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')=>
                                 $data['RECOVERY']);
-                        }
-                        else {
+                        } else {
                             $question_sets = array(
                                 tl('register_view_human_check')=>
-                                $data['CAPTCHAS'],
+                                $data['CAPTCHA'],
                                 tl('register_view_account_recovery')
                                 =>$data['RECOVERY']);
                         }
@@ -222,6 +232,13 @@ 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..6230b4d 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,9 +109,9 @@ class SuggestView extends View
                         </tr>
                         <tr>
                         <?php
-                        if(!isset($_SESSION["random_string"])) {
+                        if(!isset($_SESSION["random_string"]) && !isset($_SESSION["graphical_captcha_string"])) {
                         $question_sets = array(tl('register_view_human_check')
-                            => $data['CAPTCHAS']);
+                            => $data['CAPTCHA']);
                         $i = 0;
                         foreach($question_sets as $name => $set) {
                             $first = true;
@@ -130,6 +130,7 @@ class SuggestView extends View
                                 $this->helper("options")->render(
                                     "question-$i", "question_$i",
                                     $question, $data["question_$i"]);
+                                
                                 $first = false;
                                 e(in_array("question_$i", $missing)
                                     ?'<span class="red">*</span>':'');
@@ -138,6 +139,13 @@ class SuggestView extends View
                             }
                           }
                         }
+                        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>
                             <td></td>
@@ -176,4 +184,4 @@ class SuggestView extends View
         <?php
         }
     }
-?>
\ No newline at end of file
+?>
