| 1 | #!/usr/local/bin/php -q |
|---|
| 2 | <?php |
|---|
| 3 | /* |
|---|
| 4 | * EC-CUBE 動作検証用会員データ生成スクリプト |
|---|
| 5 | * |
|---|
| 6 | * Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 7 | * |
|---|
| 8 | * http://www.lockon.co.jp/ |
|---|
| 9 | * |
|---|
| 10 | * This program is free software; you can redistribute it and/or |
|---|
| 11 | * modify it under the terms of the GNU General Public License |
|---|
| 12 | * as published by the Free Software Foundation; either version 2 |
|---|
| 13 | * of the License, or (at your option) any later version. |
|---|
| 14 | * |
|---|
| 15 | * This program is distributed in the hope that it will be useful, |
|---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | * GNU General Public License for more details. |
|---|
| 19 | * |
|---|
| 20 | * You should have received a copy of the GNU General Public License |
|---|
| 21 | * along with this program; if not, write to the Free Software |
|---|
| 22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 23 | * |
|---|
| 24 | * @auther Kentaro Habu |
|---|
| 25 | * @version $Id$ |
|---|
| 26 | */ |
|---|
| 27 | |
|---|
| 28 | // {{{ requires |
|---|
| 29 | /** 適宜、htmlディレクトリへのrequire.phpを読み込めるよう パスを書き換えて下さい */ |
|---|
| 30 | require_once(dirname(__FILE__) . "/../html/require.php"); |
|---|
| 31 | |
|---|
| 32 | // }}} |
|---|
| 33 | // {{{ constants |
|---|
| 34 | |
|---|
| 35 | /** 会員の生成数 */ |
|---|
| 36 | define('CUSTOMERS_VOLUME', 100); // ※最大値:99999までで指定してください |
|---|
| 37 | |
|---|
| 38 | /** |
|---|
| 39 | * 会員メールアドレスのアカウント名 |
|---|
| 40 | * アカウント名の後ろに「+99999」の形で連番をつけて、別名アドレス(エイリアス)の形でメールアドレスを登録します。 |
|---|
| 41 | * 実際にメールを受信するためには、メールサーバが別名アドレスに対応している必要があります。 |
|---|
| 42 | * (例えば、Gmailは別名アドレスに対応しています) |
|---|
| 43 | */ |
|---|
| 44 | define('EMAIL_ADDRESS_ACCOUNT', 'test'); |
|---|
| 45 | |
|---|
| 46 | /** |
|---|
| 47 | * 会員メールアドレスのドメイン名 |
|---|
| 48 | */ |
|---|
| 49 | define('EMAIL_ADDRESS_DOMAIN', "@localhost"); |
|---|
| 50 | |
|---|
| 51 | // }}} |
|---|
| 52 | // {{{ Logic |
|---|
| 53 | set_time_limit(0); |
|---|
| 54 | while (@ob_end_flush()); |
|---|
| 55 | |
|---|
| 56 | $objData = new CreateEcCubeCustomerData(); |
|---|
| 57 | $start = microtime(true); |
|---|
| 58 | |
|---|
| 59 | /* |
|---|
| 60 | * ※このスクリプトは、会員データの作成に |
|---|
| 61 | * SC_Helper_Customer_Ex::sfEditCustomerData()を利用しており、 |
|---|
| 62 | * この関数内で、begin~commitされているので、 |
|---|
| 63 | * このスクリプト側でbegin~rollback/commitする事はできません。 |
|---|
| 64 | */ |
|---|
| 65 | //$objData->objQuery->begin(); |
|---|
| 66 | |
|---|
| 67 | // 会員生成 |
|---|
| 68 | print("creating Customer Data(for Test)...\n"); |
|---|
| 69 | $objData->createCustomers(); |
|---|
| 70 | |
|---|
| 71 | //$objData->objQuery->rollback(); |
|---|
| 72 | //$objData->objQuery->commit(); |
|---|
| 73 | $end = microtime(true); |
|---|
| 74 | /* |
|---|
| 75 | * Windowsのコマンドプロンプトで文字化けしないように、 |
|---|
| 76 | * 標準出力に出すメッセージにはマルチバイト文字を使用しないようにした。 |
|---|
| 77 | * (「chcp 65001」を実行してもWindows7では文字化けした) |
|---|
| 78 | */ |
|---|
| 79 | print("create customer data DONE!\n"); |
|---|
| 80 | printf("elapsed time: %f sec\n", $end - $start); |
|---|
| 81 | lfPrintLog(sprintf("elapsed time: %f sec\n", $end - $start)); |
|---|
| 82 | exit; |
|---|
| 83 | |
|---|
| 84 | // }}} |
|---|
| 85 | // {{{ classes |
|---|
| 86 | |
|---|
| 87 | /** |
|---|
| 88 | * EC-CUBE のテスト用会員データを生成する |
|---|
| 89 | */ |
|---|
| 90 | class CreateEcCubeCustomerData |
|---|
| 91 | { |
|---|
| 92 | |
|---|
| 93 | /** SC_Query インスタンス */ |
|---|
| 94 | var $objQuery; |
|---|
| 95 | |
|---|
| 96 | /** |
|---|
| 97 | * コンストラクタ. |
|---|
| 98 | */ |
|---|
| 99 | function CreateEcCubeCustomerData() |
|---|
| 100 | { |
|---|
| 101 | $this->objQuery = new SC_Query(); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | /** |
|---|
| 105 | * テスト用 会員データ を生成する. |
|---|
| 106 | * |
|---|
| 107 | * @return void |
|---|
| 108 | */ |
|---|
| 109 | function createCustomers() |
|---|
| 110 | { |
|---|
| 111 | lfPrintLog("createCustomers START.(" . CUSTOMERS_VOLUME . " data)"); |
|---|
| 112 | for ($i = 0; $i < CUSTOMERS_VOLUME; $i++) { |
|---|
| 113 | lfPrintLog("----------"); |
|---|
| 114 | lfPrintLog("creating customer data count:[" . ($i+1) . "] start."); |
|---|
| 115 | |
|---|
| 116 | $sqlval['name01'] = "検証"; |
|---|
| 117 | $sqlval['name02'] = sprintf("太郎%05d", $i+1); |
|---|
| 118 | $sqlval['kana01'] = "ケンショウ"; |
|---|
| 119 | $sqlval['kana02'] = "タロウ"; |
|---|
| 120 | $sqlval['zip01'] = '101'; |
|---|
| 121 | $sqlval['zip02'] = '0051'; |
|---|
| 122 | $sqlval['pref'] = '13'; // 13:東京都 |
|---|
| 123 | $sqlval['addr01'] = "千代田区神田神保町"; |
|---|
| 124 | $sqlval['addr02'] = "1-3-5"; |
|---|
| 125 | $sqlval['tel01'] = '012'; |
|---|
| 126 | $sqlval['tel02'] = '3456'; |
|---|
| 127 | $sqlval['tel03'] = '7890'; |
|---|
| 128 | $sqlval['email'] = EMAIL_ADDRESS_ACCOUNT . "+" . sprintf("%05d", $i+1) . EMAIL_ADDRESS_DOMAIN; |
|---|
| 129 | $sqlval['sex'] = '1'; // 1:男性 2:女性 |
|---|
| 130 | $sqlval['password'] = 'test'; |
|---|
| 131 | $sqlval['reminder'] = '1'; // 1:「母親の旧姓は?」 |
|---|
| 132 | $sqlval['reminder_answer'] = "てすと"; |
|---|
| 133 | $sqlval['mailmaga_flg'] = (string) '1'; // 1:HTMLメール 2:テキストメール 3:希望しない |
|---|
| 134 | |
|---|
| 135 | // 生年月日の作成 |
|---|
| 136 | $sqlval['birth'] = SC_Utils_Ex::sfGetTimestamp(2006, 9, 1); |
|---|
| 137 | |
|---|
| 138 | // 仮会員 1 本会員 2 |
|---|
| 139 | $sqlval['status'] = '2'; |
|---|
| 140 | |
|---|
| 141 | /* |
|---|
| 142 | * secret_keyは、テーブルで重複許可されていない場合があるので、 |
|---|
| 143 | * 本会員登録では利用されないがセットしておく。 |
|---|
| 144 | */ |
|---|
| 145 | $sqlval['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey(); |
|---|
| 146 | |
|---|
| 147 | // 入会時ポイント |
|---|
| 148 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
|---|
| 149 | $sqlval['point'] = $CONF['welcome_point']; |
|---|
| 150 | |
|---|
| 151 | // 会員データの生成 |
|---|
| 152 | SC_Helper_Customer_Ex::sfEditCustomerData($sqlval); |
|---|
| 153 | |
|---|
| 154 | print("*"); |
|---|
| 155 | lfPrintLog("creating customer data count:[" . ($i+1) . "] end."); |
|---|
| 156 | } |
|---|
| 157 | print("\n"); |
|---|
| 158 | lfPrintLog("createCustomers DONE.(" . CUSTOMERS_VOLUME . " data created)"); |
|---|
| 159 | } |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | /** テスト用スクリプトのログ出力関数 */ |
|---|
| 163 | function lfPrintLog($mess) |
|---|
| 164 | { |
|---|
| 165 | $path = DATA_REALDIR . "logs/" . basename(__FILE__, '.php') . ".log"; |
|---|
| 166 | GC_Utils::gfPrintLog($mess, $path); |
|---|
| 167 | } |
|---|