示例#1
0
 public function postEnter($userarr = array())
 {
     $userarr[] = $_POST;
     $regExp = new RegExp();
     $login = $regExp->match(trim($_POST['login']));
     $password = $regExp->match(trim($_POST['password']));
     $postarr = array('login' => $login, 'password' => $password);
     return $postarr;
 }
示例#2
0
 public function validate($value)
 {
     if (!is_string($value) || strlen($value) > 255) {
         return false;
     }
     return parent::validate($value);
 }
示例#3
0
文件: Digits.php 项目: onlime/DMS
 /**
  * {@inheritDoc}
  */
 public function applyFilter($value)
 {
     //Check for Whitespace support
     $whitespaceChar = $this->allowWhitespace ? " " : "";
     $this->unicodePattern = '/[^\\p{N}' . $whitespaceChar . ']/';
     $this->pattern = '/[^0-9' . $whitespaceChar . ']/';
     return parent::applyFilter($value);
 }
示例#4
0
 /**
  * @param string $regExp
  *
  * @return RegExp
  */
 public function parse($regExp)
 {
     if (!$regExp) {
         throw new \InvalidArgumentException('RegExp is empty');
     }
     $startDelimiter = $regExp[0];
     $delimiterPairs = RegExp::getDelimiterPairs();
     $endDelimiter = isset($delimiterPairs[$startDelimiter]) ? $delimiterPairs[$startDelimiter] : $startDelimiter;
     $endDelimiterPosition = strrpos($regExp, $endDelimiter);
     if (!$endDelimiterPosition) {
         throw new \InvalidArgumentException(sprintf('Closing delimiter %s not found', $startDelimiter));
     }
     return new RegExp($startDelimiter, $endDelimiter, substr($regExp, 1, $endDelimiterPosition - 1), substr($regExp, $endDelimiterPosition + 1));
 }
示例#5
0
文件: Subdomain.php 项目: visor/nano
 /**
  * @return boolean
  * @param string $url
  */
 public function match($url)
 {
     $domain = $this->getSubDomain();
     $matches = array();
     if (1 !== preg_match($this->domainPattern, $domain, $matches)) {
         return false;
     }
     if (null === $this->location) {
         $this->matches = $matches;
         return true;
     }
     $result = parent::match($url);
     if ($result) {
         $this->matches = array_merge($matches, $this->matches);
     }
     return $result;
 }
 public function __construct($message = "")
 {
     parent::__construct("/^[a-zA-Z0-9_-]+\$/", $message);
 }
示例#7
0
 public function post($comment)
 {
     $regExp = new RegExp();
     $this->comment = $regExp->match($comment);
     $this->save();
 }
示例#8
0
 /**
  * @param $currencyString
  * @return float
  */
 public static function currencyStringToFloat($currencyString)
 {
     //currency is always in this format € 550
     return floatval(str_replace(',', '', RegExp::getFirstMatch('/([+-]?[0-9]{1,3}(?:,?[0-9]{3})*(?:\\.[0-9]{2})?)/', $currencyString)));
 }
