示例#1
0
 /**
  * Subtract character offset
  *
  * @param Char $char
  */
 public function subtract(Char $char)
 {
     $this->ord -= $char->index();
     $lower = $this->isLower() ? self::LOWERCASE_A : self::UPPERCASE_A;
     if ($this->ord < $lower) {
         $this->ord += self::CHAR_COUNT;
     }
     $this->char = chr($this->ord);
 }
示例#2
0
文件: Ip.php 项目: buldezir/dja_orm
 public function validate($value)
 {
     parent::validate($value);
     if (!filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)) {
         throw new \InvalidArgumentException("Field '{$this->name}' must be in valid IPv4 or IPv6 format");
     }
 }
示例#3
0
 public function validate($value)
 {
     parent::validate($value);
     if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
         //if (!preg_match($this->re, $value)) {
         throw new \InvalidArgumentException("Field '{$this->name}' must be in valid email format");
     }
 }
示例#4
0
 /**
  * Show the confirmation message and return result.
  *
  * @return bool
  */
 public function show()
 {
     $char = parent::show();
     if ($this->ignoreCase) {
         $response = strtolower($char) === strtolower($this->yesChar);
     } else {
         $response = $char === $this->yesChar;
     }
     return $this->lastResponse = $response;
 }
示例#5
0
文件: Char.php 项目: wnowicki/cli
 /**
  * @author WN
  * @param Char $char
  * @return $this
  */
 public function inherit(Char $char)
 {
     if ($char->getContent() !== null) {
         $this->setContent($char->getContent());
     }
     if ($char->getColor() !== null) {
         $this->setColor($char->getColor());
     }
     if ($char->getBgcolor() !== null) {
         $this->setBgcolor($char->getBgcolor());
     }
     if ($char->getDefault() !== null) {
         $this->setDefault($char->getDefault());
     }
     return $this;
 }
 function actionIndex()
 {
     $char = new Char();
     $params = Database::GetOne("config", array("mod" => "mod_paidservice"));
     $main = new Templater();
     $main->import("boxes/ps_page.tpl");
     $main->setvar("%URL%", "http://" . $GLOBALS['url']);
     $main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
     $main->setvar("%YEAR%", date("Y"));
     $main->setvar("%CSS%", "<style>" . templater("css/game.css", array("%ROOT%" => "/storage/tpl")) . "</style>");
     $main->setvar("%GAME_TITLE%", $GLOBALS['name']);
     $main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
     $result = '';
     if (isset($_GET['buy'])) {
         if (!isset($params[$_GET['buy']]['time'])) {
             $main->setvar("%CONTENT%", "<h2>Услуга не найдена</h2>");
             $main->renderEcho();
             return 1;
         }
         if ($char->{$params}[$_GET['buy']]['currency'] < $params[$_GET['buy']]['cost']) {
             $main->setvar("%CONTENT%", "<h2>Недостаточно денег</h2>");
             $main->renderEcho();
             return 1;
         }
         $char->giveMoney(-$params[$_GET['buy']]['cost'], $params[$_GET['buy']]['currency']);
         eval($params[$_GET['buy']]['eval_bought']);
         createTimer($_GET['buy'], $params[$_GET['buy']]['time'], $params[$_GET['buy']]['eval_expired']);
     }
     foreach ($params as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         $result .= templater("boxes/ps_list.tpl", array("%ID%" => $key, "%NAME%" => $value['name'], "%COST%" => $value['cost'], "%TIME%" => $value['time'], "%CURRENCY%" => Database::GetOne("config", array("mod" => "currency"))[$value['currency']]['name'], "%TIME%" => $value['time']));
     }
     $main->setvar("%CONTENT%", $result);
     $main->renderEcho();
 }
