예제 #1
0
파일: tell.php 프로젝트: rrrz/fuzzy-search
 /**
  * 事前処理関数をオーバーライド
  * 
  * ハイフンと類似する文字をハイフンに変換
  * 文字列をすべて半角に変換
  * 空白は連続を除去する
  */
 protected static function normalize($str = '')
 {
     $str = mb_convert_kana($str, 'anhks');
     $str = self::unificate_hyphen($str, '-');
     $str = parent::normalize($str);
     return $str;
 }
예제 #2
0
 function mailaddress_check($form, $error = null)
 {
     if (isset($_POST['mailaddress1'])) {
         $_POST['mailaddress1'] = mb_convert_kana($_POST['mailaddress1'], "a");
         $emailcheck = $this->mail_check1($_POST['mailaddress1']);
         if (empty($emailcheck)) {
             $error['mailaddress1'] = "wrong";
             //Form Data is wrong = ErrorMessage
         }
     }
     if (isset($_POST['mailaddress2'])) {
         $_POST['mailaddress2'] = mb_convert_kana($_POST['mailaddress2'], "a");
         $emailcheck = $this->mail_check1($_POST['mailaddress2']);
         if (empty($emailcheck)) {
             $error['mailaddress2'] = "wrong";
             //Form Data is "wrong" = ErrorMessage
         }
     }
     if (isset($_POST['mailaddress1'], $_POST['mailaddress2'])) {
         $emailcheck = $this->check2($_POST['mailaddress1'], $_POST['mailaddress2']);
         if (empty($emailcheck)) {
             $error['mailaddress2'] = "different";
             //Form Data is "different" = ErrorMessage
         }
     }
     return $error;
 }
예제 #3
0
function datetime_implode($year, $mon, $day, $hour, $min)
{
    if (($year === "" || is_null($year)) && ($mon === "" || is_null($mon)) && ($day === "" || is_null($day)) && ($hour === "" || is_null($hour)) && ($min === "" || is_null($min))) {
        return null;
    }
    return mb_convert_kana("{$year}-{$mon}-{$day} {$hour}:{$min}:0", "n", 'UTF-8');
}
예제 #4
0
function get_nextBody($aTyp, $aCt)
{
    $clsConst = new AppConst();
    $ret = "";
    $iCt = 0;
    $buffTyp = "";
    $buffCt = "";
    if ($aTyp < $clsConst->mTYP_Date) {
        $iCt = $aTyp + 1;
        $buffTyp = getZeroStr($iCt, 2);
        $buffCt = getZeroStr("00", 2);
        switch ($aTyp) {
            case 1:
                $ret = $buffTyp . $buffCt . $clsConst->mMSG_Const;
                break;
            case 2:
                $sHH = date("H");
                $sMM = date("i");
                $sHH = mb_convert_kana($sHH, 'KVRN', "UTF-8");
                $sMM = mb_convert_kana($sMM, 'KVRN', "UTF-8");
                $ret = $buffTyp . $buffCt . "じかん " . $sHH . ":" . $sMM;
                break;
        }
    } else {
        $sMM = date("m");
        $sDD = date("d");
        $sMM = mb_convert_kana($sMM, 'KVRN', "UTF-8");
        $sDD = mb_convert_kana($sDD, 'KVRN', "UTF-8");
        $buffTyp = getZeroStr($clsConst->mTYP_Kotei, 2);
        $buffCt = getZeroStr("00", 2);
        $ret = $buffTyp . $buffCt . "ひづけ " . $sMM . "ー" . $sDD;
    }
    return $ret;
}
예제 #5
0
 public function convInt($arg)
 {
     // 全角数字や他文字を半角数字に変換
     // mb_convert_kana($arg, 'a', 'UTF-8') 全角数字を半角数字に
     // mb_ereg_replace('[^0-9]', '', foo)  半角数字以外を削除
     return mb_ereg_replace('[^0-9]', '', mb_convert_kana($arg, 'a', 'UTF-8'));
 }
