コード例 #1
0
ファイル: DOGMOD_Hangman.php プロジェクト: sinfocol/gwf3
 public function on_ADDhang_Pc()
 {
     $argv = $this->argv();
     $argc = count($argv);
     if ($argc === 1) {
         $hang_word = strtolower($argv[0]);
         $iso = Dog::getChannel()->getLangISO();
     } elseif ($argc === 2) {
         $hang_word = strtolower($argv[0]);
         $iso = strtolower($argv[1]);
     } else {
         return $this->showHelp('+hang');
     }
     if (GWF_String::strlen($hang_word) < 6 || GWF_String::strlen($hang_word) > 30) {
         return $this->rply('err_wordlen', array(6, 30));
     }
     if (!preg_match('/^\\p{L}+$/Dui', $hang_word)) {
         return $this->rply('err_alpha');
     }
     if (false !== ($word = Hangman_Words::getByWord($hang_word))) {
         return $this->rply('err_dup');
     }
     if (false === ($word = Hangman_Words::insertWord($hang_word, $iso))) {
         return Dog::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $this->rply('msg_added', array($hang_word, $word->getID()));
 }
コード例 #2
0
ファイル: GWF_HelpdeskTitle.php プロジェクト: sinfocol/gwf3
 public static function validate_other(Module_Helpdesk $m, $arg)
 {
     $len = GWF_String::strlen($arg);
     if ($len < 2) {
         return $m->lang('err_no_other');
     }
     $maxlen = $m->cfgMaxTitleLen();
     if ($len > $maxlen) {
         return $m->lang('err_other_len', array($maxlen));
     }
     return false;
 }
コード例 #3
0
ファイル: SiteAdd.php プロジェクト: sinfocol/gwf3
 public function validate_site_classname(Module_WeChall $m, $arg)
 {
     if (false !== WC_Site::getByClassName($arg)) {
         return $m->lang('err_classname_dup');
     }
     $max = $m->cfgMaxSitenameLen();
     if (1 !== preg_match('/^[a-z][a-z0-9_]+$/iD', $arg)) {
         return $m->lang('err_site_classname', array(1, $max));
     }
     $len = GWF_String::strlen($arg);
     if ($len < 1 || $len > $max) {
         return $m->lang('err_site_classname', array(1, $max));
     }
     return false;
 }
コード例 #4
0
ファイル: HangmanGame.php プロジェクト: sinfocol/gwf3
 /**
  *
  * @param string $user the username
  * @param string|char $message the guess
  * @return the answer
  */
 public function onGuess($user, $message)
 {
     $message = trim($message);
     if ($this->finish) {
         if ($message === 'false') {
             $this->CONFIG['solution_allowed_everytime'] = false;
         }
         $iso = Common::substrFrom($message, ' ', Dog::getChannel()->getLangISO());
         $this->onStartGame($iso);
     } elseif ($message === '') {
         $this->sendOutput('The game has already started');
     } else {
         if (GWF_String::strlen($message) !== 1) {
             $this->trySolution($user, $message);
         } else {
             $this->tryChar($user, $message);
         }
         if (GWF_String::toLower($this->grid) === GWF_String::tolower($this->solution)) {
             $this->winGame($nick);
         }
     }
     return $this->clearOutput();
 }
コード例 #5
0
ファイル: Moderate.php プロジェクト: sinfocol/gwf3
 public function validate_message(Module_Guestbook $m, $arg)
 {
     $arg = $_POST['message'] = trim($arg);
     $len = GWF_String::strlen($arg);
     $max = $m->cfgMaxMessageLen();
     if ($len < 1 || $len > $max) {
         return $m->lang('err_gbm_message', 1, $max);
     }
     return false;
 }
コード例 #6
0
ファイル: GWF_Validator.php プロジェクト: sinfocol/gwf3
 public static function validateClassname($m, $key, $arg, $min = 0, $max = 63, $unset = true)
 {
     $_POST[$key] = $arg = trim($arg);
     $len = GWF_String::strlen($arg);
     if ($len < $min || $len > $max || 0 === preg_match('/^[a-zA-Z][A-Za-z_0-9]+$/D', $arg)) {
         if ($unset) {
             $_POST[$key] = '';
         }
         return $m->lang('err_' . $key, array($min, $max));
     }
     return false;
 }
コード例 #7
0
ファイル: Module_PM.php プロジェクト: sinfocol/gwf3
 public function validate_foldername($arg)
 {
     $_POST['foldername'] = $arg = trim($arg);
     if (false !== GWF_PMFolder::getByName($arg)) {
         return $this->lang('err_folder_exists');
     }
     $len = GWF_String::strlen($arg);
     $max = $this->cfgMaxFolderNameLen();
     if ($len < 1 || $len > $max) {
         return $this->lang('err_folder_len', $max);
     }
     return false;
 }
コード例 #8
0
ファイル: strlen8_Pb.php プロジェクト: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% <string here>. Print the length of an utf8 string. See %T%strlen.', 'out' => 'UTF8 Length: %s.'));
$plugin = Dog::getPlugin();
if ('' === ($message = $plugin->msg())) {
    return $plugin->showHelp();
}
$plugin->rply('out', array(GWF_String::strlen($message)));
コード例 #9
0
ファイル: AddPoll.php プロジェクト: sinfocol/gwf3
 public function validate_opt(Module_Votes $m, $arg)
 {
     if ($this->checked_opt) {
         return false;
     }
     $this->checked_opt = true;
     $opts = Common::getPostArray('opt', array());
     $post = array();
     $min = $this->module->cfgMinOptionLen();
     $max = $this->module->cfgMaxOptionLen();
     $err = '';
     foreach ($opts as $i => $op) {
         $op = trim($op);
         $i = (int) $i;
         //			# XSS/SQLI escape!
         //			if (!is_numeric($i)) { $i = GWF_HTML::display($i); }
         $len = GWF_String::strlen($op);
         if ($len < $min || $len > $max) {
             $err .= ', ' . $i;
         }
         $post[$i] = $op;
         //			$_POST['opt'][$i] = $op;
     }
     $_POST['opt'] = $post;
     $this->onAddOption(false);
     if ($err === '') {
         return false;
     }
     return $this->module->lang('err_options', array(substr($err, 2), $min, $max));
 }
コード例 #10
0
ファイル: SR_Bazar.php プロジェクト: sinfocol/gwf3
 private function onSetSlogan(SR_Player $player, $new_slogan)
 {
     $pname = $player->getName();
     if (false === ($shop = SR_BazarShop::getShop($pname))) {
         if (false === SR_BazarShop::createShop($pname)) {
             $player->message('Database error 3!');
             return false;
         }
         if (false === ($shop = SR_BazarShop::getShop($pname))) {
             $player->message('Database error 4!');
             return false;
         }
     }
     if (GWF_String::strlen($new_slogan) > SR_BazarShop::MAX_SLOGAN_LEN) {
         $player->message('1117', array(SR_BazarShop::MAX_SLOGAN_LEN));
         // 			$player->message(sprintf('Your new slogan exceeds the max length of %d characters.', SR_BazarShop::MAX_SLOGAN_LEN));
         return false;
     }
     if (false === $shop->saveVar('sr4bs_message', $new_slogan)) {
         $player->message('Database error!');
         return false;
     }
     $player->msg('5159', array($new_slogan));
     // 		$player->message(sprintf('Your slogan has been set to: %s.', $new_slogan));
     return true;
 }