示例#7
0
 /**
  * Checks a value is binary
  * 
  * @param string $value     value to check in base64 form
  * @param string &$outValue Processed value 
  * 
  * @return boolean
  */
 public static function validateWithoutPrefix($value, &$outValue)
 {
     $length = strlen($value);
     if ($length == 0 || $length % 2 != 0) {
         return false;
     }
     $outValue = array();
     $outValIndex = 0;
     $valueIndex = 0;
     while ($valueIndex < $length) {
         $ch0 = $value[$valueIndex];
         $ch1 = $value[$valueIndex + 1];
         if (!Char::isHexDigit($ch0) || !Char::isHexDigit($ch1)) {
             $outValue = null;
             return false;
         }
         $ch0 = self::hexCharToNibble($ch0);
         $ch1 = self::hexCharToNibble($ch1);
         if ($ch0 == -1 || $ch1 == -1) {
             $outValue = null;
             return false;
         }
         $outValue[$outValIndex] = $ch0 << 4 + $ch1;
         $valueIndex += 2;
         $outValIndex++;
     }
     return true;
 }
示例#8
0
	public function parse($source){
		$root = new Node();
		$char = new Char();
		$tokenParsers = $this->initParsers();

		$token = $this->resetToken();
		$len = strlen($source);
		
		$parent = array(&$root);
		$current = new Node();
		
		$inBracket = false;

		for($i =0; $i<$len; ++$i){
			$c = $source[$i];
			// handle text first
			if(in_array($c, array('"', "'", '['))){				
				$ret = $this->findCDataEnd($source, $this->match[$c], $i+1);
				$i = $ret[1];
				if(!$inBracket && $c == '['){
					$this->proceedToken($token, $current, $tokenParsers);
					$this->resetToken($token);
					$current->setAttribute('[]', $ret[0]);
				}else{
					$token[$token[0]] .= $ret[0];					
				}				
			}
			
			// ',' ')' and '=' for attributes setting in '()'
			elseif($c == ',' || $c ==')'){
				if($token[$token[0]] != ''){				
					if($token[0] == 1){
						$current->setAtAttribute($token[1]);
						$this->resetToken($token);
					}else if($token[0] == 2){
						$current->setAttribute($token[1], $token[2]);
						$this->resetToken($token);
					}else{
						// should be error...
					}
				}
				if($c == ')'){
					$inBracket = false;
				}
			}else if($c == '='){
				$token[0] = 2;
			}
			
			// handle '()' and '{}' bracket
			else if(in_array($c, array('(', '{', '}'))){
				$this->proceedToken($token, $current, $tokenParsers);
				$this->resetToken($token);

				if($c == '{'){
					array_push($parent, $current);
					$current = new Node();
					
				}elseif($c == '}'){
					$p = array_pop($parent);
					if(!$current->isEmpty()){
						$p->addChild($current);
					}
					if(!$p->isEmpty()){
						$pp = end($parent);
						$pp->addChild($p);
					}
					$current = new Node();
				}elseif($c == '('){
					$inBracket = true;
				}
			}
			
			// handle tokens
			elseif($char->isSpecialChar($c)){
				$this->proceedToken($token, $current, $tokenParsers);
				$this->resetToken($token);
				$token[$token[0]] .= $c;
			}elseif($char->isTokenChar($c)){
				$token[$token[0]] .= $c;
			}
			else{				
				$this->proceedToken($token, $current, $tokenParsers);
				$this->resetToken($token);
				if(!$current->isEmpty() && !$inBracket){
					$p = end($parent);
					$p->addChild($current);
					
					$current = new Node();
				}				
			}
		}
		
			$this->proceedToken($token, $current, $tokenParsers);
		if(!$current->isEmpty() && !$inBracket){
			$p = end($parent);
			$p->addChild($current);
		}
		return $root;
	}
示例#9
0
文件: Slug.php 项目: buldezir/dja_orm
 public function toPhp($value)
 {
     $value = parent::toPhp($value);
     return slugify($value);
     // move "slugify" to this class?
 }