예제 #6
0
 /**
  * アバター自動生成処理
  *
  * @param Model $model ビヘイビア呼び出し元モデル
  * @param array $user ユーザデータ配列
  * @return mixed On success Model::$data, false on failure
  * @throws InternalErrorException
  */
 public function createAvatarAutomatically(Model $model, $user)
 {
     //imagickdraw オブジェクトを作成します
     $draw = new ImagickDraw();
     //文字色のセット
     $draw->setfillcolor('white');
     //フォントサイズを 160 に設定します
     $draw->setFontSize(140);
     //テキストを追加します
     $draw->setFont(CakePlugin::path($model->plugin) . 'webroot' . DS . 'fonts' . DS . 'ipaexg.ttf');
     $draw->annotation(19, 143, mb_substr(mb_convert_kana($user['User']['handlename'], 'KVA'), 0, 1));
     //新しいキャンバスオブジェクトを作成する
     $canvas = new Imagick();
     //ランダムで背景色を指定する
     $red1 = strtolower(dechex(mt_rand(3, 12)));
     $red2 = strtolower(dechex(mt_rand(0, 15)));
     $green1 = strtolower(dechex(mt_rand(3, 12)));
     $green2 = strtolower(dechex(mt_rand(0, 15)));
     $blue1 = strtolower(dechex(mt_rand(3, 12)));
     $blue2 = strtolower(dechex(mt_rand(0, 15)));
     $canvas->newImage(179, 179, '#' . $red1 . $red2 . $green1 . $green2 . $blue1 . $blue2);
     //ImagickDraw をキャンバス上に描画します
     $canvas->drawImage($draw);
     //フォーマットを PNG に設定します
     $canvas->setImageFormat('png');
     App::uses('TemporaryFolder', 'Files.Utility');
     $folder = new TemporaryFolder();
     $filePath = $folder->path . DS . Security::hash($user['User']['handlename'], 'md5') . '.png';
     $canvas->writeImages($filePath, true);
     return $filePath;
 }
 public function beforeSave($options = array())
 {
     if (isset($this->data['Mypage']['password'])) {
         $passwordHasher = new SimplePasswordHasher();
         $this->data['Mypage']['password'] = $passwordHasher->hash($this->data['Mypage']['password']);
     }
     //nameを使わず、name_1_2に分ける場合、合体させる
     if (isset($this->data['Mypage']['name_1'])) {
         if (isset($this->data['Mypage']['name_2'])) {
             $this->data['Mypage']['name'] = $this->data['Mypage']['name_1'] . ' ' . $this->data['Mypage']['name_2'];
         } else {
             $this->data['Mypage']['name'] = $this->data['Mypage']['name_1'];
         }
     }
     //telを使わず、tel_1_2_3に分ける場合、合体させる
     if (isset($this->data['Mypage']['tel_1'])) {
         $tel = $this->data['Mypage']['tel_1'] . $this->data['Mypage']['tel_2'] . $this->data['Mypage']['tel_3'];
         $tel = mb_convert_kana($tel, "n");
         $tel = mb_ereg_replace('[^0-9]', '', $tel);
         if (!empty($tel)) {
             $this->data['Mypage']['tel'] = $tel;
         }
     }
     return true;
 }
