/** * Page のアクション. * * @return void */ public function action() { // チェック後のデータを格納 $arrClean = array(); // $_GET['move'] が想定値かどうかチェック switch ($_GET['move']) { case 'up': case 'down': $arrClean['move'] = $_GET['move']; break; default: $arrClean['move'] = ''; break; } // 正当な数値であればOK if (Utils::sfIsInt($_GET['id'])) { $arrClean['id'] = $_GET['id']; switch ($arrClean['move']) { case 'up': $this->lfRunkUp($arrClean['id']); break; case 'down': $this->lfRunkDown($arrClean['id']); break; default: break; } // エラー処理 } else { GcUtils::gfPrintLog('error id=' . $_GET['id']); } // ページの表示 Application::alias('eccube.response')->sendRedirect(ADMIN_SYSTEM_URLPATH); }
/** * UserAgentを検証する. * * @return boolean */ public function validateModel() { $ua = $this->getModel(); if (!empty($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] === $ua) { return true; } $msg = sprintf('User agent model mismatch : %s != %s(expected), sid=%s', $_SERVER['HTTP_USER_AGENT'], $ua, session_id()); GcUtils::gfPrintLog($msg); return false; }
/** * Page のアクション. * * @return void */ public function action() { $objFormParam = Application::alias('eccube.form_param'); // パラメーターの初期化 $this->initParam($objFormParam, $_GET); // パラメーターの検証 if ($objFormParam->checkError() || !Utils::sfIsInt($id = $objFormParam->getValue('id'))) { GcUtils::gfPrintLog("error id={$id}"); Utils::sfDispError(INVALID_MOVE_ERRORR); } $id = $objFormParam->getValue('id'); // レコードの削除 $this->deleteMember($id); // リダイレクト $url = $this->getLocation(ADMIN_SYSTEM_URLPATH) . '?pageno=' . $objFormParam->getValue('pageno'); Application::alias('eccube.response')->sendRedirect($url); }
/** * 有効なプラグインのロード. プラグインエンジンが有効になっていない場合は * プラグインエンジン自身のインストール処理を起動する * * @return void */ public function load($plugin_activate_flg = true) { if (!defined('CONFIG_REALFILE') || !file_exists(CONFIG_REALFILE)) { return; } // インストール前 if (GcUtils::isInstallFunction()) { return; } // インストール中 if ($plugin_activate_flg === false) { return; } // 有効なプラグインを取得 $arrPluginDataList = PluginUtil::getEnablePlugin(); // pluginディレクトリを取得 $arrPluginDirectory = PluginUtil::getPluginDirectory(); foreach ($arrPluginDataList as $arrPluginData) { // プラグイン本体ファイル名が取得したプラグインディレクトリ一覧にある事を確認 if (array_search($arrPluginData['plugin_code'], $arrPluginDirectory) !== false) { $plugin_file_path = PLUGIN_UPLOAD_REALDIR . $arrPluginData['plugin_code'] . '/' . $arrPluginData['class_name'] . '.php'; // プラグイン本体ファイルが存在しない場合 if (!file_exists($plugin_file_path)) { // エラー出力 $msg = 'プラグイン本体ファイルが存在しない。当該プラグインを無視して続行する。'; $msg .= 'ファイル=' . var_export($plugin_file_path, true) . '; '; trigger_error($msg, E_USER_WARNING); // 次のプラグインへ続行 continue 1; } // プラグイン本体ファイルをrequire. require_once $plugin_file_path; // プラグインのインスタンス生成. $objPlugin = new $arrPluginData['class_name']($arrPluginData); // メンバ変数にプラグインのインスタンスを登録. $this->arrPluginInstances[$arrPluginData['plugin_id']] = $objPlugin; $this->arrPluginIds[] = $arrPluginData['plugin_id']; // ローカルフックポイントの登録. $this->registerLocalHookPoint($objPlugin, $arrPluginData['priority']); // スーパーフックポイントの登録. $this->registerSuperHookPoint($objPlugin, HOOK_POINT_PREPROCESS, 'preProcess', $arrPluginData['priority']); $this->registerSuperHookPoint($objPlugin, HOOK_POINT_PROCESS, 'process', $arrPluginData['priority']); } } }
/** * パラメーターから有効なセッション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); }
/** * Page のアクション. * * @return void */ public function action() { $objFormParam = Application::alias('eccube.form_param'); $this->lfInitParam($objFormParam); $objFormParam->setParam($_REQUEST); $objFormParam->convParam(); $this->arrErr = $objFormParam->checkError(); $is_error = !Utils::isBlank($this->arrErr); $this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC); switch ($this->getMode()) { // 登録 case 'regist': $this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr); if (Utils::isBlank($this->arrErr)) { if ($this->doRegister($objFormParam)) { $this->tpl_onload = "alert('登録が完了しました。');"; } } break; default: break; } if (!$is_error) { // テキストエリアに表示 $header_path = $this->getTemplatePath($this->device_type_id, 'header'); $footer_path = $this->getTemplatePath($this->device_type_id, 'footer'); if ($header_path === false || $footer_path === false) { $this->arrErr['err'] = '※ ファイルの取得に失敗しました<br />'; } else { $this->header_data = file_get_contents($header_path); $this->footer_data = file_get_contents($footer_path); } } else { // 画面にエラー表示しないため, ログ出力 GcUtils::gfPrintLog('Error: ' . print_r($this->arrErr, true)); } //サブタイトルの追加 $this->tpl_subtitle = $this->arrDeviceType[$this->device_type_id] . '>' . $this->tpl_subtitle; }
/** * Page のアクション. * * @return void */ public function action() { /* @var $objLayout PageLayoutHelper */ $objLayout = Application::alias('eccube.helper.page_layout'); $objFormParam = Application::alias('eccube.form_param'); $this->lfInitParam($objFormParam); $objFormParam->setParam($_REQUEST); $objFormParam->convParam(); $this->arrErr = $objFormParam->checkError(); $is_error = !Utils::isBlank($this->arrErr); // CSSファイル名を取得 $this->css_name = $objFormParam->getValue('css_name'); $this->old_css_name = $objFormParam->getValue('old_css_name', $this->css_name); $this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC); $css_dir = $objLayout->getTemplatePath($this->device_type_id, true) . 'css/'; $css_path = $css_dir . $this->css_name . '.css'; switch ($this->getMode()) { // データ更新処理 case 'confirm': if (!$is_error) { $this->arrErr = array_merge($this->arrErr, $this->lfCheckError($objFormParam, $this->arrErr)); if (Utils::isBlank($this->arrErr)) { if ($this->doRegister($css_dir, $this->css_name, $this->old_css_name, $css_path, $objFormParam->getValue('css_data'))) { $this->tpl_onload = "alert('登録が完了しました。');"; } } } break; case 'delete': if (!$is_error) { if ($this->doDelete($css_path)) { $arrPram = array('device_type_id' => $this->device_type_id, 'msg' => 'on'); Application::alias('eccube.response')->reload($arrPram, true); } } break; default: if (isset($_GET['msg']) && $_GET['msg'] == 'on') { // 完了メッセージ $this->tpl_onload = "alert('登録が完了しました。');"; } break; } if (Utils::isBlank($this->arrErr) && $this->checkPath($this->css_name)) { // CSSファイルの読み込み if (!Utils::isBlank($this->css_name)) { $objFormParam->setValue('css_data', file_get_contents($css_path)); } } else { // 画面にエラー表示しないため, ログ出力 GcUtils::gfPrintLog('Error: ' . print_r($this->arrErr, true)); } // ファイルリストを取得 $this->arrCSSList = $this->getCSSList($css_dir); $this->tpl_subtitle = $this->arrDeviceType[$this->device_type_id] . '>' . $this->tpl_subtitle; $this->arrForm = $objFormParam->getFormParamList(); }
/** * TXTメール送信を実行する. * * 設定された情報を利用して, メールを送信する. * * @return boolean */ public function sendMail($isHtml = false) { $header = $isHtml ? $this->getHTMLHeader() : $this->getTEXTHeader(); $recip = $this->getRecip(); // メール送信 $result = $this->objMail->send($recip, $header, $this->body); if (\PEAR::isError($result)) { // XXX Windows 環境では SJIS でメッセージを受け取るようなので変換する。 $msg = mb_convert_encoding($result->getMessage(), CHAR_CODE, 'auto'); $msg = 'メール送信に失敗しました。[' . $msg . ']'; trigger_error($msg, E_USER_WARNING); GcUtils::gfDebugLog($header); return false; } return true; }
/** * @param string $msg */ public function printLog($msg) { GcUtils::gfPrintLog($msg, DATA_REALDIR . 'logs/ownersstore_batch_update.log'); }
/** * Returns a callable given its string representation. * * @param string $name * * @return array A callable array * * @throws \InvalidArgumentException In case the method does not exist. */ public function convertCallback($name) { if (preg_match(static::PAGE_PATTERN, $name)) { return function (Application $app, Request $request) use($name) { // setpath $path_info = $request->getPathInfo(); if (substr($path_info, -1) == '/') { $path_info .= 'index.php'; } $_SERVER['SCRIPT_NAME'] = str_replace('/index.php', '', $request->server->get('SCRIPT_NAME')) . $path_info . (substr($path_info, -1) == '/' ? 'index.php' : ''); $_SERVER['SCRIPT_FILENAME'] = dirname($request->server->get('SCRIPT_FILENAME')) . $path_info; // rtrim は PHP バージョン依存対策 $GLOBALS['_realdir'] = rtrim(realpath(rtrim(realpath(dirname($request->server->get('SCRIPT_FILENAME'))), '/\\') . '/'), '/\\') . '/'; $GLOBALS['_realdir'] = str_replace('\\', '/', $GLOBALS['_realdir']); $GLOBALS['_realdir'] = str_replace('//', '/', $GLOBALS['_realdir']); define('HTML_REALDIR', $GLOBALS['_realdir']); /** HTMLディレクトリからのDATAディレクトリの相対パス */ define('HTML2DATA_DIR', '../app/'); define('USE_FILENAME_DIR_INDEX', null); if (!defined('DATA_REALDIR')) { define('DATA_REALDIR', HTML_REALDIR . HTML2DATA_DIR); } // アプリケーション初期化処理 if (!defined('CACHE_REALDIR')) { /** キャッシュ生成ディレクトリ */ define('CACHE_REALDIR', DATA_REALDIR . "cache/eccube/"); } \Eccube\Framework\Helper\HandleErrorHelper::load(); // アプリケーション初期化処理 $objInit = new \Eccube\Framework\Initial(); $objInit->init(); // Page instance $objPage = new $name($app); if ($objPage instanceof \Eccube\Page\Admin\AbstractAdminPage) { define('ADMIN_FUNCTION', true); } else { define('FRONT_FUNCTION', true); } // 定数 SAFE が設定されている場合、DBアクセスを回避する。主に、エラー画面を意図する。 if (!defined('SAFE') || !SAFE) { // インストール中で無い場合、 if (!GcUtils::isInstallFunction()) { // インストールチェック Utils::sfInitInstall(); // セッション初期化・開始 $sessionFactory = SessionFactory::getInstance(); $sessionFactory->initSession(); /* * 管理画面の場合は認証行う. * 認証処理忘れ防止のため, \Eccube\Page\Admin::init() 等ではなく, ここでチェックする. */ SessionHelper::adminAuthorization(); } } // bufferを初期化する if ($objPage instanceof \Eccube\Page\Admin\AbstractAdminPage) { ob_start(); } else { // 絵文字変換 (除去) フィルターを組み込む。 ob_start(array('\\Eccube\\Framework\\MobileEmoji', 'handler')); if (Application::alias('eccube.display')->detectDevice() == DEVICE_TYPE_MOBILE) { // resize_image.phpは除外 if (!$objPage instanceof \Eccube\Page\ResizeImage) { /* @var $objMobile MobileHelper */ $objMobile = Application::alias('eccube.helper.mobile'); $objMobile->sfMobileInit(); } } } $objPage->init(); $objPage->process(); $response = ob_get_contents(); ob_end_clean(); return $response; }; } else { return parent::convertCallback($name); } }
/** * 商品画像のパスを取得する * * @param $arrForm * @return string 指定された商品画像のパス */ public function lfGetProductImage($arrForm) { $objQuery = Application::alias('eccube.query'); $table = 'dtb_products'; $col = $arrForm['image_key']; $product_id = $arrForm['product_id']; //指定されたカラムが存在する場合にのみ商品テーブルからファイル名を取得 if (Application::alias('eccube.helper.db')->columnExists($table, $col, '', '', false)) { $product_image = $objQuery->get($col, $table, 'product_id = ?', array($product_id)); } else { GcUtils::gfPrintLog('invalid access :resize_image.php image_key=' . $col); $product_image = ''; } // ファイル名が正しく、ファイルが存在する場合だけ、$fileを設定 $file = Utils::getSaveImagePath($product_image); return $file; }
public function EndSession() { // セッション情報破棄の前にcustomer_idを保存 $customer_id = $_SESSION['customer']['customer_id']; // $_SESSION['customer']の解放 unset($_SESSION['customer']); // セッションの配送情報を全て破棄する PurchaseHelper::unsetAllShippingTemp(true); // トランザクショントークンの破棄 SessionHelper::destroyToken(); /* @var $objSiteSess SiteSession */ $objSiteSess = Application::alias('eccube.site_session'); $objSiteSess->unsetUniqId(); // ログに記録する $log = sprintf("logout : user=%d\tip=%s", $customer_id, $this->getRemoteHost()); GcUtils::gfPrintLog($log, CUSTOMER_LOG_REALFILE, false); }
/** * セッションデータが有効かどうかをチェックする。 * * 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; }
/** * プラグインアーカイブを解凍する. * * @param string $path アーカイブパス * @return boolean Archive_Tar::extractModify()のエラー */ public function unpackPluginArchive($path) { // 圧縮フラグTRUEはgzip解凍をおこなう $tar = new Archive_Tar($path, true); $dir = dirname($path); $file_name = basename($path); // 指定されたフォルダ内に解凍する $result = $tar->extractModify($dir . '/', ''); GcUtils::gfPrintLog("解凍: {$path} -> {$dir}"); // 解凍元のファイルを削除する. unlink($path); return $result; }
public function checkSessionPendingOrder() { if (isset($_SESSION['order_id']) && !Utils::isBlank($_SESSION['order_id'])) { $order_id = $_SESSION['order_id']; unset($_SESSION['order_id']); $objQuery = Application::alias('eccube.query'); $objQuery->begin(); $arrOrder = static::getOrder($order_id); if ($arrOrder['status'] == ORDER_PENDING) { /* @var $objCartSess CartSession */ $objCartSess = Application::alias('eccube.cart_session'); $cartKeys = $objCartSess->getKeys(); if (Utils::isBlank($cartKeys)) { static::rollbackOrder($order_id, ORDER_CANCEL, true); GcUtils::gfPrintLog('order rollback.(session pending) order_id=' . $order_id); } else { static::cancelOrder($order_id, ORDER_CANCEL, true); GcUtils::gfPrintLog('order rollback.(session pending and set card) order_id=' . $order_id); } } $objQuery->commit(); } }
/** * エラーメッセージの冒頭部を生成する * * @return string */ public function lfGetErrMsgHead() { $errmsg = ''; $errmsg .= GcUtils::getUrl() . "\n"; $errmsg .= "\n"; $errmsg .= 'SERVER_ADDR: ' . $_SERVER['SERVER_ADDR'] . "\n"; $errmsg .= 'REMOTE_ADDR: ' . $_SERVER['REMOTE_ADDR'] . "\n"; $errmsg .= 'USER_AGENT: ' . $_SERVER['HTTP_USER_AGENT'] . "\n"; return $errmsg; }
/** * CSVファイルからインサート実行. * * @param Query $objQuery * @param string $dir * @param string $mode * @return boolean */ public function lfExeInsertSQL(&$objQuery, $dir, $mode) { $tbl_flg = false; $col_flg = false; $ret = true; $pagelayout_flg = false; $arrVal = array(); $arrCol = array(); $arrAllTableList = $objQuery->listTables(); $objDir = dir($dir); while (false !== ($file_name = $objDir->read())) { if (!preg_match('/^((dtb|mtb|plg)_(\\w+))\\.csv$/', $file_name, $matches)) { continue; } $file_path = $dir . $file_name; $table = $matches[1]; // テーブル存在チェック if (!in_array($table, $arrAllTableList)) { if ($mode === 'restore_config') { continue; } return false; } // csvファイルからデータの取得 $fp = fopen($file_path, 'r'); if ($fp === false) { trigger_error($file_name . ' のファイルオープンに失敗しました。', E_USER_ERROR); } GcUtils::gfPrintLog('リストア実行: ' . $table); $objQuery->delete($table); $line = 0; $arrColName = array(); while (!feof($fp)) { $line++; $arrCsvLine = fgetcsv($fp, 1024 * 1024); // 1行目: 列名 if ($line === 1) { $arrColName = $arrCsvLine; continue; } // 空行を無視 // false との比較は PHP 5.2.x Windows バグ対応 // 参考: http://www.php.net/manual/ja/function.fgetcsv.php#98502 if ($arrCsvLine === array(null) || $arrCsvLine === false) { continue; } $arrVal = array_combine($arrColName, $arrCsvLine); $objQuery->insert($table, $arrVal); Utils::extendTimeOut(); } fclose($fp); } return $ret; }
/** * 前方互換用 * * @deprecated 2.12.0 GcUtils::gfPrintLog を使用すること */ public function log($mess, $log_level = 'Info') { trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); // ログレベル=Debugの場合は、DEBUG_MODEがtrueの場合のみログ出力する if ($log_level === 'Debug' && DEBUG_MODE === false) { return; } // ログ出力 GcUtils::gfPrintLog($mess, ''); }
/** * エラー捕捉時のエラーハンドラ関数 (for PHP >= 5.2.0) * * この関数は, register_shutdown_function() 関数に登録するための関数である。 * PHP 5.1 対応処理との互換運用ため E_USER_ERROR は handle_warning で捕捉する。 * * @return void */ public static function handle_error() { // 最後のエラーを確実に捉えるため、先頭で呼び出す。 $arrError = error_get_last(); $is_error = false; if (isset($arrError)) { switch ($arrError['type']) { case E_ERROR: case E_PARSE: case E_CORE_ERROR: case E_COMPILE_ERROR: $is_error = true; break; default: break; } } if (!$is_error) { return; } $error_type_name = GcUtils::getErrorTypeName($arrError['type']); $errstr = "Fatal error({$error_type_name}): {$arrError[message]} on [{$arrError[file]}({$arrError[line]})]"; GcUtils::gfPrintLog($errstr, ERROR_LOG_REALFILE, true); // エラー画面を表示する static::displaySystemError($errstr); }
/** * 指定されたパスの配下を再帰的に削除. * * @param string $path 削除対象のディレクトリまたはファイルのパス * @param boolean $del_myself $pathそのものを削除するか. true なら削除する. * @return void */ public function deleteFile($path, $del_myself = true) { $flg = false; // 対象が存在するかを検証. if (file_exists($path) === false) { GcUtils::gfPrintLog($path . ' が存在しません.'); } elseif (is_dir($path)) { // ディレクトリが指定された場合 $handle = opendir($path); if (!$handle) { GcUtils::gfPrintLog($path . ' が開けませんでした.'); } while (($item = readdir($handle)) !== false) { if ($item === '.' || $item === '..') { continue; } $cur_path = $path . '/' . $item; if (is_dir($cur_path)) { // ディレクトリの場合、再帰処理 $flg = $this->deleteFile($cur_path); } else { // ファイルの場合、unlink $flg = @unlink($cur_path); } } closedir($handle); // ディレクトリを削除 GcUtils::gfPrintLog($path . ' を削除します.'); if ($del_myself) { $flg = @rmdir($path); } } else { // ファイルが指定された場合. GcUtils::gfPrintLog($path . ' を削除します.'); $flg = @unlink($path); } return $flg; }
/** * Page のアクション. * * @return void */ public function action() { /* @var $objLayout PageLayoutHelper */ $objLayout = Application::alias('eccube.helper.page_layout'); $objFormParam = Application::alias('eccube.form_param'); $this->lfInitParam($objFormParam); $objFormParam->setParam($_REQUEST); $objFormParam->convParam(); $this->arrErr = $objFormParam->checkError(); $is_error = !Utils::isBlank($this->arrErr); $this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC); $this->page_id = $objFormParam->getValue('page_id'); switch ($this->getMode()) { // 削除 case 'delete': if (!$is_error) { if ($objLayout->isEditablePage($this->device_type_id, $this->page_id)) { $objLayout->lfDelPageData($this->page_id, $this->device_type_id); Application::alias('eccube.response')->reload(array('device_type_id' => $this->device_type_id, 'msg' => 'on'), true); Application::alias('eccube.response')->actionExit(); } } break; // 登録/編集 // 登録/編集 case 'confirm': if (!$is_error) { $this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr); if (Utils::isBlank($this->arrErr)) { $result = $this->doRegister($objFormParam, $objLayout); if ($result !== false) { $arrQueryString = array('device_type_id' => $this->device_type_id, 'page_id' => $result, 'msg' => 'on'); Application::alias('eccube.response')->reload($arrQueryString, true); Application::alias('eccube.response')->actionExit(); } } } break; default: if (isset($_GET['msg']) && $_GET['msg'] == 'on') { $this->tpl_onload = "alert('登録が完了しました。');"; } break; } if (!$is_error) { $this->arrPageList = $objLayout->getPageProperties($this->device_type_id, null); // page_id が指定されている場合にはテンプレートデータの取得 if (!Utils::isBlank($this->page_id)) { $arrPageData = $this->getTplMainpage($this->device_type_id, $this->page_id, $objLayout); $objFormParam->setParam($arrPageData); } } else { // 画面にエラー表示しないため, ログ出力 GcUtils::gfPrintLog('Error: ' . print_r($this->arrErr, true)); } $this->tpl_subtitle = $this->arrDeviceType[$this->device_type_id] . '>' . $this->tpl_subtitle; $this->arrForm = $objFormParam->getFormParamList(); }
/** * 店舗基本情報を登録する * * @param array $arrData 登録するデータ * @return void */ public function registerBasisData($arrData) { /* @var $objQuery Query */ $objQuery = Application::alias('eccube.query'); $arrData = $objQuery->extractOnlyColsOf('dtb_baseinfo', $arrData); if (isset($arrData['regular_holiday_ids']) && is_array($arrData['regular_holiday_ids'])) { // 定休日をパイプ区切りの文字列に変換 $arrData['regular_holiday_ids'] = implode('|', $arrData['regular_holiday_ids']); } $arrData['update_date'] = 'CURRENT_TIMESTAMP'; // UPDATEの実行 $ret = $objQuery->update('dtb_baseinfo', $arrData); GcUtils::gfPrintLog('dtb_baseinfo に UPDATE を実行しました。'); // UPDATE できなかった場合、INSERT if ($ret == 0) { $arrData['id'] = 1; $objQuery->insert('dtb_baseinfo', $arrData); GcUtils::gfPrintLog('dtb_baseinfo に INSERT を実行しました。'); } }
/** * メッセージを出力 * * @param string $message */ public function log($message) { GcUtils::gfPrintLog($message, OSTORE_LOG_REALFILE); }
/** * 管理画面の認証を行う. * * mtb_auth_excludes へ登録されたページは, 認証を除外する. * * @return void */ public static function adminAuthorization() { $arrScriptPath = explode('/', str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME'])); if (!GcUtils::isAdminFunction()) { return; } else { $masterData = Application::alias('eccube.db.master_data'); $arrExcludes = $masterData->getMasterData('mtb_auth_excludes'); foreach ($arrExcludes as $exclude) { $arrExcludesPath = explode('/', str_replace('\\', '/', realpath(HTML_REALDIR . ADMIN_DIR . $exclude))); $arrDiff = array_diff_assoc($arrExcludesPath, $arrScriptPath); if (count($arrDiff) === 0) { return; } } } Utils::sfIsSuccess(new Session()); }
/** * 秘密の質問確認 * * @param array $arrForm フォーム入力値 * @param array $arrReminder リマインダー質問リスト * @return string エラー文字列 問題が無ければNULL */ public function lfCheckForgotSecret(&$arrForm, &$arrReminder) { $errmsg = ''; $objQuery = Application::alias('eccube.query'); $cols = 'customer_id, reminder, reminder_answer, salt'; $table = 'dtb_customer'; $where = '(email = ? OR email_mobile = ?)' . ' AND name01 = ? AND name02 = ?' . ' AND status = 2 AND del_flg = 0'; $arrVal = array($arrForm['email'], $arrForm['email'], $arrForm['name01'], $arrForm['name02']); $result = $objQuery->select($cols, $table, $where, $arrVal); if (isset($result[0]['reminder']) and isset($arrReminder[$result[0]['reminder']]) and $result[0]['reminder'] == $arrForm['reminder']) { $is_authorized = false; if (empty($result[0]['salt'])) { // 旧バージョン(2.11未満)からの移行を考慮 if ($result[0]['reminder_answer'] == $arrForm['reminder_answer']) { $is_authorized = true; } } elseif (Utils::sfIsMatchHashPassword($arrForm['reminder_answer'], $result[0]['reminder_answer'], $result[0]['salt'])) { $is_authorized = true; } if ($is_authorized) { // 秘密の答えが一致 // 新しいパスワードを設定する $new_password = GcUtils::gfMakePassword(8); if (FORGOT_MAIL == 1) { // メールで変更通知をする /* @var $objDb DbHelper */ $objDb = Application::alias('eccube.helper.db'); $CONF = $objDb->getBasisData(); $this->lfSendMail($CONF, $arrForm['email'], $arrForm['name01'], $new_password); } $sqlval = array(); $sqlval['password'] = $new_password; Application::alias('eccube.helper.customer')->sfEditCustomerData($sqlval, $result[0]['customer_id']); $arrForm['new_password'] = $new_password; } else { // 秘密の答えが一致しなかった $errmsg = '秘密の質問が一致しませんでした。'; } } else { //不正なアクセス リマインダー値が前画面と異なる。 // 新リファクタリング基準ではここで遷移は不許可なのでエラー表示 //Utils::sfDispSiteError(PAGE_ERROR, '', true); $errmsg = '秘密の質問が一致しませんでした。'; } return $errmsg; }
/** * APIログ * * @param string $msg 出力文字列 * @param text $operation_name * @return void */ public function printApiLog($msg, $start_time = '', $operation_name = '') { if (!Utils::isBlank($operation_name)) { $msg = 'API_' . $operation_name . ':' . $msg; } if (!Utils::isBlank($start_time)) { $msg = '(RequestId:' . $start_time . ')' . $msg; } GcUtils::gfPrintLog($msg, DATA_REALDIR . self::API_LOGFILE, self::API_DEBUG_MODE); }
/** * SQL の実行ログ (トレースログ) を書き出す * * @param string 実行するSQL文 * @param array $arrVal プレースホルダに挿入する配列 * @return void */ private function lfEndDbTraceLog(&$arrStartInfo, &$objSth, &$arrVal) { if (!defined('SQL_QUERY_LOG_MODE') || SQL_QUERY_LOG_MODE === 0) { return; } $msg = "[execute end {$arrStartInfo['http_request_id']}#{$arrStartInfo['count']}]\n"; $timeEnd = microtime(true); $timeExecTime = $timeEnd - $arrStartInfo['time_start']; // ログモード1の場合、 if (SQL_QUERY_LOG_MODE === 1) { // 規定時間より速い場合、ログに出力しない if (!defined('SQL_QUERY_LOG_MIN_EXEC_TIME') || $timeExecTime < (double) SQL_QUERY_LOG_MIN_EXEC_TIME) { return; } // 開始時にログ出力していないため、ここで実行内容を出力する $msg .= 'SQL: ' . $objSth->query . "\n"; $msg .= 'PlaceHolder: ' . var_export($arrVal, true) . "\n"; } $msg .= 'execution time: ' . sprintf('%.2f sec', $timeExecTime) . "\n"; GcUtils::gfPrintLog($msg, DB_LOG_REALFILE); }
protected function log($msg) { $msg = sprintf("%s %s: %s", $this->plugin_code, $this->exec_func, $msg); GcUtils::gfPrintLog($msg, PLUGIN_LOG_REALFILE); }
/** * 指定サイズで画像を出力する. * * @param string $FromImgPath ファイル名までのパス * @param string $ToImgPath 出力先パス * @param integer $tmpMW 最大横幅 * @param integer $tmpMH 最大縦幅 * @param integer $newFileName 新ファイル名 * @param array 新ファイル名を格納した配列 */ public function MakeThumb($FromImgPath, $ToImgPath, $tmpMW, $tmpMH, $newFileName = '') { // 画像の最大横幅(単位:ピクセル) $ThmMaxWidth = LARGE_IMAGE_WIDTH; // 画像の最大縦幅(単位:ピクセル) $ThmMaxHeight = LARGE_IMAGE_HEIGHT; //拡張子取得 $array_ext = explode('.', $FromImgPath); $ext = $array_ext[count($array_ext) - 1]; $MW = $ThmMaxWidth; if ($tmpMW) { $MW = $tmpMW; } // $MWに最大横幅セット $MH = $ThmMaxHeight; if ($tmpMH) { $MH = $tmpMH; } // $MHに最大縦幅セット if (empty($FromImgPath) || empty($ToImgPath)) { return array(0, '出力元画像パス、または出力先フォルダが指定されていません。'); } if (!file_exists($FromImgPath)) { return array(0, '出力元画像が見つかりません。'); } $size = @GetImageSize($FromImgPath); $re_size = $size; // 画像の種類が不明 or swf if (!$size[2] || $size[2] > 3) { return array(0, '画像形式がサポートされていません。'); } //アスペクト比固定処理 $tmp_w = $size[0] / $MW; if ($MH != 0) { $tmp_h = $size[1] / $MH; } if ($tmp_w > 1 || $tmp_h > 1) { if ($MH == 0) { if ($tmp_w > 1) { $re_size[0] = $MW; $re_size[1] = $size[1] * $MW / $size[0]; } } else { if ($tmp_w > $tmp_h) { $re_size[0] = $MW; $re_size[1] = $size[1] * $MW / $size[0]; } else { $re_size[1] = $MH; $re_size[0] = $size[0] * $MH / $size[1]; } } } // サムネイル画像ファイル名作成処理 $tmp = array_pop(explode('/', $FromImgPath)); // /の一番最後を切り出し $FromFileName = array_shift(explode('.', $tmp)); // .で区切られた部分を切り出し $ToFile = $FromFileName; // 拡張子以外の部分までを作成 $ImgNew = imagecreatetruecolor($re_size[0], $re_size[1]); switch ($size[2]) { case '1': //gif形式 if ($tmp_w <= 1 && $tmp_h <= 1) { if ($newFileName) { $ToFile = $newFileName; } elseif ($ext) { $ToFile .= '.' . $ext; } else { $ToFile .= '.gif'; } if (!@copy($FromImgPath, $ToImgPath . $ToFile)) { // エラー処理 return array(0, 'ファイルのコピーに失敗しました。'); } ImageDestroy($ImgNew); return array(1, $ToFile); } ImageColorAllocate($ImgNew, 255, 235, 214); //背景色 $black = ImageColorAllocate($ImgNew, 0, 0, 0); $red = ImageColorAllocate($ImgNew, 255, 0, 0); Imagestring($ImgNew, 4, 5, 5, "GIF {$size['0']}x{$size['1']}", $red); ImageRectangle($ImgNew, 0, 0, $re_size[0] - 1, $re_size[1] - 1, $black); if ($newFileName) { $ToFile = $newFileName; } elseif ($ext) { $ToFile .= '.' . $ext; } else { $ToFile .= '.png'; } $TmpPath = $ToImgPath . $ToFile; @Imagepng($ImgNew, $TmpPath); // 画像が作成されていない場合 if (!@file_exists($TmpPath)) { return array(0, '画像の出力に失敗しました。'); } ImageDestroy($ImgNew); return array(1, $ToFile); case '2': //jpg形式 $ImgDefault = ImageCreateFromJpeg($FromImgPath); //ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); if ($re_size[0] != $size[0] || $re_size[0] != $size[0]) { ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); } GcUtils::gfDebugLog($size); GcUtils::gfDebugLog($re_size); if ($newFileName) { $ToFile = $newFileName; } elseif ($ext) { $ToFile .= '.' . $ext; } else { $ToFile .= '.jpg'; } $TmpPath = $ToImgPath . $ToFile; @ImageJpeg($ImgNew, $TmpPath); // 画像が作成されていない場合 if (!@file_exists($TmpPath)) { return array(0, "画像の出力に失敗しました。<br>{$ImgNew}<br>{$TmpPath}"); } $RetVal = $ToFile; break; case '3': //png形式 $ImgDefault = ImageCreateFromPNG($FromImgPath); //ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); if ($newFileName) { $ToFile = $newFileName; } elseif ($ext) { $ToFile .= '.' . $ext; } else { $ToFile .= '.png'; } $TmpPath = $ToImgPath . $ToFile; @ImagePNG($ImgNew, $TmpPath); // 画像が作成されていない場合 if (!@file_exists($TmpPath)) { return array(0, '画像の出力に失敗しました。'); } $RetVal = $ToFile; break; } ImageDestroy($ImgDefault); ImageDestroy($ImgNew); return array(1, $RetVal); }
/** * EC-CUBE がサポートする携帯端末かどうかを判別する。 * * 以下の条件に該当する場合は, false を返す. * * - 携帯端末だと判別されたが, ユーザーエージェントが解析不能な場合 * - J-PHONE C4型(パケット非対応) * - EzWeb で WAP2 以外の端末 * - DoCoMo 501i, 502i, 209i, 210i, SH821i, N821i, P821i, P651ps, R691i, F671i, SH251i, SH251iS * * @return boolean サポートしている場合は true、それ以外の場合は false を返す。 */ public static function isSupported() { $objAgent =& \Net_UserAgent_Mobile::singleton(); // 携帯端末だと認識されたが、User-Agent の形式が未知の場合 if (\Net_UserAgent_Mobile::isError($objAgent)) { GcUtils::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; } }