We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3258
    • 12 Posts
    Here’s my pickword function, it does not require any changes to config.inc.php

    	function pick_word() {
    		global $dbase,$table_prefix,$database_server,$database_user,$database_password;
    		$database = str_replace('`', '', $dbase);
    		
    		// set default words
    		$words="MODx,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
    		
    		// connect to the database
    		if(@$dbConn = mysql_connect($database_server, $database_user, $database_password)) {
    			mysql_select_db($database);
    			//$sql = "SELECT * FROM $dbase.".$table_prefix."system_settings WHERE setting_name='captcha_words'";
    			$sql = "SELECT * FROM ".$table_prefix."system_settings WHERE setting_name='captcha_words'";
    			$rs = mysql_query($sql);
    			$limit = mysql_num_rows($rs);
    			if($limit==1) {
    				$row = mysql_fetch_assoc($rs);
    				$words = $row['setting_value'];
    			}
    		}
    
    		$arr_words = explode(",", $words);
    
    		/* pick one randomly for text verification */
    		return sprintf("%s",$arr_words[array_rand($arr_words)].rand(10,90));
    	}	
      • 19220
      • 26 Posts
      None of these worked for me. I tried them a few times each, just for good measure. Leaving config.inc.php alone and replacing pick_word with
      function pick_word() {
          $words = "My,Own,List,Of,Words";
          $arr_words = explode(",", $words);
          return sprintf("%s",$arr_words[array_rand($arr_words)].rand(10,90));
      }
      

      worked for me. Unfortunately, I don’t know any php or SQL, so I wasn’t able to delve more deeply into the problem. I’d be glad to help someone else track down exactly what was wrong, though.

      -michael
        • 22985
        • 2 Posts
        if you want a totally random word, replace the function pick_word() with this..

                function pick_word() {
                        $valid_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
                        $length = 5;
                        srand((double)microtime()*1000000);
                        $i=0;
                        $word = '';
                        while($i<=$length){
                                $num = rand() % strlen($valid_chars); 
                                $tmp = substr($valid_chars,$num,1);
                                $word .= $tmp;
                                $i++;
                        }
                        return sprintf("%s",$word);                                         
                }
        


        the user can edit the selection of characters, and also the length of the word that they want.
          • 33372
          • 1,611 Posts
          Nice alternative method. I definitely get sick of coming up with CAPTCHA words for my clients, and I don’t like to leave the default ones because they tend to confuse corporate and non-profit users. This is a good quick way to not worry about that anymore when I don’t feel like being verbally creative.

          Maybe you should release this as a mod? If so, I suggest also commenting out the CAPTCHA word field in the Admin settings form. And you may want to make your default character selection a bit more limited, specifically I find that zeros and o’s are a problem, and to a lesser extent ones, lower-case l’s, and upper-case I’s.

          Or you could even take this one step further and use CAPTCHA words IF they are entered in admin and use random letters and numbers if not (and that way this could become a part of the core code)...
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 8807
            • 9 Posts
            Quote from: mglerner at Jul 04, 2006, 02:19 PM

            None of these worked for me. I tried them a few times each, just for good measure. Leaving config.inc.php alone and replacing pick_word with
            function pick_word() {
                $words = "My,Own,List,Of,Words";
                $arr_words = explode(",", $words);
                return sprintf("%s",$arr_words[array_rand($arr_words)].rand(10,90));
            }
            


            But where do you replace pick_word? What file?