コード例 #1
0
 /**
  * Implementation of hex2bin (which is missing For PHP version < 5.4.0)
  *
  * @codeCoverageIgnore
  *
  * @param string $sData
  *
  * @return string
  */
 function hex2bin($sData)
 {
     static $mOld;
     if ($mOld === null) {
         $mOld = version_compare(PHP_VERSION, '5.2', '<');
     }
     $blIsObject = false;
     if (is_scalar($sData) || ($blIsObject = is_object($sData)) && method_exists($sData, '__toString')) {
         if ($blIsObject && $mOld) {
             ob_start();
             echo $sData;
             $sData = ob_get_clean();
         } else {
             $sData = (string) $sData;
         }
     } else {
         trigger_error(__FUNCTION__ . '() expects parameter 1 to be string, ' . gettype($sData) . ' given', E_USER_WARNING);
         return null;
         //null in this case
     }
     $iLength = strlen($sData);
     if ($iLength % 2) {
         trigger_error(__FUNCTION__ . '(): Hexadecimal input string must have an even length', E_USER_WARNING);
         return false;
     }
     if (strspn($sData, '0123456789abcdefABCDEF') != $iLength) {
         trigger_error(__FUNCTION__ . '(): Input string must be hexadecimal string', E_USER_WARNING);
         return false;
     }
     return pack('H*', $sData);
 }
コード例 #2
0
ファイル: MyNumber.php プロジェクト: serima/mynumber
 /**
  * Check the number of digits.
  * Pass the number as string, if starting letter is beginning zero.
  *
  * @param integer|string $number
  * @param integer $digit
  * @return bool
  */
 public static function checkLength($number, $digit)
 {
     if (strlen($number) !== $digit || strspn($number, '1234567890') !== $digit) {
         return false;
     }
     return true;
 }
コード例 #3
0
ファイル: modifier.domain.php プロジェクト: drehere/shenmegui
/**
 *
 *
 * @file modifier.domain.php
 * @package plugins
 * @author liyudong@baidu.com
 * @date 2011-11-03 10:47
 */
function smarty_modifier_domain($string, $encodeURI = false)
{
    $logArr['smarty_modifier'] = "modifier_domain";
    $status = 0;
    $logArr['url'] = $string;
    $domain = $string;
    if (strncasecmp($domain, "http://", 7) == 0) {
        $domain = substr($domain, 7);
    } elseif (strncasecmp($domain, "url:", 4) == 0) {
        $pos = strspn($domain, " ", 4);
        $domain = substr($domain, 4 + $pos);
        if (strncasecmp($domain, "http://", 7) == 0) {
            $domain = substr($domain, 7);
        }
    }
    if (strlen($domain) == 0) {
        $domain = $string;
    }
    if ($encodeURI) {
        $result = hilight_encodeURI($domain);
        $logArr['result'] = $result;
        if (false === $result) {
            $status = -1;
            CLog::warning("fail to call hilight_domain", $status, $logArr, 1);
            return $domain;
        }
    } else {
        $result = $domain;
    }
    return $result;
}
コード例 #4
0
 /**
  * Creates a new pattern layout
  *
  * @param   string format
  */
 public function __construct($format)
 {
     for ($i = 0, $s = strlen($format); $i < $s; $i++) {
         if ('%' === $format[$i]) {
             if (++$i >= $s) {
                 throw new \lang\IllegalArgumentException('Not enough input at position ' . ($i - 1));
             }
             switch ($format[$i]) {
                 case '%':
                     // Literal percent
                     $this->format[] = '%';
                     break;
                 case 'n':
                     $this->format[] = "\n";
                     break;
                 default:
                     // Any other character - verify it's supported
                     if (!strspn($format[$i], 'mclLtpx')) {
                         throw new \lang\IllegalArgumentException('Unknown format token "' . $format[$i] . '"');
                     }
                     $this->format[] = '%' . $format[$i];
             }
         } else {
             $this->format[] = $format[$i];
         }
     }
 }