예제 #8
0
 /**
  * tokenチェック
  */
 protected function tokenValidate($name = 'token')
 {
     $request = Request::getInstance();
     $value = $request->get($name, '');
     $value = mb_convert_kana($value, 'n');
     return Session::remove($name) == $value ? null : __('Token authentication is invalid');
 }
 /**
  * [ADMIN] サジェスト設定
  *
  * @return	void
  * @access	public
  */
 public function admin_index()
 {
     $this->pageTitle = 'サジェスト設定';
     if (!$this->request->data) {
         $this->request->data['SuggestConfig'] = $this->SuggestConfig->findExpanded();
     } else {
         $this->request->data['SuggestConfig']['exclude_keywords'] = mb_convert_kana(strtolower($this->request->data['SuggestConfig']['exclude_keywords']), 'a', Configure::read('App.encoding'));
         $this->SuggestConfig->set($this->request->data);
         if ($this->SuggestConfig->validates()) {
             $this->SuggestConfig->saveKeyValue($this->request->data);
             // 除外キーワードを削除
             if ($this->request->data['SuggestConfig']['exclude_keywords']) {
                 $excludeKeywords = array();
                 $excludeKeywords = explode(',', $this->request->data['SuggestConfig']['exclude_keywords']);
                 $conditions = array();
                 foreach ($excludeKeywords as $key => $value) {
                     $conditions['or'][$key] = array('SuggestKeyword.name LIKE' => "%{$value}%");
                 }
                 $suggestKeywords = $this->SuggestKeyword->find('all', array('fields' => array('SuggestKeyword.id'), 'conditions' => $conditions));
                 foreach ($suggestKeywords as $suggestKeyword) {
                     $this->SuggestKeyword->del($suggestKeyword['SuggestKeyword']['id']);
                 }
             }
             $this->setMessage('サジェスト設定を保存しました。');
             $this->redirect('index');
         } else {
             $this->setMessage('入力エラーです。内容を修正してください。', true);
         }
     }
 }
예제 #10
0
 /**
  * afterLayout
  *
  * @return void
  */
 public function afterLayout($layoutFile)
 {
     /* 出力データをSJISに変換 */
     $View = $this->_View;
     if (isset($this->request->params['ext']) && $this->request->params['ext'] == 'rss') {
         $rss = true;
     } else {
         $rss = false;
     }
     $site = BcSite::findCurrent(true);
     if (!$rss && $site && $site->device == 'mobile' && $View->layoutPath != 'Emails' . DS . 'text') {
         $View->output = str_replace('&', '&amp;', $View->output);
         $View->output = str_replace('<', '&lt;', $View->output);
         $View->output = str_replace('>', '&gt;', $View->output);
         $View->response->charset('Shift_JIS');
         $View->output = mb_convert_kana($View->output, "rak", "UTF-8");
         $View->output = mb_convert_encoding($View->output, "SJIS-win", "UTF-8");
         // 内部リンクの自動変換
         if ($site->autoLink) {
             $currentAlias = $this->request->params['Site']['alias'];
             // 一旦プレフィックスを除外
             $reg = '/href="' . preg_quote(BC_BASE_URL, '/') . '(' . $currentAlias . '\\/([^\\"]*?))\\"/';
             $View->output = preg_replace_callback($reg, array($this, '_removeMobilePrefix'), $View->output);
             // プレフィックス追加
             $reg = '/href=\\"' . preg_quote(BC_BASE_URL, '/') . '([^\\"]*?)\\"/';
             $View->output = preg_replace_callback($reg, array($this, '_addMobilePrefix'), $View->output);
         }
         // XMLとして出力する場合、デバッグモードで出力する付加情報で、
         // ブラウザによってはXMLパースエラーとなってしまうので強制的にデバッグモードをオフ
         Configure::write('debug', 0);
     }
 }
