Ejemplo n.º 1
0
 /**
  * Constructor.
  *
  * @access protected
  */
 protected function __construct()
 {
     // Init Config
     Config::init();
     // Turn on output buffering
     ob_start();
     // Display Errors
     Config::get('system.errors.display') and error_reporting(-1);
     // Set internal encoding
     function_exists('mb_language') and mb_language('uni');
     function_exists('mb_regex_encoding') and mb_regex_encoding(Config::get('system.charset'));
     function_exists('mb_internal_encoding') and mb_internal_encoding(Config::get('system.charset'));
     // Set default timezone
     date_default_timezone_set(Config::get('system.timezone'));
     // Start the session
     Session::start();
     // Init Cache
     Cache::init();
     // Init Plugins
     Plugins::init();
     // Init Blocks
     Blocks::init();
     // Init Pages
     Pages::init();
     // Flush (send) the output buffer and turn off output buffering
     ob_end_flush();
 }
Ejemplo n.º 2
0
 public function escape(array $values)
 {
     if (extension_loaded("mbstring")) {
         $toEnc = defined("SDB_MSSQL_ENCODING") ? SDB_MSSQL_ENCODING : "SJIS";
         $fromEnc = mb_internal_encoding();
         $currentRegexEnc = mb_regex_encoding();
         mb_regex_encoding($fromEnc);
         foreach ($values as $k => &$val) {
             if (is_bool($val)) {
                 $val = $val ? "1" : "0";
             } elseif (is_string($val)) {
                 $val = "'" . mb_convert_encoding(mb_ereg_replace("'", "''", $val), $toEnc, $fromEnc) . "'";
             }
         }
         mb_regex_encoding($currentRegexEnc);
     } else {
         foreach ($values as &$val) {
             if (is_bool($val)) {
                 $val = $val ? "1" : "0";
             } elseif (is_string($val)) {
                 $val = "'" . str_replace("'", "''", $val) . "'";
             }
         }
     }
     return $values;
 }
Ejemplo n.º 3
0
 public static function stem($word)
 {
     mb_internal_encoding(self::ENCODING);
     mb_regex_encoding(self::ENCODING);
     $word = mb_strtolower($word);
     $len = mb_strlen($word);
     if ($len <= 2) {
         return self::removeAccent($word);
     }
     $r1 = self::R($word);
     $r2 = self::R($word, $r1);
     $rv = self::RV($word);
     // Step 0: Attached pronoun
     $word = $step0Word = self::step0($word, $r1, $r2, $rv);
     // Step 1: Stadanrd Suffix removal
     $word = $step1Word = self::step1($step0Word, $r1, $r2, $rv);
     // Step 2: Verb Suffix
     if ($step1Word == $step0Word) {
         // Step 2a
         $word = $step2aWord = self::step2a($step1Word, $r1, $r2, $rv);
         // Step 2b
         if ($step1Word == $step2aWord) {
             $word = $step2bWord = self::step2b($step2aWord, $r1, $r2, $rv);
         }
     }
     // Step 3: Residual suffix
     $word = self::step3($word, $r1, $r2, $rv);
     return self::removeAccent($word);
 }
