Exemple #1
0
 function addWord($word)
 {
     $old_word = $word;
     $word = libString::convertUmlaute($word);
     $word = libString::capitalize($word);
     if (preg_match("/[^a-zA-Z]/", $word)) {
         $this->sendOutput("Your word must contain only letters.");
         return;
     }
     $sql = "SELECT id FROM hangman WHERE word='" . addslashes($word) . "'";
     $res = $this->MySQL->sendQuery($sql);
     if ($res['count'] != 0) {
         $this->sendOutput("This word is already in the database.");
         return;
     }
     $google_results = libInternet::googleResults($old_word);
     if ($google_results < $this->CONFIG['google_min']) {
         //$output = sprintf($this->CONFIG['googlemin_text'],
         //					$this->CONFIG['google_min']
         //				 );
         $this->sendOutput($this->CONFIG['googlemin_text']);
         return;
     }
     $blacklist = array("add", "del", "stats", "start", "stop");
     if (array_search(strtolower($word), $blacklist) !== false) {
         $this->sendOutput("Stuuuuupiiid!");
         return;
     }
     $sql = "INSERT INTO\n\t\t\t\t\thangman\n\t\t\t\t\t(word, author, created)\n\t\t\t\tVALUES (\n\t\t\t\t\t'" . addslashes($word) . "',\n\t\t\t\t\t'" . addslashes($this->info['nick']) . "',\n\t\t\t\t\tNOW()\n\t\t\t\t)";
     $this->MySQL->sendQuery($sql);
     $this->sendOutput("Word '" . $word . "' has been added to the database.");
     return;
 }
Exemple #2
0
 function trySolution($nick, $solution)
 {
     $solution = libString::convertUmlaute($solution);
     if (strtolower($solution) != strtolower($this->solution)) {
         if ($this->subLife() === "lose") {
             return;
         }
         $this->IRC->sendOutput("Sorry " . $nick . ", that was not the correct solution.");
         $this->sendGrid();
         $this->sendLivesLeft();
         return false;
     }
     $this->winGame($nick);
     return true;
 }