示例#10
0
 /**
  * Show the confirmation message and return result.
  *
  * @return bool
  */
 public function show()
 {
     $response = parent::show() === $this->yesChar;
     return $this->lastResponse = $response;
 }
示例#11
0
 /**
  * Generate an anchor name for a given string.
  *
  * @param string  $text    A string
  * @param bool    $unique  Always generate a unique name
  *                         (consider all previously generated names)
  */
 public function getAnchorName($text, $unique = true)
 {
     $text = Char::cyr2lat($text);
     $text = strtolower($text);
     $text = strtr($text, array(' ' => '_', '/' => '-', '<br />' => '_'));
     $text = strip_tags($text);
     $text = preg_replace('/[^\\w_-]/', '', $text);
     $text = urlencode(iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $text));
     if ($text === '') {
         $text = '_' . $text;
     }
     if ($unique) {
         if (isset($this->_anchorNames[$text])) {
             $this->_anchorNames[$text]++;
             $text .= '.' . $this->_anchorNames[$text];
         } else {
             $this->_anchorNames[$text] = 1;
         }
     }
     return $text;
 }
示例#12
0
文件: Row.php 项目: wnowicki/cli
 /**
  * @author WN
  * @param int|null $length
  * @param int|null $color
  * @param int|null $option
  * @param int|null $bgcolor
  * @param string|null $default
  * @return Char[]
  */
 private function buildVector($length, $color, $option, $bgcolor, $default)
 {
     $output = [];
     for ($i = 0; $i < $length; $i++) {
         $output[] = Char::make(null, $color, $option, $bgcolor, $default);
     }
     return $output;
 }