コード例 #5
0
ファイル: database_pgsql.php プロジェクト: aottibia/www
 public function tableName($name)
 {
     if (strspn($name, "1234567890qwertyuiopasdfghjklzxcvbnm_") != strlen($name)) {
         new Error_Critic('', 'Invalid table name format.');
     }
     return '"' . $name . '"';
 }
コード例 #6
0
ファイル: Crossword.php プロジェクト: manaphp/manaphp
 /**
  * @param string|array $words
  * @param string       $word
  *
  * @return string|false
  */
 public function guess($words, $word)
 {
     if (is_string($words)) {
         $words = strpos($words, ',') !== false ? explode(',', $words) : [$words];
     }
     $word = strtolower($word);
     /** @noinspection ForeachSourceInspection */
     foreach ($words as $v) {
         if (strtolower($v) === $word) {
             return $v;
         }
     }
     /** @noinspection ForeachSourceInspection */
     foreach ($words as $k => $v) {
         if (strspn($word, strtolower($v)) !== strlen($word)) {
             unset($words[$k]);
         }
     }
     if (count($words) === 0) {
         return false;
     } elseif (count($words) === 1) {
         return array_values($words)[0];
     } else {
         return false;
     }
 }
コード例 #7
0
ファイル: node.type.php プロジェクト: umonkey/molinos-cms
 public function save()
 {
     $isnew = null === $this->id;
     if (empty($this->title)) {
         $this->title = $this->name;
     }
     if (empty($this->name)) {
         throw new ValidationException('name', t('Внутреннее имя типа ' . 'не может быть пустым.'));
     } elseif (strspn(strtolower($this->name), 'abcdefghijklmnopqrstuvwxyz0123456789_') != strlen($this->name)) {
         throw new ValidationException('name', t('Внутреннее имя типа может ' . 'содержать только латинские буквы, арабские цифры и прочерк.'));
     }
     parent::checkUnique('name', t('Тип документа со внутренним именем %name уже есть.', array('%name' => $this->name)));
     // Подгружаем поля, ранее описанные отдельными объектами (9.03 => 9.05).
     $this->backportLinkedFields();
     // Добавляем привычные поля, если ничего нет.
     if ($isnew and empty($this->fields)) {
         $this->fields = array('name' => array('type' => 'TextLineControl', 'label' => t('Название'), 'required' => true, 'weight' => 10), 'uid' => array('type' => 'UserControl', 'label' => t('Автор'), 'required' => true, 'weight' => 20), 'created' => array('type' => class_exists('DateTimeControl') ? 'DateTimeControl' : 'TextLineControl', 'label' => t('Дата создания'), 'weight' => 100));
     }
     // Всегда сохраняем без очистки.
     parent::save();
     $this->publish();
     // Обновляем тип документов, если он изменился.
     if (null !== $this->oldname and $this->name != $this->oldname) {
         $this->getDB()->exec("UPDATE `node` SET `class` = ? WHERE `class` = ?", array($this->name, $this->oldname));
     }
     // Обновляем кэш.
     $this->flush();
     return $this;
 }
コード例 #8
0
ファイル: handler.php プロジェクト: krayon/flyspray
 function header($match, $state, $pos)
 {
     global $conf;
     // get level and title
     $title = trim($match);
     $level = 7 - strspn($title, '=');
     if ($level < 1) {
         $level = 1;
     }
     $title = trim($title, '=');
     $title = trim($title);
     if ($this->status['section']) {
         $this->_addCall('section_close', array(), $pos);
     }
     if ($level <= $conf['maxseclevel']) {
         $this->_addCall('section_edit', array($this->status['section_edit_start'], $pos - 1, $this->status['section_edit_level'], $this->status['section_edit_title']), $pos);
         $this->status['section_edit_start'] = $pos;
         $this->status['section_edit_level'] = $level;
         $this->status['section_edit_title'] = $title;
     }
     $this->_addCall('header', array($title, $level, $pos), $pos);
     $this->_addCall('section_open', array($level), $pos);
     $this->status['section'] = TRUE;
     return TRUE;
 }
