/** * mod_ktai コードをデコード (サブ関数) by nao-pon * * @param string $match * @return string */ function _decodeModKtai($match) { if ($match[1]) { if ($this->to !== 'COMMON' && strtolower(substr($match[1], 0, 9)) === '<textarea') { $carrier = ''; switch ($this->to) { case MPC_TO_FOMA: $carrier = MPC_FROM_FOMA; break; case MPC_TO_EZWEB: $carrier = MPC_FROM_EZWEB; break; case MPC_TO_SOFTBANK: $carrier = MPC_FROM_SOFTBANK; break; } if ($carrier) { $mpc = MobilePictogramConverter::factory($match[1], $carrier, $this->from_charset, MPC_FROM_OPTION_MODKTAI); return $mpc->autoConvert(); } } return $match[0]; } if (isset($match[4])) { $emj_table = 'emj2i_table'; $match[2] = 'i'; if (!empty($match[5])) { switch (strtolower($match[5])) { case 'sb': $emj_table = 'emj2s_table'; $match[2] = 's'; break; case 'ez': $emj_table = 'e2icon_table'; $match[2] = 'e'; break; default: $emj_table = 'emj2i_table'; $match[2] = 'i'; } } if (empty($this->{$emj_table})) { require 'map/' . $emj_table . '.php'; } $_table = $this->{$emj_table}; if (!isset($_table[$match[4]])) { return $match[0]; } $match[3] = $match[2] === 'e' ? dechex($_table[$match[4]]) : $_table[$match[4]]; /* if ($this->emj_to === 's') { if (empty($this->i2s_table)) { require 'map/i2s_table.php'; } $match[2] = 's'; $match[3] = dechex($this->i2s_table[hexdec($match[3])]); } else if ($this->emj_to === 'e') { if (empty($this->i2e_table)) { require 'map/i2e_table.php'; } if (empty($this->e2icon_table)) { require 'map/e2icon_table.php'; } $match[2] = 'e'; $match[3] = dechex($this->e2icon_table[$this->i2e_table[hexdec($match[3])]]); } */ } $mode = strtolower($match[2]); if ($mode === 'v') { $mode = 's'; } // ezweb convert to icon number $dec = HexDec($match[3]); if ($mode === 'e') { if (empty($this->e2icon_table)) { require 'map/e2icon_table.php'; } $dec = intval(array_search($dec, $this->e2icon_table)); } $_dec = $dec; //exists check switch ($mode) { case 'i': $table = $mode . '2e_table'; break; case 's': $table = $mode . '2e_table'; break; case 'e': $table = $mode . '2s_table'; break; } if (empty($this->{$table})) { require 'map/' . $table . '.php'; } $table_array =& $this->{$table}; if (!isset($table_array[$dec])) { return $match[0]; } // set convert table $table = ''; switch ($this->to) { case MPC_TO_FOMA: if ($mode !== 'i') { $table = $mode . '2i_table'; } $decode_func = 'i_options_encode'; break; case MPC_TO_SOFTBANK: if ($mode !== 's') { $table = $mode . '2s_table'; } $decode_func = 's_options_encode'; break; case MPC_TO_EZWEB: if ($mode !== 'e') { $table = $mode . '2e_table'; } $decode_func = 'e_options_encode'; break; default: $decode_func = $mode . '_options_encode'; } // convert if ($table) { if (empty($this->{$table})) { require 'map/' . $table . '.php'; } $table_array =& $this->{$table}; $dec = isset($table_array[$dec]) ? $table_array[$dec] : FALSE; } // show image if nonexist $_option = ''; if (!is_numeric($dec)) { $dec = $_dec; $_option = $this->getOption(); $this->setOption(MPC_TO_OPTION_IMG); $decode_func = $mode . '_options_encode'; } // decode $ret = $this->{$decode_func}($dec); if ($_option) { $this->setOption($_option); } return $ret; }
function mobileEmojiConverter($buffer) { require_once DIR_FS_CATALOG . '/includes/classes/MobilePictogramConverter/MobilePictogramConverter.php'; $mec =& MobilePictogramConverter::factory($buffer, MPC_FROM_FOMA, MPC_FROM_CHARSET_SJIS, MPC_FROM_OPTION_WEB); if (is_object($mec) == false) { die($mec); } return $mec->autoConvert(); }
function _modKtaiEmojiEncode($vars) { if (!defined('HYP_POST_ENCODING')) { return $vars; } if (is_array($vars)) { foreach ($vars as $key => $var) { $vars[$key] = $this->_modKtaiEmojiEncode($var); } return $vars; } static $mpc; static $to; static $euc = FALSE; $to = $mpc = NULL; if (is_null($mpc)) { if (!XC_CLASS_EXISTS('MobilePictogramConverter')) { HypCommonFunc::loadClass('MobilePictogramConverter'); } $carrier = ''; $mpc = ''; $from_encode = ''; switch (HYP_POST_ENCODING) { case 'UTF-8': case 'UTF_8': case 'UTF8': $from_encode = MPC_FROM_CHARSET_UTF8; break; case 'SJIS': case 'SHIFT-JIS': case 'SHIFT_JIS': case 'SJIS-WIN': $from_encode = MPC_FROM_CHARSET_SJIS; break; case 'EUCJP-WIN': case 'EUC-JP': $euc = TRUE; $from_encode = MPC_FROM_CHARSET_SJIS; // fake // EUC-JP なフォームからで絵文字が化けている場合に備えて除去。結果的に絵文字対応できない。 $vars = preg_replace('/[\\x00-\\x08\\x0b-\\x0c\\x0e\\x10-\\x1a\\x1c-\\x1f\\x7f]+/', '', $vars); if ($vars !== $vars) { $from_encode = ''; } break; } if ($from_encode) { $check = ''; if (defined('HYP_K_TAI_RENDER') && HYP_K_TAI_RENDER) { $check = $this->HypKTaiRender->vars['ua']['carrier']; } else { $ua = $_SERVER['HTTP_X_ORIGINAL_USER_AGENT']; if (preg_match('#(?:(SoftBank|Vodafone|J-PHONE)|(DoCoMo)|(UP\\.Browser))#i', $ua, $match)) { if (!empty($match[1])) { $check = 'softbank'; } else { if (!empty($match[2])) { $check = 'docomo'; } else { $check = 'au'; } } } } switch ($check) { case 'docomo': $to = MPC_TO_FOMA; $carrier = MPC_FROM_FOMA; break; case 'softbank': $to = MPC_TO_SOFTBANK; $carrier = MPC_FROM_SOFTBANK; break; case 'au': $to = MPC_TO_EZWEB; $carrier = MPC_FROM_EZWEB; break; default: $carrier = ''; } if ($carrier) { $mpc =& MobilePictogramConverter::factory('', $carrier, $from_encode, MPC_FROM_OPTION_RAW); } } } if (!$mpc || !$vars) { return $vars; } if ($euc) { return $mpc->euc2ktaimod($vars); } else { $mpc->setString($vars); return $mpc->Convert($to, MPC_TO_OPTION_MODKTAI); } }