示例#13
0
 case 3:
     if (isset($_POST['name'])) {
         $in = array('modules' => array(), 'active' => '1', 'id' => uniqid()) + $_POST;
         Database::Insert("config", $in);
         foreach ($config as $as) {
             Database::Insert("config", $as);
         }
         Database::Insert("scripts", array('name' => 'main', 'code' => 'ZnVuY3Rpb24gc2NyaXB0RW5naW5lSW5pdCgpIHsNCiAgcmV0dXJuIDE7DQp9DQoNCmZ1bmN0aW9uIG9uUGxheWVyTG9naW4oJGxvZ2luLCAkcGFzc3dvcmQsICRzdWNjZXNzKSB7DQogIHJldHVybiAxOw0KfQ0KDQpmdW5jdGlvbiBvblBsYXllclJlZ2lzdGVyKCRsb2dpbiwgJHBhc3N3b3JkLCAkZW1haWwpIHsNCiAgcmV0dXJuIDE7DQp9DQoNCmZ1bmN0aW9uIEV2ZW50VGltZXJFeHBpcmVkKCRpZCkgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gVXNlSXRlbSgkaWQsICRpdGVtKSB7DQogIHJldHVybiAxOw0KfQ0KDQpmdW5jdGlvbiBvblJvdXRlZCgkZHJpdmVyLCAkYWN0aW9uLCAkbGluaykgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gb25DbGllbnRDYWxsKCRpbnB1dCwgJHBhcmFtcykgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gb25BcGlNZXRob2RDYWxsZWQoJG1ldGhvZCwgJHJlcXVlc3QpIHsNCiAgcmV0dXJuIGZhbHNlOw0KfQ0KDQpmdW5jdGlvbiBvbkRpYWxvZ1Jlc3BvbnNlKCRkaWFsb2dpZCwgJGFuc3dlcikgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gb25QbGF5ZXJDb250ZXh0TWVudSgkbGlzdGl0ZW0sICR0YXJnZXQpIHsNCiAgcmV0dXJuIDE7DQp9'));
         echo "<div class='alert alert-success'>База данных заполнена. <a href='?step=4'>Перейти к последнему шагу</a></div>";
     }
     raptor_print('PGZvcm0gYWN0aW9uPSIiIG1ldGhvZD0iUE9TVCI+DQoJCTxkaXYgY2xhc3M9ImZvcm0tZ3JvdXAiPg0KCQkJPGxhYmVsPtCd0LDQt9Cy0LDQvdC40LUg0LjQs9GA0Ys8L2xhYmVsPg0KCQkJPGlucHV0IGNsYXNzPSJmb3JtLWNvbnRyb2wiIG5hbWU9Im5hbWUiIHZhbHVlPSIiPg0KCQk8L2Rpdj4NCgkJPGRpdiBjbGFzcz0iZm9ybS1ncm91cCI+DQoJCQk8bGFiZWw+0JLQtdGA0YHQuNGPINC40LPRgNGLPC9sYWJlbD4NCgkJCTxpbnB1dCBjbGFzcz0iZm9ybS1jb250cm9sIiBuYW1lPSJ2ZXJzaW9uIiB2YWx1ZT0iIj4NCgkJPC9kaXY+DQoJCTxkaXYgY2xhc3M9ImZvcm0tZ3JvdXAiPg0KCQkJPGxhYmVsPlB1YmxpYyBLZXkgKNC/0YPQsdC70LjRh9C90YvQuSDQutC70Y7RhyDQtNC70Y8gQVBJKTwvbGFiZWw+DQoJCQk8aW5wdXQgY2xhc3M9ImZvcm0tY29udHJvbCIgbmFtZT0icHVibGljX2tleSIgdmFsdWU9IiI+DQoJCTwvZGl2Pg0KCQk8ZGl2IGNsYXNzPSJmb3JtLWdyb3VwIj4NCgkJCTxsYWJlbD5Qcml2YXRlIEtleSAo0L/RgNC40LLQsNGC0L3Ri9C5INC60LvRjtGHINC00LvRjyBBUEk7INC90LUg0YHQvtC+0LHRidCw0LnRgtC1INC10LPQviDRgdGC0L7RgNC+0L3QvdC40Lwg0LvQuNGG0LDQvCk8L2xhYmVsPg0KCQkJPGlucHV0IGNsYXNzPSJmb3JtLWNvbnRyb2wiIG5hbWU9InByaXZhdGVfa2V5IiB2YWx1ZT0iIj4NCgkJPC9kaXY+DQoJCTxidXR0b24gdHlwZT0ic3VibWl0IiBjbGFzcz0iYnRuIGJ0bi1kZWZhdWx0Ij7QodC+0YXRgNCw0L3QuNGC0Yw8L2J1dHRvbj4NCgk8L2Zvcm0+');
     break;
 case 4:
     if (isset($_POST['name'])) {
         $id = Player::register($_POST['name'], $_POST['password'], $_POST['email']);
         Char::create(array('name' => $_POST['name'], 'player' => $id, 'about' => $_POST['about'], 'admin' => '1'));
         if (file_put_contents(CACHE_ROOT . SEPARATOR . "installed.cache", "What are you looking for, admin?")) {
             echo '<h3>Игра полностью установлена. <a href="/">Вход</a></h3>';
         } else {
             echo '<h3>Ошибка при создании файла завершения установки. <a href="?step=4&file=1">Повторить попытку</a></h3>';
         }
     }
     if (isset($_GET['file'])) {
         if (file_put_contents(CACHE_ROOT . SEPARATOR . "installed.cache", "What are you looking for, admin?")) {
             echo '<h3>Игра полностью установлена. <a href="/">Вход</a></h3>';
         } else {
             echo '<h3>Ошибка при создании файла завершения установки. <a href="?step=4&file=1">Повторить попытку</a></h3>';
         }
     }
     raptor_print('PGgzPtCS0LLQtdC00LjRgtC1INC00LDQvdC90YvQtSDQtNC70Y8g0LLQsNGI0LXQs9C+INC40LPRgNC+0LrQsCDQuCDQv9C10YDRgdC+0L3QsNC20LA8L2gzPjxmb3JtIGFjdGlvbj0iIiBtZXRob2Q9IlBPU1QiPg0KCQk8ZGl2IGNsYXNzPSJmb3JtLWdyb3VwIj4NCgkJCTxsYWJlbD7Qm9C+0LPQuNC9INC4INC40LzRjzwvbGFiZWw+DQoJCQk8aW5wdXQgY2xhc3M9ImZvcm0tY29udHJvbCIgbmFtZT0ibmFtZSIgdmFsdWU9IiI+DQoJCTwvZGl2Pg0KCQk8ZGl2IGNsYXNzPSJmb3JtLWdyb3VwIj4NCgkJCTxsYWJlbD5FLU1BSUw8L2xhYmVsPg0KCQkJPGlucHV0IGNsYXNzPSJmb3JtLWNvbnRyb2wiIG5hbWU9ImVtYWlsIiB2YWx1ZT0iIj4NCgkJPC9kaXY+DQoJCTxkaXYgY2xhc3M9ImZvcm0tZ3JvdXAiPg0KCQkJPGxhYmVsPtCf0LDRgNC+0LvRjDwvbGFiZWw+DQoJCQk8aW5wdXQgY2xhc3M9ImZvcm0tY29udHJvbCIgbmFtZT0icGFzc3dvcmQiIHZhbHVlPSIiPg0KCQk8L2Rpdj4NCgkJPGRpdiBjbGFzcz0iZm9ybS1ncm91cCI+DQoJCQk8bGFiZWw+0JPRgNCw0YTQsCAi0J7QsdC+INC80L3QtSI8L2xhYmVsPg0KCQkJPGlucHV0IGNsYXNzPSJmb3JtLWNvbnRyb2wiIG5hbWU9ImFib3V0IiB2YWx1ZT0iIj4NCgkJPC9kaXY+DQoJCTxidXR0b24gdHlwZT0ic3VibWl0IiBjbGFzcz0iYnRuIGJ0bi1kZWZhdWx0Ij7QodC+0LfQtNCw0YLRjCDQsNC60LrQsNGD0L3RgjwvYnV0dG9uPg0KCQk8L2Zvcm0+');
     break;