コード例 #9
0
ファイル: div.php プロジェクト: rusidea/analitika
    /**
     * Handle the match
     */
    function handle($match, $state, $pos, Doku_Handler $handler){
        global $conf;
        switch ($state) {
            case DOKU_LEXER_ENTER:
            case DOKU_LEXER_SPECIAL:
                $data = strtolower(trim(substr($match,strpos($match,' '),-1)," \t\n/"));
                return array($state, $data);

            case DOKU_LEXER_UNMATCHED:
                $handler->_addCall('cdata', array($match), $pos);
                break;

            case DOKU_LEXER_MATCHED:
                // we have a == header ==, use the core header() renderer
                // (copied from core header() in inc/parser/handler.php)
                $title = trim($match);
                $level = 7 - strspn($title,'=');
                if($level < 1) $level = 1;
                $title = trim($title,'=');
                $title = trim($title);

                $handler->_addCall('header',array($title,$level,$pos), $pos);
                // close the section edit the header could open
                if ($title && $level <= $conf['maxseclevel']) {
                    $handler->addPluginCall('wrap_closesection', array(), DOKU_LEXER_SPECIAL, $pos, '');
                }
                break;

            case DOKU_LEXER_EXIT:
                return array($state, '');
        }
        return false;
    }
コード例 #10
0
 /**
  * Normalize address
  *
  * @param   string addr
  * @return  string
  */
 public static function normalize($addr)
 {
     $out = '';
     $hexquads = explode(':', $addr);
     // Shortest address is ::1, this results in 3 parts...
     if (sizeof($hexquads) < 3) {
         throw new \lang\FormatException('Address contains less than 1 hexquad part: [' . $addr . ']');
     }
     if ('' == $hexquads[0]) {
         array_shift($hexquads);
     }
     foreach ($hexquads as $hq) {
         if ('' == $hq) {
             $out .= str_repeat('0000', 8 - (sizeof($hexquads) - 1));
             continue;
         }
         // Catch cases like ::ffaadd00::
         if (strlen($hq) > 4) {
             throw new \lang\FormatException('Detected hexquad w/ more than 4 digits in [' . $addr . ']');
         }
         // Not hex
         if (strspn($hq, '0123456789abcdefABCDEF') < strlen($hq)) {
             throw new \lang\FormatException('Illegal digits in [' . $addr . ']');
         }
         $out .= str_repeat('0', 4 - strlen($hq)) . $hq;
     }
     return $out;
 }
コード例 #11
0
ファイル: TagsSource.class.php プロジェクト: xp-forge/mirrors
 /** @return var */
 protected function next()
 {
     while ($this->tokens->hasMoreTokens()) {
         $token = $this->tokens->nextToken();
         if (strspn($token, ' ')) {
             continue;
         } else {
             if ('@' === $token || '$' === $token) {
                 $token .= $this->tokens->nextToken();
             } else {
                 if (0 === substr_compare($token, '...', -3)) {
                     $token = substr($token, 0, -3);
                     $this->tokens->pushBack('*');
                 }
             }
         }
         if (false !== strpos(self::DELIMITERS, $token)) {
             return $token;
         } else {
             if (isset(self::$keywords[$token])) {
                 return [self::$keywords[$token], $token];
             } else {
                 return [self::T_WORD, $token];
             }
         }
     }
     return null;
 }