예제 #11
0
 /**
  * あいまい検索用正規表現の集合体を取得する。
  *
  * @param string    もとになるキーワード
  * @return    array(string)    あいまい検索用正規表現を集めた配列
  */
 static function makefuzzyexplist($key)
 {
     //仮名は全角カタカナに、英数字・空白文字は半角に、 濁点付きの文字を一文字に、記号は全角に。
     $_key = mb_strtolower(mb_convert_kana($key, 'KVCas'));
     foreach (self::$han2zen_mark_table as $han => $zen) {
         $_key = mb_ereg_replace(mb_ereg_quote($han), $zen, $_key);
     }
     //2文字以上での表現を1文字にする
     foreach (self::$two2one as $from => $to) {
         $_key = mb_ereg_replace($from, $to, $_key);
     }
     //文字により削除(表記ゆれまたはごみ)
     $_key = mb_ereg_replace('[ッー・゛゜、。]', '', $_key);
     //異体文字に対応する。
     $char = array();
     $len = mb_strlen($_key);
     for ($i = 0; $i < $len; $i++) {
         $c = mb_substr($_key, $i, 1);
         $char[] = isset($GLOBALS['itaimojitable'][$c]) ? $GLOBALS['itaimojitable'][$c] : mb_ereg_quote($c);
     }
     //ちょっと違う単語を許すようにする
     $list = self::makeagrepexplist($char);
     //表記ゆれになる文字を挟み込む
     $ret = array();
     foreach ($list as $a) {
         $ret[] = join('[・ーー]?', $a);
     }
     return $ret;
 }
 public function get($zip = null, $ken_furi = null, $city_furi = null, $town_furi = null)
 {
     $addr = new Models\Address();
     /** @var \Illuminate\Database\Query\Builder $q */
     $q = $addr->newQuery();
     $decoded_zip = Models\Address::processZip($zip);
     $q->orWhere('zip', '=', $decoded_zip);
     foreach (['ken_furi', 'city_furi', 'town_furi'] as $col) {
         Models\Address::filterQueryFuri(${$col}, $q, $col);
     }
     /** @var \Illuminate\Database\Eloquent\Collection|static[] $results */
     $columns = ['ken_id', 'zip', 'ken_name', 'ken_furi', 'city_name', 'city_furi', 'town_name', 'town_furi', 'kyoto_street', 'block_name', 'office_name', 'office_address'];
     $results = $q->take(10)->get($columns);
     // NULLのフィールドを省略
     $resultsArray = array_map(function ($result) use($columns) {
         foreach ($columns as $col) {
             if (array_key_exists($col, $result) && ($result[$col] === 'NULL' || trim(mb_convert_kana($result[$col], 's')) === '')) {
                 unset($result[$col]);
             }
         }
         return $result;
     }, $results->toArray());
     $date = date('Y/m/d H:i:s');
     return $results->count() > 0 ? response()->json(['error' => 'success', 'date' => $date, 'count' => $results->count(), 'results' => $resultsArray]) : response()->json(['error' => 'error', 'date' => $date, 'count' => 0]);
 }
 function afterLayout()
 {
     $view =& ClassRegistry::getObject('view');
     mb_internal_encoding('UTF-8');
     $view->output = mb_convert_kana($view->output, 'k');
     $view->output = mb_convert_encoding($view->output, 'SJIS', 'UTF-8');
 }
예제 #14
0
 /**
  * 事前処理関数をオーバーライド
  * 
  * 空白以外の文字列を全角に変換
  * 空白は連続を除去して半角に変換
  */
 protected static function normalize($str = '')
 {
     $str = mb_convert_kana($str, 'AKV');
     $str = mb_convert_kana($str, 's');
     $str = parent::normalize($str);
     return $str;
 }
function mb_convert_kana_deep($str, $option = 'sa', $encoding = 'utf-8')
{
    if (is_array($str)) {
        return array_map(__FUNCTION__, $str, array($option, $encoding));
    }
    return mb_convert_kana($str, $option, $encoding);
}
예제 #16
0
 public function index()
 {
     $tags = array();
     if (!empty($this->data['Study']['search'])) {
         $tags = mb_convert_kana(mb_trim($this->data['Study']['search']), 'as');
         $tags = preg_replace('!\\s+!', ' ', $tags);
         $this->passedArgs['tags'] = urlencode($tags);
     }
     if (!empty($this->passedArgs['tags'])) {
         $tags = urldecode($this->passedArgs['tags']);
         $this->data['Study']['search'] = $tags;
         $tags = explode(' ', $tags);
     }
     $ids = null;
     foreach ($tags as $key => $tag) {
         if (is_null($ids)) {
             $conditions = array('LOWER(Tag.tag) LIKE' => strtolower($tag));
         } else {
             $conditions = array('LOWER(Tag.tag) LIKE' => strtolower($tag), 'StudiesTag.study_id' => $ids);
         }
         $joins = array(array('table' => 'tags', 'alias' => 'Tag', 'type' => 'INNER', 'conditions' => array('StudiesTag.tag_id = Tag.id')));
         $fields = array('id', 'study_id');
         $ids = $this->Study->StudiesTag->find('list', compact('conditions', 'joins', 'fields'));
     }
     $this->paginate = array('foreignKey' => false, 'order' => array('study_date' => 'desc'), 'contain' => array('User', 'Tag'));
     if (!is_null($ids)) {
         $this->paginate['conditions'] = array('Study.id' => $ids);
     }
     $this->set('studies', $this->paginate());
 }
