/** * Converts a YAML string to a PHP array. * * @param string $value A YAML string * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise * @param Boolean $objectSupport true if object support is enabled, false otherwise * * @return array A PHP array representing the YAML string */ public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) { self::$exceptionOnInvalidType = $exceptionOnInvalidType; self::$objectSupport = $objectSupport; $value = trim($value); if (0 == strlen($value)) { return ''; } if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('ASCII'); } $i = 0; switch ($value[0]) { case '[': $result = self::parseSequence($value, $i); ++$i; break; case '{': $result = self::parseMapping($value, $i); ++$i; break; default: $result = self::parseScalar($value, null, array('"', "'"), $i); } // some comments are allowed at the end if (preg_replace('/\\s+#.*$/A', '', substr($value, $i))) { throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i))); } if (isset($mbEncoding)) { mb_internal_encoding($mbEncoding); } return $result; }
/** * Tokenizes a source code. * * @param string $code The source code * @param string $filename A unique identifier for the source code * * @return Twig_TokenStream A token stream instance */ public function tokenize($code, $filename = 'n/a') { if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('ASCII'); } $this->code = str_replace(array("\r\n", "\r"), "\n", $code); $this->filename = $filename; $this->cursor = 0; $this->lineno = 1; $this->pushedBack = array(); $this->end = strlen($this->code); $this->position = self::POSITION_DATA; $tokens = array(); $end = false; while (!$end) { $token = $this->nextToken(); $tokens[] = $token; $end = $token->getType() === Twig_Token::EOF_TYPE; } if (isset($mbEncoding)) { mb_internal_encoding($mbEncoding); } return new Twig_TokenStream($tokens, $this->filename, $this->env->getTrimBlocks()); }
public function __construct($params, $encoding = 'utf-8') { //get parameters $this->encoding = $encoding; mb_internal_encoding($encoding); $this->contents = $this->replace_chars($params['content']); // single word if (isset($params['min_word_length'])) { $this->wordLengthMin = $params['min_word_length']; } if (isset($params['min_word_occur'])) { $this->wordOccuredMin = $params['min_word_occur']; } // 2 word phrase if (isset($params['min_2words_length'])) { $this->word2WordPhraseLengthMin = $params['min_2words_length']; } if (isset($params['min_2words_phrase_length'])) { $this->phrase2WordLengthMin = $params['min_2words_phrase_length']; } if (isset($params['min_2words_phrase_occur'])) { $this->phrase2WordLengthMinOccur = $params['min_2words_phrase_occur']; } // 3 word phrase if (isset($params['min_3words_length'])) { $this->word3WordPhraseLengthMin = $params['min_3words_length']; } if (isset($params['min_3words_phrase_length'])) { $this->phrase3WordLengthMin = $params['min_3words_phrase_length']; } if (isset($params['min_3words_phrase_occur'])) { $this->phrase3WordLengthMinOccur = $params['min_3words_phrase_occur']; } //parse single, two words and three words }
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); } }
/** * Convenience method for htmlspecialchars. * * @param string|array|object $text Text to wrap through htmlspecialchars. Also works with arrays, and objects. * Arrays will be mapped and have all their elements escaped. Objects will be string cast if they * implement a `__toString` method. Otherwise the class name will be used. * @param bool $double Encode existing html entities. * @param string $charset Character set to use when escaping. Defaults to config value in `mb_internal_encoding()` * or 'UTF-8'. * @return string Wrapped text. * @link http://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#h */ function h($text, $double = true, $charset = null) { if (is_string($text)) { //optimize for strings } elseif (is_array($text)) { $texts = []; foreach ($text as $k => $t) { $texts[$k] = h($t, $double, $charset); } return $texts; } elseif (is_object($text)) { if (method_exists($text, '__toString')) { $text = (string) $text; } else { $text = '(object)' . get_class($text); } } elseif (is_bool($text)) { return $text; } static $defaultCharset = false; if ($defaultCharset === false) { $defaultCharset = mb_internal_encoding(); if ($defaultCharset === null) { $defaultCharset = 'UTF-8'; } } if (is_string($double)) { $charset = $double; } return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, $charset ? $charset : $defaultCharset, $double); }
function requiring() { mb_internal_encoding('UTF-8'); require_once dirname(__FILE__) . '/config.php'; if (DB_STORAGE == 'mysql') { require_once DIR_LIBRARY . 'connection' . DB_STORAGE . '.php'; } else { require_once DIR_LIBRARY . 'connection.php'; } require_once DIR_LIBRARY . 'validation.php'; require_once DIR_LIBRARY . 'helper.php'; require_once DIR_LIBRARY . 'pagination.php'; require_once DIR_LIBRARY . 'authority.php'; require_once DIR_LIBRARY . 'filing.php'; require_once DIR_LIBRARY . 'postcode.php'; require_once DIR_MODEL . 'model.php'; require_once DIR_MODEL . 'applicationmodel.php'; require_once DIR_MODEL . 'config.php'; require_once DIR_MODEL . 'item.php'; require_once DIR_VIEW . 'view.php'; require_once DIR_VIEW . 'applicationview.php'; require_once DIR_VIEW . 'liquid.php'; if (get_magic_quotes_gpc()) { if (is_array($_POST)) { $_POST = $this->strip($_POST); } if (is_array($_GET)) { $_GET = $this->strip($_GET); } } }
/** * Configures mbstring settings */ function configureMBSettings($charset) { $charset = _ml_strtolower($charset); $this->_charset = $charset; $this->_internal_charset = $charset; if (!$this->_mb_enabled) { // setting the codepage for mysql connection $this->_codepage = $this->getSQLCharacterSet(); return; } // getting the encoding for post/get data if (_ml_strtolower(ini_get('mbstring.http_input')) == 'pass' || !ini_get('mbstring.encoding_translation')) { $data_charset = $charset; } else { $data_charset = ini_get('mbstring.internal_encoding'); } $this->_internal_charset = 'UTF-8'; mb_internal_encoding('UTF-8'); mb_http_output($charset); if (!$this->_mb_output) { ob_start("mb_output_handler", 8096); } // setting the codepage for mysql connection $this->_codepage = $this->getSQLCharacterSet(); // checking if get/post data is properly encoded if ($data_charset != $this->_internal_charset) { convertInputData($this->_internal_charset, $data_charset); } }
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(); }
/** * found here http://stackoverflow.com/a/11871948 * @param $input * @param $pad_length * @param string $pad_string * @param int $pad_type * @return string */ function mb_str_pad($input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT) { mb_internal_encoding('utf-8'); // @important $diff = strlen($input) - mb_strlen($input); return str_pad($input, $pad_length + $diff, $pad_string, $pad_type); }
static function StoreFileInfo($file_id, $info) { global $wpdb; self::cleanInfoByRef($info); // set encoding to utf8 (required for getKeywords) if (function_exists('mb_internal_encoding')) { $cur_enc = mb_internal_encoding(); mb_internal_encoding('UTF-8'); } $keywords = array(); self::getKeywords($info, $keywords); $keywords = strip_tags(join(' ', $keywords)); $keywords = str_replace(array('\\n', ' '), '', $keywords); $keywords = preg_replace('/\\s\\s+/', ' ', $keywords); if (!function_exists('mb_detect_encoding') || mb_detect_encoding($keywords, "UTF-8") != "UTF-8") { $keywords = utf8_encode($keywords); } // restore prev encoding if (function_exists('mb_internal_encoding')) { mb_internal_encoding($cur_enc); } // don't store keywords 2 times: unset($info['keywords']); self::removeLongData($info, 8000); $data = empty($info) ? '0' : base64_encode(serialize($info)); $res = $wpdb->replace($wpdb->wpfilebase_files_id3, array('file_id' => (int) $file_id, 'analyzetime' => time(), 'value' => &$data, 'keywords' => &$keywords)); unset($data, $keywords); return $res; }
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; }
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); }
/** * Smarty mb_truncate modifier plugin * * Type: modifier<br> * Name: mb_truncate<br> * Purpose: Truncate a string to a certain length if necessary, * optionally splitting in the middle of a word, and * appending the $etc string. (MultiByte version) * @link http://smarty.php.net/manual/en/language.modifier.truncate.php * truncate (Smarty online manual) * @param string * @param string * @param integer * @param string * @param boolean * @return string */ function smarty_modifier_mb_truncate($string, $length = 80, $etc = '...', $break_words = false) { if ($length == 0) { return ''; } $string = str_replace("&", "&", $string); if (function_exists("mb_internal_encoding") && function_exists("mb_strlen") && function_exists("mb_substr")) { mb_internal_encoding("UTF8"); if (mb_strlen($string) > $length) { $length -= mb_strlen($etc); if (!$break_words) { $string = preg_replace('/\\s+?(\\S+)?$/', '', mb_substr($string, 0, $length + 1)); } $string = mb_substr($string, 0, $length) . $etc; } } else { //modifier.truncate if (strlen($string) > $length) { $length -= strlen($etc); if (!$break_words) { $string = preg_replace('/\\s+?(\\S+)?$/', '', substr($string, 0, $length + 1)); } $string = substr($string, 0, $length) . $etc; } } $string = str_replace("&", "&", $string); return $string; }
public function __construct($debug = 0, $maxpass = 50) { global $modx; $this->name = "PHx"; $this->version = "2.2.0"; $this->user["mgrid"] = isset($_SESSION['mgrInternalKey']) ? intval($_SESSION['mgrInternalKey']) : 0; $this->user["usrid"] = isset($_SESSION['webInternalKey']) ? intval($_SESSION['webInternalKey']) : 0; $this->user["id"] = $this->user["usrid"] > 0 ? -$this->user["usrid"] : $this->user["mgrid"]; $this->cache["cm"] = array(); $this->cache["ui"] = array(); $this->cache["mo"] = array(); $this->safetags[0][0] = '~(?<![\\[]|^\\^)\\[(?=[^\\+\\*\\(\\[]|$)~s'; $this->safetags[0][1] = '~(?<=[^\\+\\*\\)\\]]|^)\\](?=[^\\]]|$)~s'; $this->safetags[1][0] = '&_PHX_INTERNAL_091_&'; $this->safetags[1][1] = '&_PHX_INTERNAL_093_&'; $this->safetags[2][0] = '['; $this->safetags[2][1] = ']'; $this->console = array(); $this->debug = $debug != '' ? $debug : 0; $this->debugLog = false; $this->curPass = 0; $this->maxPasses = $maxpass != '' ? $maxpass : 50; $this->swapSnippetCache = array(); $modx->setPlaceholder("phx", "&_PHX_INTERNAL_&"); if (function_exists('mb_internal_encoding')) { mb_internal_encoding($modx->config['modx_charset']); } }
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; } }
/** * เรียกใช้งาน Class แบบสามารถเรียกได้ครั้งเดียวเท่านั้น * * @param array $config ค่ากำหนดของ แอพพลิเคชั่น * @return Singleton */ public function __construct() { /* display error */ if (defined('DEBUG') && DEBUG === true) { /* ขณะออกแบบ แสดง error และ warning ของ PHP */ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(-1); } else { /* ขณะใช้งานจริง */ error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); } /* config */ self::$cfg = \Config::create(); /* charset default UTF-8 */ ini_set('default_charset', self::$char_set); if (extension_loaded('mbstring')) { mb_internal_encoding(self::$char_set); } /* inint Input */ Input::normalizeRequest(); // template ที่กำลังใช้งานอยู่ Template::inint(Input::get($_GET, 'skin', self::$cfg->skin)); /* time zone default Thailand */ @date_default_timezone_set(self::$cfg->timezone); }
/** * setup */ public function setup() { require_once __DIR__ . '/libs/simple_html_dom.php'; $this->fs = new \tomk79\filesystem(); mb_internal_encoding('utf-8'); @date_default_timezone_set('Asia/Tokyo'); }
/** * Устанавливаем кодировку UTF-8 для функций mb_* * */ protected function _initEncoding() { if (phpversion() < 5.6) { mb_internal_encoding('utf-8'); iconv_set_encoding('internal_encoding', 'utf-8'); } }
/** * The constructor */ public function __construct($encoding = null) { $this->encoding = $encoding == null ? mb_internal_encoding() : $encoding; $this->headers = new HeaderFieldSet(); $this->headers->setEncoding($this->encoding); // $this->headers->set('date', date('r')); // RFC-2822 format. }
function boot($light = false) { //define all needed constants $this->setContants(); mb_internal_encoding("UTF-8"); //First thing to do, define error management (in case of error forward) $this->setLogs(); //Check if vital system need is OK $this->checkSystem(); if (!$light) { $this->setBrowserSupport(); } $this->loadSystem(); $this->loadCommonLibraries(); $this->loadDispatcher(); $this->loadHelpers(); $loadmodlsuccess = $this->loadModl(); $this->setTimezone(); $this->setLogLevel(); if ($loadmodlsuccess) { $this->startingSession(); $this->loadLanguage(); } else { throw new Exception('Error loading Modl'); } }
/** * cssファイルの取り込み (自動漢字変換対応) * * @param string $css_file_path cssファイルパス * @return mixed 正常時...ファイル内容/エラー時...FALSE */ function set_css_contents($css_file_path) { $this->css_file_path = $css_file_path; $contents =& implode(NULL, file($css_file_path)); $this->css_file_contents = mb_convert_encoding($contents, mb_internal_encoding(), mb_detect_encoding($contents)); return $this->css_file_contents; }
public function resultAction() { $post = $this->request->getPost(); $email = $post["email"]; $error = array(); if ("" == $email) { array_push($error, "メールアドレスを入力してください"); } else { $pre_user_id = uniqid(rand(100, 999)); $userModel = new Users(); $result = $userModel->addEmail(array($pre_user_id, $email)); if (false == $result) { array_push($error, "データベースに登録できませんでした。"); } else { mb_language("japanese"); mb_internal_encoding("utf-8"); $to = $email; $subject = "seapaメンバー登録URL"; $message = "以下のURLよりメンバー登録を行ってください。\n" . "http://localhost/regist/input/{$pre_user_id}"; $header = "From: mail.seapa@gmail.com"; if (!mb_send_mail($to, $subject, $message, $header, '-f' . '*****@*****.**')) { array_push($error, "メールが送信できませんでした。<a href='http://localhost/regist/input/{$pre_user_id}'>遷移先</a>"); } $this->view->assign('email', $email); } } }
/** * Initialize the Titanium core framework and autoloader * * @access public * @return void */ public static function init() { // Register the framework autoloader spl_autoload_register(array('Titanium', 'auto_loader')); // Set the timezone for the date() functions date_default_timezone_set('America/Chicago'); // Set internal locale setlocale(LC_ALL, 'en_US.utf-8'); // Set internet encoding to utf8 ini_set('default_charset', 'UTF-8'); // Register the script shurdown handler register_shutdown_function(array('Titanium', 'handle_shutdown')); /* set_exception_handler( array('Titanium', 'exception_handler') ); set_error_handler( array('Titanium', 'error_handler') ); */ if (function_exists('mb_internal_encoding')) { mb_internal_encoding('UTF-8'); } self::$is_cli = PHP_SAPI === 'cli'; self::$is_windows = DIRECTORY_SEPARATOR === '\\'; self::load_functions(); }
public function up() { mb_internal_encoding("UTF-8"); $tableOptions = $this->db->driverName === 'mysql' ? 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB' : null; $this->createTable('{{%wysiwyg}}', ['id' => Schema::primaryKey(), 'name' => Schema::string()->notNull(), 'class_name' => Schema::string()->notNull(), 'params' => Schema::text(), 'configuration_model' => Schema::string()], $tableOptions); $this->insert('{{%wysiwyg}}', ['name' => 'Imperavi', 'class_name' => 'vova07\\imperavi\\Widget', 'params' => Json::encode(['settings' => ['replaceDivs' => false, 'minHeight' => 200, 'paragraphize' => false, 'pastePlainText' => true, 'buttonSource' => true, 'imageManagerJson' => Url::to(['/backend/dashboard/imperavi-images-get']), 'plugins' => ['table', 'fontsize', 'fontfamily', 'fontcolor', 'video', 'imagemanager'], 'replaceStyles' => [], 'replaceTags' => [], 'deniedTags' => [], 'removeEmpty' => [], 'imageUpload' => Url::to(['/backend/dashboard/imperavi-image-upload'])]]), 'configuration_model' => 'app\\modules\\core\\models\\WysiwygConfiguration\\Imperavi']); }
/** * Returns the set encoding * * @return string */ public function getEncoding() { if ($this->options['encoding'] === null && function_exists('mb_internal_encoding')) { $this->options['encoding'] = mb_internal_encoding(); } return $this->options['encoding']; }
/** * Fix basic php issues and check version */ function initialBasicFixes() { /** * bypass date & timezone-related warnings with php 5.1 */ if (function_exists('date_default_timezone_set')) { $tz = @date_default_timezone_get(); date_default_timezone_set($tz); } ini_set('zend.ze1_compatibility_mode', 0); ini_set("pcre.backtrack_limit", -1); # fix 5.2.0 prce bug with render_wiki if (function_exists('mb_internal_encoding')) { mb_internal_encoding("UTF-8"); } #ini_set("mbstring.func_overload", 2); /** * add rough php-version check to at least avoid parsing errors. * fine version-check follows further down */ if (phpversion() < "5.0.0") { echo "Sorry, but Streber requires php5 or higher."; exit; } }
/** * Print line in a certain color * Inspired by Garp_Spawn_Util::addStringColoring() * * @param string $s * @param string $color * @return void */ public static function addStringColoring(&$s, $color) { $prevEnc = mb_internal_encoding(); mb_internal_encoding("UTF-8"); $s = "[{$color}m{$s}[0m"; mb_internal_encoding($prevEnc); }
/** * Convert a YAML string to a PHP array. * * @param string $value A YAML string * * @return array A PHP array representing the YAML string */ public static function load($value) { $value = trim($value); if (0 == strlen($value)) { return ''; } if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('ASCII'); } switch ($value[0]) { case '[': $result = self::parseSequence($value); break; case '{': $result = self::parseMapping($value); break; default: $result = self::parseScalar($value); } if (isset($mbEncoding)) { mb_internal_encoding($mbEncoding); } return $result; }
/** * Construct the sanitizer * */ public function __construct() { $this->multibyteSupport = function_exists("mb_strlen"); if ($this->multibyteSupport) { mb_internal_encoding("UTF-8"); } }
public function run() { ignore_user_abort(false); ob_implicit_flush(1); ini_set('implicit_flush', true); cachemgr::init(false); if (strpos(strtolower(PHP_OS), 'win') === 0) { if (function_exists('mb_internal_encoding')) { mb_internal_encoding('UTF-8'); mb_http_output('GBK'); ob_start('mb_output_handler', 2); } elseif (function_exists('iconv_set_encoding')) { iconv_set_encoding('internal_encoding', 'UTF-8'); iconv_set_encoding('output_encoding', 'GBK'); ob_start('ob_iconv_handler', 2); } } if (isset($_SERVER['argv'][1])) { $args = array_shift($_SERVER['argv']); $rst = $this->exec_command(implode(' ', $_SERVER['argv'])); if ($rst === false) { exit(-1); } } else { $this->interactive(); } }