/** * marqueeタグで囲む。 * * DoCoMoの携帯端末の場合はmarqueeを使用しない。 * * @return string 出力 */ function smarty_block_marquee($params, $content, &$smarty, &$repeat) { // {/marquee}の場合のみ出力する。 if ($repeat || !isset($content)) { return null; } // 末尾の改行などを取り除く。 $content = rtrim($content); // marqueeタグを使用しない場合 if (Display::detectDevice() == DEVICE_TYPE_MOBILE && MobileUserAgent::getCarrier() == 'docomo') { return "<div>\n{$content}\n</div>\n"; } return "<marquee>\n{$content}\n</marquee>\n"; }
/** * 絵文字タグを各キャリア用の文字コードに変換する * output buffering 用コールバック関数 * * @param string 入力 * @return string 出力 */ public static function handler($buffer) { return preg_replace_callback('/\\[emoji:(e?\\d+)\\]/', function ($matches) { $index = $matches[1]; $carrier = MobileUserAgent::getCarrier(); if ($carrier === false) { return MOBILE_EMOJI_SUBSTITUTE; } static $arrMap = array(); if (empty($arrMap)) { $arrMap = @(include_once dirname(__FILE__) . "/../../mobile_emoji/mobile_emoji_map_{$carrier}.inc"); } return isset($arrMap[$index]) ? $arrMap[$index] : MOBILE_EMOJI_SUBSTITUTE; }, $buffer); }
/** * 携帯のIDを登録する. * */ public function updatePhoneId() { $this->setValue('phone_id', MobileUserAgent::getId()); }
/** * 画像を端末の解像度に合わせて変換する * output buffering 用コールバック関数 * * @param string 入力 * @return string 出力 */ public static function handler($buffer) { // 端末情報を取得する $carrier = MobileUserAgent::getCarrier(); $model = MobileUserAgent::getModel(); // 携帯電話の場合のみ処理を行う if ($carrier !== FALSE) { // HTML中のIMGタグを取得する $images = array(); $pattern = '/<img\\s+[^<>]*src=[\'"]?([^>"\'\\s]+)[\'"]?[^>]*>/i'; $result = preg_match_all($pattern, $buffer, $images); // 端末の情報を取得する $fp = fopen(MOBILE_IMAGE_INC_REALDIR . "/mobile_image_map_{$carrier}.csv", 'r'); // 取得できない場合は, 入力内容をそのまま返す if ($fp === false) { return $buffer; } while (($data = fgetcsv($fp, 1000, ',')) !== FALSE) { if ($data[1] == $model || $data[1] == '*') { $cacheSize = $data[2]; $imageFileSize = $data[7]; $imageType = $data[6]; $imageWidth = $data[5]; $imageHeight = $data[4]; break; } } fclose($fp); // docomoとsoftbankの場合は画像ファイル一つに利用可能なサイズの上限を計算する // auはHTMLのbyte数上限に画像ファイルサイズが含まれないのでimageFileSizeのまま。 if ($carrier == 'docomo' or $carrier == 'softbank') { if ($result != false && $result > 0) { // 計算式:(利用端末で表示可能なcacheサイズ - HTMLのバイト数 - 変換後の画像名のバイト数(目安値)) / HTML中の画像数 $temp_imagefilesize = ($cacheSize - strlen($buffer) - 140 * $result) / $result; } else { // 計算式:(利用端末で表示可能なcacheサイズ - HTMLのバイト数) $temp_imagefilesize = $cacheSize - strlen($buffer); } // 計算結果が端末の表示可能ファイルサイズ上限より小さい場合は計算結果の値を有効にする if ($temp_imagefilesize < $imageFileSize) { $imageFileSize = $temp_imagefilesize; } } // 画像変換の情報をセットする $imageConverter = new ImageConverter(); $imageConverter->setOutputDir(MOBILE_IMAGE_REALDIR); $imageConverter->setImageType($imageType); $imageConverter->setImageWidth($imageWidth); $imageConverter->setImageHeight($imageHeight); $imageConverter->setFileSize($imageFileSize); // HTML中のIMGタグを変換後のファイルパスに置換する foreach ($images[1] as $key => $path) { // resize_image.phpは除外 if (stripos($path, ROOT_URLPATH . 'resize_image.php') !== FALSE) { continue; } $realpath = html_entity_decode($path, ENT_QUOTES); $realpath = substr_replace($realpath, HTML_REALDIR, 0, strlen(ROOT_URLPATH)); $converted = $imageConverter->execute($realpath); if (isset($converted['outputImageName'])) { $buffer = str_replace($path, MOBILE_IMAGE_URLPATH . $converted['outputImageName'], $buffer); } else { $buffer = str_replace($images[0][$key], '<!--No image-->', $buffer); } } } return $buffer; }
/** * パラメーターから有効なセッションIDを取得する。 * * @return string|false 取得した有効なセッションIDを返す。 * 取得できなかった場合は false を返す。 */ public function getSessionId() { // パラメーターからセッションIDを取得する。 $sessionId = @$_POST[session_name()]; if (!isset($sessionId)) { $sessionId = @$_GET[session_name()]; // AU動画音声ファイルダウンロード対策 // キャリアがAUで、動画、音声ファイルをダウンロードする際に // SESSIONIDの後に余計なパラメータが付与され、セッションが無効になるケースがある if (MobileUserAgent::getCarrier() == 'ezweb') { $idArray = split("\\?", $sessionId); $sessionId = $idArray[0]; } } if (!isset($sessionId)) { $sessionId = $this->getExtSessionId(); } if (!isset($sessionId)) { return false; } // セッションIDの存在をチェックする。 if ($this->sfSessRead($sessionId) === null) { GcUtils::gfPrintLog("Non-existent session id : sid={$sessionId}"); return false; } return session_id($sessionId); }
/** * 会員登録に必要なSQLパラメーターの配列を生成する. * * フォームに入力された情報を元に, SQLパラメーターの配列を生成する. * モバイル端末の場合は, email を email_mobile にコピーし, * mobile_phone_id に携帯端末IDを格納する. * * @param FormParam $objFormParam * @access private * @return $arrResults */ public function lfMakeSqlVal(&$objFormParam) { $arrForm = $objFormParam->getHashArray(); $arrResults = $objFormParam->getDbArray(); // 生年月日の作成 $arrResults['birth'] = Utils::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']); // 仮会員 1 本会員 2 $arrResults['status'] = CUSTOMER_CONFIRM_MAIL == true ? '1' : '2'; /* * secret_keyは、テーブルで重複許可されていない場合があるので、 * 本会員登録では利用されないがセットしておく。 */ $arrResults['secret_key'] = Application::alias('eccube.helper.customer')->sfGetUniqSecretKey(); // 入会時ポイント $CONF = Application::alias('eccube.helper.db')->getBasisData(); $arrResults['point'] = $CONF['welcome_point']; if (Application::alias('eccube.display')->detectDevice() == DEVICE_TYPE_MOBILE) { // 携帯メールアドレス $arrResults['email_mobile'] = $arrResults['email']; // PHONE_IDを取り出す $arrResults['mobile_phone_id'] = MobileUserAgent::getId(); } return $arrResults; }
/** * セッションデータが有効かどうかをチェックする。 * * FIXME '@' でエラーを抑制するのは良くない * * @return boolean セッションデータが有効な場合は true、無効な場合は false を返す。 */ public function lfMobileValidateSession() { // 配列 mobile が登録されているかどうかをチェックする。 if (!is_array(@$_SESSION['mobile'])) { return false; } // 有効期限を過ぎていないかどうかをチェックする。 if (intval(@$_SESSION['mobile']['expires']) < time()) { $msg = 'Session expired at ' . date('Y/m/d H:i:s', @$_SESSION['mobile']['expires']) . ' : sid=' . session_id(); GcUtils::gfPrintLog($msg); return false; } // 携帯端末の機種が一致するかどうかをチェックする。 $model = MobileUserAgent::getModel(); if (@$_SESSION['mobile']['model'] != $model) { $msg = 'User agent model mismatch : ' . '"$model" != "' . @$_SESSION['mobile']['model'] . '" (expected), sid=' . session_id(); GcUtils::gfPrintLog($msg); return false; } return true; }
/** * 特定キャリア(AU)モバイルダウンロード処理 * キャリアがAUのモバイル端末からダウンロードする場合は単純に * Aタグでダウンロードできないケースがある為、対応する。 * * @param $arrOrderDetail 購入履歴の配列 */ public function lfSetAU($arrOrderDetails) { $this->isAU = false; // モバイル端末かつ、キャリアがAUの場合に処理を行う if (Application::alias('eccube.display')->detectDevice() == DEVICE_TYPE_MOBILE && MobileUserAgent::getCarrier() == 'ezweb') { // MIMETYPE、ファイル名のセット $this->tpl_arrOrderDetail = $this->lfSetMimetype($arrOrderDetails); // @deprecated 2.12.0 PHP 定数 SID を使うこと $this->phpsessid = $_GET['PHPSESSID']; $this->isAU = true; } }
/** * 携帯端末IDを使用して会員を検索し、パスワードの照合を行う。 * パスワードが合っている場合は会員情報を取得する。 * * @param string $pass パスワード * @return boolean 該当する会員が存在し、パスワードが合っている場合は true、 * それ以外の場合は false を返す。 */ public function getCustomerDataFromMobilePhoneIdPass($pass) { //docomo用にデータを取り出す。 if (MobileUserAgent::getCarrier() == 'docomo') { if ($_SESSION['mobile']['phone_id'] == '' && strlen($_SESSION['mobile']['phone_id']) == 0) { $_SESSION['mobile']['phone_id'] = MobileUserAgent::getId(); } } if (!isset($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) { return false; } // 携帯端末IDが一致し、本登録された会員を検索する。 $sql = 'SELECT * FROM dtb_customer WHERE mobile_phone_id = ? AND del_flg = 0 AND status = 2'; $objQuery = Application::alias('eccube.query'); @(list($data) = $objQuery->getAll($sql, array($_SESSION['mobile']['phone_id']))); // パスワードが合っている場合は、会員情報をcustomer_dataに格納してtrueを返す。 if (Utils::sfIsMatchHashPassword($pass, $data['password'], $data['salt'])) { $this->customer_data = $data; $this->startSession(); return true; } return false; }
/** * Page のResponse. * * todo たいした処理でないのに異常に処理が重い * @return void */ public function sendResponse() { // TODO sendResponseをオーバーライドしている為、afterフックポイントが実行されない.直接実行する.(#1790) $objPlugin = PluginHelper::getSingletonInstance($this->plugin_activate_flg); $objPlugin->doAction('LC_Page_Mypage_DownLoad_action_after', array($this)); $this->objDisplay->noAction(); // パラメーター取得 $customer_id = $_SESSION['customer']['customer_id']; $order_id = $_GET['order_id']; $product_class_id = $_GET['product_class_id']; //DBから商品情報の読込 $arrForm = $this->lfGetRealFileName($customer_id, $order_id, $product_class_id); //ファイル情報が無い場合はNG if ($arrForm['down_realfilename'] == '') { Utils::sfDispSiteError(DOWNFILE_NOT_FOUND, '', true); } //ファイルそのものが無い場合もとりあえずNG $realpath = DOWN_SAVE_REALDIR . $arrForm['down_realfilename']; if (!file_exists($realpath)) { Utils::sfDispSiteError(DOWNFILE_NOT_FOUND, '', true); } //ファイル名をエンコードする Safariの対策はUTF-8で様子を見る $encoding = 'Shift_JIS'; if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari')) { $encoding = 'UTF-8'; } $sdown_filename = mb_convert_encoding($arrForm['down_filename'], $encoding, 'auto'); // flushなどを利用しているので、現行のDisplayは利用できません。 // DisplayやResponseに大容量ファイルレスポンスが実装されたら移行可能だと思います。 // ダウンロード実行 モバイル端末はダウンロード方法が異なる if (Application::alias('eccube.display')->detectDevice() == DEVICE_TYPE_MOBILE) { // キャリアがAUのモバイル端末はさらにダウンロード方法が異なる if (MobileUserAgent::getCarrier() == 'ezweb') { // AUモバイル $this->lfMobileAuDownload($realpath, $sdown_filename); } else { // AU以外のモバイル $this->lfMobileDownload($realpath, $sdown_filename); } } else { // PC、スマフォ $this->lfDownload($realpath, $sdown_filename); } }