1 | #!/usr/local/bin/php -q |
---|
2 | <?php |
---|
3 | /* |
---|
4 | * EC-CUBE 動作検証用会員データ生成スクリプト |
---|
5 | * |
---|
6 | * Copyright(c) 2000-2011 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_float(); |
---|
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_float(); |
---|
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 | /** SC_Query インスタンス */ |
---|
93 | var $objQuery; |
---|
94 | |
---|
95 | /** |
---|
96 | * コンストラクタ. |
---|
97 | */ |
---|
98 | function CreateEcCubeCustomerData() { |
---|
99 | $this->objQuery = new SC_Query(); |
---|
100 | } |
---|
101 | |
---|
102 | /** |
---|
103 | * テスト用 会員データ を生成する. |
---|
104 | * |
---|
105 | * @return void |
---|
106 | */ |
---|
107 | function createCustomers() { |
---|
108 | lfPrintLog("createCustomers START.(" . CUSTOMERS_VOLUME . " data)"); |
---|
109 | for ($i = 0; $i < CUSTOMERS_VOLUME; $i++) { |
---|
110 | lfPrintLog("----------"); |
---|
111 | lfPrintLog("creating customer data count:[" . ($i+1) . "] start."); |
---|
112 | |
---|
113 | $sqlval['name01'] = "検証"; |
---|
114 | $sqlval['name02'] = sprintf("太郎%05d", $i+1); |
---|
115 | $sqlval['kana01'] = "ケンショウ"; |
---|
116 | $sqlval['kana02'] = "タロウ"; |
---|
117 | $sqlval['zip01'] = '101'; |
---|
118 | $sqlval['zip02'] = '0051'; |
---|
119 | $sqlval['pref'] = '13'; // 13:東京都 |
---|
120 | $sqlval['addr01'] = "千代田区神田神保町"; |
---|
121 | $sqlval['addr02'] = "1-3-5"; |
---|
122 | $sqlval['tel01'] = '012'; |
---|
123 | $sqlval['tel02'] = '3456'; |
---|
124 | $sqlval['tel03'] = '7890'; |
---|
125 | $sqlval['email'] = EMAIL_ADDRESS_ACCOUNT . "+" . sprintf("%05d", $i+1) . EMAIL_ADDRESS_DOMAIN; |
---|
126 | $sqlval['sex'] = '1'; // 1:男性 2:女性 |
---|
127 | $sqlval['password'] = 'test'; |
---|
128 | $sqlval['reminder'] = '1'; // 1:「母親の旧姓は?」 |
---|
129 | $sqlval['reminder_answer'] = "てすと"; |
---|
130 | $sqlval['mailmaga_flg'] = (string) '1'; // 1:HTMLメール+テキストメールを受け取る 2:テキストメールを受け取る 3:受け取らない |
---|
131 | |
---|
132 | // 生年月日の作成 |
---|
133 | $sqlval['birth'] = SC_Utils_Ex::sfGetTimestamp(2006, 9, 1); |
---|
134 | |
---|
135 | // 仮会員 1 本会員 2 |
---|
136 | $sqlval['status'] = '2'; |
---|
137 | |
---|
138 | /* |
---|
139 | * secret_keyは、テーブルで重複許可されていない場合があるので、 |
---|
140 | * 本会員登録では利用されないがセットしておく。 |
---|
141 | */ |
---|
142 | $sqlval['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey(); |
---|
143 | |
---|
144 | // 入会時ポイント |
---|
145 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
146 | $sqlval['point'] = $CONF['welcome_point']; |
---|
147 | |
---|
148 | // 会員データの生成 |
---|
149 | SC_Helper_Customer_Ex::sfEditCustomerData($sqlval); |
---|
150 | |
---|
151 | print("*"); |
---|
152 | lfPrintLog("creating customer data count:[" . ($i+1) . "] end."); |
---|
153 | } |
---|
154 | print("\n"); |
---|
155 | lfPrintLog("createCustomers DONE.(" . CUSTOMERS_VOLUME . " data created)"); |
---|
156 | } |
---|
157 | |
---|
158 | } |
---|
159 | |
---|
160 | /** テスト用スクリプトのログ出力関数 */ |
---|
161 | function lfPrintLog($mess) { |
---|
162 | $path = DATA_REALDIR . "logs/" . basename(__FILE__, '.php') . ".log"; |
---|
163 | GC_Utils::gfPrintLog($mess, $path); |
---|
164 | } |
---|
165 | |
---|
166 | /** PHP4対応のための microtime 関数 */ |
---|
167 | function microtime_float() { |
---|
168 | list($usec, $sec) = explode(" ", microtime()); |
---|
169 | return ((float)$usec + (float)$sec); |
---|
170 | } |
---|
171 | |
---|
172 | ?> |
---|