public function submitInfo() { $this->load->model("settings_model"); // Gather the values $values = array('nickname' => htmlspecialchars($this->input->post("nickname")), 'location' => htmlspecialchars($this->input->post("location"))); // Change language if ($this->config->item('show_language_chooser')) { $values['language'] = $this->input->post("language"); if (!is_dir("application/language/" . $values['language'])) { die("3"); } else { $this->user->setLanguage($values['language']); $this->plugins->onSetLanguage($this->user->getId(), $values['language']); } } // Remove the nickname field if it wasn't changed if ($values['nickname'] == $this->user->getNickname()) { $values = array('location' => $this->input->post("location")); } elseif (strlen($values['nickname']) < 4 || strlen($values['nickname']) > 14 || !preg_match("/[A-Za-z0-9]*/", $values['nickname'])) { die(lang("nickname_error", "ucp")); } elseif ($this->internal_user_model->nicknameExists($values['nickname'])) { die("2"); } if (strlen($values['location']) > 32 && !ctype_alpha($values['location'])) { die(lang("location_error", "ucp")); } $this->settings_model->saveSettings($values); $this->plugins->onSaveSettings($this->user->getId(), $values); die("1"); }
private function getExpressionPartsPattern() { $signs = ' '; $patterns = ['\\$[a-zA-Z_]+[a-zA-Z_0-9]+' => 25, ':[a-zA-Z_\\-0-9]+' => 16, '"(?:\\\\.|[^"\\\\])*"' => 21, "'(?:\\\\.|[^'\\\\])*'" => 21, '(?<!\\w)\\d+(?:\\.\\d+)?' => 20]; $iterator = new \AppendIterator(); $iterator->append(new \CallbackFilterIterator(new \ArrayIterator(self::$operators), function ($operator) { return !ctype_alpha($operator); })); $iterator->append(new \ArrayIterator(self::$punctuation)); foreach ($iterator as $symbol) { $length = strlen($symbol); if ($length === 1) { $signs .= $symbol; } else { if (strpos($symbol, ' ') !== false) { $symbol = "(?<=^|\\W){$symbol}(?=[\\s()\\[\\]]|\$)"; } else { $symbol = preg_quote($symbol, '/'); } $patterns[$symbol] = $length; } } arsort($patterns); $patterns = implode('|', array_keys($patterns)); $signs = preg_quote($signs, '/'); return "/({$patterns}|[{$signs}])/i"; }
/** * * Validates that the value is letters only (upper or lower case). * * @param mixed $value The value to validate. * * @return bool True if valid, false if not. * */ public function validateAlpha($value) { if ($this->_filter->validateBlank($value)) { return !$this->_filter->getRequire(); } return ctype_alpha($value); }
/** * Tokenization stream API * Get next token * Returns null at the end of stream * * @return Zend_Search_Lucene_Analysis_Token|null */ public function nextToken() { if ($this->_input === null) { return null; } while ($this->_position < strlen($this->_input)) { // skip white space while ($this->_position < strlen($this->_input) && !ctype_alpha($this->_input[$this->_position])) { $this->_position++; } $termStartPosition = $this->_position; // read token while ($this->_position < strlen($this->_input) && ctype_alpha($this->_input[$this->_position])) { $this->_position++; } // Empty token, end of stream. if ($this->_position == $termStartPosition) { return null; } $token = new Zend_Search_Lucene_Analysis_Token(substr($this->_input, $termStartPosition, $this->_position - $termStartPosition), $termStartPosition, $this->_position); $token = $this->normalize($token); if ($token !== null) { return $token; } // Continue if token is skipped } return null; }
function StdDecodePeerId($id_data, $id_name) { $version_str = ''; for ($i = 0; $i <= strlen($id_data); $i++) { $c = $id_data[$i]; if ($id_name == 'BitTornado' || $id_name == 'ABC') { if ($c != '-' && ctype_digit($c)) { $version_str .= $c . '.'; } elseif ($c != '-' && ctype_alpha($c)) { $version_str .= ord($c) - 55 . '.'; } else { break; } } elseif ($id_name == 'BitComet' || $id_name == 'BitBuddy' || $id_name == 'Lphant' || $id_name == 'BitPump' || $id_name == 'BitTorrent Plus! v2') { if ($c != '-' && ctype_alnum($c)) { $version_str .= $c; if ($i == 0) { $version_str = (int) $version_str . '.'; } } else { $version_str .= '.'; break; } } else { if ($c != '-' && ctype_alnum($c)) { $version_str .= $c . '.'; } else { break; } } } $version_str = substr($version_str, 0, strlen($version_str) - 1); return $id_name . ' ' . $version_str; }
/** * {@inheritdoc} */ public function validate($value, Constraint $constraint) { if (null === $value || '' === $value) { return; } $canonicalize = str_replace(' ', '', $value); // the bic must be either 8 or 11 characters long if (!in_array(strlen($canonicalize), array(8, 11))) { $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->setCode(Bic::INVALID_LENGTH_ERROR)->addViolation(); } // must contain alphanumeric values only if (!ctype_alnum($canonicalize)) { $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->setCode(Bic::INVALID_CHARACTERS_ERROR)->addViolation(); } // first 4 letters must be alphabetic (bank code) if (!ctype_alpha(substr($canonicalize, 0, 4))) { $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->setCode(Bic::INVALID_BANK_CODE_ERROR)->addViolation(); } // next 2 letters must be alphabetic (country code) if (!ctype_alpha(substr($canonicalize, 4, 2))) { $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->setCode(Bic::INVALID_COUNTRY_CODE_ERROR)->addViolation(); } // should contain uppercase characters only if (strtoupper($canonicalize) !== $canonicalize) { $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->setCode(Bic::INVALID_CASE_ERROR)->addViolation(); } }
/** * @param string $path * * @return boolean */ private function isAbsolutePath($path) { if ($path[0] === '/' || $path[0] === '\\' || strlen($path) > 3 && ctype_alpha($path[0]) && $path[1] === ':' && ($path[2] === '\\' || $path[2] === '/') || null !== parse_url($path, PHP_URL_SCHEME)) { return true; } return false; }
public static function to($url = '', $scheme = false, $urlManager = null) { if (is_array($url)) { return static::toRoute($url, $scheme, $urlManager); } $url = Yii::getAlias($url); if ($url === '') { $url = Yii::$app->getRequest()->getUrl(); } if (!$scheme) { return $url; } if (strncmp($url, '//', 2) === 0) { // e.g. //hostname/path/to/resource return is_string($scheme) ? "{$scheme}:{$url}" : $url; } if (($pos = strpos($url, ':')) == false || !ctype_alpha(substr($url, 0, $pos))) { // turn relative URL into absolute $url = Yii::$app->getUrlManager()->getHostInfo() . '/' . ltrim($url, '/'); } if (is_string($scheme) && ($pos = strpos($url, ':')) !== false) { // replace the scheme with the specified one $url = $scheme . substr($url, $pos); } return $url; }
public function isValid() { if (ctype_alpha($this->value)) { return true; } return false; }
/** * Returns true if the file is an existing absolute path. * * @param string $file * @return boolean */ protected static function isAbsolutePath($file) { if ($file[0] == '/' || $file[0] == '\\' || strlen($file) > 3 && ctype_alpha($file[0]) && $file[1] == ':' && ($file[2] == '\\' || $file[2] == '/') || null !== parse_url($file, PHP_URL_SCHEME)) { return true; } return false; }
/** * @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; }
public function parse($stream) { $stream->forward(); $stream->skipSpaces(); if ($stream->getFirstCharacters(4) == 'true') { $value = true; $stream->forward(4); } elseif ($stream->getFirstCharacters(5) == 'false') { $value = false; $stream->forward(5); } else { $char = $stream->getFirstCharacter(); if (ctype_digit($char) || $char == '-') { $parser = new AnnotationNumericParser(); } elseif ($char == '"' || $char == '\'') { $parser = new AnnotationStringParser(); } elseif (ctype_alpha($char)) { $parser = new AnnotationHashPairsParser(); } else { $parser = new AnnotationDummyParser(); } $value = $parser->parse($stream); } $stream->skipSpaces(); if ($stream->shift() != ')') { trigger_error("Error parsing annotation '" . $stream->getString() . "' at position " . $stream->getPosition()); } return $value; }
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; }
public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') { $langfile = str_replace('.php', '', $langfile); if ($add_suffix === TRUE) { $langfile = str_replace('_lang', '', $langfile) . '_lang'; } $langfile .= '.php'; if (empty($idiom) or !ctype_alpha($idiom)) { $config =& get_config(); $idiom = empty($config['language']) ? 'english' : $config['language']; } if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) { return; } // Load the base file, so any others found can override it $basepath = BASEPATH . 'language/' . $idiom . '/' . $langfile; if (($found = file_exists($basepath)) === TRUE) { include $basepath; } // Do we have an alternative path to look in? if ($alt_path !== '') { $alt_path .= 'language/' . $idiom . '/' . $langfile; if (file_exists($alt_path)) { include $alt_path; $found = TRUE; } } else { // Added by Ivan Tcholakov, 18-APR-2013. if (is_object(get_instance())) { // foreach (get_instance()->load->get_package_paths(TRUE) as $package_path) { $package_path .= 'language/' . $idiom . '/' . $langfile; if ($basepath !== $package_path && file_exists($package_path)) { include $package_path; $found = TRUE; break; } } // } // } if ($found !== TRUE) { show_error('Unable to load the requested language file: language/' . $idiom . '/' . $langfile); } if (!isset($lang) or !is_array($lang)) { log_message('error', 'Language file contains no data: language/' . $idiom . '/' . $langfile); if ($return === TRUE) { return array(); } return; } if ($return === TRUE) { return $lang; } $this->is_loaded[$langfile] = $idiom; $this->language = array_merge($this->language, $lang); log_message('debug', 'Language file loaded: language/' . $idiom . '/' . $langfile); return TRUE; }
function testSaltedFieldnameFirstCharIsLetter() { $input = new T_Form_Upload('myalias', 'mylabel'); $input->setFieldnameSalt('mysalt', new T_Filter_RepeatableHash()); $field = $input->getFieldname(); $this->assertTrue(ctype_alpha($field[0])); }
function StdDecodePeerId($id_data, $id_name) { $version_str = ""; for ($i = 0; $i <= strlen($id_data); $i++) { $c = $id_data[$i]; if ($id_name == "BitTornado" || $id_name == "ABC") { if ($c != '-' && ctype_digit($c)) { $version_str .= "{$c}."; } elseif ($c != '-' && ctype_alpha($c)) { $version_str .= ord($c) - 55 . "."; } else { break; } } elseif ($id_name == "BitComet" || $id_name == "BitBuddy" || $id_name == "Lphant" || $id_name == "BitPump" || $id_name == "BitTorrent Plus! v2") { if ($c != '-' && ctype_alnum($c)) { $version_str .= "{$c}"; if ($i == 0) { $version_str = intval($version_str) . "."; } } else { $version_str .= "."; break; } } else { if ($c != '-' && ctype_alnum($c)) { $version_str .= "{$c}."; } else { break; } } } $version_str = substr($version_str, 0, strlen($version_str) - 1); return "{$id_name} {$version_str}"; }
function isAbsolute($path) { if ($path[0] == '/' || $path[0] == '\\' || strlen($path) > 3 && ctype_alpha($path[0]) && $path[1] == ':' && ($path[2] == '\\' || $path[2] == '/')) { return true; } return false; }
/** * Tokenize text to a terms * Returns array of Zend_Search_Lucene_Analysis_Token objects * * @param string $data * @return array */ public function tokenize($data) { $tokenStream = array(); $position = 0; while ($position < strlen($data)) { // skip white space while ($position < strlen($data) && !ctype_alpha($data[$position])) { $position++; } $termStartPosition = $position; // read token while ($position < strlen($data) && ctype_alpha($data[$position])) { $position++; } // Empty token, end of stream. if ($position == $termStartPosition) { break; } $token = new Zend_Search_Lucene_Analysis_Token(substr($data, $termStartPosition, $position - $termStartPosition), $termStartPosition, $position); $token = $this->normalize($token); if (!is_null($token)) { $tokenStream[] = $token; } } return $tokenStream; }
/** * Name format * alphabetic characters only * @param $name input */ function is_valid_name($name) { if (ctype_alpha($name)) { return true; } return false; }
public function isAlpha($string = '') { if (!is_string($string)) { return Error::set(lang('Error', 'stringParameter', '1.(string)')); } return ctype_alpha($string); }
/** * SCPlib constructor. Setup main variables. * * @param $server the server we will connect to * @param $config optional. path to an ssh_config file */ function SCPlib($server, $config = null) { if (!ctype_alpha($server)) { trigger_error('specified server name has non-alpha characters', E_USER_ERROR); return NULL; } // pre-run error checks $old_umask = umask(077); $www_user = posix_getuid(); $info = posix_getpwuid($www_user); $home_ssh = $info['dir'] . '/.ssh'; $known_hosts = $home_ssh . '/known_hosts'; if (!is_readable($known_hosts)) { throw new SCPException(SCPException::KNOWN_HOSTS, $known_hosts); } $this->_server = $server; $this->_scp_cmd = '/usr/bin/scp -o "BatchMode yes"'; $this->_ssh_cmd = '/usr/bin/ssh -o "BatchMode yes"'; if ($config !== null) { if (!is_file($config)) { throw new SCPException(SCPException::CONFIG_NOT_FILE, $config); } if (!is_readable($config)) { throw new SCPException(SCPException::CONFIG_NOT_READABLE, $config); } $this->_config = $config; $this->_scp_cmd .= ' -F ' . escapeshellarg($config); $this->_ssh_cmd .= ' -F ' . escapeshellarg($config); } $this->_rfutil = "~/rfutil"; }
function counterRepeat($user_word, $user_string) { //creates a standard error message to use below $error_message = -1; //checks to see if the user word inputted is a word and of alphabetic form //also checks to see if the user string is inputted if (!empty($user_word) && ctype_alpha($user_word) && !empty($user_string)) { //makes sure that there are no special characters enter within the string. //if there is it replaces them with the second argument which is "". $user_replace = preg_replace("/[^A-Za-z 0-9 ]/", "", $user_string); //takes the sentence the user inputs to search through and makes seperate //arrays out of them. $string_array = explode(" ", $user_replace); //makes the user word all lowercase $user_word = strtolower($user_word); //starting point for the counting how many times the word appears in the string $count = 0; //looks through the string array to see which words match the users input word //if they are equal then the count will add 1 increment foreach ($string_array as $word) { if ($user_word == $word) { $count++; } } //this will return the number of times the word is in the sentence return $count; } else { return $error_message; } }
protected static function isAbsolutePath($file) { if ($file[0] == '/' || $file[0] == '\\' || strlen($file) > 3 && ctype_alpha($file[0]) && $file[1] == ':' && ($file[2] == '\\' || $file[2] == '/')) { return true; } return false; }
/** * @dataProvider getTestVersions * * @param string $semver * @param string $composer */ public function testConverter($semver, $composer) { $this->assertEquals($composer, $this->converter->convertVersion($semver)); if (!ctype_alpha($semver) && !in_array($semver, array(null, ''))) { $this->assertEquals('v' . $composer, $this->converter->convertVersion('v' . $semver)); } }
public function nextToken() { while ($this->peek != self::EOF) { if (ctype_digit($this->peek)) { return $this->digit(); } if (ctype_alpha($this->peek) || $this->is('_') || $this->is('_') && ctype_alnum((string) $this->preview())) { return $this->identifier(); } if (ctype_space($this->peek)) { $this->space(); continue; } if ($this->matches(':') && (ctype_alpha($this->preview()) || '_' === $this->preview())) { return $this->atom(); } if ($this->matches('--')) { $this->singlelineComment(); continue; } if ($this->matches('{-')) { $this->multilineComment(); continue; } if ($this->is('"') || $this->is("'")) { return $this->string($this->peek); } if ($this->matches('&/')) { return $this->regex(); } // Multichar symbol analysis return SymbolDecypher::{$this->peek}($this); } return new Token(self::EOF_TYPE); }
public function render($parameters = array()) { if (isset($parameters['categoryId'])) { $categoryId = $parameters['categoryId']; } else { $advertcat = Advertcat::first(); if ($advertcat) { $categoryId = $advertcat->id; } else { $categoryId = 0; } } /* * Create the id attribute for the (div) container of the advert. * The idea is to create a "random" name instead of something like * "advert-top" so it's harder to use an ad blocker. * Different types have different IDs. */ $key = substr(Config::get('app.key'), 0, 10); $salt = 'f2h8wqhdfn'; // Even more salt - you may change this value! $containerId = substr(md5($categoryId . $key . $salt), 0, 5); /* * Ensure $containerId starts with an alphabetic character */ if (!ctype_alpha(substr($containerId, 0, 1))) { $containerId = chr(ord(substr($containerId, 0, 1)) % 26 + 97) . $containerId; } $advert = Advert::orderBy(DB::raw('RAND()'))->published()->whereAdvertcatId($categoryId)->first(); if ($advert) { return View::make('adverts::widget', compact('advert', 'containerId'))->render(); } }
/** * Returns the country names for a locale * * @param string $locale The locale to use for the country names * * @return array The country names with their codes as keys * * @throws \RuntimeException When the resource bundles cannot be loaded */ public static function getDisplayCountries($locale) { if (!isset(self::$countries[$locale])) { $bundle = \ResourceBundle::create($locale, self::getIcuDataDirectory() . '/region'); if (null === $bundle) { throw new \RuntimeException(sprintf('The country resource bundle could not be loaded for locale "%s"', $locale)); } $collator = new \Collator($locale); $countries = array(); $bundleCountries = $bundle->get('Countries') ?: array(); foreach ($bundleCountries as $code => $name) { // Global countries (f.i. "America") have numeric codes // Countries have alphabetic codes // "ZZ" is the code for unknown country if (ctype_alpha($code) && 'ZZ' !== $code) { $countries[$code] = $name; } } $fallbackLocale = self::getFallbackLocale($locale); if (null !== $fallbackLocale) { $countries = array_merge(self::getDisplayCountries($fallbackLocale), $countries); } $collator->asort($countries); self::$countries[$locale] = $countries; } return self::$countries[$locale]; }
function RemoveLineNumbers($S = 'test.txt') { $handle = fopen($S, "r"); $temp = fopen('file.txt', "w"); while (!feof($handle)) { $a = fgets($handle); $pieces = explode(" ", $a); //var_dump($pieces); for ($i = 0; $i < sizeof($pieces); $i++) { if (!ctype_alpha($pieces[$i])) { unset($pieces[$i]); /*if($pieces[$i+1]==' '){ for($j = $i ; $j< sizeof($pieces);$j++){ if($pieces[$j]== ' '){ } } }*/ } } // echo $a.'<br/>'; //var_dump($pieces); $b = implode(' ', $pieces); echo $b . "<br/>"; fwrite($temp, $b); } fclose($temp); fclose($handle); }
/** * セッションを開始する * @param string $name * @return $this */ protected function __new__($name = 'sess') { $this->ses_n = $name; if ('' === session_id()) { $session_name = \org\rhaco\Conf::get('session_name', 'SID'); if (!ctype_alpha($session_name)) { throw new \InvalidArgumentException('session name is is not a alpha value'); } session_cache_limiter(\org\rhaco\Conf::get('session_limiter', 'nocache')); session_cache_expire((int) (\org\rhaco\Conf::get('session_expire', 10800) / 60)); session_name(); if (static::has_module('session_read')) { ini_set('session.save_handler', 'user'); session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc')); if (isset($this->vars[$session_name])) { session_regenerate_id(true); } } session_start(); register_shutdown_function(function () { if ('' != session_id()) { session_write_close(); } }); } }
/** * Returns the country names for a locale * * @param string $locale The locale to use for the country names * * @return array The country names with their codes as keys * * @throws RuntimeException When the resource bundles cannot be loaded */ static public function getDisplayCountries($locale) { if (!isset(self::$countries[$locale])) { $bundle = \ResourceBundle::create($locale, __DIR__.'/Resources/data/region'); if (null === $bundle) { throw new \RuntimeException('The country resource bundle could not be loaded'); } $collator = new \Collator($locale); $countries = array(); foreach ($bundle->get('Countries') as $code => $name) { // Global countries (f.i. "America") have numeric codes // Countries have alphabetic codes // "ZZ" is the code for unknown country if (ctype_alpha($code) && 'ZZ' !== $code) { $countries[$code] = $name; } } $collator->asort($countries); self::$countries[$locale] = $countries; } return self::$countries[$locale]; }