/** * Browser detection */ private function _is_keitai() { $agent = Net_UserAgent_Mobile::singleton(); switch( true ) { case ($agent->isDoCoMo()): // DoCoMoかどうか return true; if( $agent->isFOMA() ) return true; break; case ($agent->isVodafone()): // softbankかどうか return true; if( $agent->isType3GC() ) return true; break; case ($agent->isEZweb()): // ezwebかどうか return true; if( $agent->isWIN() ) return true; break; default: return false; break; } }
function from_tumblr() { global $sessionkey; $db = get_db_connectiuon(); list($sessionkey, $cookies, $u) = get_login_cookie($db); $page = getPage(); $agent = Net_UserAgent_Mobile::singleton(); // paging a page if ($agent->isDoCoMo()) { $page = ceil($page / 2); } //$postid = getPostId(); $url = 'http://www.tumblr.com/dashboard/'; if ($page > 1) { $url .= $page; } if ($postid > 1) { $url .= "/{$postid}"; } #print "<!--$url-->"; $retry = 2; while ($retry--) { $req =& new HTTP_Request($url); $req->setMethod(HTTP_REQUEST_METHOD_GET); foreach ($cookies as $v) { $req->addCookie($v['name'], $v['value']); } if (PEAR::isError($req->sendRequest())) { $err = 1; } $code = $req->getResponseCode(); if ($code == 302) { $err = true; if ($u['email']) { list($err, $cookies) = update_cookie_info($u['email'], $u['password'], true, $u['hash']); } if ($err) { $retry = 0; break; } } else { if ($code == 200) { return $req->getResponseBody(); } else { print '<html><body><pre>x_x'; print " {$code} "; print '</body></html>'; exit; } } } if ($retry == 0) { header('Location: /login'); } else { print '<html><body><pre>x_x'; print '</body></html>'; } exit; }
function __construct($content) { $html = $this->wash($content); $dom = new DOMDocument(); $dom->loadXML($html); $this->dom = $dom; $this->agent = Net_UserAgent_Mobile::singleton(); }
protected function __construct() { require_once 'Net/UserAgent/Mobile.php'; self::$mobile = Net_UserAgent_Mobile::factory(); if (self::$mobile instanceof Net_UserAgent_Mobile_Error) { self::$mobile = new Net_UserAgent_Mobile_NonMobile(''); } }
/** * Copyright (C) 2012 Vizualizer All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @author Naohisa Minagawa <*****@*****.**> * @copyright Copyright (c) 2010, Vizualizer * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0 * @since PHP 5.3 * @version 1.0.0 */ function smarty_function_emoji($params, $smarty, $template) { // codeパラメータは必須です。 if (empty($params['code'])) { trigger_error("emoji: missing code parameter", E_USER_WARNING); return; } // パラメータを変数にコピー $code = $params['code']; if (preg_match("/[0-9]{1,3}/", $code) && is_numeric($code) && 0 < $code && $code < 253) { // 変換表を配列に格納 $emoji_array = array(); $emoji_array[] = ""; $contents = @file(dirname(__FILE__) . "/emojix.csv"); foreach ($contents as $line) { $line = rtrim($line); $emoji_array[] = explode(",", $line); } if (Net_UserAgent_Mobile::isMobile()) { // モバイルユーザーエージェントのインスタンスを取得 $agent = Net_UserAgent_Mobile::singleton(); if ($agent->isDoCoMo()) { // DoCoMo echo mb_convert_encoding($emoji_array[$code][1], "UTF-8", "SJIS"); } elseif ($agent->isEZweb()) { // au if (preg_match("/[^0-9]/", $emoji_array[$code][2])) { echo $emoji_array[$code][2]; } else { echo "<img localsrc=\"" . $emoji_array[$code][2] . "\" />"; } } elseif ($agent->isSoftbank()) { if ($agent->isType3GC()) { // Softbank-UTF8 $e = new Emoji(); if (preg_match("/^[A-Z]{1}?/", $emoji_array[$code][3])) { echo "\$" . $emoji_array[$code][3] . ""; } else { echo $emoji_array[$code][3]; } } else { // Softbank-SJIS if (preg_match("/^[A-Z]{1}?/", $emoji_array[$code][3])) { echo "\$" . mb_convert_encoding($emoji_array[$code][3], "SJIS", "UTF-8") . ""; } else { echo mb_convert_encoding($emoji_array[$code][3], "SJIS", "UTF-8"); } } } } else { echo "<img src=\"/emoji_images/" . $emoji_array[$code][0] . ".gif\" width=\"12\" height=\"12\" border=\"0\" alt=\"\" />"; } } else { // 絵文字のコードが規定値以外 return "[Error!]\n"; } }
/** * detect * * @param Symfony\Component\HttpFoundation\Request $request * * @return string The type name of the user agent (ex. 'docomo') */ public function detect(Request $request) { $ua = parent::detect($request); if (!$ua) { $mobile = \Net_UserAgent_Mobile::factory($request->server->get('HTTP_USER_AGENT')); $ua = strtolower($mobile->getCarrierlongName()); } return $ua; }
public function execute($filterChain) { $response = $this->getContext()->getResponse(); if ($this->isFirstCall()) { $agent = Net_UserAgent_Mobile::singleton(); $this->getContext()->getRequest()->setAttribute("userAgent", $agent); $this->getContext()->getResponse()->setSlot("carrier_css", $agent); } $filterChain->execute(); }
protected function __construct() { require_once 'Net/UserAgent/Mobile.php'; require_once 'Net/UserAgent/Mobile/NonMobile.php'; // ignore `Non-static method Net_UserAgent_Mobile::factory()' error $oldErrorLevel = error_reporting(error_reporting() & ~E_STRICT); self::$mobile = Net_UserAgent_Mobile::factory(); error_reporting($oldErrorLevel); if (self::$mobile instanceof Net_UserAgent_Mobile_Error) { self::$mobile = new Net_UserAgent_Mobile_NonMobile(''); } }
public function initialize($context, $parameters = null) { parent::initialize($context, $parameters); // UserAgent取得 $agent = new Net_UserAgent_Mobile(); //$agent = $this->getContext()->getRequest()->getAttribute('userAgent'); if ($agent->isDoCoMo()) { ini_set("session.use_trans_sid", 1); ini_set("session.use_cookies", 0); } else { if ($agent->isSoftBank()) { ini_set("session.use_trans_sid", 0); ini_set("session.use_cookies", 1); } else { if ($agent->isEZweb()) { ini_set("session.use_trans_sid", 0); ini_set("session.use_cookies", 1); } } } }
function after($output) { require_once 'Net/UserAgent/Mobile.php'; if (Net_UserAgent_Mobile::factory()->isDoCoMo()) { $output = after_render_docomo($output); } elseif (Net_UserAgent_Mobile::factory()->isSoftBank()) { $output = after_render_softbank($output); } elseif (Net_UserAgent_Mobile::factory()->isEZweb()) { $output = after_render_au($output); } else { $output = after_render_pc($output); } return $output; }
public function __construct() { $uri = Mage::app()->getRequest(); if (preg_match("/extensions_(custom|local)/i", $uri->getRequestUri())) { $this->_isAdmin = true; } if (!$this->_isAdmin) { $error = error_reporting(E_ALL); $include_path = get_include_path(); set_include_path($include_path . PS . BP . DS . 'lib/PEAR'); require_once 'Net/UserAgent/Mobile.php'; $this->_agent = Net_UserAgent_Mobile::singleton(); } }
/** * ファクトリー * * @return Net_UserAgent_Mobile */ public function factory() { $userAgent = $this->_config['user_agent']; $netUserAgentMobile = Net_UserAgent_Mobile::factory($userAgent); if (PEAR::isError($netUserAgentMobile)) { switch (true) { case strstr($userAgent, 'DoCoMo'): $botAgent = BEAR_Agent::BOT_DOCOMO; break; case strstr($userAgent, 'KDDI-'): $botAgent = BEAR_Agent::BOT_AU; break; case preg_match('/(SoftBank|Vodafone|J-PHONE|MOT-)/', $userAgent): $botAgent = BEAR_Agent::BOT_SOFTBANK; break; default: $botAgent = ''; } $netUserAgentMobile = Net_UserAgent_Mobile::factory($botAgent); } return $netUserAgentMobile; }
/** * パラメーター管理で設定したセッション維持設定に従って適切なオブジェクトを返す. * * @return SC_SessionFactory */ function getInstance() { $type = defined('SESSION_KEEP_METHOD') ? SESSION_KEEP_METHOD : ''; switch ($type) { // セッションの維持にリクエストパラメーターを使用する case 'useRequest': $session = new SC_SessionFactory_UseRequest(); SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE ? $session->setState('mobile') : $session->setState('pc'); break; // クッキーを使用する // クッキーを使用する case 'useCookie': // モバイルの場合はSC_SessionFactory_UseRequestを使用する if (Net_UserAgent_Mobile::isMobile() === true) { $session = new SC_SessionFactory_UseRequest(); $session->setState('mobile'); break; } default: $session = new SC_SessionFactory_UseCookie(); break; } return $session; }
/** * Checks whether or not the user agent is mobile by a given user agent string. * * @param string $userAgent * @return boolean * @since Method available since Release 0.31.0 */ function isMobile($userAgent = null) { if (Net_UserAgent_Mobile::isDoCoMo($userAgent)) { return true; } elseif (Net_UserAgent_Mobile::isEZweb($userAgent)) { return true; } elseif (Net_UserAgent_Mobile::isSoftBank($userAgent)) { return true; } elseif (Net_UserAgent_Mobile::isWillcom($userAgent)) { return true; } return false; }
function ic2_display($path, $params) { global $_conf, $ini, $thumb, $dpr, $redirect, $id, $uri, $file, $thumbnailer; if (P2_OS_WINDOWS) { $path = str_replace('\\', '/', $path); } if (strncmp($path, '/', 1) == 0) { $s = empty($_SERVER['HTTPS']) ? '' : 's'; $to = 'http' . $s . '://' . $_SERVER['HTTP_HOST'] . $path; } else { $dir = dirname(P2Util::getMyUrl()); if (strncasecmp($path, './', 2) == 0) { $to = $dir . substr($path, 1); } elseif (strncasecmp($path, '../', 3) == 0) { $to = dirname($dir) . substr($path, 2); } else { $to = $dir . '/' . $path; } } $name = basename($path); $ext = strrchr($name, '.'); switch ($redirect) { case 1: header("Location: {$to}"); exit; case 2: switch ($ext) { case '.jpg': header("Content-Type: image/jpeg; name=\"{$name}\""); break; case '.png': header("Content-Type: image/png; name=\"{$name}\""); break; case '.gif': header("Content-Type: image/gif; name=\"{$name}\""); break; default: if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) { header("Content-Type: application/octetstream; name=\"{$name}\""); } else { header("Content-Type: application/octet-stream; name=\"{$name}\""); } } header("Content-Disposition: inline; filename=\"{$name}\""); header('Content-Length: ' . filesize($path)); readfile($path); exit; default: if (!class_exists('HTML_Template_Flexy', false)) { require 'HTML/Template/Flexy.php'; } if (!class_exists('HTML_QuickForm', false)) { require 'HTML/QuickForm.php'; } if (!class_exists('HTML_QuickForm_Renderer_ObjectFlexy', false)) { require 'HTML/QuickForm/Renderer/ObjectFlexy.php'; } if (isset($uri)) { $img_o = 'uri'; $img_p = $uri; } elseif (isset($id)) { $img_o = 'id'; $img_p = $id; } else { $img_o = 'file'; $img_p = $file; } $img_q = $img_o . '=' . rawurlencode($img_p); // QuickFormの初期化 $_size = explode('x', $thumbnailer->calc($params['width'], $params['height'])); $_constants = array('o' => sprintf('原寸 (%dx%d)', $params['width'], $params['height']), 's' => '作成', 't' => $thumb, 'd' => $dpr, 'u' => $img_p, 'v' => $img_o, 'x' => $_size[0], 'y' => $_size[1]); $_defaults = array('q' => $ini["Thumb{$thumb}"]['quality'], 'r' => '0'); $mobile = Net_UserAgent_Mobile::singleton(); $qa = 'size=3 maxlength=3'; if ($mobile->isDoCoMo()) { $qa .= ' istyle=4'; } elseif ($mobile->isEZweb()) { $qa .= ' format=*N'; } elseif ($mobile->isSoftBank()) { $qa .= ' mode=numeric'; } $_presets = array('' => 'サイズ・品質'); foreach ($ini['Dynamic']['presets'] as $_preset_name => $_preset_params) { $_presets[$_preset_name] = $_preset_name; } $qf = new HTML_QuickForm('imgmaker', 'get', 'ic2_mkthumb.php'); $qf->setConstants($_constants); $qf->setDefaults($_defaults); $qf->addElement('hidden', 't'); $qf->addElement('hidden', 'u'); $qf->addElement('hidden', 'v'); $qf->addElement('text', 'x', '高さ', $qa); $qf->addElement('text', 'y', '横幅', $qa); $qf->addElement('text', 'q', '品質', $qa); $qf->addElement('select', 'p', 'プリセット', $_presets); $qf->addElement('select', 'r', '回転', array('0' => 'なし', '90' => '右に90°', '270' => '左に90°', '180' => '180°')); $qf->addElement('checkbox', 'w', 'トリム'); $qf->addElement('checkbox', 'z', 'DL'); $qf->addElement('submit', 's'); $qf->addElement('submit', 'o'); // FlexyとQurickForm_Rendererの初期化 $_flexy_options = array('locale' => 'ja', 'charset' => 'cp932', 'compileDir' => $_conf['compile_dir'] . DIRECTORY_SEPARATOR . 'ic2', 'templateDir' => P2EX_LIB_DIR . '/ic2/templates', 'numberFormat' => ''); $flexy = new HTML_Template_Flexy($_flexy_options); $rdr = new HTML_QuickForm_Renderer_ObjectFlexy($flexy); $qf->accept($rdr); // 表示 $flexy->setData('p2vid', P2_VERSION_ID); $flexy->setData('title', 'IC2::Cached'); $flexy->setData('pc', !$_conf['ktai']); $flexy->setData('iphone', $_conf['iphone']); if (!$_conf['ktai']) { $flexy->setData('skin', $GLOBALS['skin_name']); //$flexy->setData('stylesheets', array('css')); //$flexy->setData('javascripts', array('js')); } else { $flexy->setData('k_color', array('c_bgcolor' => !empty($_conf['mobile.background_color']) ? $_conf['mobile.background_color'] : '#ffffff', 'c_text' => !empty($_conf['mobile.text_color']) ? $_conf['mobile.text_color'] : '#000000', 'c_link' => !empty($_conf['mobile.link_color']) ? $_conf['mobile.link_color'] : '#0000ff', 'c_vlink' => !empty($_conf['mobile.vlink_color']) ? $_conf['mobile.vlink_color'] : '#9900ff')); } $rank = isset($params['rank']) ? $params['rank'] : 0; if ($_conf['iphone']) { $img_dir = 'img/iphone/'; $img_ext = '.png'; } else { $img_dir = 'img/'; $img_ext = $_conf['ktai'] ? '.gif' : '.png'; } $stars = array(); $stars[-1] = $img_dir . ($rank == -1 ? 'sn1' : 'sn0') . $img_ext; //$stars[0] = $img_dir . (($rank == 0) ? 'sz1' : 'sz0') . $img_ext; $stars[0] = $img_dir . ($_conf['iphone'] ? 'sz0' : 'sz1') . $img_ext; for ($i = 1; $i <= 5; $i++) { $stars[$i] = $img_dir . ($rank >= $i ? 's1' : 's0') . $img_ext; } $k_at_a = str_replace('&', '&', $_conf['k_at_a']); $setrank_url = "ic2.php?{$img_q}&t={$thumb}&r=0{$k_at_a}"; $flexy->setData('stars', $stars); $flexy->setData('params', $params); if ($thumb == 2 && $rank >= 0) { if ($ini['General']['inline'] == 1) { $t = 2; $link = null; } else { $t = 1; $link = $path; } $r = $ini['General']['redirect'] == 1 ? 1 : 2; $preview = "{$_SERVER['SCRIPT_NAME']}?o=1&r={$r}&t={$t}&{$img_q}{$k_at_a}"; $flexy->setData('preview', $preview); $flexy->setData('link', $link); $flexy->setData('info', null); } else { $flexy->setData('preview', null); $flexy->setData('link', $path); $flexy->setData('info', null); } if (!$_conf['ktai'] || $_conf['iphone']) { $flexy->setData('backto', null); } elseif (isset($_REQUEST['from'])) { $flexy->setData('backto', $_REQUEST['from']); $setrank_url .= '&from=' . rawurlencode($_REQUEST['from']); } elseif (isset($_SERVER['HTTP_REFERER'])) { $flexy->setData('backto', $_SERVER['HTTP_REFERER']); } else { $flexy->setData('backto', null); } $flexy->setData('stars', $stars); $flexy->setData('sertank', $setrank_url . '&rank='); if ($_conf['iphone']) { $_conf['extra_headers_ht'] .= <<<EOP <link rel="stylesheet" type="text/css" href="css/ic2_iphone.css?{$_conf['p2_version_id']}"> EOP; $_conf['extra_headers_xht'] .= <<<EOP <link rel="stylesheet" type="text/css" href="css/ic2_iphone.css?{$_conf['p2_version_id']}" /> EOP; } $flexy->setData('edit', extension_loaded('gd') && $rank >= 0); $flexy->setData('form', $rdr->toObject()); $flexy->setData('doctype', $_conf['doctype']); $flexy->setData('extra_headers', $_conf['extra_headers_ht']); $flexy->setData('extra_headers_x', $_conf['extra_headers_xht']); $flexy->compile('preview.tpl.html'); P2Util::header_nocache(); $flexy->output(); } exit; }
function sfSendOrderMail($order_id, $template_id, $subject = "", $header = "", $footer = "", $send = true) { $arrTplVar = new stdClass(); $arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); $arrTplVar->arrInfo = $arrInfo; $objQuery = new SC_Query_Ex(); if ($subject == "" && $header == "" && $footer == "") { // メールテンプレート情報の取得 $where = "template_id = ?"; $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($template_id)); $arrTplVar->tpl_header = $arrRet[0]['header']; $arrTplVar->tpl_footer = $arrRet[0]['footer']; $tmp_subject = $arrRet[0]['subject']; } else { $arrTplVar->tpl_header = $header; $arrTplVar->tpl_footer = $footer; $tmp_subject = $subject; } // 受注情報の取得 $where = "order_id = ?"; $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id)); $arrOrder = $arrRet[0]; $objQuery->setOrder('order_detail_id'); $arrTplVar->arrOrderDetail = $objQuery->select("*", "dtb_order_detail", $where, array($order_id)); $objProduct = new SC_Product_Ex(); $objQuery->setOrder('shipping_id'); $arrRet = $objQuery->select("*", "dtb_shipping", "order_id = ?", array($order_id)); foreach (array_keys($arrRet) as $key) { $objQuery->setOrder('shipping_id'); $arrItems = $objQuery->select("*", "dtb_shipment_item", "order_id = ? AND shipping_id = ?", array($order_id, $arrRet[$key]['shipping_id'])); foreach ($arrItems as $itemKey => $arrDetail) { foreach ($arrDetail as $detailKey => $detailVal) { $arrRet[$key]['shipment_item'][$arrDetail['product_class_id']][$detailKey] = $detailVal; } $arrRet[$key]['shipment_item'][$arrDetail['product_class_id']]['productsClass'] =& $objProduct->getDetailAndProductsClass($arrDetail['product_class_id']); } } $arrTplVar->arrShipping = $arrRet; $arrTplVar->Message_tmp = $arrOrder['message']; // 会員情報の取得 $customer_id = $arrOrder['customer_id']; $objQuery->setOrder('customer_id'); $arrRet = $objQuery->select('point', "dtb_customer", "customer_id = ?", array($customer_id)); $arrCustomer = isset($arrRet[0]) ? $arrRet[0] : ""; $arrTplVar->arrCustomer = $arrCustomer; $arrTplVar->arrOrder = $arrOrder; //その他決済情報 if ($arrOrder['memo02'] != "") { $arrOther = unserialize($arrOrder['memo02']); foreach ($arrOther as $other_key => $other_val) { if (SC_Utils_Ex::sfTrim($other_val['value']) == "") { $arrOther[$other_key]['value'] = ""; } } $arrTplVar->arrOther = $arrOther; } // 都道府県変換 $arrTplVar->arrPref = $this->arrPref; $objCustomer = new SC_Customer_Ex(); $arrTplVar->tpl_user_point = $objCustomer->getValue('point'); if (Net_UserAgent_Mobile::isMobile() === true) { $objMailView = new SC_MobileView_Ex(); } else { $objMailView = new SC_SiteView_Ex(); } // メール本文の取得 $objMailView->assignobj($arrTplVar); $body = $objMailView->fetch($this->arrMAILTPLPATH[$template_id]); // メール送信処理 $objSendMail = new SC_SendMail_Ex(); $bcc = $arrInfo['email01']; $from = $arrInfo['email03']; $error = $arrInfo['email04']; $tosubject = $this->sfMakeSubject($tmp_subject, $objMailView); $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); $objSendMail->setTo($arrOrder["order_email"], $arrOrder["order_name01"] . " " . $arrOrder["order_name02"] . " 様"); // 送信フラグ:trueの場合は、送信する。 if ($send) { if ($objSendMail->sendMail()) { $this->sfSaveMailHistory($order_id, $template_id, $tosubject, $body); } } return $objSendMail; }
// ファイルがなければ生成 $fp = @fopen($_conf['auth_user_file'], 'wb'); if (!$fp) { p2die("{$_conf['auth_user_file']} を保存できませんでした。認証ユーザ登録失敗。"); } flock($fp, LOCK_EX); fputs($fp, $auth_user_cont); flock($fp, LOCK_UN); fclose($fp); P2Util::pushInfoHtml('<p>○認証パスワードを変更登録しました</p>'); } } //==================================================== // 補助認証 //==================================================== $mobile = Net_UserAgent_Mobile::singleton(); $p_htm['auth_ctl'] = ''; // docomo認証 if ($mobile->isDoCoMo()) { if (file_exists($_conf['auth_imodeid_file'])) { $p_htm['auth_ctl'] .= <<<EOP iモードID認証登録済[<a href="{$_SERVER['SCRIPT_NAME']}?ctl_regist_imodeid=1{$_conf['k_at_a']}">解除</a>]<br> EOP; } if (file_exists($_conf['auth_docomo_file'])) { $p_htm['auth_ctl'] .= <<<EOP 端末ID認証登録済[<a href="{$_SERVER['SCRIPT_NAME']}?ctl_regist_docomo=1{$_conf['k_at_a']}">解除</a>]<br> EOP; } if ($p_htm['auth_ctl'] == '' && $_login->pass_x) { if (empty($_SERVER['HTTPS'])) {
/** * Parses HTTP_USER_AGENT string. * * @param string $userAgent User-Agent string * @throws Net_UserAgent_Mobile_Error */ function parse($userAgent) { $agent = explode(' ', $userAgent); preg_match('!^(?:(SoftBank|Semulator|Vodafone|Vemulator|J-PHONE|J-EMULATOR)/\\d\\.\\d|MOT-|MOTEMULATOR)!', $agent[0], $matches); if (count($matches) > 1) { $carrier = $matches[1]; } else { $carrier = 'Motorola'; } switch ($carrier) { case 'SoftBank': case 'Semulator': case 'Vodafone': case 'Vemulator': $result = $this->_parseVodafone($agent); break; case 'J-PHONE': case 'J-EMULATOR': $result = $this->_parseJphone($agent); break; case 'Motorola': case 'MOTEMULATOR': $result = $this->_parseMotorola($agent); break; } if (Net_UserAgent_Mobile::isError($result)) { return $result; } $this->_msname = $this->getHeader('X-JPHONE-MSNAME'); }
/** * Registers services on the given app. * * This method should only be used to configure services and parameters. * It should not get services. * * @param BaseApplication $app An Application instance */ public function register(BaseApplication $app) { // PEAR $app['smarty'] = function () { return new \Smarty(); }; $app['mobile.detect'] = function () { return new \Mobile_Detect(); }; $app['pear.archive.tar'] = $app->protect(function ($p_tarname, $p_compress = null) { return new \Archive_Tar($p_tarname, $p_compress); }); $app['pear.cache.lite'] = $app->protect(function ($options = array()) { return new \Cache_Lite($options); }); $app['pear.calendar.month.weekdays'] = $app->protect(function ($y, $m, $firstDay = null) { return new \Calendar_Month_Weekdays($y, $m, $firstDay); }); $app['pear.http.request'] = $app->protect(function ($url = '', $params = array()) { return new \HTTP_Request($url, $params); }); $app['pear.mail'] = $app->protect(function ($driver, $params = array()) { return \Mail::factory($driver, $params); }); $app['pear.net.user_agent.mobile'] = $app->protect(function ($userAgent = null) { return \Net_UserAgent_Mobile::singleton($userAgent); }); $app['pear.net.url'] = $app->protect(function ($url = null, $useBrackets = true) { return new \Net_URL($url, $useBrackets); }); $app['pear.services.json'] = $app->protect(function ($use = 0) { return new \Services_JSON($use); }); $app['pear.text.password'] = $app->protect(function ($length = 10, $type = 'pronounceable', $chars = '') { return \Text_Password::create($length, $type, $chars); }); $app['pear.xml.serializer'] = $app->protect(function ($options = null) { return new \XML_Serializer($options); }); // framework $app['eccube.cart_session'] = $app->protect(function ($cartKey = 'cart') { return new \Eccube\Framework\CartSession($cartKey); }); $app['eccube.customer'] = function () { return new \Eccube\Framework\Customer(); }; $app['eccube.customer_list'] = $app->protect(function ($array, $mode = '') { return new \Eccube\Framework\CustomerList($array, $mode); }); $app['eccube.cookie'] = $app->protect(function ($day = COOKIE_EXPIRE) { return new \Eccube\Framework\Cookie($day); }); $app['eccube.check_error'] = $app->protect(function ($array = '') { return new \Eccube\Framework\CheckError($array); }); $app['eccube.date'] = $app->protect(function ($start_year = '', $end_year = '') { return new \Eccube\Framework\Date($start_year, $end_year); }); $app['eccube.display'] = $app->protect(function ($hasPrevURL = true) { return new \Eccube\Framework\Display($hasPrevURL); }); $app['eccube.form_param'] = function () { return new \Eccube\Framework\FormParam(); }; $app['eccube.page_navi'] = $app->protect(function ($now_page, $all_row, $page_row, $func_name, $navi_max = NAVI_PMAX, $urlParam = '', $display_number = true) { return new \Eccube\Framework\PageNavi($now_page, $all_row, $page_row, $func_name, $navi_max, $urlParam, $display_number); }); $app['eccube.product'] = $app->protect(function () { return new \Eccube\Framework\Product(); }); $app['eccube.response'] = $app->protect(function () { return new \Eccube\Framework\Response(); }); $app['eccube.query'] = $app->protect(function ($dsn = '', $force_run = false, $new = false) { return \Eccube\Framework\Query::getSingletonInstance($dsn, $force_run, $new); }); $app['eccube.site_session'] = $app->share(function () { return new \Eccube\Framework\SiteSession(); }); $app['eccube.sendmail'] = $app->protect(function () { return new \Eccube\Framework\Sendmail(); }); // db $app['eccube.db.factory'] = $app->protect(function ($db_type = DB_TYPE) { return \Eccube\Framework\DB\DBFactory::getInstance($db_type); }); $app['eccube.db.master_data'] = $app->share(function () { return new \Eccube\Framework\DB\MasterData(); }); // graph $app['eccube.graph.bar'] = $app->protect(function ($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) { return new \Eccube\Framework\Graph\BarGraph($bgw, $bgh, $left, $top, $area_width, $area_height); }); $app['eccube.graph.line'] = $app->protect(function ($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) { return new \Eccube\Framework\Graph\LineGraph($bgw, $bgh, $left, $top, $area_width, $area_height); }); $app['eccube.graph.pie'] = $app->protect(function ($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = PIE_LEFT, $top = PIE_TOP) { return new \Eccube\Framework\Graph\PieGraph($bgw, $bgh, $left, $top); }); // helper $app['eccube.helper.address'] = $app->share(function () { return new \Eccube\Framework\Helper\AddressHelper(); }); $app['eccube.helper.best_products'] = $app->share(function () { return new \Eccube\Framework\Helper\BestProductsHelper(); }); $app['eccube.helper.bloc'] = $app->protect(function ($devide_type_id = DEVICE_TYPE_PC) { return new \Eccube\Framework\Helper\BlocHelper($devide_type_id); }); $app['eccube.helper.category'] = $app->protect(function ($count_check = false) { return new \Eccube\Framework\Helper\CategoryHelper($count_check); }); $app['eccube.helper.csv'] = function () { return new \Eccube\Framework\Helper\CsvHelper(); }; $app['eccube.helper.customer'] = $app->share(function () { return new \Eccube\Framework\Helper\CustomerHelper(); }); $app['eccube.helper.db'] = $app->share(function () { return new \Eccube\Framework\Helper\DbHelper(); }); $app['eccube.helper.delivery'] = $app->share(function () { return new \Eccube\Framework\Helper\DeliveryHelper(); }); $app['eccube.helper.file_manager'] = $app->share(function () { return new \Eccube\Framework\Helper\FileManagerHelper(); }); $app['eccube.helper.fpdi'] = $app->protect(function ($orientation = 'P', $unit = 'mm', $size = 'A4') { return new \Eccube\Framework\Helper\FpdiHelper($orientation, $unit, $size); }); $app['eccube.helper.holiday'] = $app->share(function () { return new \Eccube\Framework\Helper\HolidayHelper(); }); $app['eccube.helper.kiyaku'] = $app->share(function () { return new \Eccube\Framework\Helper\KiyakuHelper(); }); $app['eccube.helper.mail'] = $app->share(function () { return new \Eccube\Framework\Helper\MailHelper(); }); $app['eccube.helper.mailtemplate'] = $app->share(function () { return new \Eccube\Framework\Helper\MailtemplateHelper(); }); $app['eccube.helper.maker'] = $app->share(function () { return new \Eccube\Framework\Helper\MakerHelper(); }); $app['eccube.helper.mobile'] = $app->share(function () { return new \Eccube\Framework\Helper\MobileHelper(); }); $app['eccube.helper.news'] = $app->share(function () { return new \Eccube\Framework\Helper\NewsHelper(); }); $app['eccube.helper.page_layout'] = $app->share(function () { return new \Eccube\Framework\Helper\PageLayoutHelper(); }); $app['eccube.helper.payment'] = $app->share(function () { return new \Eccube\Framework\Helper\PaymentHelper(); }); $app['eccube.helper.plugin'] = function () { $plugin_activate_flg = PLUGIN_ACTIVATE_FLAG; return \Eccube\Framework\Helper\PluginHelper::getSingletonInstance($plugin_activate_flg); }; $app['eccube.helper.purchase'] = $app->share(function () { return new \Eccube\Framework\Helper\PurchaseHelper(); }); $app['eccube.helper.session'] = $app->share(function () { return new \Eccube\Framework\Helper\SessionHelper(); }); $app['eccube.helper.tax_rule'] = $app->share(function () { return new \Eccube\Framework\Helper\TaxRuleHelper(); }); $app['eccube.helper.transform'] = $app->protect(function ($source) { return new \Eccube\Framework\Helper\TransformHelper($source); }); // util $app['eccube.util.utils'] = $app->share(function () { return new \Eccube\Framework\Util\Utils(); }); $app['eccube.util.gc_utils'] = $app->share(function () { return new \Eccube\Framework\Util\GcUtils(); }); // smarty $app['smarty'] = $app->extend('smarty', function ($smarty) { /* @var $DbHelper \Eccube\Framework\Helper\DbHelper */ $DbHelper = Application::alias('eccube.helper.db'); /* @var $Utils \Eccube\Framework\Util\Utils */ $Utils = Application::alias('eccube.util.utils'); /* @var $GcUtils \Eccube\Framework\Util\GcUtils */ $GcUtils = Application::alias('eccube.util.gc_utils'); $smarty->left_delimiter = '<!--{'; $smarty->right_delimiter = '}-->'; $smarty->plugins_dir = array(realpath(__DIR__ . '/../../smarty_extends'), realpath(__DIR__ . '/../../../vendor/smarty/smarty/libs/plugins')); $smarty->register_modifier('sfDispDBDate', array($Utils, 'sfDispDBDate')); $smarty->register_modifier('sfGetErrorColor', array($Utils, 'sfGetErrorColor')); $smarty->register_modifier('sfTrim', array($Utils, 'sfTrim')); $smarty->register_modifier('sfCalcIncTax', array($DbHelper, 'calcIncTax')); $smarty->register_modifier('sfPrePoint', array($Utils, 'sfPrePoint')); $smarty->register_modifier('sfGetChecked', array($Utils, 'sfGetChecked')); $smarty->register_modifier('sfTrimURL', array($Utils, 'sfTrimURL')); $smarty->register_modifier('sfMultiply', array($Utils, 'sfMultiply')); $smarty->register_modifier('sfRmDupSlash', array($Utils, 'sfRmDupSlash')); $smarty->register_modifier('sfCutString', array($Utils, 'sfCutString')); $smarty->register_modifier('sfMbConvertEncoding', array($Utils, 'sfMbConvertEncoding')); $smarty->register_modifier('sfGetEnabled', array($Utils, 'sfGetEnabled')); $smarty->register_modifier('sfNoImageMainList', array($Utils, 'sfNoImageMainList')); // XXX register_function で登録すると if で使用できないのではないか? $smarty->register_function('sfIsHTTPS', array($Utils, 'sfIsHTTPS')); $smarty->register_function('sfSetErrorStyle', array($Utils, 'sfSetErrorStyle')); $smarty->register_function('printXMLDeclaration', array($GcUtils, 'printXMLDeclaration')); $smarty->default_modifiers = array('script_escape'); $smarty->force_compile = SMARTY_FORCE_COMPILE_MODE === true; return $smarty; }); }
/** * EC-CUBE がサポートする携帯キャリアかどうかを判別する。 * * ※一部モジュールで使用。ただし、本メソッドは将来的に削除しますので新規ご利用は控えてください。 * * @return boolean サポートしている場合は true、それ以外の場合は false を返す。 */ function isMobile() { $objAgent =& Net_UserAgent_Mobile::singleton(); if (Net_UserAgent_Mobile::isError($objAgent)) { return false; } else { return $objAgent->isDoCoMo() || $objAgent->isEZweb() || $objAgent->isVodafone(); } }
/** * Parses HTTP_USER_AGENT string. * * @param string $userAgent User-Agent string * @throws Net_UserAgent_Mobile_Error */ function parse($userAgent) { @(list($main, $foma_or_comment) = explode(' ', $userAgent, 2)); if ($foma_or_comment && preg_match('/^\\((.*)\\)$/', $foma_or_comment, $matches)) { // DoCoMo/1.0/P209is (Google CHTML Proxy/1.0) $this->_comment = $matches[1]; $result = $this->_parseMain($main); } elseif ($foma_or_comment) { // DoCoMo/2.0 N2001(c10;ser0123456789abcde;icc01234567890123456789) $this->_isFOMA = true; list($this->name, $this->version) = explode('/', $main); $result = $this->_parseFOMA($foma_or_comment); } else { // DoCoMo/1.0/R692i/c10 $result = $this->_parseMain($main); } if (Net_UserAgent_Mobile::isError($result)) { return $result; } }
/** * UAでセッションの妥当性をチェックする * * @return bool */ private function _checkUA() { // {{{ docomoはUTN時にUA後部が変わるので機種名で検証する $mobile = Net_UserAgent_Mobile::singleton(); if ($mobile->isDoCoMo()) { $mobile_b = Net_UserAgent_Mobile::factory($_SESSION[$this->sess_array]['ua']); if ($mobile_b->getModel() == $mobile->getModel()) { return true; } } // }}} // $offset = 12; if (empty($offset)) { $offset = strlen($_SERVER['HTTP_USER_AGENT']); } if (substr($_SERVER['HTTP_USER_AGENT'], 0, $offset) == substr($_SESSION[$this->sess_array]['ua'], 0, $offset)) { return true; } else { return false; } }
/** * スレッド表示オブジェクトにAASで使う変数をアサインする */ public static function initAAS($aShowThread) { global $_conf; if ($_conf['iphone']) { $aShowThread->aas_rotate = '↻'; } elseif ($_conf['ktai']) { $mobile = Net_UserAgent_Mobile::singleton(); /** * @link http://www.nttdocomo.co.jp/service/imode/make/content/pictograph/ * @link http://www.au.kddi.com/ezfactory/tec/spec/3.html * @link http://mb.softbank.jp/mb/service/3G/mail/pictogram/ */ if ($mobile->isDoCoMo()) { $aShowThread->aas_rotate = '栗'; // リサイクル, 拡42 } elseif ($mobile->isEZweb()) { $aShowThread->aas_rotate = ''; // 循環矢印, 807 } elseif ($mobile->isSoftBank()) { $aShowThread->aas_rotate = "\$Pc"; // 渦巻, 414 } } else { // } }
/** * 機種を判別する。 * * SC_Display::MOBILE = ガラケー = 1 * SC_Display::SMARTPHONE = スマホ = 2 * SC_Display::PC = PC = 10 * * @static * @return integer 端末種別ID */ function detectDevice() { $nu = new Net_UserAgent_Mobile(); $su = new SC_SmartphoneUserAgent_Ex(); $retDevice = 0; if ($nu->isMobile()) { return DEVICE_TYPE_MOBILE; } elseif ($su->isSmartphone()) { return DEVICE_TYPE_SMARTPHONE; } else { return DEVICE_TYPE_PC; } }
function ZenCart_Mobile($strUserAgent, $db) { $this->mobile =& Net_UserAgent_Mobile::factory($strUserAgent); $this->db = $db; }
/** * スマートフォンかどうかを判別する。 * $_SESSION['pc_disp'] = true の場合はPC表示。 * * @return boolean */ function isSmartphone() { $nu = new Net_UserAgent_Mobile(); // SPでかつPC表示OFFの場合 return $nu->isSmartphone() && !SC_SmartphoneUserAgent_Ex::getSmartphonePcFlag(); }
/** * 端末種別を判別する。 * * SC_Display::MOBILE = ガラケー = 1 * SC_Display::SMARTPHONE = スマホ = 2 * SC_Display::PC = PC = 10 * * @static * @param $reset boolean * @return integer 端末種別ID */ public static function detectDevice($reset = FALSE) { if (is_null(SC_Display_Ex::$device) || $reset) { $nu = new Net_UserAgent_Mobile(); $su = new SC_SmartphoneUserAgent_Ex(); if ($nu->isMobile()) { SC_Display_Ex::$device = DEVICE_TYPE_MOBILE; } elseif ($su->isSmartphone()) { SC_Display_Ex::$device = DEVICE_TYPE_SMARTPHONE; } else { SC_Display_Ex::$device = DEVICE_TYPE_PC; } } return SC_Display_Ex::$device; }
/** * 最初のログイン画面を表示する */ function printLoginFirst(Login $_login) { global $STYLE, $_conf; global $_login_failed_flag, $_p2session; global $skin_en; // {{{ データ保存ディレクトリのパーミッションの注意を喚起する P2Util::checkDirWritable($_conf['dat_dir']); $checked_dirs[] = $_conf['dat_dir']; // チェック済みのディレクトリを格納する配列に if (!in_array($_conf['idx_dir'], $checked_dirs)) { P2Util::checkDirWritable($_conf['idx_dir']); $checked_dirs[] = $_conf['idx_dir']; } if (!in_array($_conf['pref_dir'], $checked_dirs)) { P2Util::checkDirWritable($_conf['pref_dir']); $checked_dirs[] = $_conf['pref_dir']; } // }}} // 前処理 $_login->checkAuthUserFile(); clearstatcache(); //========================================================= // 書き出し用変数 //========================================================= $ptitle = 'rep2'; $myname = basename($_SERVER['SCRIPT_NAME']); $auth_sub_input_ht = ""; $body_ht = ""; $p_str = array('user' => 'ユーザ', 'password' => 'パスワード'); // 携帯用表示文字列全角→半角変換 if ($_conf['ktai'] && function_exists('mb_convert_kana')) { foreach ($p_str as $k => $v) { $p_str[$k] = mb_convert_kana($v, 'rnsk'); } } //============================================== // 補助認証 //============================================== $mobile = Net_UserAgent_Mobile::singleton(); // {{{ docomo iモードID認証 if ($mobile->isDoCoMo()) { /** * @link http://www.nttdocomo.co.jp/service/imode/make/content/ip/index.html#imodeid */ if (($UID = $mobile->getUID()) !== null) { // HTTPかつguid=ONでリクエストされない限りここに来ることはない if (file_exists($_conf['auth_imodeid_file'])) { include $_conf['auth_imodeid_file']; if (isset($registed_imodeid) && $registed_imodeid == $UID) { $auth_sub_input_ht = 'iモードID OK : ユーザ名だけでログインできます。<br>'; } } } if ($auth_sub_input_ht == '') { if (empty($_SERVER['HTTPS'])) { $regist_imodeid_chedked = ' checked'; $regist_docomo_chedked = ''; } else { $regist_imodeid_chedked = ''; $regist_docomo_chedked = ' checked'; } $auth_sub_input_ht = <<<EOP <input type="hidden" name="ctl_regist_imodeid" value="1"> <input type="hidden" name="ctl_regist_docomo" value="1"> <input type="checkbox" name="regist_imodeid" value="1"{$regist_imodeid_chedked}>iモードIDで認証を登録<br> <input type="checkbox" name="regist_docomo" value="1"{$regist_docomo_chedked}>端末IDで認証を登録<br> EOP; } // }}} // {{{ EZweb サブスクライバID認証 } elseif ($mobile->isEZweb()) { /** * @link http://www.au.kddi.com/ezfactory/tec/spec/4_4.html */ if (($UID = $mobile->getUID()) !== null) { if (file_exists($_conf['auth_ez_file'])) { include $_conf['auth_ez_file']; if (isset($registed_ez) && $registed_ez == $UID) { $auth_sub_input_ht = '端末ID OK : ユーザ名だけでログインできます。<br>'; } } } if ($auth_sub_input_ht == '') { $auth_sub_input_ht = <<<EOP <input type="hidden" name="ctl_regist_ez" value="1"> <input type="checkbox" name="regist_ez" value="1" checked>端末IDで認証を登録<br> EOP; } // }}} // {{{ SoftBank 端末シリアル番号認証 } elseif ($mobile->isSoftBank()) { /** * パケット対応機 要ユーザID通知ONの設定 * @link http://creation.mb.softbank.jp/web/web_ua_about.html */ if (($SN = $mobile->getSerialNumber()) !== null) { if (file_exists($_conf['auth_jp_file'])) { include $_conf['auth_jp_file']; if (isset($registed_jp) && $registed_jp == $SN) { $auth_sub_input_ht = '端末ID OK : ユーザ名だけでログインできます。<br>'; } } } if ($auth_sub_input_ht == '') { $auth_sub_input_ht = <<<EOP <input type="hidden" name="ctl_regist_jp" value="1"> <input type="checkbox" name="regist_jp" value="1" checked>端末IDで認証を登録<br> EOP; } // }}} // {{{ Cookie認証 } else { $regist_cookie_checked = ' checked'; if (isset($_POST['submit_new']) || isset($_POST['submit_member'])) { if ($_POST['regist_cookie'] != '1') { $regist_cookie_checked = ''; } } $ignore_cip_checked = ''; if (isset($_POST['submit_newuser']) || isset($_POST['submit_userlogin'])) { if (geti($_POST['ignore_cip']) == '1') { $ignore_cip_checked = ' checked'; } } else { if (geti($_COOKIE['ignore_cip']) == '1') { $ignore_cip_checked = ' checked'; } } $auth_sub_input_ht = '<input type="hidden" name="ctl_regist_cookie" value="1">' . sprintf('<input type="checkbox" id="regist_cookie" name="regist_cookie" value="1"%s><label for="regist_cookie">ログイン情報をCookieに保存する(推奨)</label><br>', $regist_cookie_checked) . sprintf('<input type="checkbox" id="ignore_cip" name="ignore_cip" value="1"%s><label for="ignore_cip">Cookie認証時にIPの同一性をチェックしない</label><br>', $ignore_cip_checked); } // }}} // ログインフォームからの指定 if (!empty($GLOBALS['brazil'])) { $add_mail = '.,@-'; } else { $add_mail = ''; } if (preg_match("/^[0-9A-Za-z_{$add_mail}]+\$/", $_login->user_u)) { $hd['form_login_id'] = htmlspecialchars($_login->user_u, ENT_QUOTES); } elseif (!empty($_POST['form_login_id']) && preg_match("/^[0-9A-Za-z_{$add_mail}]+\$/", $_POST['form_login_id'])) { $hd['form_login_id'] = htmlspecialchars($_POST['form_login_id'], ENT_QUOTES); } else { $hd['form_login_id'] = ''; } if (!empty($_POST['form_login_pass']) && preg_match('/^[0-9A-Za-z_]+$/', $_POST['form_login_pass'])) { $hd['form_login_pass'] = htmlspecialchars($_POST['form_login_pass'], ENT_QUOTES); } else { $hd['form_login_pass'] = ''; } // docomoの固有端末認証 $docomo_auth_ht = ''; if ($mobile->isDoCoMo()) { if (file_exists($_conf['auth_imodeid_file']) && empty($_SERVER['HTTPS'])) { $docomo_auth_ht .= sprintf('<p><a href="%s?auth_type=imodeid&user=%s&guid=ON">iモードID認証</a></p>', $myname, rawurldecode($_login->user_u)); } if (file_exists($_conf['auth_docomo_file'])) { $docomo_auth_ht .= sprintf('<p><a href="%s?auth_type=utn&user=%s" utn>端末ID認証</a></p>', $myname, rawurldecode($_login->user_u)); } } // docomoならpasswordにしない if ($mobile->isDoCoMo()) { $type = 'text'; $utn = ' utn'; } else { $type = 'password'; $utn = ''; } // {{{ ログイン用フォームを生成 $hd['REQUEST_URI'] = htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES); if ($mobile->isDoCoMo()) { if (strpos($hd['REQUEST_URI'], '?') === false) { $hd['REQUEST_URI'] .= '?guid=ON'; } else { $hd['REQUEST_URI'] .= '&guid=ON'; } } if (file_exists($_conf['auth_user_file'])) { $submit_ht = '<input type="submit" name="submit_member" value="ユーザログイン">'; } else { $submit_ht = '<input type="submit" name="submit_new" value="新規登録">'; } if ($_conf['ktai']) { //$k_roman_input_at = ' istyle="3" format="*m" mode="alphabet"'; $k_roman_input_at = ' istyle="3" format="*x" mode="alphabet"'; $k_input_size_at = ''; } else { $k_roman_input_at = ''; $k_input_size_at = ' size="32"'; } $login_form_ht = <<<EOP {$docomo_auth_ht} <form id="login" method="POST" action="{$hd['REQUEST_URI']}" target="_self"{$utn}> {$_conf['k_input_ht']} {$p_str['user']}: <input type="text" name="form_login_id" value="{$hd['form_login_id']}"{$k_roman_input_at}{$k_input_size_at}><br> {$p_str['password']}: <input type="{$type}" name="form_login_pass" value="{$hd['form_login_pass']}"{$k_roman_input_at}><br> {$auth_sub_input_ht} <br> {$submit_ht} </form> EOP; // }}} //================================================================= // 新規ユーザ登録処理 //================================================================= if (!file_exists($_conf['auth_user_file']) && !$_login_failed_flag and !empty($_POST['submit_new']) && !empty($_POST['form_login_id']) && !empty($_POST['form_login_pass'])) { // {{{ 入力エラーをチェック、判定 if (!preg_match('/^[0-9A-Za-z_]+$/', $_POST['form_login_id']) || !preg_match('/^[0-9A-Za-z_]+$/', $_POST['form_login_pass'])) { P2Util::pushInfoHtml("<p class=\"info-msg\">rep2 error: 「{$p_str['user']}」名と「{$p_str['password']}」は半角英数字で入力して下さい。</p>"); $show_login_form_flag = true; // }}} // {{{ 登録処理 } else { $_login->makeUser($_POST['form_login_id'], $_POST['form_login_pass']); // 新規登録成功 $hd['form_login_id'] = htmlspecialchars($_POST['form_login_id'], ENT_QUOTES); $body_ht .= "<p class=\"info-msg\">○ 認証{$p_str['user']}「{$hd['form_login_id']}」を登録しました</p>"; $body_ht .= "<p><a href=\"{$myname}?form_login_id={$hd['form_login_id']}{$_conf['k_at_a']}\">rep2 start</a></p>"; $_login->setUser($_POST['form_login_id']); $_login->pass_x = sha1($_POST['form_login_pass']); // セッションが利用されているなら、セッションを更新 if (isset($_p2session)) { // ユーザ名とパスXを更新 $_SESSION['login_user'] = $_login->user_u; $_SESSION['login_pass_x'] = $_login->pass_x; } // 要求があれば、補助認証を登録 $_login->registCookie(); $_login->registKtaiId(); } // }}} // {{{ ログインエラーがある } else { if (isset($_POST['form_login_id']) || isset($_POST['form_login_pass'])) { $info_msg_ht = '<p class="info-msg">'; if (!$_POST['form_login_id']) { $info_msg_ht .= "rep2 error: 「{$p_str['user']}」が入力されていません。<br>"; } if (!$_POST['form_login_pass']) { $info_msg_ht .= "rep2 error: 「{$p_str['password']}」が入力されていません。"; } $info_msg_ht .= '</p>'; P2Util::pushInfoHtml($info_msg_ht); } $show_login_form_flag = true; } // }}} //========================================================= // HTMLプリント //========================================================= P2Util::header_nocache(); echo $_conf['doctype']; echo <<<EOP <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW"> {$_conf['extra_headers_ht']} <title>{$ptitle}</title> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"> EOP; if (!$_conf['ktai']) { echo <<<EOP <style type="text/css"> /* <![CDATA[ */ EOP; include P2_STYLE_DIR . '/style_css.inc'; include P2_STYLE_DIR . '/login_first_css.inc'; echo <<<EOP /* ]]> */ </style> EOP; } echo "</head><body>\n"; echo "<h3>{$ptitle}</h3>\n"; // 情報表示 P2Util::printInfoHtml(); echo $body_ht; if (!empty($show_login_form_flag)) { echo $login_form_ht; } echo '</body></html>'; return true; }
/** * p2 - 最初のログイン画面をHTML表示する関数 * * @access public * @return void */ function printLoginFirst(&$_login) { global $STYLE, $_conf; global $_login_failed_flag, $_p2session; // データ保存ディレクトリに書き込み権限がなければ注意を表示セットする P2Util::checkDirsWritable(array($_conf['dat_dir'], $_conf['idx_dir'], $_conf['pref_dir'])); // 前処理 $_login->cleanInvalidAuthUserFile(); clearstatcache(); // 外部からの変数 $post['form_login_id'] = isset($_POST['form_login_id']) ? $_POST['form_login_id'] : null; $post['form_login_pass'] = isset($_POST['form_login_pass']) ? $_POST['form_login_pass'] : null; //========================================================= // 書き出し用変数 //========================================================= if (UA::isIPhoneGroup()) { $ptitle = $_conf['p2name'] . 'iPhone'; } else { $ptitle = $_conf['p2name']; } $ptitle_ht = hs($ptitle); if (!empty($GLOBALS['brazil'])) { $ptitle_ht = 'p2.2ch.net'; if (!(UA::isK() || UA::isIPhoneGroup())) { $ptitle_ht = '<a href="http://p2.2ch.net/">' . $ptitle_ht . '</a>'; } } $myname = basename($_SERVER['SCRIPT_NAME']); $body_ht = ''; $show_login_form_flag = false; $p_str = array('user' => 'ユーザ', 'password' => 'パスワード'); if (!empty($GLOBALS['brazil'])) { $p_str['user'] = '******'; } // 携帯用表示文字列全角→半角変換 if (!UA::isIPhoneGroup() && UA::isK() && function_exists('mb_convert_kana')) { foreach ($p_str as $k => $v) { $p_str[$k] = mb_convert_kana($v, 'rnsk'); } } // 補助認証 require_once P2_LIB_DIR . '/HostCheck.php'; $mobile = Net_UserAgent_Mobile::singleton(); $auth_sub_input_ht = _getAuthSubInputHtml($mobile); // ログインフォームからの指定 $form_login_id_hs = ''; if ($_login->validLoginId($_login->user_u)) { $form_login_id_hs = hs($_login->user_u); } elseif ($_login->validLoginId($post['form_login_id'])) { $form_login_id_hs = hs($post['form_login_id']); } $form_login_pass_hs = ''; if ($_login->validLoginPass($post['form_login_pass'])) { $form_login_pass_hs = hs($post['form_login_pass']); } // docomoの固有端末認証(セッション利用時のみ有効) $docomo_utn_ht = ''; //if ($_conf['use_session'] && $_login->user_u && $mobile->isDoCoMo()) { if ($_conf['use_session'] && $mobile->isDoCoMo()) { $uri = $myname . '?guid=ON&user='******'<p><a href="' . hs($uri) . '" utn>docomo固有端末認証</a></p>'; } // docomoならリトライ時にパスワード入力を password → text とする // (docomoはpassword入力が完全マスクされるUIで、入力エラーがわかりにく過ぎる) if (isset($post['form_login_pass']) and $mobile->isDoCoMo()) { $type = "text"; } else { $type = "password"; } // {{{ ログイン用フォームを生成 $ruri = $_SERVER['REQUEST_URI']; if (UA::isDoCoMo()) { $ruri = UriUtil::addQueryToUri($ruri, array('guid' => 'ON')); } $REQUEST_URI_hs = hs($ruri); if (!empty($GLOBALS['brazil']) or file_exists($_conf['auth_user_file'])) { $submit_ht = '<input type="submit" name="submit_userlogin" value="ユーザログイン">'; } else { $submit_ht = '<input type="submit" name="submit_newuser" value="新規登録">'; } $login_form_ht = <<<EOP {$docomo_utn_ht} <form id="login" method="POST" action="{$REQUEST_URI_hs}" target="_self" utn> {$_conf['k_input_ht']} {$p_str['user']}: <input type="text" name="form_login_id" value="{$form_login_id_hs}" istyle="3" size="32" autocorrect="off" autocapitalize="off"><br> {$p_str['password']}: <input type="{$type}" name="form_login_pass" value="{$form_login_pass_hs}" istyle="3" autocorrect="off" autocapitalize="off"><br> {$auth_sub_input_ht} <br> {$submit_ht} </form> EOP; // }}} //================================================================= // 新規ユーザ登録処理 //================================================================= $isAllowedNewUser = empty($GLOBALS['brazil']) ? true : false; if ($isAllowedNewUser and !file_exists($_conf['auth_user_file']) && !$_login_failed_flag and !empty($_POST['submit_newuser']) && $post['form_login_id'] && $post['form_login_pass']) { // {{{ 入力エラーをチェック、判定 if (!$_login->validLoginId($post['form_login_id']) || !$_login->validLoginPass($post['form_login_pass'])) { P2Util::pushInfoHtml(sprintf('<p class="infomsg">p2 error: 「%s」名と「%s」は半角英数字で入力して下さい。</p>', hs($p_str['user']), hs($p_str['password']))); $show_login_form_flag = true; // }}} // {{{ 登録処理 } else { $_login->makeUser($post['form_login_id'], $post['form_login_pass']); // 新規登録成功 $form_login_id_hs = hs($post['form_login_id']); $body_ht .= "<p class=\"infomsg\">○ 認証{$p_str['user']}「{$form_login_id_hs}」を登録しました</p>"; $body_ht .= "<p><a href=\"{$myname}?form_login_id={$form_login_id_hs}{$_conf['k_at_a']}\">{$_conf['p2name']} start</a></p>"; $_login->setUser($post['form_login_id']); $_login->setPassX(sha1($post['form_login_pass'])); // セッションが利用されているなら、セッションを更新 if (isset($_p2session)) { // ユーザ名とパスXを更新 $_SESSION['login_user'] = $_login->user_u; $_SESSION['login_pass_x'] = $_login->pass_x; } // 要求があれば、補助認証を登録 $_login->registCookie(); $_login->registKtaiId(); } // }}} // {{{ ログインエラーがある } else { if (isset($_POST['submit_newuser']) || isset($_POST['submit_userlogin'])) { $msg_ht = '<p class="infomsg">'; if (!$post['form_login_id']) { $msg_ht .= "p2 error: 「{$p_str['user']}」が入力されていません。" . "<br>"; } elseif (!$_login->validLoginId($post['form_login_id'])) { $msg_ht .= "p2 error: 「{$p_str['user']}」文字列が不正です。" . "<br>"; } if (!$post['form_login_pass']) { $msg_ht .= "p2 error: 「{$p_str['password']}」が入力されていません。"; } $msg_ht .= '</p>'; P2Util::pushInfoHtml($msg_ht); } $show_login_form_flag = true; } // }}} //========================================================= // HTML表示出力 //========================================================= P2Util::headerNoCache(); P2View::printDoctypeTag(); ?> <html lang="ja"> <head> <?php P2View::printExtraHeadersHtml(); ?> <title><?php eh($ptitle); ?> </title> <?php if (UA::isIPhoneGroup()) { ?> <style type="text/css" media="screen">@import "./iui/iui.css";</style><?php } if (UA::isPC() && !UA::isIPhoneGroup()) { // ユーザは未決定 //P2View::printIncludeCssHtml('style'); //P2View::printIncludeCssHtml('login_first'); ?> <link rel="stylesheet" href="style/login_first.css" type="text/css"> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> <?php } ?> </head><body><?php if (UA::isIPhoneGroup()) { ?> <div class="toolbar"><h1 id="pageTitle"><?php echo $ptitle_ht; ?> </h1></div><?php ?> <div id="usage" class="panel"><filedset><?php } else { ?> <h3><?php echo $ptitle_ht; ?> </h3><?php } P2Util::printInfoHtml(); echo $body_ht; if ($show_login_form_flag) { echo $login_form_ht; if (empty($GLOBALS['brazil']) and !(HostCheck::isAddrLocal() || HostCheck::isAddrPrivate())) { ?> <p> <font size="-1" color="gray">※このページはプライベート利用のためのシステムです。<br> 部外者によるログイン試行は、<br> 不正アクセスとして記録されます。<br> このページへのアクセスURLを部外者が<br> 不特定多数に公知することを禁止します。</font></p><?php } } if (!empty($GLOBALS['brazil']) and UA::isK() || UA::isIPhoneGroup()) { ?> <br><hr size="1"><div align="center"><a href="http://p2.2ch.net/">p2.2ch.net</a></div><?php } if (UA::isIPhoneGroup()) { ?> <br><br><br><br><br><br></filedset></div><?php } ?> </body></html><?php }
/** * EC-CUBE がサポートする携帯端末かどうかを判別する。 * * @return boolean サポートしている場合は true、それ以外の場合は false を返す。 */ function isSupported() { $objAgent =& Net_UserAgent_Mobile::singleton(); // 携帯端末だと認識されたが、User-Agent の形式が未知の場合 if (Net_UserAgent_Mobile::isError($objAgent)) { GC_Utils_Ex::gfPrintLog($objAgent->toString()); return false; } if ($objAgent->isDoCoMo()) { $arrUnsupportedSeries = array('501i', '502i', '209i', '210i'); $arrUnsupportedModels = array('SH821i', 'N821i', 'P821i ', 'P651ps', 'R691i', 'F671i', 'SH251i', 'SH251iS'); return !in_array($objAgent->getSeries(), $arrUnsupportedSeries) && !in_array($objAgent->getModel(), $arrUnsupportedModels); } elseif ($objAgent->isEZweb()) { return $objAgent->isWAP2(); } elseif ($objAgent->isVodafone()) { return $objAgent->isPacketCompliant(); } else { // 携帯端末ではない場合はサポートしていることにする。 return true; } }