예제 #17
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objView = new SC_SiteView_Ex(false);
     // 入力エラーチェック
     $arrErr = $this->fnErrorCheck($_GET);
     // 入力エラーの場合は終了
     if (count($arrErr) > 0) {
         $tpl_message = "";
         foreach ($arrErr as $key => $val) {
             $tpl_message .= preg_replace("/<br \\/>/", "\n", $val);
         }
         echo $tpl_message;
         // エラー無し
     } else {
         // 郵便番号検索文作成
         $zipcode = $_GET['zip1'] . $_GET['zip2'];
         $zipcode = mb_convert_kana($zipcode, 'n');
         // 郵便番号検索
         $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode);
         // 郵便番号が発見された場合
         if (!empty($arrAdsList)) {
             $data = $arrAdsList[0]['state'] . "|" . $arrAdsList[0]['city'] . "|" . $arrAdsList[0]['town'];
             echo $data;
             // 該当無し
         } else {
             echo "該当する住所が見つかりませんでした。";
         }
     }
 }
예제 #18
0
function decode_date($japanesedatetime)
{
    $japanesedatetime = mb_convert_kana($japanesedatetime, "n");
    $y = "(20[0-9]+)年";
    $m = "(0?[1-9]|1[012])月";
    $d = "(0?[1-9]|[12][0-9]|3[01])日";
    $t = "(\\d{2}):(\\d{2})";
    $ignore = '.*?';
    $japanese_datetime_regex = '#' . $y . $m . $d . $ignore . $t . '#uims';
    $japanese_date_regex = '#' . $m . $d . '#uims';
    $year = $month = $day = $hour = $minute = 0;
    $hour = '00';
    $minute = '00';
    if (preg_match_all($japanese_datetime_regex, $japanesedatetime, $footprints) > 0) {
        $year = $footprints[1][0];
        $month = $footprints[2][0];
        $day = $footprints[3][0];
        $hour = $footprints[4][0];
        $minute = $footprints[5][0];
    } elseif (preg_match_all($japanese_date_regex, $japanesedatetime, $footprints) > 0) {
        $year = date('Y');
        $month = $footprints[1][0];
        $day = $footprints[2][0];
    } else {
        return $japanesedatetime;
    }
    return $year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute;
}
예제 #19
0
 public function beforeValidate()
 {
     parent::beforeValidate();
     if (isset($this->data[$this->alias]['url']) && !isset($this->data[$this->alias]['study_name'])) {
         $this->data[$this->alias]['study_name'] = $this->getTitle($this->data[$this->alias]['url']);
     }
     if (isset($this->data[$this->alias]['tag_list'])) {
         preg_match_all('/\\[([^\\]]*)\\]/', $this->data[$this->alias]['tag_list'], $matches);
         if (isset($matches[1])) {
             $this->data['Tag']['Tag'] = array();
             foreach ($matches[1] as $tag) {
                 $tagValue = mb_convert_kana($tag, 'as');
                 $conditions = array('LOWER(Tag.tag)' => strtolower($tagValue));
                 $this->Tag->contain();
                 $this->Tag->foreignKey();
                 $tag_id = $this->Tag->field('id', $conditions);
                 if (!$tag_id) {
                     $data = array('Tag' => array('tag' => $tagValue));
                     $this->Tag->create();
                     if (!$this->Tag->save($data)) {
                         return false;
                     }
                     $tag_id = $this->Tag->getInsertID();
                 }
                 $this->data['Tag']['Tag'][] = $tag_id;
             }
         }
         unset($this->data[$this->alias]['tag_list']);
     }
     return true;
 }