Ejemplo n.º 4
0
function yarpp_extract_keywords($source, $max = 20)
{
    global $overusedwords;
    if (function_exists('mb_split')) {
        mb_regex_encoding(get_option('blog_charset'));
        $wordlist = mb_split('\\s*\\W+\\s*', mb_strtolower($source));
    } else {
        $wordlist = preg_split('%\\s*\\W+\\s*%', strtolower($source));
    }
    // Build an array of the unique words and number of times they occur.
    $tokens = array_count_values($wordlist);
    // Remove the stop words from the list.
    foreach ($overusedwords as $word) {
        unset($tokens[$word]);
    }
    // Remove words which are only a letter
    foreach (array_keys($tokens) as $word) {
        if (function_exists('mb_strlen')) {
            if (mb_strlen($word) < 2) {
                unset($tokens[$word]);
            } else {
                if (strlen($word) < 2) {
                    unset($tokens[$word]);
                }
            }
        }
    }
    arsort($tokens, SORT_NUMERIC);
    $types = array_keys($tokens);
    if (count($types) > $max) {
        $types = array_slice($types, 0, $max);
    }
    return implode(' ', $types);
}
 public function run($args)
 {
     mb_internal_encoding("UTF-8");
     mb_regex_encoding("UTF-8");
     Yii::app()->setImport(['application.modules.store.models.*']);
     $models = StoreCategory::model()->findAll();
     foreach ($models as $model) {
         $res = preg_replace('/\\s\\s+/', ' ', $model->name_ru);
         if ($res !== FALSE) {
             if (mb_strlen($res) !== mb_strlen($model->name_ru)) {
                 $model->name_ru = $res;
                 $model->update(['name_ru']);
                 print_r($model->id . ' ');
             }
         }
     }
     Yii::import('application.components.spreadsheetReader.SpreadsheetReader');
     $reader = new SpreadsheetReader(Yii::getPathOfAlias('application.components.spreadsheetReader.translates') . '/' . 'site_store_category.ods');
     foreach ($reader as $row) {
         if ($row[0] != 'id') {
             $res = Yii::app()->db->createCommand('
                 UPDATE `site_store_category` SET `name_en`= :row2, `name_zh_cn`= :row3, `name_zh_tw`= :row4 WHERE  `name_ru`= :row1;
             ')->execute([':row1' => $row[1], ':row2' => $row[2], ':row3' => $row[3], ':row4' => $row[4]]);
             print_r($res . ' ' . $row[2] . ' ');
         }
     }
 }
Ejemplo n.º 6
0
Archivo: k.php Proyecto: hornos/C2
function __k_enc($enc = 'UTF-8')
{
    if (C2_MB) {
        mb_internal_encoding($enc);
        mb_regex_encoding($enc);
    }
}
Ejemplo n.º 7
0
/**
 * @param announcement  Server announcement string. UTF-8 assumed.
 * @param addr          Remote server address.
 */
function update_server($announcement, $addr)
{
    mb_regex_encoding('UTF-8');
    mb_internal_encoding('UTF-8');
    // First we must determine if the announcement is valid.
    $lines = mb_split("\r\n|\n|\r", $announcement);
    $info = new ServerInfo();
    while (list($line_number, $line) = each($lines)) {
        // Separate the label from the value.
        $colon = strpos($line, ":");
        // It must exist near the beginning.
        if ($colon === false || $colon >= 16) {
            continue;
        }
        $label = substr($line, 0, $colon);
        $value = substr($line, $colon + 1, strlen($line) - $colon - 1);
        if (strlen($value) >= 128) {
            continue;
        }
        // Ensure the label identifies a known property.
        if (isset($info[$label])) {
            // This will be included in the datafile.
            $info[$label] = $value;
        }
    }
    // Also include the remote address.
    $info['at'] = $addr;
    $info['time'] = time();
    // Let's write this info into the datafile.
    write_server($info);
}
Ejemplo n.º 8
0
 /**
  * Run an application
  */
 public static function run()
 {
     // Error reporting
     error_reporting(ENV === 'production' ? E_ERROR | E_WARNING | E_PARSE : -1);
     ini_set('display_errors', ENV === 'production' ? 0 : 1);
     // Services
     $services = Services::getInstance();
     // Global configuration
     $config = $services->config()->get('config');
     // UTF-8 support
     if (isset($config['utf8']) && $config['utf8']) {
         mb_internal_encoding('UTF-8');
         mb_http_output('UTF-8');
         mb_http_input('UTF-8');
         mb_language('uni');
         mb_regex_encoding('UTF-8');
         ob_start('mb_output_handler');
     } else {
         ob_start();
     }
     // Set Locales
     if (isset($config['locale']) && $config['locale']) {
         setlocale(LC_ALL, $config['locale']);
         setlocale(LC_NUMERIC, 'C');
     }
     // Call controller
     if ($route = $services->route()) {
         list($class, $method, $params) = $route;
         $controller = new $class();
         $controller->{$method}(...$params);
     }
     $services->output()->display(!$services->input()->isClient());
     ob_end_flush();
 }
Ejemplo n.º 9
0
 /**
  * Parse title of the question by
  * tokenizing it
  * Overrides parent's parse and users mb_split
  * instead of preg_split to be UTF-8 Safe
  * because title can be a UTF-8 string
  *
  * @return array tokens;
  */
 public function parse()
 {
     if (empty($this->origString)) {
         d('string was empty, returning empty array');
         return array();
     }
     \mb_regex_encoding('UTF-8');
     $aTokens = \mb_split('([\\s,;\\"\\?]+)', $this->origString);
     $aTokens = \array_unique($aTokens);
     $aStopwords = getStopwords();
     \array_walk($aTokens, function (&$val) use($aStopwords) {
         $val = \trim($val);
         $val = strlen($val) > 1 && !in_array($val, $aStopwords) ? $val : false;
     });
     /**
      * Remove empty values
      *
      */
     $aTokens = \array_filter($aTokens);
     /**
      * Call array_values to reindex from 0
      * otherwise if filter removed some
      * elements then Mongo will not
      * treat this as normal array
      */
     return \array_values($aTokens);
 }
Ejemplo n.º 10
0
    public function loadquestion()
    {
        $session = new Zend_Session_Namespace('game');
        $formQuesten = new Application_Form_LoadQuestion($_POST);
        $this->view->formQuesten = $formQuesten;
        $session->success = 0;
        $success = null;
        $question = "";
        $answer = "";
        $session->success = 0;
        mb_regex_encoding('UTF-8');
        mb_internal_encoding("UTF-8");
        $db = Zend_Registry::get('dbc');
        $db->query('SET NAMES utf8;');
        if (!is_null($db)) {
            $stmt = $db->prepare('SELECT german, english FROM vocable
								WHERE (level = "' . $session->level . '")
								ORDER BY RAND()
								LIMIT 1');
            $stmt->execute();
            $stmt->bind_result($question, $answer);
            $ergebnis = array();
            $i = 0;
            // Array ausgeben
            while ($stmt->fetch()) {
                $ergebnis[$i][0] = $question;
                $ergebnis[$i][1] = $answer;
                $i++;
            }
            $stmt->close();
            return $ergebnis;
        }
    }
Ejemplo n.º 11
0
 function _setupMbstring()
 {
     #ifdef _MBSTRING_LANGUAGE
     if (defined('_MBSTRING_LANGUAGE') && function_exists("mb_language")) {
         if (@mb_language(_MBSTRING_LANGUAGE) != false && @mb_internal_encoding(_CHARSET) != false) {
             define('MBSTRING', true);
         } else {
             mb_language("neutral");
             mb_internal_encoding("ISO-8859-1");
             if (!defined('MBSTRING')) {
                 define('MBSTRING', false);
             }
         }
         if (function_exists('mb_regex_encoding')) {
             @mb_regex_encoding(_CHARSET);
         }
         ini_set('mbstring.http_input', 'pass');
         ini_set('mbstring.http_output', 'pass');
         ini_set('mbstring.substitute_character', 'none');
     }
     #endif
     if (!defined("MBSTRING")) {
         define("MBSTRING", FALSE);
     }
 }
Ejemplo n.º 12
0
 public function __construct()
 {
     global $connection;
     mb_internal_encoding('UTF-8');
     mb_regex_encoding('UTF-8');
     $this->link = new mysqli($this->host, $this->username, $this->password, $this->database);
 }
Ejemplo n.º 13
0
 /**
  * Set up php for zikula install
  *
  * @throws FatalErrorException if settings are not capable of performing install or sustaining Zikula
  */
 public function initPhp()
 {
     $warnings = array();
     if (!function_exists('mb_get_info')) {
         $warnings[] = __('mbstring is not installed in PHP.  Zikula cannot install or upgrade without this extension.');
     }
     if (version_compare(\PHP_VERSION, '5.6.0', '<') && ini_set('mbstring.internal_encoding', 'UTF-8') === false) {
         // mbstring.internal_encoding is deprecated in php 5.6.0
         $currentSetting = ini_get('mbstring.internal_encoding');
         $warnings[] = __f('Could not use %1$s to set the %2$s to the value of %3$s. The install or upgrade process may fail at your current setting of %4$s.', array('ini_set', 'mbstring.internal_encoding', 'UTF-8', $currentSetting));
     }
     if (ini_set('default_charset', 'UTF-8') === false) {
         $currentSetting = ini_get('default_charset');
         $warnings[] = __f('Could not use %1$s to set the %2$s to the value of %3$s. The install or upgrade process may fail at your current setting of %4$s.', array('ini_set', 'default_charset', 'UTF-8', $currentSetting));
     }
     if (mb_regex_encoding('UTF-8') === false) {
         $currentSetting = mb_regex_encoding();
         $warnings[] = __f('Could not set %1$s to the value of %2$s. The install or upgrade process may fail at your current setting of %3$s.', array('mb_regex_encoding', 'UTF-8', $currentSetting));
     }
     if (ini_set('memory_limit', '128M') === false) {
         $currentSetting = ini_get('memory_limit');
         $warnings[] = __f('Could not use %1$s to set the %2$s to the value of %3$s. The install or upgrade process may fail at your current setting of %4$s.', array('ini_set', 'memory_limit', '128M', $currentSetting));
     }
     if (ini_set('max_execution_time', 86400) === false) {
         // 86400 = 24 hours
         $currentSetting = ini_get('max_execution_time');
         if ($currentSetting > 0) {
             // 0 = unlimited time
             $warnings[] = __f('Could not use %1$s to set the %2$s to the value of %3$s. The install or upgrade process may fail at your current setting of %4$s.', array('ini_set', 'max_execution_time', '86400', $currentSetting));
         }
     }
     return $warnings;
 }
Ejemplo n.º 14
0
 public function wordwrapFilter($value, $length = 60, $separator = "\n", $preserve = false)
 {
     $lines = array();
     $value = str_replace("<p>", "", $value);
     $value = str_replace("</p>", "\n\n", $value);
     $value = preg_replace("/<br\\W*?\\/>/", "\n", $value);
     if (substr($value, -2) == "\n\n") {
         $value = substr($value, 0, -2);
     }
     $previous = mb_regex_encoding();
     mb_regex_encoding(craft()->templates->getTwig()->getCharset());
     $pieces = mb_split($separator, $value);
     mb_regex_encoding($previous);
     foreach ($pieces as $piece) {
         while (!$preserve && mb_strlen($piece, craft()->templates->getTwig()->getCharset()) > $length) {
             $count = count($lines);
             $lines[] = mb_substr($piece, 0, $length, craft()->templates->getTwig()->getCharset());
             $lastSpacePosition = strrpos($lines[$count], ' ', 0);
             $finalCharacters = trim(substr($lines[$count], $lastSpacePosition, 60));
             $lines[$count] = substr($lines[$count], 0, $lastSpacePosition);
             $piece = $finalCharacters . $piece;
             $piece = mb_substr($piece, $length, 2048, craft()->templates->getTwig()->getCharset());
         }
         $lines[] = $piece;
     }
     return implode($separator, $lines);
 }
Ejemplo n.º 15
0
 static function trim($value, $max_length, $is_html = false)
 {
     if (UTF8::len($value) > $max_length) {
         $value = UTF8::sub($value, 0, $max_length);
         // TODO: replace this with cleanstring of ctools
         $regex = '(.*)\\b.+';
         $matches = array();
         if (function_exists('mb_ereg')) {
             mb_regex_encoding('UTF-8');
             $found = mb_ereg($regex, $value, $matches);
         } else {
             $found = preg_match("/{$regex}/us", $value, $matches);
         }
         if ($found) {
             $value = $matches[1];
         }
         if ($is_html) {
             // Remove scraps of HTML entities from the end of a strings
             $regex = '/(?:<(?!.+>)|&(?!.+;)).*$/s';
             $value2 = preg_replace($regex . 'u', '', $value);
             if (preg_last_error() == 4) {
                 $value = preg_replace($regex, '', $value);
             } else {
                 $value = $value2;
             }
         }
         $value = rtrim($value);
         $value .= '...';
     }
     if ($is_html) {
         $value = self::_filter_htmlcorrector($value);
     }
     return $value;
 }
Ejemplo n.º 16
0
 /**
  * init mbstring
  */
 protected static function initMbstring()
 {
     if (extension_loaded('mbstring')) {
         if (((int) ini_get('mbstring.encoding_translation') || in_array(strtolower(ini_get('mbstring.encoding_translation')), array('on', 'yes', 'true'), true)) && !in_array(strtolower(ini_get('mbstring.http_input')), array('pass', '8bit', 'utf-8'), true)) {
             user_error('php.ini settings: Please disable mbstring.encoding_translation or set mbstring.http_input to "pass"', E_USER_WARNING);
         }
         if (MB_OVERLOAD_STRING & (int) ini_get('mbstring.func_overload')) {
             user_error('php.ini settings: Please disable mbstring.func_overload', E_USER_WARNING);
         }
         if (function_exists('mb_regex_encoding')) {
             mb_regex_encoding('UTF-8');
         }
         ini_set('mbstring.script_encoding', 'pass');
         if ('utf-8' !== strtolower(mb_internal_encoding())) {
             mb_internal_encoding('UTF-8');
         }
         if ('none' !== strtolower(mb_substitute_character())) {
             mb_substitute_character('none');
         }
         if (!in_array(strtolower(mb_http_output()), array('pass', '8bit'), true)) {
             mb_http_output('pass');
         }
         if (!in_array(strtolower(mb_language()), array('uni', 'neutral'), true)) {
             mb_language('uni');
         }
     } elseif (!defined('MB_OVERLOAD_MAIL')) {
         extension_loaded('iconv') or self::initIconv();
         require __DIR__ . '/bootup/mbstring.php';
     }
 }
Ejemplo n.º 17
0
 /**
  * Format a string data.
  *
  * @param string $str A string.
  *
  * @return string
  */
 protected function formatString($str)
 {
     if (extension_loaded('mbstring')) {
         $originalStr = $str;
         $str = mb_convert_case($str, MB_CASE_TITLE, 'UTF-8');
         // Correct for MB_TITLE_CASE's insistence on uppercasing letters
         // immediately preceded by numerals, eg: 1st -> 1St
         $originalEncoding = mb_regex_encoding();
         mb_regex_encoding('UTF-8');
         // matches an upper case letter character immediately preceded by a numeral
         mb_ereg_search_init($str, '[0-9]\\p{Lu}');
         while ($match = mb_ereg_search_pos()) {
             $charPos = $match[0] + 1;
             // Only swap it back to lowercase if it was lowercase to begin with
             if (mb_ereg_match('\\p{Ll}', $originalStr[$charPos])) {
                 $str[$charPos] = mb_strtolower($str[$charPos]);
             }
         }
         mb_regex_encoding($originalEncoding);
     } else {
         $str = $this->lowerize($str);
         $str = ucwords($str);
     }
     $str = str_replace('-', '- ', $str);
     $str = str_replace('- ', '-', $str);
     return $str;
 }
Ejemplo n.º 18
0
function test_ereg($test_enc, $pat, $str, $in_enc = 'EUC-JP')
{
    mb_regex_encoding($test_enc);
    $pat = mb_convert_encoding($pat, $test_enc, $in_enc);
    $str = mb_convert_encoding($str, $test_enc, $in_enc);
    printf("(%d)%s\n", mb_ereg($pat, $str, $reg), is_array($reg) ? bin2hex(mb_convert_encoding(implode(' ', $reg), $in_enc, $test_enc)) : '');
}
Ejemplo n.º 19
0
 /**
  * acsスタイル選択情報の取得
  *
  * @param string $lang 言語種別
  * @param string $encoding 文字エンコーディング
  */
 function get_style_selection_info_array($lang, $encoding = '')
 {
     if ($encoding != '') {
         mb_regex_encoding($encoding);
     }
     $pattern = 'acs_style_selection[ \\t]*\\{([^\\}]+)\\}';
     $result = mb_ereg($pattern, $this->css_file_contents, $regs);
     if ($result != FALSE) {
         $styles = trim($regs[1]);
         $pattern_fmt = '.*%s[ \\t\\n\\r\\f\\v]*:*([^;]+);';
         $result = array();
         // 各パラメータの取得
         mb_ereg(sprintf($pattern_fmt, 'show_list'), $styles, $regs);
         $result['show_list'] = trim($regs[1]);
         mb_ereg(sprintf($pattern_fmt, 'display_order'), $styles, $regs);
         $result['display_order'] = trim($regs[1]);
         // 言語依存パラメータの取得
         mb_ereg(sprintf($pattern_fmt, 'name\\.' . $lang), $styles, $regs);
         $result['name'] = trim($regs[1]);
         mb_ereg(sprintf($pattern_fmt, 'description\\.' . $lang), $styles, $regs);
         $result['description'] = trim($regs[1]);
         mb_ereg(sprintf($pattern_fmt, 'thumbnail\\.' . $lang), $styles, $regs);
         $result['thumbnail'] = trim($regs[1]);
         $result['filename'] = basename($this->css_file_path);
     }
     return $result;
 }
Ejemplo n.º 20
0
 public function index()
 {
     define('DEBUG', true);
     // an array of file extensions to accept
     $accepted_extensions = array("png", "jpg", "gif");
     // http://your-web-site.domain/base/url
     $base_url = url::base() . Kohana::config('upload.relative_directory', TRUE) . "jwysiwyg";
     // the root path of the upload directory on the server
     $uploads_dir = Kohana::config('upload.directory', TRUE) . "jwysiwyg";
     // the root path that the files are available from the webserver
     $uploads_access_dir = Kohana::config('upload.directory', TRUE) . "jwysiwyg";
     if (!file_exists($uploads_access_dir)) {
         mkdir($uploads_access_dir, 0775);
     }
     if (DEBUG) {
         if (!file_exists($uploads_access_dir)) {
             $error = 'Folder "' . $uploads_access_dir . '" doesn\'t exists.';
             header('Content-type: text/html; charset=UTF-8');
             print '{"error":"config.php: ' . htmlentities($error) . '","success":false}';
             exit;
         }
     }
     $capabilities = array("move" => false, "rename" => true, "remove" => true, "mkdir" => false, "upload" => true);
     if (extension_loaded('mbstring')) {
         mb_internal_encoding('UTF-8');
         mb_regex_encoding('UTF-8');
     }
     require_once Kohana::find_file('libraries/jwysiwyg', 'common', TRUE);
     require_once Kohana::find_file('libraries/jwysiwyg', 'handlers', TRUE);
     ResponseRouter::getInstance()->run();
 }
 /**
  * カタカナチェック
  *
  * @access public
  * @param mixed $val 入力値
  * @return bool チェック結果
  * @author shimma
  */
 public static function _validation_valid_kana($val)
 {
     $is_valid = false;
     mb_regex_encoding('UTF-8');
     $pattern = '/^[ァ-ヶー]+$/u';
     $is_valid = (bool) preg_match($pattern, $val);
     return $is_valid;
 }
Ejemplo n.º 22
0
 function __construct()
 {
     mb_internal_encoding("UTF-8");
     mb_regex_encoding("UTF-8");
     $this->Database = new PDO("sqlite:" . CONFIG_DATABASE);
     $log_file_name = CONFIG_DIR_LOGS . "/" . date("Y-m-d") . ".log";
     $this->LogFile = fopen($log_file_name, "a+");
 }
Ejemplo n.º 23
0
 private static function _init()
 {
     $arr = array(0xe26 => self::CHAR_NOTSTOP, 0xe2f => self::CHAR_NOTSTOP, 0xe30 => self::CHAR_NOTSTART, 0xe31 => self::CHAR_INNERVOWEL | self::CHAR_ZEROWIDTH, 0xe32 => self::CHAR_ENDINGVOWEL, 0xe33 => self::CHAR_ENDINGVOWEL, 0xe34 => self::CHAR_NOTSTART | self::CHAR_ZEROWIDTH, 0xe35 => self::CHAR_NOTSTART | self::CHAR_ZEROWIDTH, 0xe36 => self::CHAR_NOTSTART | self::CHAR_ZEROWIDTH, 0xe37 => self::CHAR_NOTSTART | self::CHAR_ZEROWIDTH, 0xe38 => self::CHAR_NOTSTART | self::CHAR_ZEROWIDTH, 0xe39 => self::CHAR_NOTSTART | self::CHAR_ZEROWIDTH, 0xe3a => self::CHAR_ENDINGVOWEL | self::CHAR_ZEROWIDTH, 0xe40 => self::CHAR_MUSTSTART, 0xe41 => self::CHAR_MUSTSTART, 0xe42 => self::CHAR_MUSTSTART, 0xe43 => self::CHAR_MUSTSTART, 0xe44 => self::CHAR_MUSTSTART, 0xe45 => self::CHAR_MUSTSTOP, 0xe47 => self::CHAR_INNERVOWEL, 0xe48 => self::CHAR_NOTSTART | self::CHAR_ZEROWIDTH, 0xe49 => self::CHAR_NOTSTART | self::CHAR_ZEROWIDTH, 0xe4a => self::CHAR_NOTSTART | self::CHAR_ZEROWIDTH, 0xe4b => self::CHAR_NOTSTART | self::CHAR_ZEROWIDTH, 0xe4c => self::CHAR_MUSTSTOP | self::CHAR_ZEROWIDTH, 0xe4d => self::CHAR_MUSTSTOP | self::CHAR_ZEROWIDTH);
     foreach ($arr as $u => $definition) {
         self::$_letterDefinitions[self::unicode2mb($u)] = $definition;
     }
     mb_regex_encoding('UTF-8');
     mb_internal_encoding('UTF-8');
 }
Ejemplo n.º 24
0
 function check()
 {
     jimport('joomla.filter.output');
     $this->title = JString::trim($this->title);
     if ($this->title == '') {
         $this->setError(JText::_('K2_ITEM_MUST_HAVE_A_TITLE'));
         return false;
     }
     if (!$this->catid) {
         $this->setError(JText::_('K2_ITEM_MUST_HAVE_A_CATEGORY'));
         return false;
     }
     if (empty($this->alias)) {
         $this->alias = $this->title;
     }
     if (K2_JVERSION != '15' && JFactory::getConfig()->get('unicodeslugs') == 1) {
         $this->alias = JApplication::stringURLSafe($this->alias);
     } else {
         if (JPluginHelper::isEnabled('system', 'unicodeslug') || JPluginHelper::isEnabled('system', 'jw_unicodeSlugsExtended')) {
             $this->alias = JFilterOutput::stringURLSafe($this->alias);
         } else {
             mb_internal_encoding("UTF-8");
             mb_regex_encoding("UTF-8");
             $this->alias = trim(mb_strtolower($this->alias));
             $this->alias = str_replace('-', ' ', $this->alias);
             $this->alias = str_replace('/', '-', $this->alias);
             $this->alias = mb_ereg_replace('[[:space:]]+', ' ', $this->alias);
             $this->alias = trim(str_replace(' ', '-', $this->alias));
             $this->alias = str_replace('.', '', $this->alias);
             $this->alias = str_replace('"', '', $this->alias);
             $this->alias = str_replace("'", '', $this->alias);
             $stripthese = ',|~|!|@|%|^|(|)|<|>|:|;|{|}|[|]|&|`|„|‹|’|‘|“|â€�|•|›|«|´|»|°|«|»|…';
             $strips = explode('|', $stripthese);
             foreach ($strips as $strip) {
                 $this->alias = str_replace($strip, '', $this->alias);
             }
             $params = JComponentHelper::getParams('com_k2');
             $SEFReplacements = array();
             $items = explode(',', $params->get('SEFReplacements'));
             foreach ($items as $item) {
                 if (!empty($item)) {
                     @(list($src, $dst) = explode('|', trim($item)));
                     $SEFReplacements[trim($src)] = trim($dst);
                 }
             }
             foreach ($SEFReplacements as $key => $value) {
                 $this->alias = str_replace($key, $value, $this->alias);
             }
             $this->alias = trim($this->alias, '-.');
             if (trim(str_replace('-', '', $this->alias)) == '') {
                 $datenow = JFactory::getDate();
                 $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
             }
         }
     }
     return true;
 }
Ejemplo n.º 25
0
Archivo: route.php Proyecto: emavro/k2
 public static function getUserRoute($userID)
 {
     if (K2_CB) {
         global $_CB_framework;
         return $_CB_framework->userProfileUrl((int) $userID);
     }
     $key = (int) $userID;
     if (isset(self::$cache['user'][$key])) {
         return self::$cache['user'][$key];
     }
     $needles = array('user' => (int) $userID);
     $user = JFactory::getUser($userID);
     if (K2_JVERSION != '15' && JFactory::getConfig()->get('unicodeslugs') == 1) {
         $alias = JApplication::stringURLSafe($user->name);
     } else {
         if (JPluginHelper::isEnabled('system', 'unicodeslug') || JPluginHelper::isEnabled('system', 'jw_unicodeSlugsExtended')) {
             $alias = JFilterOutput::stringURLSafe($user->name);
         } else {
             mb_internal_encoding("UTF-8");
             mb_regex_encoding("UTF-8");
             $alias = trim(mb_strtolower($user->name));
             $alias = str_replace('-', ' ', $alias);
             $alias = mb_ereg_replace('[[:space:]]+', ' ', $alias);
             $alias = trim(str_replace(' ', '', $alias));
             $alias = str_replace('.', '', $alias);
             $stripthese = ',|~|!|@|%|^|(|)|<|>|:|;|{|}|[|]|&|`|„|‹|’|‘|“|â€�|•|›|«|´|»|°|«|»|…';
             $strips = explode('|', $stripthese);
             foreach ($strips as $strip) {
                 $alias = str_replace($strip, '', $alias);
             }
             $params = K2HelperUtilities::getParams('com_k2');
             $SEFReplacements = array();
             $items = explode(',', $params->get('SEFReplacements', NULL));
             foreach ($items as $item) {
                 if (!empty($item)) {
                     @(list($src, $dst) = explode('|', trim($item)));
                     $SEFReplacements[trim($src)] = trim($dst);
                 }
             }
             foreach ($SEFReplacements as $key => $value) {
                 $alias = str_replace($key, $value, $alias);
             }
             $alias = trim($alias, '-.');
             if (trim(str_replace('-', '', $alias)) == '') {
                 $datenow = JFactory::getDate();
                 $alias = K2_JVERSION == '15' ? $datenow->toFormat("%Y-%m-%d-%H-%M-%S") : $datenow->format("Y-m-d-H-i-s");
             }
         }
     }
     $link = 'index.php?option=com_k2&view=itemlist&task=user&id=' . $userID . ':' . $alias;
     if ($item = K2HelperRoute::_findItem($needles)) {
         $link .= '&Itemid=' . $item->id;
     }
     self::$cache['user'][$key] = $link;
     return $link;
 }
Ejemplo n.º 26
0
 public function _validation_valid_katakana($val)
 {
     mb_regex_encoding("UTF-8");
     $val = trim($val);
     if (mb_ereg("^[ア-ン゛゜ァ-ォャ-ョー「」、 ]+\$", $val)) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 27
0
 /**
  * Sets the default charset to be used for everything
  */
 public function setCharset($charset = '')
 {
     if (!empty($charset) && is_string($charset)) {
         $charset = trim($charset);
         @mb_internal_encoding($charset);
         @mb_http_output($charset);
         @mb_http_input($charset);
         @mb_regex_encoding($charset);
     }
 }
Ejemplo n.º 28
0
 public function initConnection(ConnectionInterface $con, array $settings)
 {
     $con->query('PRAGMA foreign_keys = ON');
     parent::initConnection($con, $settings);
     //add regex support
     $con->sqliteCreateFunction('regexp', function ($pattern, $value) {
         mb_regex_encoding('UTF-8');
         return false !== mb_ereg($pattern, $value) ? 1 : 0;
     });
 }
Ejemplo n.º 29
0
function basicSetup()
{
    error_reporting(E_ALL | E_STRICT);
    date_default_timezone_set('Europe/Moscow');
    setlocale(LC_CTYPE, "en_US.UTF8");
    setlocale(LC_TIME, "en_US.UTF8");
    $defaultEncoding = 'UTF-8';
    mb_internal_encoding($defaultEncoding);
    mb_regex_encoding($defaultEncoding);
}
Ejemplo n.º 30
0
 /**
  * Create and return an instance
  * 
  * @param string $encoding
  * @param string $language
  * 
  * @return PMF_String_Mbstring
  */
 public static function getInstance($encoding = null, $language = 'en')
 {
     if (!self::$instance) {
         self::$instance = new self();
         self::$instance->encoding = null == $encoding ? self::DEFAULT_ENCODING : $encoding;
         self::$instance->language = PMF_Language::isASupportedLanguage($language) ? $language : self::DEFAULT_LANGUAGE;
         mb_regex_encoding(self::$instance->encoding);
     }
     return self::$instance;
 }