コード例 #12
0
ファイル: header.php プロジェクト: araname/plugin-creole
 function handle($match, $state, $pos, Doku_Handler $handler)
 {
     global $conf;
     // get level and title
     $title = trim($match);
     if ($this->getConf('precedence') == 'dokuwiki' && $title[strlen($title) - 1] == '=') {
         // DokuWiki
         $level = 7 - strspn($title, '=');
     } else {
         // Creole
         $level = strspn($title, '=');
     }
     if ($level < 1) {
         $level = 1;
     } elseif ($level > 5) {
         $level = 5;
     }
     $title = trim($title, '=');
     $title = trim($title);
     if ($handler->status['section']) {
         $handler->_addCall('section_close', array(), $pos);
     }
     $handler->_addCall('header', array($title, $level, $pos), $pos);
     $handler->_addCall('section_open', array($level), $pos);
     $handler->status['section'] = true;
     return true;
 }
コード例 #13
0
 function handle($match, $state, $pos, &$handler)
 {
     global $conf;
     $title = trim($match);
     $level = strspn($title, '#');
     $title = trim($title, '#');
     $title = trim($title);
     if ($level < 1) {
         $level = 1;
     } elseif ($level > 6) {
         $level = 6;
     }
     if ($handler->status['section']) {
         $handler->_addCall('section_close', array(), $pos);
     }
     if ($level <= $conf['maxseclevel']) {
         $handler->status['section_edit_start'] = $pos;
         $handler->status['section_edit_level'] = $level;
         $handler->status['section_edit_title'] = $title;
     }
     $handler->_addCall('header', array($title, $level, $pos), $pos);
     $handler->_addCall('section_open', array($level), $pos);
     $handler->status['section'] = true;
     return true;
 }
コード例 #14
0
 public static function whileValid($valueToSanitize, $useMethod, $extraChars = "")
 {
     // Prepare Values
     $sanitized = self::$useMethod($valueToSanitize, $extraChars);
     $pos = strspn($valueToSanitize ^ $sanitized, "");
     return substr($valueToSanitize, 0, $pos);
 }
コード例 #15
0
 /**
  * @param $file
  *
  * @return bool
  */
 private function isAbsolutePath($file)
 {
     if (strspn($file, '/\\', 0, 1) || strlen($file) > 3 && ctype_alpha($file[0]) && substr($file, 1, 1) === ':' && strspn($file, '/\\', 2, 1) || null !== parse_url($file, PHP_URL_SCHEME)) {
         return true;
     }
     return false;
 }
コード例 #16
0
ファイル: list.class.php プロジェクト: kurari/Nyaa-System
 function __construct($parser, $line)
 {
     $this->level = strspn($line, ' ');
     parent::__construct('ul', 'li', $this->level);
     $line = substr($line, $this->level + 1);
     $this->last = $this->last->insert($parser->lineFactory($line));
 }
コード例 #17
0
ファイル: Code.php プロジェクト: progmedia/markdownable
 /**
  * {@inheritdoc}
  */
 public function parse($node)
 {
     $content = html_entity_decode($node->ownerDocument->saveHtml($node));
     $content = str_replace(['<code>', '</code>'], null, $content);
     $lines = preg_split('/\\r\\n|\\r|\\n/', $content);
     $total = count($lines);
     if ($total > 1) {
         $first = trim($lines[0]);
         $last = trim($lines[$total - 1]);
         $first = trim($first, "&#xD;");
         $last = trim($last, "&#xD;");
         if (empty($first)) {
             array_shift($lines);
         }
         if (empty($last)) {
             array_pop($lines);
         }
         $markdown = '~~~' . PHP_EOL;
         $i = 0;
         foreach ($lines as $line) {
             if ($i === 0) {
                 $spaces = strspn($line, ' ');
             }
             $markdown .= substr($line, $spaces) . PHP_EOL;
             $i++;
         }
         $markdown .= '~~~';
         return PHP_EOL . PHP_EOL . $markdown . PHP_EOL . PHP_EOL;
     }
     return '`' . $lines[0] . '`';
 }
