/** * Page のアクション. * * @return void */ function action() { $objDb = new SC_Helper_DB_Ex(); $mode = $this->getMode(); if (!empty($_POST)) { $objFormParam = new SC_FormParam_Ex(); $objFormParam->setParam($_POST); $this->arrErr = $this->lfCheckError($mode, $objFormParam); if (!empty($this->arrErr['deliv_id'])) { SC_Utils_Ex::sfDispException(); return; } } switch ($mode) { case 'delete': // ランク付きレコードの削除 $objDb->sfDeleteRankRecord("dtb_deliv", "deliv_id", $_POST['deliv_id']); $this->objDisplay->reload(); // PRG pattern break; case 'up': $objDb->sfRankUp("dtb_deliv", "deliv_id", $_POST['deliv_id']); $this->objDisplay->reload(); // PRG pattern break; case 'down': $objDb->sfRankDown("dtb_deliv", "deliv_id", $_POST['deliv_id']); $this->objDisplay->reload(); // PRG pattern break; default: break; } $this->arrDelivList = $this->lfGetDelivList(); }
/** * Page を初期化する. * * @return void */ function init() { if (DEBUG_LOAD_PLUGIN !== true) { SC_Utils_Ex::sfDispException('プラグインは有効化されていない'); } // XXX 開発途上対応 parent::init(); $this->tpl_mainpage = 'plugin/index.tpl'; $this->tpl_mainno = 'plugin'; $this->tpl_subno = 'index'; $this->tpl_subtitle = 'プラグイン管理'; }
/** * Page のアクション. * * @return void */ function action() { // パラメーター管理クラス $this->objFormParam = new SC_FormParam_Ex(); // パラメーター情報の初期化 $this->lfInitParam(); // POST値の取得 $this->objFormParam->setParam($_REQUEST); // 入力情報を渡す $this->arrForm = $this->objFormParam->getHashArray(); $this->arrErr = $this->objFormParam->checkError(); if (count($this->arrErr) == 0) { // アンインストール $this->lfUninstall($this->arrForm['path']); $this->tpl_result = '完了しました。'; } else { SC_Utils_Ex::sfDispException(); } }
/** * Page のアクション. * * @return void */ function action() { $objDb = new SC_Helper_DB_Ex(); $mode = $this->getMode(); if (!empty($_POST)) { $objFormParam = new SC_FormParam_Ex(); $objFormParam->addParam('配送業者ID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); $objFormParam->setParam($_POST); $objFormParam->convParam(); $arrErr = $objFormParam->checkError(); if (!empty($this->arrErr['payment_id'])) { SC_Utils_Ex::sfDispException(); return; } $post = $objFormParam->getHashArray(); } switch ($this->getMode()) { case 'delete': // ランク付きレコードの削除 $objDb->sfDeleteRankRecord("dtb_payment", "payment_id", $post['payment_id']); // 再表示 $this->objDisplay->reload(); break; case 'up': $objDb->sfRankUp("dtb_payment", "payment_id", $post['payment_id']); // 再表示 $this->objDisplay->reload(); break; case 'down': $objDb->sfRankDown("dtb_payment", "payment_id", $post['payment_id']); // 再表示 $this->objDisplay->reload(); break; } $this->arrDelivList = $objDb->sfGetIDValueList("dtb_deliv", "deliv_id", "service_name"); $this->arrPaymentListFree = $this->lfGetPaymentList(); }
/** * Page のアクション. * * @return void */ function action() { $objDb = new SC_Helper_DB_Ex(); $objDate = new SC_Date_Ex(); $this->arrMonth = $objDate->getMonth(); $this->arrDay = $objDate->getDay(); $mode = $this->getMode(); if (!empty($_POST)) { $objFormParam = new SC_FormParam_Ex(); $this->lfInitParam($mode, $objFormParam); $objFormParam->setParam($_POST); $objFormParam->convParam(); $holiday_id = $objFormParam->getValue('holiday_id'); $this->arrErr = $this->lfCheckError($mode, $objFormParam); if (!empty($this->arrErr['holiday_id'])) { SC_Utils_Ex::sfDispException(); return; } $post = $objFormParam->getHashArray(); } // 要求判定 switch ($mode) { // 編集処理 case 'edit': // POST値の引き継ぎ $this->arrForm = $this->arrForm = $_POST; if (count($this->arrErr) <= 0) { // 新規作成 if ($post['holiday_id'] == "") { $this->lfInsertClass($this->arrForm, $_SESSION['member_id']); } else { $this->lfUpdateClass($this->arrForm, $post['holiday_id']); } // 再表示 $this->objDisplay->reload(); } else { // POSTデータを引き継ぐ $this->tpl_holiday_id = $post['holiday_id']; } break; // 削除 // 削除 case 'delete': $objDb->sfDeleteRankRecord("dtb_holiday", "holiday_id", $post['holiday_id'], "", true); // 再表示 $this->objDisplay->reload(); break; // 編集前処理 // 編集前処理 case 'pre_edit': // 編集項目を取得する。 $arrHolidayData = $this->lfGetHolidayDataByHolidayID($post['holiday_id']); // 入力項目にカテゴリ名を入力する。 $this->arrForm['title'] = $arrHolidayData[0]['title']; $this->arrForm['month'] = $arrHolidayData[0]['month']; $this->arrForm['day'] = $arrHolidayData[0]['day']; // POSTデータを引き継ぐ $this->tpl_holiday_id = $post['holiday_id']; break; case 'down': $objDb->sfRankDown("dtb_holiday", "holiday_id", $post['holiday_id']); // 再表示 $this->objDisplay->reload(); break; case 'up': $objDb->sfRankUp("dtb_holiday", "holiday_id", $post['holiday_id']); // 再表示 $this->objDisplay->reload(); break; default: break; } $this->arrHoliday = $this->lfGetHolidayList(); // POSTデータを引き継ぐ $this->tpl_holiday_id = $holiday_id; }
/** * アプリケーション内でリダイレクトする * * 内部で生成する URL の searchpart は、下記の順で上書きしていく。(後勝ち) * 1. 引数 $inheritQueryString が true の場合、$_SERVER['QUERY_STRING'] * 2. $location に含まれる searchpart * 3. 引数 $arrQueryString * @param string $location 「url-path」「現在のURLからのパス」「URL」のいずれか。「../」の解釈は行なわない。 * @param array $arrQueryString URL に付加する searchpart * @param bool $inheritQueryString 現在のリクエストの searchpart を継承するか * @param bool|null $useSsl true:HTTPSを強制, false:HTTPを強制, null:継承 * @return void * @static */ function sendRedirect($location, $arrQueryString = array(), $inheritQueryString = false, $useSsl = null) { // url-path → URL 変換 if ($location[0] === '/') { $netUrl = new Net_URL($location); $location = $netUrl->getUrl(); } // URL の場合 if (preg_match('/^https?:/', $location)) { $url = $location; if (is_bool($useSsl)) { if ($useSsl) { $pattern = '/^' . preg_quote(HTTP_URL, '/') . '(.*)/'; $replacement = HTTPS_URL . '\\1'; $url = preg_replace($pattern, $replacement, $url); } else { $pattern = '/^' . preg_quote(HTTPS_URL, '/') . '(.*)/'; $replacement = HTTP_URL . '\\1'; $url = preg_replace($pattern, $replacement, $url); } } } else { if (!is_bool($useSsl)) { $useSsl = SC_Utils_Ex::sfIsHTTPS(); } $netUrl = new Net_URL($useSsl ? HTTPS_URL : HTTP_URL); $netUrl->path = dirname($_SERVER['PHP_SELF']) . '/' . $location; $url = $netUrl->getUrl(); } $pattern = '/^(' . preg_quote(HTTP_URL, '/') . '|' . preg_quote(HTTPS_URL, '/') . ')/'; // アプリケーション外へのリダイレクトは扱わない if (preg_match($pattern, $url) === 0) { SC_Utils_Ex::sfDispException(); } $netUrl = new Net_URL($url); if ($inheritQueryString && !empty($_SERVER['QUERY_STRING'])) { $arrQueryStringBackup = $netUrl->querystring; // XXX メソッド名は add で始まるが、実際には置換を行う $netUrl->addRawQueryString($_SERVER['QUERY_STRING']); $netUrl->querystring = array_merge($netUrl->querystring, $arrQueryStringBackup); } $netUrl->querystring = array_merge($netUrl->querystring, $arrQueryString); $session = SC_SessionFactory::getInstance(); if (SC_MobileUserAgent_Ex::isMobile() || $session->useCookie() == false) { $netUrl->addQueryString(session_name(), session_id()); } $netUrl->addQueryString(TRANSACTION_ID_NAME, SC_Helper_Session_Ex::getToken()); $url = $netUrl->getURL(); header("Location: {$url}"); exit; }
/** * 指定ファイルが存在する場合 SQL として実行 * * XXX プラグイン用に追加。将来消すかも。 * * @param string $sqlFilePath SQL ファイルのパス * @return void */ function sfExecSqlByFile($sqlFilePath) { if (file_exists($sqlFilePath)) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $sqls = file_get_contents($sqlFilePath); if ($sqls === false) { SC_Utils_Ex::sfDispException('ファイルは存在するが読み込めない'); } foreach (explode(';', $sqls) as $sql) { $sql = trim($sql); if (strlen($sql) == 0) { continue; } $objQuery->query($sql); } } }
/** * プラグイン XML を書き込む * * @param SimpleXMLElement $pluginsXml プラグイン XML * @return integer ファイルに書き込まれたバイト数を返します。 */ function sfPutPluginsXml($pluginsXml) { if (version_compare(PHP_VERSION, '5.0.0', '>')) { return; } $xml = $pluginsXml->asXML(); if (strlen($xml) == 0) { SC_Utils_Ex::sfDispException(); } $return = file_put_contents(PLUGIN_REALDIR . 'plugins.xml', $pluginsXml->asXML()); if ($return === false) { SC_Utils_Ex::sfDispException(); } return $return; }
/** * CSVファイルからインサート実行. * * @param object $objQuery * @param string $csv * @param string $mode * @return void */ function lfExeInsertSQL(&$objQuery, $csv, $mode) { $tbl_flg = false; $col_flg = false; $ret = true; $pagelayout_flg = false; $table_name = ""; $arrVal = array(); $arrCol = array(); // csvファイルからデータの取得 $fp = fopen($csv, 'r'); if ($fp === false) { SC_Utils_Ex::sfDispException($csv . ' のファイルオープンに失敗しました。'); } while (!feof($fp)) { $data = fgetcsv($fp, 1000000); //空白行のときはテーブル変更 if (count($data) <= 1 and $data[0] == "") { $tbl_flg = false; $col_flg = false; $table_name = ""; $arrVal = array(); $arrCol = array(); continue; } // テーブルフラグがたっていない場合にはテーブル名セット if (!$tbl_flg) { $table_name = $data[0]; $tbl_flg = true; if ($table_name == "dtb_pagelayout") { $pagelayout_flg = true; } continue; } // カラムフラグがたっていない場合にはカラムセット if (!$col_flg) { if ($mode != "restore_config") { for ($i = 0; $i < count($data); $i++) { $arrCol[$i] = $data[$i]; } } $col_flg = true; continue; } for ($i = 0; $i < count($data); $i++) { if ($arrCol[$i] != '') { $arrVal[$arrCol[$i]] = $data[$i]; } } $err = $objQuery->insert($table_name, $arrVal); // エラーがあれば終了 if (PEAR::isError($err)) { SC_Utils_Ex::sfErrorHeader(">> " . $objQuery->getlastquery(false)); return false; } if ($pagelayout_flg) { // dtb_pagelayoutの場合には最初のデータはpage_id = 0にする $arrVal['page_id'] = '0'; $objQuery->update("dtb_pagelayout", $arrVal); $pagelayout_flg = false; } // タイムアウトを防ぐ SC_Utils_Ex::sfFlush(); } fclose($fp); return $ret; }
/** * ZIP アーカイブファイルを展開して、郵便番号 CSV を上書き * * @return void */ function lfExtractZipFile() { $zip = zip_open($this->zip_csv_temp_realfile); if (!is_resource($zip)) { SC_Utils_Ex::sfDispException($this->zip_csv_temp_realfile . ' をオープンできません。'); } do { $entry = zip_read($zip); } while ($entry && zip_entry_name($entry) != 'KEN_ALL.CSV'); if (!$entry) { SC_Utils_Ex::sfDispException($this->zip_csv_temp_realfile . ' に対象ファイルが見つかりません。'); } // 展開時の破損を考慮し、別名で一旦展開する。 $tmp_csv_realfile = ZIP_CSV_REALFILE . '.tmp'; $res = zip_entry_open($zip, $entry, 'rb'); if (!$res) { SC_Utils_Ex::sfDispException($this->zip_csv_temp_realfile . ' の展開に失敗しました。'); } $fp = fopen($tmp_csv_realfile, 'w'); if (!$fp) { SC_Utils_Ex::sfDispException($tmp_csv_realfile . ' を開けません。'); } $res = fwrite($fp, zip_entry_read($entry, zip_entry_filesize($entry))); if ($res === FALSE) { SC_Utils_Ex::sfDispException($tmp_csv_realfile . ' の書き込みに失敗しました。'); } fclose($fp); zip_close($zip); // CSV 削除 $res = unlink(ZIP_CSV_REALFILE); if (!$res) { SC_Utils_Ex::sfDispException(ZIP_CSV_REALFILE . ' を削除できません。'); } // CSV ファイル名変更 $res = rename($tmp_csv_realfile, ZIP_CSV_REALFILE); if (!$res) { SC_Utils_Ex::sfDispException('ファイル名を変更できません。: ' . $tmp_csv_realfile . ' -> ' . ZIP_CSV_REALFILE); } }
/** * Page のアクション. * * @return void */ function action() { $objFormParam = new SC_FormParam_Ex(); $this->lfInitParam($this->mode, $objFormParam); $objFormParam->setParam($_POST); // 入力値の変換 $objFormParam->convParam(); $this->arrErr = $this->lfCheckError($objFormParam); switch ($this->mode) { case 'edit': if (count($this->arrErr) == 0) { $objFormParam->setValue('deliv_id', $this->lfRegistData($objFormParam->getHashArray(), $_SESSION['member_id'])); $this->tpl_onload = "window.alert('配送方法設定が完了しました。');"; } break; case 'pre_edit': if (count($this->arrErr) > 0) { SC_Utils_Ex::sfDispException(); } $this->lfGetDelivData($objFormParam); break; default: break; } $this->arrForm = $objFormParam->getFormParamList(); }
/** * Page のアクション. * * @return void */ function action() { $objFormParam = new SC_FormParam_Ex(); // アップロードファイル情報の初期化 $objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); $this->lfInitFile($objUpFile); $objUpFile->setHiddenFileList($_POST); // ダウンロード販売ファイル情報の初期化 $objDownFile = new SC_UploadFile_Ex(DOWN_TEMP_REALDIR, DOWN_SAVE_REALDIR); $this->lfInitDownFile($objDownFile); $objDownFile->setHiddenFileList($_POST); // 検索パラメーター引き継ぎ $this->arrSearchHidden = $this->lfGetSearchParam($_POST); $mode = $this->getMode(); switch ($mode) { case 'pre_edit': case 'copy': // パラメーター初期化(商品ID) $this->lfInitFormParam_PreEdit($objFormParam, $_POST); // エラーチェック $this->arrErr = $objFormParam->checkError(); if (count($this->arrErr) > 0) { SC_Utils_Ex::sfDispException(); } // 商品ID取得 $product_id = $objFormParam->getValue('product_id'); // 商品データ取得 $arrForm = $this->lfGetFormParam_PreEdit($objUpFile, $objDownFile, $product_id); // 複製の場合は、ダウンロード商品情報部分はコピーしない if ($mode == 'copy') { // ダウンロード商品ファイル名をunset $arrForm['down_filename'] = ''; // $objDownFile->setDBDownFile()でsetされたダウンロードファイル名をunset unset($objDownFile->save_file[0]); } // ページ表示用パラメーター設定 $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); // 商品複製の場合、画像ファイルコピー if ($mode == 'copy') { $this->arrForm["copy_product_id"] = $this->arrForm["product_id"]; $this->arrForm["product_id"] = ""; // 画像ファイルのコピー $this->lfCopyProductImageFiles($objUpFile); } // ページonload時のJavaScript設定 $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); break; case 'edit': // パラメーター初期化, 取得 $this->lfInitFormParam($objFormParam, $_POST); $arrForm = $objFormParam->getHashArray(); // エラーチェック $this->arrErr = $this->lfCheckError_Edit($objFormParam, $objUpFile, $objDownFile, $arrForm); if (count($this->arrErr) == 0) { // 確認画面表示設定 $this->tpl_mainpage = 'products/confirm.tpl'; $this->arrCatList = $this->lfGetCategoryList_Edit(); $this->arrForm = $this->lfSetViewParam_ConfirmPage($objUpFile, $objDownFile, $arrForm); } else { // 入力画面表示設定 $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); // ページonload時のJavaScript設定 $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); } break; case 'complete': // パラメーター初期化, 取得 $this->lfInitFormParam($objFormParam, $_POST); $arrForm = $this->lfGetFormParam_Complete($objFormParam); // エラーチェック $this->arrErr = $this->lfCheckError_Edit($objFormParam, $objUpFile, $objDownFile, $arrForm); if (count($this->arrErr) == 0) { // DBへデータ登録 $product_id = $this->lfRegistProduct($objUpFile, $objDownFile, $arrForm); // 件数カウントバッチ実行 $objQuery =& SC_Query_Ex::getSingletonInstance(); $objDb = new SC_Helper_DB_Ex(); $objDb->sfCountCategory($objQuery); //$objDb->sfCountMaker($objQuery); // ダウンロード商品の複製時に、ダウンロード商品用ファイルを // 変更すると、複製元のファイルが削除されるのを回避。 if (!empty($arrForm['copy_product_id'])) { $objDownFile->save_file = array(); } // 一時ファイルを本番ディレクトリに移動する $this->lfSaveUploadFiles($objUpFile, $objDownFile, $product_id); $this->tpl_mainpage = 'products/complete.tpl'; $this->arrForm['product_id'] = $product_id; } else { // 入力画面表示設定 $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); // ページonload時のJavaScript設定 $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); } break; // 画像のアップロード // 画像のアップロード case 'upload_image': case 'delete_image': // パラメーター初期化 $this->lfInitFormParam_UploadImage($objFormParam); $this->lfInitFormParam($objFormParam, $_POST); $arrForm = $objFormParam->getHashArray(); switch ($mode) { case 'upload_image': // ファイルを一時ディレクトリにアップロード $this->arrErr[$arrForm['image_key']] = $objUpFile->makeTempFile($arrForm['image_key'], IMAGE_RENAME); if ($this->arrErr[$arrForm['image_key']] == "") { // 縮小画像作成 $this->lfSetScaleImage($objUpFile, $arrForm['image_key']); } break; case 'delete_image': // ファイル削除 $this->lfDeleteTempFile($objUpFile, $arrForm['image_key']); break; } // 入力画面表示設定 $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); // ページonload時のJavaScript設定 $anchor_hash = $this->getAnchorHash($arrForm['image_key']); $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); break; // ダウンロード商品ファイルアップロード // ダウンロード商品ファイルアップロード case 'upload_down': case 'delete_down': // パラメーター初期化 $this->lfInitFormParam_UploadDown($objFormParam); $this->lfInitFormParam($objFormParam, $_POST); $arrForm = $objFormParam->getHashArray(); switch ($mode) { case 'upload_down': // ファイルを一時ディレクトリにアップロード $this->arrErr[$arrForm['down_key']] = $objDownFile->makeTempDownFile(); break; case 'delete_down': // ファイル削除 $objDownFile->deleteFile($arrForm['down_key']); break; } // 入力画面表示設定 $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); // ページonload時のJavaScript設定 $anchor_hash = $this->getAnchorHash($arrForm['down_key']); $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); break; // 関連商品選択 // 関連商品選択 case 'recommend_select': // パラメーター初期化 $this->lfInitFormParam_RecommendSelect($objFormParam); $this->lfInitFormParam($objFormParam, $_POST); $arrForm = $objFormParam->getHashArray(); // 入力画面表示設定 $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); // 選択された関連商品IDがすでに登録している関連商品と重複していないかチェック $this->lfCheckError_RecommendSelect($this->arrForm, $this->arrErr); // ページonload時のJavaScript設定 $anchor_hash = $this->getAnchorHash($this->arrForm['anchor_key']); $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); break; // 確認ページからの戻り // 確認ページからの戻り case 'confirm_return': // パラメーター初期化 $this->lfInitFormParam($objFormParam, $_POST); $arrForm = $objFormParam->getHashArray(); // 入力画面表示設定 $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); // ページonload時のJavaScript設定 $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); break; default: // 入力画面表示設定 $arrForm = array(); $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); // ページonload時のJavaScript設定 $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); break; } // 関連商品の読み込み $this->arrRecommend = $this->lfGetRecommendProducts($this->arrForm); }