示例#14
0
if (isset($v['step']) && !empty($v['step']) && $v['step'] == 'validate') {
    require_once './controller/user.php';
    require_once './controller/char.php';
    $user = new User($sql);
    $salt = generateSalt();
    $pass = sha1($_POST['pass'] . $salt);
    $user->fillUserInfo($_POST['nickname'], $pass, $salt, $_POST['lastname'], $_POST['firstname'], $_POST['birthday'], $_POST['gender'], $_POST['mail'], $_POST['phone'], $_POST['city']);
    $sql->beginTransaction();
    $json = json_decode(urldecode($_POST['char_json']));
    $class = $json->class;
    $spec1 = $json->specs[0]->name;
    $talents1 = null;
    $spec2 = $json->specs[1]->name;
    $talents2 = null;
    if ($user_id = $user->register()) {
        $char = new Char($sql);
        $char->fillCharInfo(null, $user_id, $_POST['charname'], $_POST['realm'], $class, $spec1, $talents1, $spec2, $talents2);
        if ($char_id = $char->register()) {
            $sql->commit();
            echo 'Votre compte a bien été créé. Veuillez confirmer votre compte à l\'aide du lien envoyé à l\'adresse e-mail que vous avez renseigné.';
        }
    } else {
        echo 'Utilisateur déjà enregistré';
    }
} else {
    $template = '';
    require_once './controller/registering.php';
    $classes = new Registering();
    $tooltip = 'Le captcha sert à déterminer que vous êtes bien un humain.' . ' Renseignez le texte que vous voyez dans l\'image située au dessus du champ de saisie.';
    $sql = $classes->getConnection();
    $query = $sql->prepare("SELECT * FROM captcha;");
示例#15
0
 public function actionRemove()
 {
     Char::delete($_GET['name'], true);
     header('Location: /');
 }