コード例 #18
0
 /**
  * Constructor. Accepts one of the following:
  *
  * <ul>
  *   <li>The values TRUE or FALSE</li>
  *   <li>An integer - any non-zero value will be regarded TRUE</li>
  *   <li>The strings "true" and "false", case-insensitive</li>
  *   <li>Numeric strings - any non-zero value will be regarded TRUE</li>
  * </ul>
  *
  * @param   var value
  * @throws  lang.IllegalArgumentException if value is not acceptable
  */
 public function __construct($value)
 {
     if (TRUE === $value || FALSE === $value) {
         $this->value = $value;
     } else {
         if (is_int($value)) {
             $this->value = 0 !== $value;
         } else {
             if ('0' === $value) {
                 $this->value = FALSE;
             } else {
                 if (is_string($value) && ($l = strlen($value)) && strspn($value, '1234567890') === $l) {
                     $this->value = TRUE;
                 } else {
                     if (0 === strncasecmp($value, 'true', 4)) {
                         $this->value = TRUE;
                     } else {
                         if (0 === strncasecmp($value, 'false', 5)) {
                             $this->value = FALSE;
                         } else {
                             throw new IllegalArgumentException('Not a valid boolean: ' . xp::stringOf($value));
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #19
0
ファイル: Socket.php プロジェクト: mickdane/zidisha
 /**
  * Connect to the specified port. If called when the socket is
  * already connected, it disconnects and connects again.
  *
  * @param $addr string IP address or host name
  * @param $port int TCP port number
  * @param $persistent bool (optional) whether the connection is
  *        persistent (kept open between requests by the web server)
  * @param $timeout int (optional) how long to wait for data
  * @access public
  * @return mixed true on success or error object
  */
 function connect($addr, $port, $persistent = null, $timeout = null)
 {
     if (is_resource($this->fp)) {
         @fclose($this->fp);
         $this->fp = null;
     }
     if (strspn($addr, '.0123456789') == strlen($addr)) {
         $this->addr = $addr;
     } else {
         $this->addr = gethostbyname($addr);
     }
     $this->port = $port % 65536;
     if ($persistent !== null) {
         $this->persistent = $persistent;
     }
     if ($timeout !== null) {
         $this->timeout = $timeout;
     }
     $openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen';
     $errno = 0;
     $errstr = '';
     if ($this->timeout) {
         $fp = $openfunc($this->addr, $this->port, $errno, $errstr, $this->timeout);
     } else {
         $fp = $openfunc($this->addr, $this->port, $errno, $errstr);
     }
     if (!$fp) {
         return $this->raiseError($errstr, $errno);
     }
     $this->fp = $fp;
     return $this->setBlocking($this->blocking);
 }
コード例 #20
0
ファイル: div.php プロジェクト: JakubKrizka/homepage-02
 /**
  * Handle the match
  */
 function handle($match, $state, $pos, Doku_Handler $handler)
 {
     global $conf;
     switch ($state) {
         case DOKU_LEXER_ENTER:
             $data = strtolower(trim(substr($match, strpos($match, ' '), -1)));
             return array($state, $data);
         case DOKU_LEXER_UNMATCHED:
             // check if $match is a == header ==
             $headerMatch = preg_grep('/([ \\t]*={2,}[^\\n]+={2,}[ \\t]*(?=))/msSi', array($match));
             if (empty($headerMatch)) {
                 $handler->_addCall('cdata', array($match), $pos);
             } else {
                 // if it's a == header ==, use the core header() renderer
                 // (copied from core header() in inc/parser/handler.php)
                 $title = trim($match);
                 $level = 7 - strspn($title, '=');
                 if ($level < 1) {
                     $level = 1;
                 }
                 $title = trim($title, '=');
                 $title = trim($title);
                 $handler->_addCall('header', array($title, $level, $pos), $pos);
                 // close the section edit the header could open
                 if ($title && $level <= $conf['maxseclevel']) {
                     $handler->addPluginCall('wrap_closesection', array(), DOKU_LEXER_SPECIAL, $pos, '');
                 }
             }
             return false;
         case DOKU_LEXER_EXIT:
             return array($state, '');
     }
     return false;
 }
コード例 #21
0
 /**
  * Internal callback function for {@link getFileSubDir}.
  * @param array $matches set of regular expression matches.
  * @throws Exception on failure.
  * @return string value of the placeholder.
  */
 protected function getFileSubDirPlaceholderValue($matches)
 {
     $placeholderName = $matches[1];
     $placeholderPartSymbolPosition = strspn($placeholderName, '^') - 1;
     if ($placeholderPartSymbolPosition >= 0) {
         $placeholderName = $matches[2];
     }
     $fileName = $this->_internalCache['getFileSubDirFileName'];
     switch ($placeholderName) {
         case 'name':
             $placeholderValue = $fileName;
             break;
         case 'ext':
         case 'extension':
             $placeholderValue = pathinfo($fileName, PATHINFO_EXTENSION);
             break;
         default:
             throw new Exception("Unable to resolve file sub dir: unknown placeholder '{$placeholderName}'!");
     }
     $defaultPlaceholderValue = '0';
     if ($placeholderPartSymbolPosition >= 0) {
         if ($placeholderPartSymbolPosition < strlen($placeholderValue)) {
             $placeholderValue = substr($placeholderValue, $placeholderPartSymbolPosition, 1);
         } else {
             $placeholderValue = $defaultPlaceholderValue;
         }
     }
     if (strlen($placeholderValue) <= 0 || in_array($placeholderValue, ['.'])) {
         $placeholderValue = $defaultPlaceholderValue;
     }
     return $placeholderValue;
 }
コード例 #22
0
 /**
 	Return the default value of the column.
 
 	@return	string	The default value of the column.
 	@throw	IllegalStateException	The column does not have a default value.
 */
 public function defaultValue()
 {
     $this->hasDefault() or burn('IllegalStateException', _WT('The column does not have a default value.'));
     // Strip wrapping parenthesis.
     $i = strspn($this->aData['default'], '(');
     return substr($this->aData['default'], $i, -$i);
 }
コード例 #23
0
 /**
  * ValueOf factory
  *
  * @param   string $value
  * @return  self
  * @throws  lang.IllegalArgumentException
  */
 public static function valueOf($value)
 {
     if (is_int($value) || is_string($value) && strspn($value, '0123456789') === strlen($value)) {
         return new self($value);
     }
     throw new IllegalArgumentException('Not a long: ' . $value);
 }
コード例 #24
0
ファイル: div.php プロジェクト: nitcalicut/Nakshatra-Wiki
 /**
  * Handle the match
  */
 function handle($match, $state, $pos, &$handler)
 {
     switch ($state) {
         case DOKU_LEXER_ENTER:
             $data = strtolower(trim(substr($match, strpos($match, ' '), -1)));
             return array($state, $data);
         case DOKU_LEXER_UNMATCHED:
             // check if $match is a == header ==
             $headerMatch = preg_grep('/([ \\t]*={2,}[^\\n]+={2,}[ \\t]*(?=))/msSi', array($match));
             if (empty($headerMatch)) {
                 $handler->_addCall('cdata', array($match), $pos);
             } else {
                 // if it's a == header ==, use the core header() renderer
                 // (copied from core header() in inc/parser/handler.php)
                 $title = trim($match);
                 $level = 7 - strspn($title, '=');
                 if ($level < 1) {
                     $level = 1;
                 }
                 $title = trim($title, '=');
                 $title = trim($title);
                 $handler->_addCall('header', array($title, $level, $pos), $pos);
             }
             return false;
         case DOKU_LEXER_EXIT:
             return array($state, '');
     }
     return false;
 }
コード例 #25
0
 /**
  * Check if the clients IP is in a given netmask or array of netmasks
  *
  * @param string  String with the netmask 
  *
  * @return boolean  True if client IP is in netmask
  **/
 public static function applyNetmask($netmask)
 {
     // We do not support IPv6 yet
     if (self::$IsIPv6) {
         return false;
     }
     // Determine mask length
     $netmask_parts = explode('/', $netmask);
     if (count($netmask_parts) > 2) {
         return false;
     }
     if (count($netmask_parts) < 1) {
         return false;
     }
     // Only one part, so we are dealing with a host here
     if (count($netmask_parts) == 1) {
         $netmask_parts[1] = 32;
     }
     // Now we detect the length of the netmask
     if (strpos($netmask_parts[1], '.') === true) {
         // Dot notation
         $netmask_parts[1] = strspn(sprintf("%032b", ip2long($netmask_parts[1])), "1");
     }
     if ($netmask_parts[1] > 0 && $netmask_parts[1] < 33) {
         // Thanks to jwadhams1 @ php.net ip2long documentation
         $client_ip_bin = sprintf("%032b", ip2long(self::$ClientIP));
         $net_ip_bin = sprintf("%032b", ip2long($netmask_parts[0]));
         return substr_compare($client_ip_bin, $net_ip_bin, 0, $netmask_parts[1]) === 0;
     } else {
         return false;
     }
 }
コード例 #26
0
ファイル: PathUtils.php プロジェクト: webuni/assetic-bundle
 public static function isAbsolutePath($file)
 {
     if (strspn($file, '/\\', 0, 1) || strlen($file) > 3 && ctype_alpha($file[0]) && substr($file, 1, 1) === ':' && strspn($file, '/\\', 2, 1) || false !== strpos($file, '://')) {
         return true;
     }
     return false;
 }
コード例 #27
0
 function name_valid($name)
 {
     // validacja wyst±pienia spacji w nazwie u¿ytkownika
     if (strpos($name, ' ') > 0) {
         $this->monit .= "Nazwa u¿ytkownika nie mo¿e zawieraæ ¿adnych spacji.<br />";
         return FALSE;
     }
     // sprawdzanie semantycznej poprawno¶ci nazwy u¿ytkownika
     if (strspn($name, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") == 0) {
         $this->monit .= "Nazwa u¿ytkownika musi zawieraæ conajmniej jeden znak alfabetu.<br />";
         return FALSE;
     }
     // sprawdzanie d³ugosci(conajmniej 4 znaki w nazwie u¿ytkownika)
     if (strlen($name) < 4) {
         $this->monit .= "Nazwa u¿ytkownika musi zawieraæ conajmniej 4 znaki.<br />";
         return FALSE;
     }
     // sprawdzanie d³ugosci(maksymalnie 15 znaków w nazwie u¿ytkownika)
     if (strlen($name) > 15) {
         $this->monit .= "Nazwa u¿ytkownika mo¿e mieæ maksymalnie 15 znaków.<br />";
         return FALSE;
     }
     // sprawdzanie dozwolonych nazw
     $unav_logins = array('admin', 'root', 'bin', 'daemon', 'adm', 'lp', 'sync', 'shutdown', 'halt', 'mail', 'news', 'uucp', 'operator', 'games', 'mysql', 'httpd', 'nobody', 'dummy', 'www', 'cvs', 'shell', 'ftp', 'irc', 'debian', 'ns', 'download');
     if (in_array($name, $unav_logins)) {
         $this->monit .= "Podana nazwa u¿ytkownika jest zarezerwowana.<br />";
         return FALSE;
     }
     // sprawdzanie nazwy zarezerwowanej dla cvs
     if (substr($name, 0, 8) == 'anoncvs_') {
         $this->monit .= "Podana nazwa jest zarezerwowana dla CVS.<br />";
         return FALSE;
     }
 }
コード例 #28
0
ファイル: Validator.php プロジェクト: cs278/libphp-vin
 public function validate(\libphpvin\Vin $vin)
 {
     $result = new \libphpvin\Vin\Validator\Result($vin);
     $value = $vin->getValue();
     $length = strlen($value);
     if ($length < 17) {
         $result->addError(self::ERROR_TOO_SHORT);
     } else {
         if ($length > 17) {
             $result->addError(self::ERROR_TOO_LONG);
         }
     }
     if (strspn($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890') !== $length) {
         $result->addError(self::ERROR_NON_ALPHANUMERIC);
     }
     if (stripos($value, 'I') !== false) {
         $result->addError(self::ERROR_PROHIBITED_I);
     }
     if (stripos($value, 'O') !== false) {
         $result->addError(self::ERROR_PROHIBITED_O);
     }
     if (stripos($value, 'Q') !== false) {
         $result->addError(self::ERROR_PROHIBITED_Q);
     }
     return $result;
 }
コード例 #29
0
ファイル: RunLength.php プロジェクト: rapsli/404crawler
 /**
  * Encode data
  *
  * @param string $data
  * @param array $params
  * @return string
  * @throws Zend_Pdf_Exception
  */
 public static function encode($data, $params = null)
 {
     $output = '';
     $chainStartOffset = 0;
     $offset = 0;
     while ($offset < strlen($data)) {
         // Do not encode 2 char chains since they produce 2 char run sequence,
         // but it takes more time to decode such output (because of processing additional run)
         if (($repeatedCharChainLength = strspn($data, $data[$offset], $offset + 1, 127) + 1) > 2) {
             if ($chainStartOffset != $offset) {
                 // Drop down previouse (non-repeatable chars) run
                 $output .= chr($offset - $chainStartOffset - 1) . substr($data, $chainStartOffset, $offset - $chainStartOffset);
             }
             $output .= chr(257 - $repeatedCharChainLength) . $data[$offset];
             $offset += $repeatedCharChainLength;
             $chainStartOffset = $offset;
         } else {
             $offset++;
             if ($offset - $chainStartOffset == 128) {
                 // Maximum run length is reached
                 // Drop down non-repeatable chars run
                 $output .= "" . substr($data, $chainStartOffset, 128);
                 $chainStartOffset = $offset;
             }
         }
     }
     if ($chainStartOffset != $offset) {
         // Drop down non-repeatable chars run
         $output .= chr($offset - $chainStartOffset - 1) . substr($data, $chainStartOffset, $offset - $chainStartOffset);
     }
     $output .= "€";
     return $output;
 }
コード例 #30
0
function url_parse($url, &$container)
{
    $temp = @parse_url($url);
    if (!empty($temp)) {
        $temp['port_ext'] = '';
        $temp['base'] = $temp['scheme'] . '://' . $temp['host'];
        if (isset($temp['port'])) {
            $temp['base'] .= $temp['port_ext'] = ':' . $temp['port'];
        } else {
            $temp['port'] = $temp['scheme'] === 'https' ? 443 : 80;
        }
        $temp['path'] = isset($temp['path']) ? $temp['path'] : '/';
        $path = array();
        $temp['path'] = explode('/', $temp['path']);
        foreach ($temp['path'] as $dir) {
            if ($dir === '..') {
                array_pop($path);
            } else {
                if ($dir !== '.') {
                    for ($dir = rawurldecode($dir), $new_dir = '', $i = 0, $count_i = strlen($dir); $i < $count_i; $new_dir .= strspn($dir[$i], 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$-_.+!*\'(),?:@&;=') ? $dir[$i] : rawurlencode($dir[$i]), ++$i) {
                    }
                    $path[] = $new_dir;
                }
            }
        }
        $temp['path'] = str_replace('/%7E', '/~', '/' . ltrim(implode('/', $path), '/'));
        $temp['file'] = substr($temp['path'], strrpos($temp['path'], '/') + 1);
        $temp['dir'] = substr($temp['path'], 0, strrpos($temp['path'], '/'));
        $temp['base'] .= $temp['dir'];
        $temp['prev_dir'] = substr_count($temp['path'], '/') > 1 ? substr($temp['base'], 0, strrpos($temp['base'], '/') + 1) : $temp['base'] . '/';
        $container = $temp;
        return true;
    }
    return false;
}