示例#9
0
文件: globals.php 项目: mk-pmb/js2php
$undefined = null;
$Infinity = INF;
$NaN = NAN;
$Object = Object::getGlobalConstructor();
$Function = Func::getGlobalConstructor();
$Array = Arr::getGlobalConstructor();
$Boolean = Bln::getGlobalConstructor();
$Number = Number::getGlobalConstructor();
$String = Str::getGlobalConstructor();
$Date = Date::getGlobalConstructor();
$Error = Error::getGlobalConstructor();
$RangeError = RangeError::getGlobalConstructor();
$ReferenceError = ReferenceError::getGlobalConstructor();
$SyntaxError = SyntaxError::getGlobalConstructor();
$TypeError = TypeError::getGlobalConstructor();
$RegExp = RegExp::getGlobalConstructor();
$Buffer = Buffer::getGlobalConstructor();
call_user_func(function () use(&$escape, &$unescape, &$encodeURI, &$decodeURI, &$encodeURIComponent, &$decodeURIComponent) {
    $ord = function ($ch) {
        $i = ord($ch[0]);
        if ($i <= 0x7f) {
            return $i;
        } else {
            if ($i < 0xc2) {
                return $i;
                //invalid byte sequence
            } else {
                if ($i <= 0xdf) {
                    return ($i & 0x1f) << 6 | ord($ch[1]) & 0x3f;
                } else {
                    if ($i <= 0xef) {
 /**
  *
  * @param string|RegExp $regex
  * @return JSArray
  */
 public function match($regex)
 {
     if (!$regex instanceof RegExp) {
         $regex = new RegExp((string) $regex);
     }
     $ret = $regex->exec($this);
     if ($ret && !$regex->global) {
         $ret->input = $this;
     }
     return $ret;
 }
示例#11
0
     $comments = $commentMapper->select($commentObj);
     ini_set('display_errors', 'Off');
     $checkrights = new Checkrights();
     $checkrights->Render($files, $app, $comments);
     if (!empty($_POST['comment'])) {
         $logged = new Logged();
         $cookie = $app->getCookie('username');
         $user_id = $logged->getLogged($db, $cookie);
         $postcomment = new postComment($file_id, $user_id, $db);
         $regExp = new RegExp();
         $comment = $regExp->match(trim($_POST['comment']));
         $postcomment->post($comment);
         $app->redirect("{$id}");
     }
     if (isset($_POST['public'])) {
         $regExp = new RegExp();
         $tags = $regExp->match(trim($_POST['tags']));
         $description = $regExp->match(trim($_POST['description']));
         $public = $regExp->match($_POST['public']);
         $terminate = $regExp->match($_POST['terminate']);
         $foo = new Foo();
         $foo->id = $file_id;
         $foo->tags = $tags;
         $foo->public = $public;
         $foo->description = $description;
         $foo->terminate = $terminate;
         $foomapper = new FooMapper($db);
         $foomapper->save($foo);
         $app->redirect("{$id}");
     }
 })->via('GET', 'POST')->name('FileEdit');
 public function __construct($sMessage = '')
 {
     $this->message = t('Error: %element% must be alphanumeric (contain only numbers, letters, underscores, and/or hyphens).');
     parent::__construct('/^[a-zA-Z0-9_-]+$/', $sMessage);
 }
示例#13
0
<?php

$app->post('/search', function () use($app) {
    if (isset($_POST)) {
        $regExp = new RegExp();
        $tag1 = $regExp->match($_POST['search']);
        $checksearch = new CheckSearch();
        $tag = $checksearch->getSearch($tag1);
        $db = $app->db;
        $foo = new Foo();
        $foo->tag = '%' . $tag . '%';
        $foomapper = new FooMapper($db);
        $files = $foomapper->search($foo);
        $filesize = new Filesize();
        $app->render('Search.php', ['files' => $files, 'filesize' => $filesize]);
    }
})->name('searchpost');
$app->get('/search/:tag', function ($tag) use($app) {
    $db = $app->db;
    $foo = new Foo();
    $foo->tag = '%' . $tag . '%';
    $foomapper = new FooMapper($db);
    $files = $foomapper->search($foo);
    $filesize = new Filesize();
    $app->render('Search.php', ['files' => $files, 'filesize' => $filesize]);
})->name('search');
示例#14
0
文件: RegExp.php 项目: mk-pmb/js2php
 /**
  * Creates the global constructor used in user-land
  * @return Func
  */
 static function getGlobalConstructor()
 {
     $RegExp = new Func(function () {
         $reg = new RegExp();
         $reg->init(func_get_args());
         return $reg;
     });
     $RegExp->set('prototype', RegExp::$protoObject);
     $RegExp->setMethods(RegExp::$classMethods, true, false, true);
     return $RegExp;
 }
示例#15
0
文件: tests.php 项目: mk-pmb/js2php
    Test::assert('date local string', $date->callMethod('toString') === 'Mon Aug 05 2013 18:11:08 GMT-0800 (PST)');
    //todo: PHP 5.4 will output 2013-08-06T01:11:08.411Z
    Test::assert('date json string', $date->callMethod('toJSON') === '2013-08-06T02:11:08.411Z');
    $date = new Date(1375751468412.0);
    Test::assert('init from value', $date->callMethod('toJSON') === '2013-08-06T01:11:08.412Z');
    $date = new Date('2013-08-06T01:11:08.412Z');
    Test::assert('init from string', $date->callMethod('toJSON') === '2013-08-06T01:11:08.412Z');
    //test Date.UTC
    $ms = $Date->callMethod('UTC', 2013, 7, 5, 18, 11, 8, 411);
    $date = $Date->construct($ms);
    Test::assert('date from UTC', $date->callMethod('toJSON') === '2013-08-05T18:11:08.411Z');
    Test::assert('date from UTC toString', $date->callMethod('toString') === 'Mon Aug 05 2013 10:11:08 GMT-0800 (PST)');
});
Test::suite('RegExp', function () use($RegExp, $Object, $Array) {
    $str = 'xabcdef';
    $reg = new RegExp('a(b|c)', 'i');
    Test::assert('reg source', $reg->get('source') === 'a(b|c)');
    Test::assert('reg toString', $reg->callMethod('toString') === '/a(b|c)/i');
    $match = $reg->callMethod('exec', $str);
    Test::assert('match result', $match->get(0) === 'ab');
    Test::assert('match length', $match->get('length') === 2.0);
    Test::assert('match index', $match->get('index') === 1.0);
    Test::assert('match input', $match->get('input') === $str);
    Test::assert('match lastIndex', $reg->get('lastIndex') === 3.0);
});
Test::suite('String object', function () use($String, $Object) {
    $str = $String->construct('hi');
    Test::assert('instanceof', $str instanceof Str);
    Test::assert('type is object', _typeof($str) === 'object');
    Test::assert('has value', $str->value === 'hi');
    Test::assert('has value', $str->callMethod('toString') === 'hi');
示例#16
0
 public function parseFile(array $files = array())
 {
     foreach ($files as $post => $value) {
         $regExp = new RegExp();
         $this->path = $regExp->match($value['path']);
         $this->cookie = $regExp->match($value['cookie']);
         $this->filesize = $regExp->match($value['filesize']);
         $info = new SplFileInfo($value['path']);
         $this->extension = $info->getExtension();
         $tagArr = $regExp->match($value['tags']);
         $tags = new Tags();
         $this->tags = $tags->parseTags($tagArr);
         //creating aray from the string of tags
         $this->description = $regExp->match($value['description']);
         $this->user_id = $regExp->match($value['user_id']);
         $this->token = $regExp->match($value['token']);
         $this->id = $regExp->match($value['id']);
         $this->time = $regExp->match($value['time']);
         $this->count = $regExp->match($value['count']);
         $exif = exif_read_data('uploads/' . $value['path'], 0, true);
         $this->exif = $exif;
         $this->public = $regExp->match($value['public']);
     }
 }
示例#17
0
 $filepost = new FilePost();
 $generateToken = new Token();
 $array = $filepost->postFile($generateToken, $_POST, $_FILES);
 //var_dump($filepost->postFile($generateToken, $_POST, $_FILES));
 //var_dump($array);
 $cookiecheck = new Cookie();
 //setting cookie
 $cookie = $cookiecheck->getCookie($app);
 $db = $app->db;
 $user = new User();
 $usermapper = new UserMapper($db);
 $userid = new UserId();
 $user_id = $userid->checkId($user, $usermapper, $cookie);
 //saving file in DB
 $foo = new Foo();
 $regExp = new RegExp();
 $token = $regExp->match($array['token']);
 $foo->public = $regExp->match($array['public']);
 $foo->terminate = $array['terminate'];
 $foo->user_id = $regExp->match($user_id);
 $foo->path = $regExp->match($array['filename']);
 // $foo->cookie = $cookie;
 $foo->token = $regExp->match($token);
 $foo->filesize = $regExp->match($array['filesize']);
 $mapper = new FooMapper($db);
 $mapper->save($foo);
 //setting unique token
 /*
                     $db = $app->db;
 $_FILES['img']['tmp_name'];
           $target_dir = "uploads/";
示例#18
0
文件: String.php 项目: mk-pmb/js2php
            return join('', $result);
        } else {
            $matchIndex = strpos($str, $search);
            if ($matchIndex === false) {
                return $str;
            }
            $before = substr($str, 0, $matchIndex);
            $after = substr($str, $matchIndex + strlen($search));
            //mb_strlen used to calculate multi-byte character index
            $args = array($search, mb_strlen($before), $str);
            return $before . to_string($replace->apply(null, $args)) . $after;
        }
    }
    $replace = to_string($replace);
    if ($isRegEx) {
        $replace = RegExp::toReplacementString($replace);
        return preg_replace($search, $replace, $str, $limit);
    } else {
        $parts = explode($search, $str);
        $first = array_shift($parts);
        return $first . $replace . implode($search, $parts);
    }
}, 'toLowerCase' => function () {
    $self = Func::getContext();
    return mb_strtolower($self->value);
}, 'toLocaleLowerCase' => function () {
    $self = Func::getContext();
    return mb_strtolower($self->value);
}, 'toUpperCase' => function () {
    $self = Func::getContext();
    return mb_strtoupper($self->value);
 /**
  * {@inheritdoc}
  *
  * @see \Mcustiel\SimpleRequest\Validator\RegExp::setSpecification()
  */
 public function setSpecification($specification = null)
 {
     parent::setSpecification(self::REGEXP);
 }
示例#20
0
 public function Load($files, $app)
 {
     foreach ($files as $file => $value) {
         $regExp = new RegExp();
         $log = "uploads/" . $regExp->match($value["path"]);
         $res = $app->response();
         $res['Content-Description'] = 'File Transfer';
         $res['Content-Type'] = 'application/octet-stream';
         $res['Content-Disposition'] = 'attachment; filename=' . basename($log);
         $res['Content-Transfer-Encoding'] = 'binary';
         $res['Expires'] = '0';
         $res['Cache-Control'] = 'must-revalidate';
         $res['Pragma'] = 'public';
         $res['Content-Length'] = filesize($log);
         readfile($log);
         ini_set('display_errors', 'Off');
     }
     $foo2 = new Foo();
     $foo2->token = $this->token;
     $foomapper2 = new FooMapper($this->db);
     $foomapper2->updatecount($foo2);
 }