PluginProbe
Welcart e-Commerce / 1.3.4
Welcart e-Commerce v1.3.4
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / classes / dataTable.class.php

dataTable.class.php in Welcart e-Commerce 1.3.4, at classes/dataTable.class.php

1,513 lines 48.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class dataTable
3 {
4 var $dbCon; //データベース接続リソース
5 var $table; //テーブル名
6 var $optionTableName; //オプションテーブル名
7 var $errorMes; //エラーメッセージ
8 var $action; //アクション
9 var $maxRow; //最大表示行数
10 var $startRow; //表示開始行番号
11 var $sortColumn; //現在ソート中のフィールド
12 var $sortOldColumn; //比較用
13 var $listPatternId; //絞込みlistPatternID
14 var $listPatternRows; //listPatternオブジェクト
15 var $listPatternTableName; //listPatternテーブル名
16 var $listPatternNavigation; //ナヴィゲーションhtmlコード
17 var $listPatternSelect; //セレクトhtmlコード
18 var $totalRow; //�
19 �行数
20 var $selectedRow; //絞り込まれた行数
21 var $currentPage; //現在のページNo
22 var $firstPage; //最初のページNo
23 var $previousPage; //前のページNo
24 var $nextPage; //次のページNo
25 var $lastPage; //最終ページNo
26 var $naviMaxButton; //ページネーション・ナビのボタンの数
27 var $displayColumns;//表示するフィールド
28 var $defaultColumns;//�
29 �てのフィールド
30 var $userHeaderNames; //ユーザー指定のヘッダ名
31 var $columnTypes; //フィールドのデータタイプ
32 var $valueLabels; //選択タイプ用ヴァリュー
33 var $headers; //表示するヘッダ文字列
34 var $rows; //メインテーブルオブジェクト
35 var $sortSwitchs; //各フィールド毎の昇順降順スイッチ
36 var $dataTableNavigation; //ナヴィゲーションhtmlコード
37 var $expiration; //Cookie有効期限
38 var $editMemberId; //編集対象のメンバーID
39 var $searchs; //簡易絞込み対象フィールド、式、キーワード
40 var $searchSql; //簡易絞込みSQL
41 var $searchSwitchStatus; //サーチ表示スイッチ
42 var $useListPattern;//ボタン表示フラグ
43 var $useEditField; //ボタン表示フラグ
44 var $useUpload; //ボタン表示フラグ
45 var $useDownload; //ボタン表示フラグ
46 var $useAllDelete; //ボタン表示フラグ
47 var $useBackButton; //ボタン表示フラグ
48 var $useNewButton; //ボタン表示フラグ
49 var $useDoubleClickEdit; //ボタン表示フラグ
50 var $editListPatternName; //パターンリスト編集用
51 var $editListPatternShikis; //パターンリスト編集用
52 var $editListPatternFieldNames; //パターンリスト編集用
53 var $editListPatternFieldDatas; //パターンリスト編集用
54 var $tableValue; //一時データ
55 var $overlap; //sendMail 重複許可
56
57 //Constructor
58 function dataTable($dbConnection, $databaseName, $tableName)
59 {
60 //@session_start();
61
62 $this->dbCon = $dbConnection;
63 mysql_select_db($databaseName, $dbConnection);
64 $this->table = $tableName;
65 $this->optionTableName = 'datatable_options';
66 $this->optionFlag = TRUE;
67
68 $this->listPatternTableName = '';
69 $this->useListPattern = '';
70 $this->useEditField = '';
71 $this->useUpload = '';
72 $this->useDownload = '';
73 $this->useAllDelete = '';
74 $this->useBackButton = '';
75 $this->useNewButton = '';
76 $this->useDoubleClickEdit = '';
77
78 $this->overlap = '';
79
80 $this->maxRow = 20;
81 $this->naviMaxButton = 11;
82 $this->firstPage = 1;
83 $this->expiration = time()+31536000;
84
85 $this->SetParamByQuery();
86
87 }
88
89 //Controller
90 function MakeTable()
91 {
92 switch ($this->action){
93 case 'default':
94 $this->SetDefaultParam();
95 $res = $this->GetRows();
96 break;
97 case 'changeDispColumn':
98 $this->SetParam();
99 $res = $this->GetRows();
100 break;
101 case 'changePage':
102 $this->SetParam();
103 $res = $this->GetRows();
104 break;
105 case 'changeSort':
106 $this->SetParam();
107 $res = $this->GetRows();
108 break;
109 case 'changeListPattern':
110 $this->SetParam();
111 $this->SetTotalRow();
112 $this->SetSelectedRow();
113 $res = $this->GetRows();
114 break;
115 case 'deletListMember':
116 $this->SetParam();
117 $status = $this->DeleteRows();
118 $this->SetTotalRow();
119 $this->SetSelectedRow();
120 $res = $this->GetRows();
121 break;
122 case 'searchIn':
123 $this->SetParam();
124 $status = $this->SearchIn();
125 $this->SetTotalRow();
126 $this->SetSelectedRow();
127 $res = $this->GetRows();
128 break;
129 case 'searchOut':
130 $this->SetParam();
131 $status = $this->SearchOut();
132 $this->SetTotalRow();
133 $this->SetSelectedRow();
134 $res = $this->GetRows();
135 break;
136 case 'uploadCSV':
137 $this->SetParam();
138 $status = $this->upload();
139 $this->SetTotalRow();
140 $this->SetSelectedRow();
141 $res = $this->GetRows();
142 break;
143 case 'downloadCSV':
144 $this->SetParam();
145 $this->DownloadCSV();
146 exit;
147 break;
148 case 'refresh':
149 $this->GetListPatternRows($this->listPatternTableName);
150 $this->SetParam();
151 $this->SetSelectedRow();
152 $res = $this->GetRows();
153 break;
154 case 'editMember':
155 $this->SetParam();
156 $status = $this->UpdateMember();
157 $this->SetSelectedRow();
158 $res = $this->GetRows();
159 break;
160 case 'addMember':
161 $this->SetParam();
162 $status = $this->InsertMember();
163 $this->SetTotalRow();
164 $this->SetSelectedRow();
165 $res = $this->GetRows();
166 break;
167 case 'getMemberData':
168 $this->SetParam();
169 $this->GetMemberData($this->editMemberId);
170 exit;
171 break;
172 case 'changeSearchSwitch':
173 $this->ChangeSearchSwitchStatus();
174 exit;
175 break;
176 case 'changeListPatternAjax':
177 $this->ChangeListPatternAjax();
178 exit;
179 break;
180 case 'addListPattern':
181 $this->SetParam();
182 $status = $this->AddPatternList();
183 $this->SetTotalRow();
184 $this->SetSelectedRow();
185 $res = $this->GetRows();
186 break;
187 case 'rowButtonDelete':
188 $this->SetParam();
189 $status = $this->RowButtonDelete();
190 $this->SetTotalRow();
191 $this->SetSelectedRow();
192 $res = $this->GetRows();
193 break;
194 }
195
196 $this->SetListPatternNavi();
197 $this->SetNavi();
198 $this->SetHeaders();
199
200 if($res){
201
202 $this->SetSESSION();
203 return TRUE;
204
205 }else{
206 return FALSE;
207 }
208 }
209
210 //DefaultParam
211 function SetDefaultParam()
212 {
213 unset($_SESSION[$this->table]);
214 $this->startRow = 0;
215 $this->currentPage = 1;
216 $this->searchs = array('column'=>'', 'shiki'=>'', 'word'=>'');
217 if(isset($_SESSION[$this->table]['searchSwitchStatus'])){
218 $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
219 }else{
220 $this->searchSwitchStatus = 'OFF';
221 }
222 $this->GetListPatternRows($this->listPatternTableName);
223 $this->searchSql = '';
224 $this->SetDefaultColumns();
225
226
227 //リストパターン
228 if(isset($_COOKIE[$this->table.'listPatternId']) && $this->listPatternTableName != ''){
229 $this->listPatternId = $_COOKIE[$this->table.'listPatternId'];
230 }else if($this->listPatternTableName != ''){
231 $this->listPatternId =1;
232 setcookie($this->table.'listPatternId', $this->listPatternId, $this->expiration);
233 }
234 // if($optionValue = $this->GetOptions($this->table, 'listPatternId')){
235 // $this->listPatternId = $optionValue;
236 // }else{
237 // $this->listPatternId =1;
238 // $this->SetOptions($this->table, 'listPatternId', $this->listPatternId);
239 // }
240 //ヘッダ表示文字列
241 // if(isset($_COOKIE[$this->table.'userHeaderNames'])){
242 // $this->userHeaderNames = $this->GetCookieArray($this->table.'userHeaderNames');
243 // }else{
244 // for($i=0; $i<count($this->defaultColumns); $i++){
245 // $headerKey = $this->defaultColumns[$i];
246 // $this->userHeaderNames[$headerKey] = $this->defaultColumns[$i];
247 // }
248 // $this->SetCookieArray($this->table.'userHeaderNames', $this->userHeaderNames);
249 // }
250 if($optionValue = $this->GetOptions($this->table, 'userHeaderNames')){
251 $this->userHeaderNames = $optionValue;
252 }else{
253 for($i=0; $i<count($this->defaultColumns); $i++){
254 $headerKey = $this->defaultColumns[$i];
255 $this->userHeaderNames[$headerKey] = $this->defaultColumns[$i];
256 }
257 $this->SetOptions($this->table, 'userHeaderNames', $this->userHeaderNames);
258 }
259 //表示フィールド
260 // if(isset($_COOKIE[$this->table.'displayColumns'])){
261 // $this->displayColumns = $this->GetCookieArray($this->table.'displayColumns');
262 // }else{
263 // $this->displayColumns = $this->defaultColumns;
264 // $this->SetCookieArray($this->table.'displayColumns', $this->displayColumns);
265 // }
266 if($optionValue = $this->GetOptions($this->table, 'displayColumns')){
267 $this->displayColumns = $optionValue;
268 }else{
269 $this->displayColumns = $this->defaultColumns;
270 $this->SetOptions($this->table, 'displayColumns', $this->displayColumns);
271 }
272 //フィールドのデータタイプ
273 // if(isset($_COOKIE[$this->table.'columnTypes'])){
274 // $this->columnTypes = $this->GetCookieArray($this->table.'columnTypes');
275 // }else{
276 // for($i=1; $i<count($this->defaultColumns); $i++){
277 // $headerKey = $this->defaultColumns[$i];
278 // $this->columnTypes[$headerKey] = 0;
279 // }
280 // $this->SetCookieArray($this->table.'columnTypes', $this->columnTypes);
281 // }
282 if($optionValue = $this->GetOptions($this->table, 'columnTypes')){
283 $this->columnTypes = $optionValue;
284 }else{
285 for($i=1; $i<count($this->defaultColumns); $i++){
286 $headerKey = $this->defaultColumns[$i];
287 $this->columnTypes[$headerKey] = 0;
288 }
289 $this->SetOptions($this->table, 'columnTypes', $this->columnTypes);
290 }
291 //選択タイプ用ヴァリュー
292 // if(isset($_COOKIE[$this->table.'valueLabels'])){
293 // $this->valueLabels = $this->GetCookieArray($this->table.'valueLabels');
294 // }else{
295 // for($i=1; $i<count($this->defaultColumns); $i++){
296 // $headerKey = $this->defaultColumns[$i];
297 // $this->valueLabels[$headerKey] = '';
298 // }
299 // $this->SetCookieArray($this->table.'valueLabels', $this->valueLabels);
300 // }
301 if($optionValue = $this->GetOptions($this->table, 'valueLabels')){
302 $this->valueLabels = $optionValue;
303 }else{
304 for($i=1; $i<count($this->defaultColumns); $i++){
305 $headerKey = $this->defaultColumns[$i];
306 $this->valueLabels[$headerKey] = '';
307 }
308 $this->SetOptions($this->table, 'valueLabels', $this->valueLabels);
309 }
310
311
312 //トータル行数、デフォルトフィールド名
313 $this->SetTotalRow();
314 $this->SetSelectedRow();
315
316 }
317
318 //Param
319 function SetParam()
320 {
321 $this->startRow = ($this->currentPage-1) * $this->maxRow;
322 //$this->totalRow = $_SESSION[$this->table]['totalRow'];
323 $this->defaultColumns = $_SESSION[$this->table]['defaultColumns'];
324 $this->listPatternRows = $_SESSION[$this->table]['listPatternRows'];
325 $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
326 }
327
328 //Query
329 function SetParamByQuery()
330 {
331
332 if(isset($_REQUEST['changeDispColumn'])){
333
334 $this->action = 'changeDispColumn';
335 $this->displayColumns = $_POST['checkedColumns'];
336 $this->SetOptions($this->table, 'displayColumns', $this->displayColumns);
337 $getnames = $_POST['userHeaderNames'];
338 $coltypes = $_POST['columnTypes'];
339 $vallabels = $_POST['valueLabels'];
340 $this->SetDefaultColumns();
341 for($i=0; $i< count($this->defaultColumns); $i++){
342 $headerKey = $this->defaultColumns[$i];
343 if( WCUtils::is_blank($getnames[$i]) ){
344 $this->userHeaderNames[$headerKey] = $this->defaultColumns[$i];
345 }else{
346 $this->userHeaderNames[$headerKey] = htmlspecialchars($getnames[$i]);
347 }
348 }
349 $this->SetOptions($this->table, 'userHeaderNames', $this->userHeaderNames);
350 for($i=1; $i< count($this->defaultColumns); $i++){
351 $headerKey = $this->defaultColumns[$i];
352 if(($coltypes[$i-1] == 1 || $coltypes[$i-1] == 2) && WCUtils::is_blank($vallabels[$i-1]) ){
353 $valstr = $this->GetSelectData($headerKey);
354 $this->valueLabels[$headerKey] = $valstr;
355 }else{
356 $this->valueLabels[$headerKey] = htmlspecialchars($vallabels[$i-1]);
357 }
358 $this->columnTypes[$headerKey] = htmlspecialchars($coltypes[$i-1]);
359 }
360 $this->SetOptions($this->table, 'columnTypes', $this->columnTypes);
361 $this->SetOptions($this->table, 'valueLabels', $this->valueLabels);
362
363 $this->currentPage = $_SESSION[$this->table]['currentPage'];
364 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
365 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
366 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
367 $this->searchSql = $_SESSION[$this->table]['searchSql'];
368 $this->searchs = $_SESSION[$this->table]['searchs'];
369 $this->totalRow = $_SESSION[$this->table]['totalRow'];
370 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
371
372
373 }else if(isset($_REQUEST['changePage'])){
374
375 $this->action = 'changePage';
376 $this->currentPage = $_REQUEST['changePage'];
377
378 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
379 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
380 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
381 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
382 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
383 $this->searchSql = $_SESSION[$this->table]['searchSql'];
384 $this->searchs = $_SESSION[$this->table]['searchs'];
385 $this->totalRow = $_SESSION[$this->table]['totalRow'];
386 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
387 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
388 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
389
390 }else if(isset($_REQUEST['changeSort'])){
391
392 $this->action = 'changeSort';
393 $this->sortOldColumn = $this->sortColumn;
394 $this->sortColumn = $_REQUEST['changeSort'];
395 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
396 $this->sortSwitchs[$this->sortColumn] = $_REQUEST['switch'];
397
398 $this->currentPage = $_SESSION[$this->table]['currentPage'];
399 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
400 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
401 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
402 $this->searchSql = $_SESSION[$this->table]['searchSql'];
403 $this->searchs = $_SESSION[$this->table]['searchs'];
404 $this->totalRow = $_SESSION[$this->table]['totalRow'];
405 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
406 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
407 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
408
409 }else if(isset($_REQUEST['searchIn'])){
410
411 $this->action = 'searchIn';
412 $this->searchs['column'] = $_REQUEST['column'];
413 $this->searchs['shiki'] = intval($_REQUEST['shiki']);
414 $this->searchs['word'] = $_REQUEST['word'];
415
416 $this->currentPage = 1;
417 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
418 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
419 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
420 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
421 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
422 $this->searchSql = $_SESSION[$this->table]['searchSql'];
423 $this->totalRow = $_SESSION[$this->table]['totalRow'];
424 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
425 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
426
427 }else if(isset($_REQUEST['searchOut'])){
428
429 $this->action = 'searchOut';
430 $this->searchs['column'] = '';
431 $this->searchs['shiki'] = '';
432 $this->searchs['word'] = '';
433
434 $this->currentPage = 1;
435 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
436 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
437 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
438 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
439 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
440 $this->searchSql = $_SESSION[$this->table]['searchSql'];
441 $this->totalRow = $_SESSION[$this->table]['totalRow'];
442 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
443 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
444
445 }else if(isset($_REQUEST['changeListPattern'])){
446
447 $this->action = 'changeListPattern';
448 $this->listPatternId = $_REQUEST['changeListPattern'];
449 setcookie($this->table.'listPatternId', $this->listPatternId, $this->expiration);;
450
451 $this->currentPage = 1;
452 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
453 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
454 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
455 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
456 $this->searchSql = $_SESSION[$this->table]['searchSql'];
457 $this->searchs = $_SESSION[$this->table]['searchs'];
458 $this->totalRow = $_SESSION[$this->table]['totalRow'];
459 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
460 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
461
462 }else if(isset($_POST['tableAction']) && ($_POST['tableAction'] == 'deletListMember')){
463
464 $this->action = 'deletListMember';
465
466 $this->currentPage = 1;
467 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
468 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
469 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
470 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
471 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
472 $this->searchSql = $_SESSION[$this->table]['searchSql'];
473 $this->searchs = $_SESSION[$this->table]['searchs'];
474 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
475 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
476
477 }else if(isset($_REQUEST['uploadCSV'])){
478
479 $this->action = 'uploadCSV';
480
481 $this->currentPage = $_SESSION[$this->table]['currentPage'];
482 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
483 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
484 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
485 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
486 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
487 $this->searchSql = $_SESSION[$this->table]['searchSql'];
488 $this->searchs = $_SESSION[$this->table]['searchs'];
489 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
490 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
491
492 }else if(isset($_REQUEST['tableAction']) && ($_POST['tableAction'] == 'downloadCSV')){
493
494 $this->action = 'downloadCSV';
495
496 $this->currentPage = $_SESSION[$this->table]['currentPage'];
497 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
498 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
499 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
500 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
501 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
502 $this->searchSql = $_SESSION[$this->table]['searchSql'];
503 $this->searchs = $_SESSION[$this->table]['searchs'];
504 $this->totalRow = $_SESSION[$this->table]['totalRow'];
505 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
506 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
507 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
508
509 }else if(isset($_REQUEST['refresh'])){
510
511 $this->action = 'refresh';
512
513 $this->currentPage = $_SESSION[$this->table]['currentPage'];
514 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
515 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
516 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
517 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
518 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
519 $this->searchSql = $_SESSION[$this->table]['searchSql'];
520 $this->searchs = $_SESSION[$this->table]['searchs'];
521 $this->totalRow = $_SESSION[$this->table]['totalRow'];
522 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
523 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
524 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
525
526 }else if(isset($_REQUEST['editMember']) && ($_POST['editMember'] == 'edit')){
527
528 $this->action = 'editMember';
529 $this->editMemberId = $_POST['memberId'];
530 $this->currentPage = $_SESSION[$this->table]['currentPage'];
531 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
532 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
533 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
534 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
535 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
536 $this->searchSql = $_SESSION[$this->table]['searchSql'];
537 $this->searchs = $_SESSION[$this->table]['searchs'];
538 $this->totalRow = $_SESSION[$this->table]['totalRow'];
539 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
540 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
541
542 }else if(isset($_REQUEST['editMember']) && ($_POST['editMember'] == 'add')){
543
544 $this->action = 'addMember';
545 $this->editMemberId = $_POST['memberId'];
546 $this->currentPage = $_SESSION[$this->table]['currentPage'];
547 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
548 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
549 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
550 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
551 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
552 $this->searchSql = $_SESSION[$this->table]['searchSql'];
553 $this->searchs = $_SESSION[$this->table]['searchs'];
554 $this->totalRow = $_SESSION[$this->table]['totalRow'];
555 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
556 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
557
558 }else if(isset($_REQUEST['getMemberData'])){
559
560 $this->action = 'getMemberData';
561 $this->editMemberId = $_REQUEST['getMemberData'];
562
563 $this->currentPage = $_SESSION[$this->table]['currentPage'];
564 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
565 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
566 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
567 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
568 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
569 $this->searchSql = $_SESSION[$this->table]['searchSql'];
570 $this->searchs = $_SESSION[$this->table]['searchs'];
571 $this->totalRow = $_SESSION[$this->table]['totalRow'];
572 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
573 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
574 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
575
576 }else if(isset($_REQUEST['editListPattern'])){
577
578 if($_REQUEST['editListPattern'] == 'add'){
579 $this->action = 'addListPattern';
580 }
581 $this->editListPatternName = $_POST['patternName'];
582 $this->editListPatternShikis = $_POST['shikis'];
583 $this->editListPatternFieldNames = $_POST['fieldNames'];
584 $this->editListPatternFieldDatas = $_POST['fieldDatas'];
585
586 $this->currentPage = $_SESSION[$this->table]['currentPage'];
587 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
588 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
589 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
590 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
591 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
592 $this->searchSql = $_SESSION[$this->table]['searchSql'];
593 $this->searchs = $_SESSION[$this->table]['searchs'];
594 $this->totalRow = $_SESSION[$this->table]['totalRow'];
595 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
596 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
597 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
598
599 }else if(isset($_REQUEST['tableAction']) && ($_POST['tableAction'] == 'rowButtonDelete')){
600
601 $this->action = 'rowButtonDelete';
602 $this->tableValue = $_POST['tableValue'];
603
604 $this->currentPage = $_SESSION[$this->table]['currentPage'];
605 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
606 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
607 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
608 $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
609 $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
610 $this->searchSql = $_SESSION[$this->table]['searchSql'];
611 $this->searchs = $_SESSION[$this->table]['searchs'];
612 $this->totalRow = $_SESSION[$this->table]['totalRow'];
613 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
614 $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
615 $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
616
617 }else if(isset($_REQUEST['changeSearchSwitch'])){
618
619 $this->action = 'changeSearchSwitch';
620 $this->searchSwitchStatus = $_REQUEST['changeSearchSwitch'];
621
622 }else if(isset($_REQUEST['changeListPatternAjax'])){
623
624 $this->action = 'changeListPatternAjax';
625 $this->listPatternId = $_REQUEST['changeListPatternAjax'];
626 if(isset($_REQUEST['overlap'])){
627 $this->overlap = $_REQUEST['overlap'];
628 }else{
629 $this->overlap = '';
630 }
631
632 }else{
633
634 $this->action = 'default';
635 }
636 }
637
638 function SetListPatternNavi()
639 {
640 if( WCUtils::is_blank($this->listPatternTableName) ){
641 $this->listPatternNavigation = '';
642 $this->listPatternSelect = '';
643 return;
644 }
645 $sel = '';
646 $str = '';
647 $str .= '<form action="' . $_SERVER['PHP_SELF'] . '" method="post" name="listpattern" id="listpattern" >' . "\n";
648 $str .= __('Pattern List', 'usces');
649 $sel .= '<select name="changeListPattern" id="listPattern" onchange="onChange_listPattern()">' . "\n";
650 for($i=0; $i<count($this->listPatternRows); $i++){
651 if($this->listPatternRows[$i]['id'] == $this->listPatternId){
652 $selected = ' selected="selected"';
653 }else{
654 $selected = '';
655 }
656 $sel .= '<option value="' . $this->listPatternRows[$i]['id'] . '"' . $selected . '>' . $this->listPatternRows[$i]['name'] . '</option>' . "\n";
657 }
658 $sel .= '</select>' . "\n";
659 $str .= $sel;
660 $str .= '</form>' . "\n";
661 $this->listPatternNavigation = $str;
662 $this->listPatternSelect = $sel;
663 }
664
665 function SetNavi()
666 {
667
668 $this->lastPage = ceil($this->selectedRow / $this->maxRow);
669 $this->previousPage = ($this->currentPage - 1 == 0) ? 1 : $this->currentPage - 1;
670 $this->nextPage = ($this->currentPage + 1 > $this->lastPage) ? $this->lastPage : $this->currentPage + 1;
671
672 for($i=0; $i<$this->naviMaxButton; $i++){
673 if($i > $this->lastPage-1) break;
674 if($this->lastPage <= $this->naviMaxButton) {
675 $box[] = $i+1;
676 }else{
677 if($this->currentPage <= 6) {
678 $label = $i + 1;
679 $box[] = $label;
680 }else{
681 $label = $i + 1 + $this->currentPage - 6;
682 $box[] = $label;
683 if($label == $this->lastPage) break;
684 }
685 }
686 }
687
688 $html = '';
689 $html .= '<ul class="clearfix">'."\n";
690 $html .= '<li class="rowsnum">' . $this->selectedRow . ' / ' . $this->totalRow . ' '.__('cases', 'usces').'</li>' . "\n";
691 if(($this->currentPage == 1) || ($this->selectedRow == 0)){
692 $html .= '<li class="navigationStr">first&lt;&lt;</li>' . "\n";
693 $html .= '<li class="navigationStr">prev&lt;</li>'."\n";
694 }else{
695 $html .= '<li class="navigationStr"><a href="' . $_SERVER['PHP_SELF'] . '?changePage=1">first&lt;&lt;</a></li>' . "\n";
696 $html .= '<li class="navigationStr"><a href="' . $_SERVER['PHP_SELF'] . '?changePage=' . $this->previousPage . '">prev&lt;</a></li>'."\n";
697 }
698 if($this->selectedRow > 0) {
699 for($i=0; $i<count($box); $i++){
700 if($box[$i] == $this->currentPage){
701 $html .= '<li class="navigationButtonSelected">' . $box[$i] . '</li>'."\n";
702 }else{
703 $html .= '<li class="navigationButton"><a href="' . $_SERVER['PHP_SELF'] . '?changePage=' . $box[$i] . '">' . $box[$i] . '</a></li>'."\n";
704 }
705 }
706 }
707 if(($this->currentPage == $this->lastPage) || ($this->selectedRow == 0)){
708 $html .= '<li class="navigationStr">&gt;next</li>'."\n";
709 $html .= '<li class="navigationStr">&gt;&gt;last</li>'."\n";
710 }else{
711 $html .= '<li class="navigationStr"><a href="' . $_SERVER['PHP_SELF'] . '?changePage=' . $this->nextPage . '">&gt;next</a></li>'."\n";
712 $html .= '<li class="navigationStr"><a href="' . $_SERVER['PHP_SELF'] . '?changePage=' . $this->lastPage . '">&gt;&gt;last</a></li>'."\n";
713 }
714 if($this->searchSwitchStatus == 'OFF'){
715 $html .= '<li class="rowsnum"><a href="#" id="searchSwitch">' . __('Display Search', 'usces') . '</a>'."\n";
716 }else{
717 $html .= '<li class="rowsnum"><a href="#" id="searchSwitch">' . __('Hide Search', 'usces') . '</a>'."\n";
718 }
719
720 $html .= '<li class="refresh"><a href="' . $_SERVER['PHP_SELF'] . '?refresh">' . __('updates it to latest information', 'usces') . '</a></li>' . "\n";
721 $html .= '</ul>'."\n";
722
723 $this->dataTableNavigation = $html;
724 }
725
726 function SetHeaders()
727 {
728 for($i=0; $i<count($this->displayColumns); $i++){
729 //$userHaederKey = array_search($this->displayColumns[$i], $this->defaultColumns);
730 $userHeaderKey = $this->displayColumns[$i];
731 if($this->displayColumns[$i] == $this->sortColumn){
732 if($this->sortSwitchs[$this->sortColumn] == 'ASC'){
733 $str = __('[ASC]', 'usces');
734 $switch = 'DESC';
735 }else{
736 $str = __('[DESC]', 'usces');
737 $switch = 'ASC';
738 }
739 $this->headers[$i] = '<a href="' . $_SERVER['PHP_SELF'] . '?changeSort=' . $this->displayColumns[$i] . '&switch=' . $switch . '"><span class="sortcolumn">' . $this->userHeaderNames[$userHeaderKey] . ' ' . $str . '</span></a>';
740 }else{
741 $cname = $this->displayColumns[$i];
742 $switch = $this->sortSwitchs[$cname];
743 $this->headers[$i] = '<a href="' . $_SERVER['PHP_SELF'] . '?changeSort=' . $this->displayColumns[$i] . '&switch=' . $switch . '"><span>' . $this->userHeaderNames[$userHeaderKey] . '</span></a>';
744 }
745 }
746 // echo 'SetHeaders:' . "<br>";
747 //var_dump($this->userHeaderNames);
748 }
749
750 function SetSESSION()
751 {
752
753 // var $dbCon; //データベース接続リソース
754 // var $table; //テーブル名
755 // var $errorMes; //エラーメッセージ
756 // var $action; //アクション
757 // var $maxRow; //最大表示行数
758 $_SESSION[$this->table]['startRow'] = $this->startRow; //表示開始行番号
759 $_SESSION[$this->table]['sortColumn'] = $this->sortColumn; //現在ソート中のフィールド
760 // var $sortNewColumn; //新たにソートリクエストがあったフィールド
761 $_SESSION[$this->table]['totalRow'] = $this->totalRow; //�
762 �行数
763 $_SESSION[$this->table]['selectedRow'] = $this->selectedRow; //絞り込まれた行数
764 $_SESSION[$this->table]['currentPage'] = $this->currentPage; //現在のページNo
765 // var $firstPage; //最初のページNo
766 $_SESSION[$this->table]['previousPage'] = $this->previousPage; //前のページNo
767 $_SESSION[$this->table]['nextPage'] = $this->nextPage; //次のページNo
768 $_SESSION[$this->table]['lastPage'] = $this->lastPage; //最終ページNo
769 // var $naviMaxButton; //ページネーション・ナビのボタンの数
770 $_SESSION[$this->table]['displayColumns'] = $this->displayColumns;//実際に表示するフィールド
771 $_SESSION[$this->table]['defaultColumns'] = $this->defaultColumns;//�
772 �てのフィールド
773 $_SESSION[$this->table]['userHeaderNames'] = $this->userHeaderNames;//�
774 �てのフィールド
775 $_SESSION[$this->table]['headers'] = $this->headers;//表示するヘッダ文字列
776 $_SESSION[$this->table]['rows'] = $this->rows; //表示する行オブジェクト
777 $_SESSION[$this->table]['sortSwitchs'] = $this->sortSwitchs; //各フィールド毎の昇順降順スイッチ
778 $_SESSION[$this->table]['dataTableNavigation'] = $this->dataTableNavigation;
779 $_SESSION[$this->table]['listPatternId'] = $this->listPatternId; //絞込みSQL文(listPatternテーブルより取得)
780 $_SESSION[$this->table]['listPatternRows'] = $this->listPatternRows;
781 $_SESSION[$this->table]['searchSql'] = $this->searchSql;
782 $_SESSION[$this->table]['listPatternNavigation'] = $this->listPatternNavigation;
783 $_SESSION[$this->table]['listPatternSelect'] = $this->listPatternSelect;
784 $_SESSION[$this->table]['searchs'] = $this->searchs;
785 $_SESSION[$this->table]['searchSwitchStatus'] = $this->searchSwitchStatus;
786 $_SESSION[$this->table]['searchSql'] = $this->searchSql;
787 $_SESSION[$this->table]['useListPattern'] = $this->useListPattern;
788 $_SESSION[$this->table]['useEditField'] = $this->useEditField;
789 $_SESSION[$this->table]['useUpload'] = $this->useUpload;
790 $_SESSION[$this->table]['useDownload'] = $this->useDownload;
791 $_SESSION[$this->table]['useAllDelete'] = $this->useAllDelete;
792 $_SESSION[$this->table]['useBackButton'] = $this->useBackButton;
793 $_SESSION[$this->table]['useNewButton'] = $this->useNewButton;
794 $_SESSION[$this->table]['useDoubleClickEdit'] = $this->useDoubleClickEdit;
795 $_SESSION[$this->table]['columnTypes'] = $this->columnTypes;
796 $_SESSION[$this->table]['valueLabels'] = $this->valueLabels;
797 }
798
799 //GetRows
800 function GetRows()
801 {
802 $table = '`' . $this->table . '`';
803 $where = $this->GetWhere($this->listPatternTableName);
804 // if($where == '' && $this->searchSql != ''){
805 // $where = ' WHERE ' . $this->searchSql;
806 // }else if($where != '' && $this->searchSql != ''){
807 // $where .= ' AND ' . $this->searchSql;
808 // }
809 $order = ' ORDER BY `' . $this->sortColumn . '` ' . $this->sortSwitchs[$this->sortColumn];
810 $limit = ' LIMIT ' . $this->startRow . ', ' . $this->maxRow;
811
812 $query = sprintf("SELECT * FROM %s%s%s%s",
813 mysql_real_escape_string($table),
814 $where,
815 mysql_real_escape_string($order),
816 mysql_real_escape_string($limit)
817 );
818 $res = mysql_query($query, $this->dbCon);
819 if($res){
820 while($rows = mysql_fetch_assoc($res)){
821 foreach($rows as $key=>$value){
822 if( WCUtils::is_blank($value) ){
823 $rows[$key] = '&nbsp;';
824 }
825 }
826
827 $this->rows[] = $rows;
828 }
829
830 $this->errorMes = '';
831
832 return TRUE;
833
834 }else{
835
836 $this->errorMes = 'ERROR : ' . mysql_error() . 'QUERY : ' . $query;
837 return FALSE;
838 }
839 }
840
841 //DeleteRows
842 function DeleteRows()
843 {
844 $table = '`' . $this->table . '`';
845 $where = $this->GetWhere($this->listPatternTableName);
846
847 $query = sprintf("DELETE FROM %s%s",
848 mysql_real_escape_string($table),
849 $where
850 );
851 $res = mysql_query($query, $this->dbCon);
852 if($res){
853
854
855 $this->errorMes = '';
856 return TRUE;
857
858 }else{
859
860 $this->errorMes = 'ERROR : ' . mysql_error() . 'QUERY : ' . $query;
861 return FALSE;
862 }
863 }
864 //DeleteButtonRow
865 function RowButtonDelete()
866 {
867 $table = '`' . $this->table . '`';
868
869 $query = sprintf("DELETE FROM %s WHERE id = %s LIMIT 1",
870 mysql_real_escape_string($table),
871 "'" . mysql_real_escape_string($this->tableValue) . "'"
872 );
873 $res = mysql_query($query, $this->dbCon);
874 if($res){
875 $this->errorMes = '';
876 return TRUE;
877 }else{
878 $this->errorMes = 'ERROR : ' . mysql_error() . 'QUERY : ' . $query;
879 return FALSE;
880 }
881 }
882 //UpdateMember
883 function UpdateMember()
884 {
885 $fieldDatas = $_POST['fieldDatas'];
886 $fieldNames = $_POST['fieldNames'];
887 $str = '';
888 for($i=1; $i<count($fieldNames); $i++){
889 if( WCUtils::is_blank($fieldDatas[$i]) || $fieldDatas[$i] == '&nbsp;'){
890 $str .= $fieldNames[$i] . " = DEFAULT, ";
891 }else{
892 $str .= $fieldNames[$i] . " = '" . mysql_real_escape_string($fieldDatas[$i]) . "', ";
893 }
894 }
895 $str = rtrim($str, ", ");
896 $query = sprintf("UPDATE `%s` SET %s WHERE id = %d",
897 mysql_real_escape_string($this->table),
898 $str,
899 $this->editMemberId
900 );
901 $res = mysql_query($query, $this->dbCon);
902 if($res){
903
904 $this->errorMes = '';
905 return TRUE;
906
907 }else{
908
909 $this->errorMes = 'ERROR : ' . mysql_error() . 'QUERY : ' . $query;
910 echo $this->errorMes;
911 exit;
912 return FALSE;
913 }
914 }
915
916 //InsertMember
917 function InsertMember()
918 {
919 $fieldDatas = $_POST['fieldDatas'];
920 $fieldNames = $_POST['fieldNames'];
921 $str = '';
922 for($i=1; $i<count($fieldNames); $i++){
923 if( WCUtils::is_blank($fieldDatas[$i]) || $fieldDatas[$i] == '&nbsp;'){
924 $str .= "DEFAULT, ";
925 }else{
926 $str .= "'" . mysql_real_escape_string($fieldDatas[$i]) . "', ";
927 }
928 }
929 $str = rtrim($str, ", ");
930 $query = sprintf("INSERT INTO `%s` VALUES ( NULL, %s )",
931 mysql_real_escape_string($this->table),
932 $str
933 );
934 $res = mysql_query($query, $this->dbCon);
935 if($res){
936
937 $this->errorMes = '';
938 return TRUE;
939
940 }else{
941
942 $this->errorMes = 'ERROR : ' . mysql_error() . 'QUERY : ' . $query;
943 echo $this->errorMes;
944 exit;
945 return FALSE;
946 }
947 }
948
949 //Uploader
950 function upload()
951 {
952 foreach ($_FILES as $key => $file) {
953 $filename = $file['tmp_name'];
954 }
955 if(!is_uploaded_file($filename)){
956 $this->errorMes = "Possible file upload attack: filename '". $filename . "'.";
957 return FALSE;
958 }
959 $fp = fopen($filename, 'r');
960 $values = "";
961 while(!feof($fp)){
962 $line = fgets($fp);
963 if( WCUtils::is_blank($line) ) break;
964 $rows = explode(',', $line);
965 if(count($rows) != 15){
966 break;
967 $this->errorMes = 'ERROR : ' . __('CSV format is invalid!', 'usces');
968 return FALSE;
969 }
970 $values .= "(NULL,";
971 foreach($rows as $data){
972 if( WCUtils::is_blank($data) ){
973 $values .= "DEFAULT,";
974 }else{
975 $values .= "'" . mysql_real_escape_string(mb_convert_encoding($data,'EUC-JP', 'auto')) . "',";
976 }
977 }
978 $values = trim($values, ',') . "),";
979 }
980 $values = trim($values, ',');
981
982 $query = sprintf("INSERT INTO `%s` VALUES %s", $this->table, $values);
983 $res = mysql_query($query, $this->dbCon);
984 if($res){
985 $this->errorMes = '';
986 return TRUE;
987 }else{
988 $this->errorMes = 'ERROR : ' . mysql_error() . 'QUERY : ' . $query;
989 return FALSE;
990 }
991 }
992
993 //DownloadCSV
994 function DownloadCSV()
995 {
996 $table = '`' . $this->table . '`';
997 $where = $this->GetWhere($this->listPatternTableName);
998 // if($where == '' && $this->searchSql != ''){
999 // $where = ' WHERE ' . $this->searchSql;
1000 // }else if($where != '' && $this->searchSql != ''){
1001 // $where .= ' AND ' . $this->searchSql;
1002 // }
1003 $order = ' ORDER BY `' . $this->sortColumn . '` ' . $this->sortSwitchs[$this->sortColumn];
1004
1005 $query = sprintf("SELECT * FROM %s%s%s",
1006 mysql_real_escape_string($table),
1007 $where,
1008 mysql_real_escape_string($order)
1009 );
1010 $res = mysql_query($query, $this->dbCon);
1011 if($res){
1012
1013 $data = '';
1014 while($rows = mysql_fetch_assoc($res)){
1015 foreach($rows as $key=>$value){
1016 $data .= $value . ',';
1017 }
1018 $data = rtrim($data, ',') . "\n";
1019 }
1020 $this->errorMes = '';
1021
1022 header("Content-Type: application/octet-stream");
1023 header("Content-Disposition: attachment; filename=listData.csv");
1024 print(mb_convert_encoding($data,"SJIS","EUC-JP"));
1025
1026
1027 }else{
1028
1029 $this->errorMes = 'ERROR : ' . mysql_error() . 'QUERY : ' . $query;
1030 echo $this->errorMes;
1031 }
1032
1033 }
1034
1035 function GetWhere($table)
1036 {
1037 $str = '';
1038
1039 if($table != ''){
1040
1041 $query = sprintf("SELECT * FROM `%s` WHERE id = %d", $table, $this->listPatternId);
1042 $res = mysql_query($query, $this->dbCon);
1043 if(!$res){
1044
1045 $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1046 return FALSE;
1047
1048 }else{
1049
1050 $rows = mysql_fetch_assoc($res);
1051 $num = mysql_num_rows($res);
1052
1053 if($num == 0){
1054 $this->listPatternId = 1;
1055 $_SESSION[$this->table]['listPatternId'] = $this->listPatternId;
1056 setcookie($this->table.'listPatternId', $this->listPatternId, $this->expiration);
1057 $str = '';
1058 }else if( WCUtils::is_blank($rows['pattern']) ){
1059 $str = '';
1060 }else{
1061 $str = ' WHERE ' . $rows['pattern'];
1062 }
1063 }
1064 }
1065
1066 if( WCUtils::is_blank($str) && !WCUtils::is_blank($this->searchSql) ){
1067 $str = ' WHERE ' . $this->searchSql;
1068 }else if($str != '' && $this->searchSql != ''){
1069 $str .= ' AND ' . $this->searchSql;
1070 }
1071 return $str;
1072 }
1073
1074 function SearchIn()
1075 {
1076 $column = '`' . $this->searchs['column'] . '`';
1077 switch ($this->searchs['shiki']){
1078 case 1:
1079 $shiki = ' = ';
1080 $word = "'" . mysql_real_escape_string($this->searchs['word']) . "'";
1081 break;
1082 case 2:
1083 $shiki = ' LIKE ';
1084 $word = "'%" . mysql_real_escape_string($this->searchs['word']) . "%'";
1085 break;
1086 case 3:
1087 $shiki = ' <> ';
1088 $word = "'" . mysql_real_escape_string($this->searchs['word']) . "'";
1089 break;
1090 case 4:
1091 $shiki = ' NOT LIKE ';
1092 $word = "'%" . mysql_real_escape_string($this->searchs['word']) . "%'";
1093 break;
1094 }
1095 $this->searchSql = $column . $shiki . $word;
1096 }
1097
1098 function SearchOut()
1099 {
1100 $this->searchSql = '';
1101 }
1102
1103 function GetErrorMes()
1104 {
1105 return $this->errorMes;
1106 }
1107
1108
1109 function DispError($mes)
1110 {
1111 echo $mes;
1112 exit;
1113 }
1114
1115 function UseListPattern($table)
1116 {
1117 $this->listPatternTableName = $table;
1118 $this->useListPattern = 1;
1119 }
1120 function UseEditField()
1121 {
1122 $this->useEditField = 1;
1123 }
1124 function UseUpload()
1125 {
1126 $this->useUpload = 1;
1127 }
1128 function UseDownload()
1129 {
1130 $this->useDownload = 1;
1131 }
1132 function UseAllDelete()
1133 {
1134 $this->useAllDelete = 1;
1135 }
1136 function UseBackButton($previous)
1137 {
1138 $this->useBackButton = $previous;
1139 }
1140 function UseNewButton()
1141 {
1142 $this->useNewButton = 1;
1143 }
1144 function UseDoubleClickEdit()
1145 {
1146 $this->useDoubleClickEdit = 1;
1147 }
1148
1149 //ListPatternOBJ
1150 function GetListPatternRows($table)
1151 {
1152 if( WCUtils::is_blank($table) ){
1153 $this->listPatternId = '';
1154 $this->listPatternRows = '';
1155 return;
1156 }
1157
1158 $query = sprintf("SELECT * FROM `%s` ORDER BY id", $table);
1159 $res = mysql_query($query, $this->dbCon);
1160 if(!$res){
1161
1162 $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1163 return FALSE;
1164
1165 }else{
1166
1167 while($rows = mysql_fetch_assoc($res)){
1168 $this->listPatternRows[] = $rows;
1169 }
1170 $_SESSION[$this->table]['listPatternRows'] = $this->listPatternRows;
1171 return TRUE;
1172 }
1173 }
1174
1175 function SetTotalRow()
1176 {
1177
1178 $query = sprintf("SELECT * FROM `%s`", $this->table);
1179 $res = mysql_query($query, $this->dbCon);
1180 if(!$res){
1181
1182 $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1183
1184 }else{
1185
1186 $this->totalRow = mysql_num_rows($res);
1187
1188 }
1189
1190 }
1191 function SetDefaultColumns()
1192 {
1193 $this->defaultColumns = array();
1194
1195 $query = sprintf("SELECT * FROM `%s`", $this->table);
1196 $res = mysql_query($query, $this->dbCon);
1197 if(!$res){
1198
1199 $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1200
1201 }else{
1202
1203 $length = mysql_num_fields($res);
1204 for($i=0; $i<$length; $i++){
1205 $name = mysql_field_name($res, $i);
1206 $this->defaultColumns[] = $name;
1207 $this->sortSwitchs[$name] = 'ASC';
1208 }
1209 $this->sortColumn = $this->defaultColumns[0];
1210 }
1211
1212 }
1213
1214 function SetSelectedRow()
1215 {
1216 //絞込み後行数
1217 $where = $this->GetWhere($this->listPatternTableName);
1218 if($this->overlap == 'DISALLOW'){
1219 $group = ' GROUP BY mailaddress';
1220 }else{
1221 $group = '';
1222 }
1223 $query = sprintf("SELECT * FROM `%s`%s%s", $this->table, $where,$group);
1224 $res = mysql_query($query, $this->dbCon);
1225 if(!$res){
1226
1227 $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1228 return FALSE;
1229
1230 }else{
1231
1232 $num = mysql_num_rows($res);
1233 $this->selectedRow = $num;
1234 }
1235 }
1236
1237 function GetSelectData($headerKey)
1238 {
1239 $query = sprintf("SELECT `%s` FROM `%s` GROUP BY `%s`", $headerKey, $this->table, $headerKey);
1240 $res = mysql_query($query, $this->dbCon);
1241 if(!$res){
1242
1243 $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1244 return FALSE;
1245
1246 }else{
1247 $str = '';
1248 while($rows = mysql_fetch_assoc($res)){
1249 $str .= $rows[$headerKey] . ':';
1250 }
1251 $str = rtrim($str, ':');
1252 return $str;
1253 }
1254 }
1255
1256
1257 function SetSortStatus($column, $switch)
1258 {
1259 $this->sortColumn = $column;
1260 $this->sortSwitchs[$column] = $switch;
1261 $this->rows = array();
1262 $this->GetRows();
1263 $this->SetSession();
1264 }
1265
1266 function SetMaxRow($num)
1267 {
1268 $this->maxRow = $num;
1269 $this->rows = array();
1270 $this->GetRows();
1271 $this->SetSession();
1272 }
1273
1274 function SetCookieArray($name, $values)
1275 {
1276 $valuestr = '';
1277 foreach($values as $key=>$str){
1278 $valuestr .= $key . '=' . $str . ',';
1279 }
1280 $valuestr = trim($valuestr, ',');
1281 // echo '<br>setcookie:' . "<br>";
1282 //var_dump($values);
1283 //var_dump($valuestr);
1284 setcookie($name, $valuestr, $this->expiration);
1285 }
1286
1287 function GetCookieArray($name)
1288 {
1289 if(!isset($_COOKIE[$name])) return FALSE;
1290
1291 $names = explode(',', $_COOKIE[$name]);
1292 foreach($names as $str){
1293 $parts = explode('=', $str);
1294 $key = $parts[0];
1295 if(isset($parts[1])){
1296 $value = $parts[1];
1297 }else{
1298 $value = '';
1299 }
1300 $arrays[$key] = $value;
1301 }
1302 return $arrays;
1303 }
1304
1305 function SetOptions($tableName, $optionName, $value)
1306 {
1307 if(is_array($value)){
1308 $str_value = '';
1309 foreach($value as $key=>$str){
1310 $str_value .= $key . '=' . $str . ',';
1311 }
1312 $str_value = trim($str_value, ',');
1313 }else{
1314 $str_value = trim($value);
1315 }
1316 $query = sprintf("REPLACE INTO `%s` VALUES ('%s','%s','%s')",
1317 $this->optionTableName,
1318 $tableName,
1319 $optionName,
1320 mysql_real_escape_string($str_value)
1321 );
1322 $res = mysql_query($query, $this->dbCon);
1323 if(!$res){
1324
1325 $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1326 return FALSE;
1327
1328 }else{
1329 // if(mysql_affected_rows() == 0){
1330 // $query = sprintf("INSERT INTO `%s` VALUES ('%s','%s','%s')",
1331 // $this->optionTableName,
1332 // $tableName,
1333 // $optionName,
1334 // mysql_real_escape_string($str_value)
1335 // );
1336 // $res = mysql_query($query, $this->dbCon);
1337 // if(!$res){
1338 //
1339 // $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1340 // return FALSE;
1341 //
1342 // }else{
1343 //
1344 // return TRUE;
1345 //
1346 // }
1347 //
1348 // }else{
1349
1350 return TRUE;
1351
1352 // }
1353 }
1354 }
1355
1356 function GetOptions($tableName, $optionName)
1357 {
1358 $query = sprintf("SELECT * FROM `%s` WHERE option_name = '%s' AND table_name = '%s'",
1359 $this->optionTableName,
1360 $optionName,
1361 $tableName
1362 );
1363 $res = mysql_query($query, $this->dbCon);
1364 if(!$res){
1365
1366 $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1367 return FALSE;
1368
1369 }else{
1370 $rows = mysql_fetch_assoc($res);
1371 $str_value = $rows['value'];
1372 if( WCUtils::is_blank($str_value) ){
1373 return FALSE;
1374 }else{
1375
1376 if(strpos($str_value, ',') === FALSE){
1377 $return_value = $array_value;
1378 }else{
1379 $array_value = explode(',', $str_value);
1380 foreach($array_value as $str){
1381 $parts = explode('=', $str);
1382 $key = $parts[0];
1383 if(isset($parts[1])){
1384 $value = $parts[1];
1385 }else{
1386 $value = '';
1387 }
1388 $return_value[$key] = $value;
1389 }
1390 }
1391 return $return_value;
1392 }
1393 }
1394 }
1395
1396 //パターンリスト追加
1397 function AddPatternList()
1398 {
1399 $flag = '';
1400 for($i=0; $i<count($this->editListPatternFieldDatas); $i++){
1401 $flag .= $this->editListPatternFieldDatas[$i];
1402 }
1403 if(!$flag) return FALSE;
1404
1405 $pattern = $this->GetPattern();
1406 $query = sprintf("INSERT INTO `%s` (`%s`,`%s`) VALUES ('%s','%s')",
1407 $this->table,
1408 'name',
1409 'pattern',
1410 mysql_real_escape_string($this->editListPatternName),
1411 mysql_real_escape_string($pattern)
1412 );
1413 $res = mysql_query($query, $this->dbCon);
1414 if(!$res){
1415
1416 $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1417 return FALSE;
1418
1419 }else{
1420 return TRUE;
1421 }
1422 }
1423 function GetPattern()
1424 {
1425 $str = '';
1426 for($i=0; $i<count($this->editListPatternFieldDatas); $i++){
1427 switch ($this->editListPatternShikis[$i]){
1428 case 1:
1429 $shiki = ' = ';
1430 $word = "'" . mysql_real_escape_string($this->editListPatternFieldDatas[$i]) . "'";
1431 break;
1432 case 2:
1433 $shiki = ' LIKE ';
1434 $word = "'%" . mysql_real_escape_string($this->editListPatternFieldDatas[$i]) . "%'";
1435 break;
1436 case 3:
1437 $shiki = ' <> ';
1438 $word = "'" . mysql_real_escape_string($this->editListPatternFieldDatas[$i]) . "'";
1439 break;
1440 case 4:
1441 $shiki = ' NOT LIKE ';
1442 $word = "'%" . mysql_real_escape_string($this->editListPatternFieldDatas[$i]) . "%'";
1443 break;
1444 }
1445 if($this->editListPatternFieldDatas[$i] != ''){
1446 $str .= "`" . $this->editListPatternFieldNames[$i] . "`" . $shiki . $word . " AND ";
1447 }
1448 }
1449 $str = rtrim($str,' AND ');
1450 return $str;
1451 }
1452
1453
1454
1455 //AJAX
1456 function GetMemberData($id)
1457 {
1458 $data = '';
1459
1460 $query = sprintf("SELECT * FROM `%s` WHERE id = %d", $this->table, $id);
1461 $res = mysql_query($query, $this->dbCon);
1462 if(!$res){
1463
1464 $this->DispError('ERROR : ' . mysql_error() . 'QUERY : ' . $query);
1465 $data .= '<Result>ERROR</Result>';
1466
1467 }else{
1468
1469 $rows = mysql_fetch_assoc($res);
1470 $data .= '<Count>'.count($rows).'</Count>';
1471 $data .= '<Item>';
1472 foreach($rows as $value){
1473 if( WCUtils::is_blank($value) ){
1474 $data .= '<info>undefineinfodata</info>';
1475 }else{
1476 $data .= '<info>'.$value.'</info>';
1477 }
1478 }
1479 $data .= '</Item>';
1480
1481 $this->sendXML($data);
1482 }
1483 }
1484 function ChangeSearchSwitchStatus()
1485 {
1486 $_SESSION[$this->table]['searchSwitchStatus'] = $this->searchSwitchStatus;
1487 $data = '<Status>' . $this->searchSwitchStatus . '</Status>';
1488 $this->sendXML($data);
1489 }
1490 function ChangeListPatternAjax()
1491 {
1492 $this->SetSelectedRow();
1493 setcookie($this->table.'listPatternId', $this->listPatternId, $this->expiration);
1494 $_SESSION[$this->table]['listPatternId'] = $this->listPatternId;
1495 $_SESSION[$this->table]['selectedRow'] = $this->selectedRow;
1496 $data = '<Status>' . $this->selectedRow . '</Status>';
1497 $this->sendXML($data);
1498 }
1499
1500
1501 function sendXML($data) {
1502 //$data = htmlspecialchars($data, ENT_QUOTES);
1503 header("Content-type:text/xml;charset=euc-jp");
1504 echo '<?xml version="1.0" encoding="euc-jp"?>';
1505 //echo '<error>'.$msg.'</error>'."\n";
1506 echo '<ResultSet>';
1507 echo $data;
1508 echo '</ResultSet>';
1509 exit;
1510 }
1511 }
1512 ?>
1513