예제 #20
0
 /**
  * Invokes the plugin specific code.
  *
  * Converts Japanese JIS X0208 kana to JIS X0201 kana.
  *
  * @param string $buffer
  * @return string
  */
 function invoke($buffer)
 {
     if ($this->_getConfiguration('enabled')) {
         return mb_convert_kana($buffer, 'k');
     }
     return $buffer;
 }
예제 #21
0
 function _hankaku($output)
 {
     // 連続する半角スペースを半角スペース1としてカウント
     //$output = preg_replace('!\s+!', ' ', $output);
     // 全角を半角に変換
     $output = mb_convert_kana($output, 'rank');
     return $output;
 }
예제 #22
0
파일: setting.php 프로젝트: hiro1173/legacy
 function xoops_language_trim($text)
 {
     if (function_exists('mb_convert_kana')) {
         $text = mb_convert_kana($text, 's');
     }
     $text = trim($text);
     return $text;
 }
 /**
  * Test for PMA_Kanji_strConv
  *
  * @return void
  * @test
  */
 public function testStrConv()
 {
     $this->assertEquals('test', PMA_Kanji_strConv('test', '', ''));
     $GLOBALS['kanji_encoding_list'] = 'ASCII,SJIS,EUC-JP,JIS';
     $this->assertEquals('test è', PMA_Kanji_strConv('test è', '', ''));
     $this->assertEquals(mb_convert_encoding('test è', 'ASCII', 'SJIS'), PMA_Kanji_strConv('test è', 'ASCII', ''));
     $this->assertEquals(mb_convert_kana('全角', 'KV', 'SJIS'), PMA_Kanji_strConv('全角', '', 'kana'));
 }
예제 #24
0
 public static function tel($text, $phone = null, $options = [])
 {
     $phone = $phone === null ? $text : $phone;
     $phone = mb_convert_kana($phone, 'a', 'UTF-8');
     $phone = preg_replace('~[^+0-9]+~', '', $phone);
     $options['href'] = 'tel:' . $phone;
     return \yii\helpers\Html::tag('a', $text, $options);
 }
 private function editSummonerName($summonerName)
 {
     $tmp = htmlentities($summonerName, ENT_QUOTES, "UTF-8");
     $tmp = mb_convert_kana($tmp, 'as');
     $tmp = strtolower($tmp);
     $tmp = str_replace(" ", "", $tmp);
     return $tmp;
 }
예제 #26
0
 /**
  * Build array of hiragana chars for furigana.
  *
  * @param array $wordChars
  * @param array $katakanaChars
  *
  * @return array
  */
 private function buildHiraganaChars(array $wordChars, array $katakanaChars)
 {
     $results = [];
     foreach (array_diff($katakanaChars, $wordChars) as $key => $value) {
         $results[$key] = mb_convert_kana($value, 'c');
     }
     return $results;
 }
예제 #27
0
 function validCaptcha($data)
 {
     $check = current($data);
     $check = mb_convert_kana($check, 'a');
     if (empty($this->answerCaptcha)) {
         return false;
     }
     return $check == $this->answerCaptcha;
 }
예제 #28
0
 /**
  * Get romaji string for results.
  *
  * @param RomajiConverter $converter
  * @param LimelightResults $results
  *
  * @return string
  */
 protected function getRomajiConversion($converter, $results)
 {
     $conversion = '';
     foreach ($results as $word) {
         $reading = mb_convert_kana($word->reading, 'c');
         $conversion .= $converter->handle($reading, $word);
     }
     return $conversion;
 }
예제 #29
0
 public function beforeValidate()
 {
     if (isset($this->data['Post']['subject'])) {
         $this->data['Post']['subject'] = mb_convert_kana($this->data['Post']['subject'], 'KV');
     }
     if (isset($this->data['Post']['body'])) {
         $this->data['Post']['body'] = mb_convert_kana($this->data['Post']['body'], 'KV');
     }
 }
예제 #30
0
function wpcf7_canonicalize($text)
{
    if (function_exists('mb_convert_kana') && 'UTF-8' == get_option('blog_charset')) {
        $text = mb_convert_kana($text, 'asKV', 'UTF-8');
    }
    $text = strtolower($text);
    $text = trim($text);
    return $text;
}