1 | <?php
|
---|
2 | /*
|
---|
3 | * This file is part of EC-CUBE
|
---|
4 | *
|
---|
5 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
|
---|
6 | *
|
---|
7 | * http://www.lockon.co.jp/
|
---|
8 | *
|
---|
9 | * This program is free software; you can redistribute it and/or
|
---|
10 | * modify it under the terms of the GNU General Public License
|
---|
11 | * as published by the Free Software Foundation; either version 2
|
---|
12 | * of the License, or (at your option) any later version.
|
---|
13 | *
|
---|
14 | * This program is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | * GNU General Public License for more details.
|
---|
18 | *
|
---|
19 | * You should have received a copy of the GNU General Public License
|
---|
20 | * along with this program; if not, write to the Free Software
|
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
22 | */
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * 各種ユーティリティクラス.
|
---|
26 | *
|
---|
27 | * 主に static 参照するユーティリティ系の関数群
|
---|
28 | *
|
---|
29 | * :XXX: 内部でインスタンスを生成している関数は, Helper クラスへ移動するべき...
|
---|
30 | *
|
---|
31 | * @package Util
|
---|
32 | * @author LOCKON CO.,LTD.
|
---|
33 | * @version $Id:SC_Utils.php 15532 2007-08-31 14:39:46Z nanasess $
|
---|
34 | */
|
---|
35 | class SC_Utils {
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * サイト管理情報から値を取得する。
|
---|
39 | * データが存在する場合、必ず1以上の数値が設定されている。
|
---|
40 | * 0を返した場合は、呼び出し元で対応すること。
|
---|
41 | *
|
---|
42 | * @param $control_id 管理ID
|
---|
43 | * @param $dsn DataSource
|
---|
44 | * @return $control_flg フラグ
|
---|
45 | */
|
---|
46 | function sfGetSiteControlFlg($control_id, $dsn = "") {
|
---|
47 |
|
---|
48 | // データソース
|
---|
49 | if($dsn == "") {
|
---|
50 | if(defined('DEFAULT_DSN')) {
|
---|
51 | $dsn = DEFAULT_DSN;
|
---|
52 | } else {
|
---|
53 | return;
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | // クエリ生成
|
---|
58 | $target_column = "control_flg";
|
---|
59 | $table_name = "dtb_site_control";
|
---|
60 | $where = "control_id = ?";
|
---|
61 | $arrval = array($control_id);
|
---|
62 | $control_flg = 0;
|
---|
63 |
|
---|
64 | // クエリ発行
|
---|
65 | $objQuery = new SC_Query($dsn, true, true);
|
---|
66 | $arrSiteControl = $objQuery->select($target_column, $table_name, $where, $arrval);
|
---|
67 |
|
---|
68 | // データが存在すればフラグを取得する
|
---|
69 | if (count($arrSiteControl) > 0) {
|
---|
70 | $control_flg = $arrSiteControl[0]["control_flg"];
|
---|
71 | }
|
---|
72 |
|
---|
73 | return $control_flg;
|
---|
74 | }
|
---|
75 |
|
---|
76 | // インストール初期処理
|
---|
77 | function sfInitInstall() {
|
---|
78 | // インストール済みが定義されていない。
|
---|
79 | if(!defined('ECCUBE_INSTALL')) {
|
---|
80 | if(!ereg("/install/", $_SERVER['PHP_SELF'])) {
|
---|
81 | header("Location: ./install/"); // TODO 絶対URL にする
|
---|
82 | }
|
---|
83 | } else {
|
---|
84 | $path = HTML_PATH . "install/index.php";
|
---|
85 | if(file_exists($path)) {
|
---|
86 | SC_Utils::sfErrorHeader(">> /install/index.phpは、インストール完了後にファイルを削除してください。");
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | // 装飾付きエラーメッセージの表示
|
---|
92 | function sfErrorHeader($mess, $print = false) {
|
---|
93 | global $GLOBAL_ERR;
|
---|
94 | $GLOBAL_ERR.="<div style='color: #F00; font-weight: bold; font-size: 12px;"
|
---|
95 | . "background-color: #FEB; text-align: center; padding: 5px;'>";
|
---|
96 | $GLOBAL_ERR.= $mess;
|
---|
97 | $GLOBAL_ERR.= "</div>";
|
---|
98 | if($print) {
|
---|
99 | print($GLOBAL_ERR);
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 | /* エラーページの表示 */
|
---|
104 | function sfDispError($type) {
|
---|
105 |
|
---|
106 | require_once(CLASS_EX_PATH . "page_extends/error/LC_Page_Error_DispError_Ex.php");
|
---|
107 |
|
---|
108 | $objPage = new LC_Page_Error_DispError_Ex();
|
---|
109 | register_shutdown_function(array($objPage, "destroy"));
|
---|
110 | $objPage->init();
|
---|
111 | $objPage->type = $type;
|
---|
112 | $objPage->process();
|
---|
113 | exit;
|
---|
114 | }
|
---|
115 |
|
---|
116 | /* サイトエラーページの表示 */
|
---|
117 | function sfDispSiteError($type, $objSiteSess = "", $return_top = false, $err_msg = "", $is_mobile = false) {
|
---|
118 | global $objCampaignSess;
|
---|
119 |
|
---|
120 | require_once(CLASS_EX_PATH . "page_extends/error/LC_Page_Error_Ex.php");
|
---|
121 |
|
---|
122 | $objPage = new LC_Page_Error_Ex();
|
---|
123 | register_shutdown_function(array($objPage, "destroy"));
|
---|
124 | $objPage->init();
|
---|
125 | $objPage->type = $type;
|
---|
126 | $objPage->objSiteSess = $objSiteSess;
|
---|
127 | $objPage->return_top = $return_top;
|
---|
128 | $objPage->err_msg = $err_msg;
|
---|
129 | $objPage->is_mobile = (defined('MOBILE_SITE')) ? true : false;
|
---|
130 | $objPage->process();
|
---|
131 | exit;
|
---|
132 | }
|
---|
133 |
|
---|
134 | /* 認証の可否判定 */
|
---|
135 | function sfIsSuccess($objSess, $disp_error = true) {
|
---|
136 | $ret = $objSess->IsSuccess();
|
---|
137 | if($ret != SUCCESS) {
|
---|
138 | if($disp_error) {
|
---|
139 | // エラーページの表示
|
---|
140 | SC_Utils::sfDispError($ret);
|
---|
141 | }
|
---|
142 | return false;
|
---|
143 | }
|
---|
144 | // リファラーチェック(CSRFの暫定的な対策)
|
---|
145 | // 「リファラ無」 の場合はスルー
|
---|
146 | // 「リファラ有」 かつ 「管理画面からの遷移でない」 場合にエラー画面を表示する
|
---|
147 | if ( empty($_SERVER['HTTP_REFERER']) ) {
|
---|
148 | // TODO 警告表示させる?
|
---|
149 | // sfErrorHeader('>> referrerが無効になっています。');
|
---|
150 | } else {
|
---|
151 | $domain = SC_Utils::sfIsHTTPS() ? SSL_URL : SITE_URL;
|
---|
152 | $pattern = sprintf('|^%s.*|', $domain);
|
---|
153 | $referer = $_SERVER['HTTP_REFERER'];
|
---|
154 |
|
---|
155 | // 管理画面から以外の遷移の場合はエラー画面を表示
|
---|
156 | if (!preg_match($pattern, $referer)) {
|
---|
157 | if ($disp_error) SC_Utils::sfDispError(INVALID_MOVE_ERRORR);
|
---|
158 | return false;
|
---|
159 | }
|
---|
160 | }
|
---|
161 | return true;
|
---|
162 | }
|
---|
163 |
|
---|
164 | /**
|
---|
165 | * 文字列をアスタリスクへ変換する.
|
---|
166 | *
|
---|
167 | * @param string $passlen 変換する文字列
|
---|
168 | * @return string アスタリスクへ変換した文字列
|
---|
169 | */
|
---|
170 | function lfPassLen($passlen){
|
---|
171 | $ret = "";
|
---|
172 | for ($i=0;$i<$passlen;true){
|
---|
173 | $ret.="*";
|
---|
174 | $i++;
|
---|
175 | }
|
---|
176 | return $ret;
|
---|
177 | }
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * HTTPSかどうかを判定
|
---|
181 | *
|
---|
182 | * @return bool
|
---|
183 | */
|
---|
184 | function sfIsHTTPS () {
|
---|
185 | // HTTPS時には$_SERVER['HTTPS']には空でない値が入る
|
---|
186 | // $_SERVER['HTTPS'] != 'off' はIIS用
|
---|
187 | if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
|
---|
188 | return true;
|
---|
189 | } else {
|
---|
190 | return false;
|
---|
191 | }
|
---|
192 | }
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * 正規の遷移がされているかを判定
|
---|
196 | * 前画面でuniqidを埋め込んでおく必要がある
|
---|
197 | * @param obj SC_Session, SC_SiteSession
|
---|
198 | * @return bool
|
---|
199 | */
|
---|
200 | function sfIsValidTransition($objSess) {
|
---|
201 | // 前画面からPOSTされるuniqidが正しいものかどうかをチェック
|
---|
202 | $uniqid = $objSess->getUniqId();
|
---|
203 | if ( !empty($_POST['uniqid']) && ($_POST['uniqid'] === $uniqid) ) {
|
---|
204 | return true;
|
---|
205 | } else {
|
---|
206 | return false;
|
---|
207 | }
|
---|
208 | }
|
---|
209 |
|
---|
210 | /* 前のページで正しく登録が行われたか判定 */
|
---|
211 | function sfIsPrePage(&$objSiteSess, $is_mobile = false) {
|
---|
212 | $ret = $objSiteSess->isPrePage();
|
---|
213 | if($ret != true) {
|
---|
214 | // エラーページの表示
|
---|
215 | SC_Utils::sfDispSiteError(PAGE_ERROR, $objSiteSess, false, "", $is_mobile);
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | function sfCheckNormalAccess(&$objSiteSess, &$objCartSess) {
|
---|
220 | // ユーザユニークIDの取得
|
---|
221 | $uniqid = $objSiteSess->getUniqId();
|
---|
222 | // 購入ボタンを押した時のカート内容がコピーされていない場合のみコピーする。
|
---|
223 | $objCartSess->saveCurrentCart($uniqid);
|
---|
224 | // POSTのユニークIDとセッションのユニークIDを比較(ユニークIDがPOSTされていない場合はスルー)
|
---|
225 | $ret = $objSiteSess->checkUniqId();
|
---|
226 | if($ret != true) {
|
---|
227 | // エラーページの表示
|
---|
228 | SC_Utils_Ex::sfDispSiteError(CANCEL_PURCHASE, $objSiteSess);
|
---|
229 | }
|
---|
230 |
|
---|
231 | // カート内が空でないか || 購入ボタンを押してから変化がないか
|
---|
232 | $quantity = $objCartSess->getTotalQuantity();
|
---|
233 | $ret = $objCartSess->checkChangeCart();
|
---|
234 | if($ret == true || !($quantity > 0)) {
|
---|
235 | // カート情報表示に強制移動する
|
---|
236 | // FIXME false を返して, Page クラスで遷移させるべき...
|
---|
237 | if (defined("MOBILE_SITE")) {
|
---|
238 | header("Location: ". MOBILE_URL_CART_TOP
|
---|
239 | . "?" . session_name() . "=" . session_id());
|
---|
240 | } else {
|
---|
241 | header("Location: ".URL_CART_TOP);
|
---|
242 | }
|
---|
243 | exit;
|
---|
244 | }
|
---|
245 | return $uniqid;
|
---|
246 | }
|
---|
247 |
|
---|
248 | /* DB用日付文字列取得 */
|
---|
249 | function sfGetTimestamp($year, $month, $day, $last = false) {
|
---|
250 | if($year != "" && $month != "" && $day != "") {
|
---|
251 | if($last) {
|
---|
252 | $time = "23:59:59";
|
---|
253 | } else {
|
---|
254 | $time = "00:00:00";
|
---|
255 | }
|
---|
256 | $date = $year."-".$month."-".$day." ".$time;
|
---|
257 | } else {
|
---|
258 | $date = "";
|
---|
259 | }
|
---|
260 | return $date;
|
---|
261 | }
|
---|
262 |
|
---|
263 | // INT型の数値チェック
|
---|
264 | function sfIsInt($value) {
|
---|
265 | if($value != "" && strlen($value) <= INT_LEN && is_numeric($value)) {
|
---|
266 | return true;
|
---|
267 | }
|
---|
268 | return false;
|
---|
269 | }
|
---|
270 |
|
---|
271 | function sfCSVDownload($data, $prefix = ""){
|
---|
272 |
|
---|
273 | if($prefix == "") {
|
---|
274 | $dir_name = SC_Utils::sfUpDirName();
|
---|
275 | $file_name = $dir_name . date("ymdHis") .".csv";
|
---|
276 | } else {
|
---|
277 | $file_name = $prefix . date("ymdHis") .".csv";
|
---|
278 | }
|
---|
279 |
|
---|
280 | /* HTTPヘッダの出力 */
|
---|
281 | Header("Content-disposition: attachment; filename=${file_name}");
|
---|
282 | Header("Content-type: application/octet-stream; name=${file_name}");
|
---|
283 | Header("Cache-Control: ");
|
---|
284 | Header("Pragma: ");
|
---|
285 |
|
---|
286 | if (mb_internal_encoding() == CHAR_CODE){
|
---|
287 | $data = mb_convert_encoding($data,'SJIS',CHAR_CODE);
|
---|
288 | }
|
---|
289 |
|
---|
290 | /* データを出力 */
|
---|
291 | echo $data;
|
---|
292 | }
|
---|
293 |
|
---|
294 | /* 1階層上のディレクトリ名を取得する */
|
---|
295 | function sfUpDirName() {
|
---|
296 | $path = $_SERVER['PHP_SELF'];
|
---|
297 | $arrVal = split("/", $path);
|
---|
298 | $cnt = count($arrVal);
|
---|
299 | return $arrVal[($cnt - 2)];
|
---|
300 | }
|
---|
301 |
|
---|
302 |
|
---|
303 |
|
---|
304 |
|
---|
305 | /**
|
---|
306 | * 現在のサイトを更新(ただしポストは行わない)
|
---|
307 | *
|
---|
308 | * @deprecated LC_Page::reload() を使用して下さい.
|
---|
309 | */
|
---|
310 | function sfReload($get = "") {
|
---|
311 | if ($_SERVER["SERVER_PORT"] == "443" ){
|
---|
312 | $url = ereg_replace(URL_DIR . "$", "", SSL_URL);
|
---|
313 | } else {
|
---|
314 | $url = ereg_replace(URL_DIR . "$", "", SITE_URL);
|
---|
315 | }
|
---|
316 |
|
---|
317 | if($get != "") {
|
---|
318 | header("Location: ". $url . $_SERVER['PHP_SELF'] . "?" . $get);
|
---|
319 | } else {
|
---|
320 | header("Location: ". $url . $_SERVER['PHP_SELF']);
|
---|
321 | }
|
---|
322 | exit;
|
---|
323 | }
|
---|
324 |
|
---|
325 | // チェックボックスの値をマージ
|
---|
326 | function sfMergeCBValue($keyname, $max) {
|
---|
327 | $conv = "";
|
---|
328 | $cnt = 1;
|
---|
329 | for($cnt = 1; $cnt <= $max; $cnt++) {
|
---|
330 | if ($_POST[$keyname . $cnt] == "1") {
|
---|
331 | $conv.= "1";
|
---|
332 | } else {
|
---|
333 | $conv.= "0";
|
---|
334 | }
|
---|
335 | }
|
---|
336 | return $conv;
|
---|
337 | }
|
---|
338 |
|
---|
339 | // html_checkboxesの値をマージして2進数形式に変更する。
|
---|
340 | function sfMergeCheckBoxes($array, $max) {
|
---|
341 | $ret = "";
|
---|
342 | if(is_array($array)) {
|
---|
343 | foreach($array as $val) {
|
---|
344 | $arrTmp[$val] = "1";
|
---|
345 | }
|
---|
346 | }
|
---|
347 | for($i = 1; $i <= $max; $i++) {
|
---|
348 | if(isset($arrTmp[$i]) && $arrTmp[$i] == "1") {
|
---|
349 | $ret.= "1";
|
---|
350 | } else {
|
---|
351 | $ret.= "0";
|
---|
352 | }
|
---|
353 | }
|
---|
354 | return $ret;
|
---|
355 | }
|
---|
356 |
|
---|
357 |
|
---|
358 | // html_checkboxesの値をマージして「-」でつなげる。
|
---|
359 | function sfMergeParamCheckBoxes($array) {
|
---|
360 | $ret = '';
|
---|
361 | if(is_array($array)) {
|
---|
362 | foreach($array as $val) {
|
---|
363 | if($ret != "") {
|
---|
364 | $ret.= "-$val";
|
---|
365 | } else {
|
---|
366 | $ret = $val;
|
---|
367 | }
|
---|
368 | }
|
---|
369 | } else {
|
---|
370 | $ret = $array;
|
---|
371 | }
|
---|
372 | return $ret;
|
---|
373 | }
|
---|
374 |
|
---|
375 | // html_checkboxesの値をマージしてSQL検索用に変更する。
|
---|
376 | function sfSearchCheckBoxes($array) {
|
---|
377 | $max = 0;
|
---|
378 | $ret = "";
|
---|
379 | foreach($array as $val) {
|
---|
380 | $arrTmp[$val] = "1";
|
---|
381 | if($val > $max) {
|
---|
382 | $max = $val;
|
---|
383 | }
|
---|
384 | }
|
---|
385 | for($i = 1; $i <= $max; $i++) {
|
---|
386 | if($arrTmp[$i] == "1") {
|
---|
387 | $ret.= "1";
|
---|
388 | } else {
|
---|
389 | $ret.= "_";
|
---|
390 | }
|
---|
391 | }
|
---|
392 |
|
---|
393 | if($ret != "") {
|
---|
394 | $ret.= "%";
|
---|
395 | }
|
---|
396 | return $ret;
|
---|
397 | }
|
---|
398 |
|
---|
399 | // 2進数形式の値をhtml_checkboxes対応の値に切り替える
|
---|
400 | function sfSplitCheckBoxes($val) {
|
---|
401 | $arrRet = array();
|
---|
402 | $len = strlen($val);
|
---|
403 | for($i = 0; $i < $len; $i++) {
|
---|
404 | if(substr($val, $i, 1) == "1") {
|
---|
405 | $arrRet[] = ($i + 1);
|
---|
406 | }
|
---|
407 | }
|
---|
408 | return $arrRet;
|
---|
409 | }
|
---|
410 |
|
---|
411 | // チェックボックスの値をマージ
|
---|
412 | function sfMergeCBSearchValue($keyname, $max) {
|
---|
413 | $conv = "";
|
---|
414 | $cnt = 1;
|
---|
415 | for($cnt = 1; $cnt <= $max; $cnt++) {
|
---|
416 | if ($_POST[$keyname . $cnt] == "1") {
|
---|
417 | $conv.= "1";
|
---|
418 | } else {
|
---|
419 | $conv.= "_";
|
---|
420 | }
|
---|
421 | }
|
---|
422 | return $conv;
|
---|
423 | }
|
---|
424 |
|
---|
425 | // チェックボックスの値を分解
|
---|
426 | function sfSplitCBValue($val, $keyname = "") {
|
---|
427 | $len = strlen($val);
|
---|
428 | $no = 1;
|
---|
429 | for ($cnt = 0; $cnt < $len; $cnt++) {
|
---|
430 | if($keyname != "") {
|
---|
431 | $arr[$keyname . $no] = substr($val, $cnt, 1);
|
---|
432 | } else {
|
---|
433 | $arr[] = substr($val, $cnt, 1);
|
---|
434 | }
|
---|
435 | $no++;
|
---|
436 | }
|
---|
437 | return $arr;
|
---|
438 | }
|
---|
439 |
|
---|
440 | // キーと値をセットした配列を取得
|
---|
441 | function sfArrKeyValue($arrList, $keyname, $valname, $len_max = "", $keysize = "") {
|
---|
442 | $arrRet = array();
|
---|
443 | $max = count($arrList);
|
---|
444 |
|
---|
445 | if($len_max != "" && $max > $len_max) {
|
---|
446 | $max = $len_max;
|
---|
447 | }
|
---|
448 |
|
---|
449 | for($cnt = 0; $cnt < $max; $cnt++) {
|
---|
450 | if($keysize != "") {
|
---|
451 | $key = SC_Utils::sfCutString($arrList[$cnt][$keyname], $keysize);
|
---|
452 | } else {
|
---|
453 | $key = $arrList[$cnt][$keyname];
|
---|
454 | }
|
---|
455 | $val = $arrList[$cnt][$valname];
|
---|
456 |
|
---|
457 | if(!isset($arrRet[$key])) {
|
---|
458 | $arrRet[$key] = $val;
|
---|
459 | }
|
---|
460 |
|
---|
461 | }
|
---|
462 | return $arrRet;
|
---|
463 | }
|
---|
464 |
|
---|
465 | // キーと値をセットした配列を取得(値が複数の場合)
|
---|
466 | function sfArrKeyValues($arrList, $keyname, $valname, $len_max = "", $keysize = "", $connect = "") {
|
---|
467 |
|
---|
468 | $max = count($arrList);
|
---|
469 |
|
---|
470 | if($len_max != "" && $max > $len_max) {
|
---|
471 | $max = $len_max;
|
---|
472 | }
|
---|
473 |
|
---|
474 | for($cnt = 0; $cnt < $max; $cnt++) {
|
---|
475 | if($keysize != "") {
|
---|
476 | $key = SC_Utils::sfCutString($arrList[$cnt][$keyname], $keysize);
|
---|
477 | } else {
|
---|
478 | $key = $arrList[$cnt][$keyname];
|
---|
479 | }
|
---|
480 | $val = $arrList[$cnt][$valname];
|
---|
481 |
|
---|
482 | if($connect != "") {
|
---|
483 | $arrRet[$key].= "$val".$connect;
|
---|
484 | } else {
|
---|
485 | $arrRet[$key][] = $val;
|
---|
486 | }
|
---|
487 | }
|
---|
488 | return $arrRet;
|
---|
489 | }
|
---|
490 |
|
---|
491 | // 配列の値をカンマ区切りで返す。
|
---|
492 | function sfGetCommaList($array, $space=true, $arrPop = array()) {
|
---|
493 | if (count($array) > 0) {
|
---|
494 | $line = "";
|
---|
495 | foreach($array as $val) {
|
---|
496 | if (!in_array($val, $arrPop)) {
|
---|
497 | if ($space) {
|
---|
498 | $line .= $val . ", ";
|
---|
499 | } else {
|
---|
500 | $line .= $val . ",";
|
---|
501 | }
|
---|
502 | }
|
---|
503 | }
|
---|
504 | if ($space) {
|
---|
505 | $line = ereg_replace(", $", "", $line);
|
---|
506 | } else {
|
---|
507 | $line = ereg_replace(",$", "", $line);
|
---|
508 | }
|
---|
509 | return $line;
|
---|
510 | } else {
|
---|
511 | return false;
|
---|
512 | }
|
---|
513 |
|
---|
514 | }
|
---|
515 |
|
---|
516 | /* 配列の要素をCSVフォーマットで出力する。*/
|
---|
517 | function sfGetCSVList($array) {
|
---|
518 | $line = "";
|
---|
519 | if (count($array) > 0) {
|
---|
520 | foreach($array as $key => $val) {
|
---|
521 | $val = mb_convert_encoding($val, CHAR_CODE, CHAR_CODE);
|
---|
522 | $line .= "\"".$val."\",";
|
---|
523 | }
|
---|
524 | $line = ereg_replace(",$", "\r\n", $line);
|
---|
525 | }else{
|
---|
526 | return false;
|
---|
527 | }
|
---|
528 | return $line;
|
---|
529 | }
|
---|
530 |
|
---|
531 | /* 配列の要素をPDFフォーマットで出力する。*/
|
---|
532 | function sfGetPDFList($array) {
|
---|
533 | foreach($array as $key => $val) {
|
---|
534 | $line .= "\t".$val;
|
---|
535 | }
|
---|
536 | $line.="\n";
|
---|
537 | return $line;
|
---|
538 | }
|
---|
539 |
|
---|
540 |
|
---|
541 |
|
---|
542 | /*-----------------------------------------------------------------*/
|
---|
543 | /* check_set_term
|
---|
544 | /* 年月日に別れた2つの期間の妥当性をチェックし、整合性と期間を返す
|
---|
545 | /* 引数 (開始年,開始月,開始日,終了年,終了月,終了日)
|
---|
546 | /* 戻値 array(1,2,3)
|
---|
547 | /* 1.開始年月日 (YYYY/MM/DD 000000)
|
---|
548 | /* 2.終了年月日 (YYYY/MM/DD 235959)
|
---|
549 | /* 3.エラー ( 0 = OK, 1 = NG )
|
---|
550 | /*-----------------------------------------------------------------*/
|
---|
551 | function sfCheckSetTerm ( $start_year, $start_month, $start_day, $end_year, $end_month, $end_day ) {
|
---|
552 |
|
---|
553 | // 期間指定
|
---|
554 | $error = 0;
|
---|
555 | if ( $start_month || $start_day || $start_year){
|
---|
556 | if ( ! checkdate($start_month, $start_day , $start_year) ) $error = 1;
|
---|
557 | } else {
|
---|
558 | $error = 1;
|
---|
559 | }
|
---|
560 | if ( $end_month || $end_day || $end_year){
|
---|
561 | if ( ! checkdate($end_month ,$end_day ,$end_year) ) $error = 2;
|
---|
562 | }
|
---|
563 | if ( ! $error ){
|
---|
564 | $date1 = $start_year ."/".sprintf("%02d",$start_month) ."/".sprintf("%02d",$start_day) ." 000000";
|
---|
565 | $date2 = $end_year ."/".sprintf("%02d",$end_month) ."/".sprintf("%02d",$end_day) ." 235959";
|
---|
566 | if ($date1 > $date2) $error = 3;
|
---|
567 | } else {
|
---|
568 | $error = 1;
|
---|
569 | }
|
---|
570 | return array($date1, $date2, $error);
|
---|
571 | }
|
---|
572 |
|
---|
573 | // エラー箇所の背景色を変更するためのfunction SC_Viewで読み込む
|
---|
574 | function sfSetErrorStyle(){
|
---|
575 | return 'style="background-color:'.ERR_COLOR.'"';
|
---|
576 | }
|
---|
577 |
|
---|
578 | /* DBに渡す数値のチェック
|
---|
579 | * 10桁以上はオーバーフローエラーを起こすので。
|
---|
580 | */
|
---|
581 | function sfCheckNumLength( $value ){
|
---|
582 | if ( ! is_numeric($value) ){
|
---|
583 | return false;
|
---|
584 | }
|
---|
585 |
|
---|
586 | if ( strlen($value) > 9 ) {
|
---|
587 | return false;
|
---|
588 | }
|
---|
589 |
|
---|
590 | return true;
|
---|
591 | }
|
---|
592 |
|
---|
593 | // 一致した値のキー名を取得
|
---|
594 | function sfSearchKey($array, $word, $default) {
|
---|
595 | foreach($array as $key => $val) {
|
---|
596 | if($val == $word) {
|
---|
597 | return $key;
|
---|
598 | }
|
---|
599 | }
|
---|
600 | return $default;
|
---|
601 | }
|
---|
602 |
|
---|
603 | function sfGetErrorColor($val) {
|
---|
604 | if($val != "") {
|
---|
605 | return "background-color:" . ERR_COLOR;
|
---|
606 | }
|
---|
607 | return "";
|
---|
608 | }
|
---|
609 |
|
---|
610 | function sfGetEnabled($val) {
|
---|
611 | if( ! $val ) {
|
---|
612 | return " disabled=\"disabled\"";
|
---|
613 | }
|
---|
614 | return "";
|
---|
615 | }
|
---|
616 |
|
---|
617 | function sfGetChecked($param, $value) {
|
---|
618 | if($param == $value) {
|
---|
619 | return "checked=\"checked\"";
|
---|
620 | }
|
---|
621 | return "";
|
---|
622 | }
|
---|
623 |
|
---|
624 | function sfTrim($str) {
|
---|
625 | $ret = ereg_replace("^[ \n\r]*", "", $str);
|
---|
626 | $ret = ereg_replace("[ \n\r]*$", "", $ret);
|
---|
627 | return $ret;
|
---|
628 | }
|
---|
629 |
|
---|
630 | /* 税金計算 */
|
---|
631 | function sfTax($price, $tax, $tax_rule) {
|
---|
632 | $real_tax = $tax / 100;
|
---|
633 | $ret = $price * $real_tax;
|
---|
634 | switch($tax_rule) {
|
---|
635 | // 四捨五入
|
---|
636 | case 1:
|
---|
637 | $ret = round($ret);
|
---|
638 | break;
|
---|
639 | // 切り捨て
|
---|
640 | case 2:
|
---|
641 | $ret = floor($ret);
|
---|
642 | break;
|
---|
643 | // 切り上げ
|
---|
644 | case 3:
|
---|
645 | $ret = ceil($ret);
|
---|
646 | break;
|
---|
647 | // デフォルト:切り上げ
|
---|
648 | default:
|
---|
649 | $ret = ceil($ret);
|
---|
650 | break;
|
---|
651 | }
|
---|
652 | return $ret;
|
---|
653 | }
|
---|
654 |
|
---|
655 | /* 税金付与 */
|
---|
656 | function sfPreTax($price, $tax, $tax_rule) {
|
---|
657 | $real_tax = $tax / 100;
|
---|
658 | $ret = $price * (1 + $real_tax);
|
---|
659 |
|
---|
660 | switch($tax_rule) {
|
---|
661 | // 四捨五入
|
---|
662 | case 1:
|
---|
663 | $ret = round($ret);
|
---|
664 | break;
|
---|
665 | // 切り捨て
|
---|
666 | case 2:
|
---|
667 | $ret = floor($ret);
|
---|
668 | break;
|
---|
669 | // 切り上げ
|
---|
670 | case 3:
|
---|
671 | $ret = ceil($ret);
|
---|
672 | break;
|
---|
673 | // デフォルト:切り上げ
|
---|
674 | default:
|
---|
675 | $ret = ceil($ret);
|
---|
676 | break;
|
---|
677 | }
|
---|
678 | return $ret;
|
---|
679 | }
|
---|
680 |
|
---|
681 | // 桁数を指定して四捨五入
|
---|
682 | function sfRound($value, $pow = 0){
|
---|
683 | $adjust = pow(10 ,$pow-1);
|
---|
684 |
|
---|
685 | // 整数且つ0出なければ桁数指定を行う
|
---|
686 | if(SC_Utils::sfIsInt($adjust) and $pow > 1){
|
---|
687 | $ret = (round($value * $adjust)/$adjust);
|
---|
688 | }
|
---|
689 |
|
---|
690 | $ret = round($ret);
|
---|
691 |
|
---|
692 | return $ret;
|
---|
693 | }
|
---|
694 |
|
---|
695 | /* ポイント付与 */
|
---|
696 | function sfPrePoint($price, $point_rate, $rule = POINT_RULE, $product_id = "") {
|
---|
697 | if(SC_Utils::sfIsInt($product_id)) {
|
---|
698 | $objQuery = new SC_Query();
|
---|
699 | $where = "now() >= cast(start_date as date) AND ";
|
---|
700 | $where .= "now() < cast(end_date as date) AND ";
|
---|
701 |
|
---|
702 | $where .= "del_flg = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )";
|
---|
703 | //登録(更新)日付順
|
---|
704 | $objQuery->setorder('update_date DESC');
|
---|
705 | //キャンペーンポイントの取得
|
---|
706 | $arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id));
|
---|
707 | }
|
---|
708 | //複数のキャンペーンに登録されている商品は、最新のキャンペーンからポイントを取得
|
---|
709 | if(isset($arrRet[0]['campaign_point_rate'])
|
---|
710 | && $arrRet[0]['campaign_point_rate'] != "") {
|
---|
711 |
|
---|
712 | $campaign_point_rate = $arrRet[0]['campaign_point_rate'];
|
---|
713 | $real_point = $campaign_point_rate / 100;
|
---|
714 | } else {
|
---|
715 | $real_point = $point_rate / 100;
|
---|
716 | }
|
---|
717 | $ret = $price * $real_point;
|
---|
718 | switch($rule) {
|
---|
719 | // 四捨五入
|
---|
720 | case 1:
|
---|
721 | $ret = round($ret);
|
---|
722 | break;
|
---|
723 | // 切り捨て
|
---|
724 | case 2:
|
---|
725 | $ret = floor($ret);
|
---|
726 | break;
|
---|
727 | // 切り上げ
|
---|
728 | case 3:
|
---|
729 | $ret = ceil($ret);
|
---|
730 | break;
|
---|
731 | // デフォルト:切り上げ
|
---|
732 | default:
|
---|
733 | $ret = ceil($ret);
|
---|
734 | break;
|
---|
735 | }
|
---|
736 | //キャンペーン商品の場合
|
---|
737 | if(isset($campaign_point_rate) && $campaign_point_rate != "") {
|
---|
738 | $ret = "(".$arrRet[0]['campaign_name']."ポイント率".$campaign_point_rate."%)".$ret;
|
---|
739 | }
|
---|
740 | return $ret;
|
---|
741 | }
|
---|
742 |
|
---|
743 | /* 規格分類の件数取得 */
|
---|
744 | function sfGetClassCatCount() {
|
---|
745 | $sql = "select count(dtb_class.class_id) as count, dtb_class.class_id ";
|
---|
746 | $sql.= "from dtb_class inner join dtb_classcategory on dtb_class.class_id = dtb_classcategory.class_id ";
|
---|
747 | $sql.= "where dtb_class.del_flg = 0 AND dtb_classcategory.del_flg = 0 ";
|
---|
748 | $sql.= "group by dtb_class.class_id, dtb_class.name";
|
---|
749 | $objQuery = new SC_Query();
|
---|
750 | $arrList = $objQuery->getall($sql);
|
---|
751 | // キーと値をセットした配列を取得
|
---|
752 | $arrRet = SC_Utils::sfArrKeyValue($arrList, 'class_id', 'count');
|
---|
753 |
|
---|
754 | return $arrRet;
|
---|
755 | }
|
---|
756 |
|
---|
757 | /* 規格の登録 */
|
---|
758 | function sfInsertProductClass($objQuery, $arrList, $product_id , $product_class_id = "") {
|
---|
759 | // すでに規格登録があるかどうかをチェックする。
|
---|
760 | $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0";
|
---|
761 | $count = $objQuery->count("dtb_products_class", $where, array($product_id));
|
---|
762 |
|
---|
763 | // すでに規格登録がない場合
|
---|
764 | if($count == 0) {
|
---|
765 | // 既存規格の削除
|
---|
766 | $where = "product_id = ?";
|
---|
767 | $objQuery->delete("dtb_products_class", $where, array($product_id));
|
---|
768 |
|
---|
769 | // 配列の添字を定義
|
---|
770 | $checkArray = array("product_code", "stock", "stock_unlimited", "price01", "price02");
|
---|
771 | $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray);
|
---|
772 |
|
---|
773 | $sqlval['product_id'] = $product_id;
|
---|
774 | if(strlen($product_class_id ) > 0 ){
|
---|
775 | $sqlval['product_class_id'] = $product_class_id;
|
---|
776 | }
|
---|
777 | $sqlval['classcategory_id1'] = '0';
|
---|
778 | $sqlval['classcategory_id2'] = '0';
|
---|
779 | $sqlval['product_code'] = $arrList["product_code"];
|
---|
780 | $sqlval['stock'] = $arrList["stock"];
|
---|
781 | $sqlval['stock_unlimited'] = $arrList["stock_unlimited"];
|
---|
782 | $sqlval['price01'] = $arrList['price01'];
|
---|
783 | $sqlval['price02'] = $arrList['price02'];
|
---|
784 | $sqlval['creator_id'] = $_SESSION['member_id'];
|
---|
785 | $sqlval['create_date'] = "now()";
|
---|
786 |
|
---|
787 | if($_SESSION['member_id'] == "") {
|
---|
788 | $sqlval['creator_id'] = '0';
|
---|
789 | }
|
---|
790 |
|
---|
791 | // INSERTの実行
|
---|
792 | $objQuery->insert("dtb_products_class", $sqlval);
|
---|
793 | }
|
---|
794 | }
|
---|
795 |
|
---|
796 | function sfGetProductClassId($product_id, $classcategory_id1, $classcategory_id2) {
|
---|
797 | $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
|
---|
798 | $objQuery = new SC_Query();
|
---|
799 | $ret = $objQuery->get("dtb_products_class", "product_class_id", $where, Array($product_id, $classcategory_id1, $classcategory_id2));
|
---|
800 | return $ret;
|
---|
801 | }
|
---|
802 |
|
---|
803 | /* 文末の「/」をなくす */
|
---|
804 | function sfTrimURL($url) {
|
---|
805 | $ret = ereg_replace("[/]+$", "", $url);
|
---|
806 | return $ret;
|
---|
807 | }
|
---|
808 |
|
---|
809 | /* DBから取り出した日付の文字列を調整する。*/
|
---|
810 | function sfDispDBDate($dbdate, $time = true) {
|
---|
811 | list($y, $m, $d, $H, $M) = split("[- :]", $dbdate);
|
---|
812 |
|
---|
813 | if(strlen($y) > 0 && strlen($m) > 0 && strlen($d) > 0) {
|
---|
814 | if ($time) {
|
---|
815 | $str = sprintf("%04d/%02d/%02d %02d:%02d", $y, $m, $d, $H, $M);
|
---|
816 | } else {
|
---|
817 | $str = sprintf("%04d/%02d/%02d", $y, $m, $d, $H, $M);
|
---|
818 | }
|
---|
819 | } else {
|
---|
820 | $str = "";
|
---|
821 | }
|
---|
822 | return $str;
|
---|
823 | }
|
---|
824 |
|
---|
825 | /* 配列をキー名ごとの配列に変更する */
|
---|
826 | function sfSwapArray($array, $isColumnName = true) {
|
---|
827 | $arrRet = array();
|
---|
828 | $max = count($array);
|
---|
829 | for($i = 0; $i < $max; $i++) {
|
---|
830 | $j = 0;
|
---|
831 | foreach($array[$i] as $key => $val) {
|
---|
832 | if ($isColumnName) {
|
---|
833 | $arrRet[$key][] = $val;
|
---|
834 | } else {
|
---|
835 | $arrRet[$j][] = $val;
|
---|
836 | }
|
---|
837 | $j++;
|
---|
838 | }
|
---|
839 | }
|
---|
840 | return $arrRet;
|
---|
841 | }
|
---|
842 |
|
---|
843 | /**
|
---|
844 | * 連想配列から新たな配列を生成して返す.
|
---|
845 | *
|
---|
846 | * $requires が指定された場合, $requires に含まれるキーの値のみを返す.
|
---|
847 | *
|
---|
848 | * @param array 連想配列
|
---|
849 | * @param array 必須キーの配列
|
---|
850 | * @return array 連想配列の値のみの配列
|
---|
851 | */
|
---|
852 | function getHash2Array($hash, $requires = array()) {
|
---|
853 | $array = array();
|
---|
854 | $i = 0;
|
---|
855 | foreach ($hash as $key => $val) {
|
---|
856 | if (!empty($requires)) {
|
---|
857 | if (in_array($key, $requires)) {
|
---|
858 | $array[$i] = $val;
|
---|
859 | $i++;
|
---|
860 | }
|
---|
861 | } else {
|
---|
862 | $array[$i] = $val;
|
---|
863 | $i++;
|
---|
864 | }
|
---|
865 | }
|
---|
866 | return $array;
|
---|
867 | }
|
---|
868 |
|
---|
869 | /* かけ算をする(Smarty用) */
|
---|
870 | function sfMultiply($num1, $num2) {
|
---|
871 | return ($num1 * $num2);
|
---|
872 | }
|
---|
873 |
|
---|
874 | // カードの処理結果を返す
|
---|
875 | function sfGetAuthonlyResult($dir, $file_name, $name01, $name02, $card_no, $card_exp, $amount, $order_id, $jpo_info = "10"){
|
---|
876 |
|
---|
877 | $path = $dir .$file_name; // cgiファイルのフルパス生成
|
---|
878 | $now_dir = getcwd(); // requireがうまくいかないので、cgi実行ディレクトリに移動する
|
---|
879 | chdir($dir);
|
---|
880 |
|
---|
881 | // パイプ渡しでコマンドラインからcgi起動
|
---|
882 | $cmd = "$path card_no=$card_no name01=$name01 name02=$name02 card_exp=$card_exp amount=$amount order_id=$order_id jpo_info=$jpo_info";
|
---|
883 |
|
---|
884 | $tmpResult = popen($cmd, "r");
|
---|
885 |
|
---|
886 | // 結果取得
|
---|
887 | while( ! FEOF ( $tmpResult ) ) {
|
---|
888 | $result .= FGETS($tmpResult);
|
---|
889 | }
|
---|
890 | pclose($tmpResult); // パイプを閉じる
|
---|
891 | chdir($now_dir); // 元にいたディレクトリに帰る
|
---|
892 |
|
---|
893 | // 結果を連想配列へ格納
|
---|
894 | $result = ereg_replace("&$", "", $result);
|
---|
895 | foreach (explode("&",$result) as $data) {
|
---|
896 | list($key, $val) = explode("=", $data, 2);
|
---|
897 | $return[$key] = $val;
|
---|
898 | }
|
---|
899 |
|
---|
900 | return $return;
|
---|
901 | }
|
---|
902 |
|
---|
903 | /* 加算ポイントの計算式 */
|
---|
904 | function sfGetAddPoint($totalpoint, $use_point, $arrInfo) {
|
---|
905 | // 購入商品の合計ポイントから利用したポイントのポイント換算価値を引く方式
|
---|
906 | $add_point = $totalpoint - intval($use_point * ($arrInfo['point_rate'] / 100));
|
---|
907 |
|
---|
908 | if($add_point < 0) {
|
---|
909 | $add_point = '0';
|
---|
910 | }
|
---|
911 | return $add_point;
|
---|
912 | }
|
---|
913 |
|
---|
914 | /* 一意かつ予測されにくいID */
|
---|
915 | function sfGetUniqRandomId($head = "") {
|
---|
916 | // 予測されないようにランダム文字列を付与する。
|
---|
917 | $random = GC_Utils_Ex::gfMakePassword(8);
|
---|
918 | // 同一ホスト内で一意なIDを生成
|
---|
919 | $id = uniqid($head);
|
---|
920 | return ($id . $random);
|
---|
921 | }
|
---|
922 |
|
---|
923 | // カテゴリ別オススメ品の取得
|
---|
924 | function sfGetBestProducts( $conn, $category_id = 0){
|
---|
925 | // 既に登録されている内容を取得する
|
---|
926 | $sql = "SELECT name, main_image, main_list_image, price01_min, price01_max, price02_min, price02_max, point_rate,
|
---|
927 | A.product_id, A.comment FROM dtb_best_products as A LEFT JOIN vw_products_allclass AS allcls
|
---|
928 | USING (product_id) WHERE A.category_id = ? AND A.del_flg = 0 AND status = 1 ORDER BY A.rank";
|
---|
929 | $arrItems = $conn->getAll($sql, array($category_id));
|
---|
930 |
|
---|
931 | return $arrItems;
|
---|
932 | }
|
---|
933 |
|
---|
934 | // 特殊制御文字の手動エスケープ
|
---|
935 | function sfManualEscape($data) {
|
---|
936 | // 配列でない場合
|
---|
937 | if(!is_array($data)) {
|
---|
938 | if (DB_TYPE == "pgsql") {
|
---|
939 | $ret = pg_escape_string($data);
|
---|
940 | }else if(DB_TYPE == "mysql"){
|
---|
941 | $ret = mysql_real_escape_string($data);
|
---|
942 | }
|
---|
943 | $ret = ereg_replace("%", "\\%", $ret);
|
---|
944 | $ret = ereg_replace("_", "\\_", $ret);
|
---|
945 | return $ret;
|
---|
946 | }
|
---|
947 |
|
---|
948 | // 配列の場合
|
---|
949 | foreach($data as $val) {
|
---|
950 | if (DB_TYPE == "pgsql") {
|
---|
951 | $ret = pg_escape_string($val);
|
---|
952 | }else if(DB_TYPE == "mysql"){
|
---|
953 | $ret = mysql_real_escape_string($val);
|
---|
954 | }
|
---|
955 |
|
---|
956 | $ret = ereg_replace("%", "\\%", $ret);
|
---|
957 | $ret = ereg_replace("_", "\\_", $ret);
|
---|
958 | $arrRet[] = $ret;
|
---|
959 | }
|
---|
960 |
|
---|
961 | return $arrRet;
|
---|
962 | }
|
---|
963 |
|
---|
964 | /**
|
---|
965 | * ドメイン間で有効なセッションのスタート
|
---|
966 | * 共有SSL対応のための修正により、この関数は廃止します。
|
---|
967 | * セッションはrequire.phpを読み込んだ際に開始されます。
|
---|
968 | */
|
---|
969 | function sfDomainSessionStart() {
|
---|
970 | /**
|
---|
971 | * 2.1.1ベータからはSC_SessionFactory_UseCookie::initSession()で処理するため、
|
---|
972 | * ここでは何も処理しない
|
---|
973 | */
|
---|
974 | if (defined('SESSION_KEEP_METHOD')) {
|
---|
975 | return;
|
---|
976 | }
|
---|
977 |
|
---|
978 | if (session_id() === "") {
|
---|
979 |
|
---|
980 | session_set_cookie_params(0, "/", DOMAIN_NAME);
|
---|
981 |
|
---|
982 | if (!ini_get("session.auto_start")) {
|
---|
983 | // セッション開始
|
---|
984 | session_start();
|
---|
985 | }
|
---|
986 | }
|
---|
987 | }
|
---|
988 |
|
---|
989 | /* 文字列に強制的に改行を入れる */
|
---|
990 | function sfPutBR($str, $size) {
|
---|
991 | $i = 0;
|
---|
992 | $cnt = 0;
|
---|
993 | $line = array();
|
---|
994 | $ret = "";
|
---|
995 |
|
---|
996 | while($str[$i] != "") {
|
---|
997 | $line[$cnt].=$str[$i];
|
---|
998 | $i++;
|
---|
999 | if(strlen($line[$cnt]) > $size) {
|
---|
1000 | $line[$cnt].="<br />";
|
---|
1001 | $cnt++;
|
---|
1002 | }
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 | foreach($line as $val) {
|
---|
1006 | $ret.=$val;
|
---|
1007 | }
|
---|
1008 | return $ret;
|
---|
1009 | }
|
---|
1010 |
|
---|
1011 | // 二回以上繰り返されているスラッシュ[/]を一つに変換する。
|
---|
1012 | function sfRmDupSlash($istr){
|
---|
1013 | if(ereg("^http://", $istr)) {
|
---|
1014 | $str = substr($istr, 7);
|
---|
1015 | $head = "http://";
|
---|
1016 | } else if(ereg("^https://", $istr)) {
|
---|
1017 | $str = substr($istr, 8);
|
---|
1018 | $head = "https://";
|
---|
1019 | } else {
|
---|
1020 | $str = $istr;
|
---|
1021 | }
|
---|
1022 | $str = ereg_replace("[/]+", "/", $str);
|
---|
1023 | $ret = $head . $str;
|
---|
1024 | return $ret;
|
---|
1025 | }
|
---|
1026 |
|
---|
1027 | /**
|
---|
1028 | * テキストファイルの文字エンコーディングを変換する.
|
---|
1029 | *
|
---|
1030 | * $filepath に存在するテキストファイルの文字エンコーディングを変換する.
|
---|
1031 | * 変換前の文字エンコーディングは, mb_detect_order で設定した順序で自動検出する.
|
---|
1032 | * 変換後は, 変換前のファイル名に「enc_」というプレフィクスを付与し,
|
---|
1033 | * $out_dir で指定したディレクトリへ出力する
|
---|
1034 | *
|
---|
1035 | * TODO $filepath のファイルがバイナリだった場合の扱い
|
---|
1036 | * TODO fwrite などでのエラーハンドリング
|
---|
1037 | *
|
---|
1038 | * @access public
|
---|
1039 | * @param string $filepath 変換するテキストファイルのパス
|
---|
1040 | * @param string $enc_type 変換後のファイルエンコーディングの種類を表す文字列
|
---|
1041 | * @param string $out_dir 変換後のファイルを出力するディレクトリを表す文字列
|
---|
1042 | * @return string 変換後のテキストファイルのパス
|
---|
1043 | */
|
---|
1044 | function sfEncodeFile($filepath, $enc_type, $out_dir) {
|
---|
1045 | $ifp = fopen($filepath, "r");
|
---|
1046 |
|
---|
1047 | // 正常にファイルオープンした場合
|
---|
1048 | if ($ifp !== false) {
|
---|
1049 |
|
---|
1050 | $basename = basename($filepath);
|
---|
1051 | $outpath = $out_dir . "enc_" . $basename;
|
---|
1052 |
|
---|
1053 | $ofp = fopen($outpath, "w+");
|
---|
1054 |
|
---|
1055 | while(!feof($ifp)) {
|
---|
1056 | $line = fgets($ifp);
|
---|
1057 | $line = mb_convert_encoding($line, $enc_type, "auto");
|
---|
1058 | fwrite($ofp, $line);
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | fclose($ofp);
|
---|
1062 | fclose($ifp);
|
---|
1063 | }
|
---|
1064 | // ファイルが開けなかった場合はエラーページを表示
|
---|
1065 | else {
|
---|
1066 | SC_Utils::sfDispError('');
|
---|
1067 | exit;
|
---|
1068 | }
|
---|
1069 | return $outpath;
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | function sfCutString($str, $len, $byte = true, $commadisp = true) {
|
---|
1073 | if($byte) {
|
---|
1074 | if(strlen($str) > ($len + 2)) {
|
---|
1075 | $ret =substr($str, 0, $len);
|
---|
1076 | $cut = substr($str, $len);
|
---|
1077 | } else {
|
---|
1078 | $ret = $str;
|
---|
1079 | $commadisp = false;
|
---|
1080 | }
|
---|
1081 | } else {
|
---|
1082 | if(mb_strlen($str) > ($len + 1)) {
|
---|
1083 | $ret = mb_substr($str, 0, $len);
|
---|
1084 | $cut = mb_substr($str, $len);
|
---|
1085 | } else {
|
---|
1086 | $ret = $str;
|
---|
1087 | $commadisp = false;
|
---|
1088 | }
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 | // 絵文字タグの途中で分断されないようにする。
|
---|
1092 | if (isset($cut)) {
|
---|
1093 | // 分割位置より前の最後の [ 以降を取得する。
|
---|
1094 | $head = strrchr($ret, '[');
|
---|
1095 |
|
---|
1096 | // 分割位置より後の最初の ] 以前を取得する。
|
---|
1097 | $tail_pos = strpos($cut, ']');
|
---|
1098 | if ($tail_pos !== false) {
|
---|
1099 | $tail = substr($cut, 0, $tail_pos + 1);
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | // 分割位置より前に [、後に ] が見つかった場合は、[ から ] までを
|
---|
1103 | // 接続して絵文字タグ1個分になるかどうかをチェックする。
|
---|
1104 | if ($head !== false && $tail_pos !== false) {
|
---|
1105 | $subject = $head . $tail;
|
---|
1106 | if (preg_match('/^\[emoji:e?\d+\]$/', $subject)) {
|
---|
1107 | // 絵文字タグが見つかったので削除する。
|
---|
1108 | $ret = substr($ret, 0, -strlen($head));
|
---|
1109 | }
|
---|
1110 | }
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | if($commadisp){
|
---|
1114 | $ret = $ret . "...";
|
---|
1115 | }
|
---|
1116 | return $ret;
|
---|
1117 | }
|
---|
1118 |
|
---|
1119 | // 年、月、締め日から、先月の締め日+1、今月の締め日を求める。
|
---|
1120 | function sfTermMonth($year, $month, $close_day) {
|
---|
1121 | $end_year = $year;
|
---|
1122 | $end_month = $month;
|
---|
1123 |
|
---|
1124 | // 開始月が終了月と同じか否か
|
---|
1125 | $same_month = false;
|
---|
1126 |
|
---|
1127 | // 該当月の末日を求める。
|
---|
1128 | $end_last_day = date("d", mktime(0, 0, 0, $month + 1, 0, $year));
|
---|
1129 |
|
---|
1130 | // 月の末日が締め日より少ない場合
|
---|
1131 | if($end_last_day < $close_day) {
|
---|
1132 | // 締め日を月末日に合わせる
|
---|
1133 | $end_day = $end_last_day;
|
---|
1134 | } else {
|
---|
1135 | $end_day = $close_day;
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | // 前月の取得
|
---|
1139 | $tmp_year = date("Y", mktime(0, 0, 0, $month, 0, $year));
|
---|
1140 | $tmp_month = date("m", mktime(0, 0, 0, $month, 0, $year));
|
---|
1141 | // 前月の末日を求める。
|
---|
1142 | $start_last_day = date("d", mktime(0, 0, 0, $month, 0, $year));
|
---|
1143 |
|
---|
1144 | // 前月の末日が締め日より少ない場合
|
---|
1145 | if ($start_last_day < $close_day) {
|
---|
1146 | // 月末日に合わせる
|
---|
1147 | $tmp_day = $start_last_day;
|
---|
1148 | } else {
|
---|
1149 | $tmp_day = $close_day;
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 | // 先月の末日の翌日を取得する
|
---|
1153 | $start_year = date("Y", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
|
---|
1154 | $start_month = date("m", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
|
---|
1155 | $start_day = date("d", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year));
|
---|
1156 |
|
---|
1157 | // 日付の作成
|
---|
1158 | $start_date = sprintf("%d/%d/%d 00:00:00", $start_year, $start_month, $start_day);
|
---|
1159 | $end_date = sprintf("%d/%d/%d 23:59:59", $end_year, $end_month, $end_day);
|
---|
1160 |
|
---|
1161 | return array($start_date, $end_date);
|
---|
1162 | }
|
---|
1163 |
|
---|
1164 | // PDF用のRGBカラーを返す
|
---|
1165 | function sfGetPdfRgb($hexrgb) {
|
---|
1166 | $hex = substr($hexrgb, 0, 2);
|
---|
1167 | $r = hexdec($hex) / 255;
|
---|
1168 |
|
---|
1169 | $hex = substr($hexrgb, 2, 2);
|
---|
1170 | $g = hexdec($hex) / 255;
|
---|
1171 |
|
---|
1172 | $hex = substr($hexrgb, 4, 2);
|
---|
1173 | $b = hexdec($hex) / 255;
|
---|
1174 |
|
---|
1175 | return array($r, $g, $b);
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | //メルマガ仮登録とメール配信
|
---|
1179 | /*
|
---|
1180 | * FIXME
|
---|
1181 | */
|
---|
1182 | function sfRegistTmpMailData($mail_flag, $email){
|
---|
1183 | $objQuery = new SC_Query();
|
---|
1184 | $objConn = new SC_DBConn();
|
---|
1185 | $objPage = new LC_Page();
|
---|
1186 |
|
---|
1187 | $random_id = sfGetUniqRandomId();
|
---|
1188 | $arrRegistMailMagazine["mail_flag"] = $mail_flag;
|
---|
1189 | $arrRegistMailMagazine["email"] = $email;
|
---|
1190 | $arrRegistMailMagazine["temp_id"] =$random_id;
|
---|
1191 | $arrRegistMailMagazine["end_flag"]='0';
|
---|
1192 | $arrRegistMailMagazine["update_date"] = 'now()';
|
---|
1193 |
|
---|
1194 | //メルマガ仮登録用フラグ
|
---|
1195 | $flag = $objQuery->count("dtb_customer_mail_temp", "email=?", array($email));
|
---|
1196 | $objConn->query("BEGIN");
|
---|
1197 | switch ($flag){
|
---|
1198 | case '0':
|
---|
1199 | $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine);
|
---|
1200 | break;
|
---|
1201 |
|
---|
1202 | case '1':
|
---|
1203 | $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine, "email = " .SC_Utils::sfQuoteSmart($email));
|
---|
1204 | break;
|
---|
1205 | }
|
---|
1206 | $objConn->query("COMMIT");
|
---|
1207 | $subject = sfMakeSubject('メルマガ仮登録が完了しました。');
|
---|
1208 | $objPage->tpl_url = SSL_URL."mailmagazine/regist.php?temp_id=".$arrRegistMailMagazine['temp_id'];
|
---|
1209 | switch ($mail_flag){
|
---|
1210 | case '1':
|
---|
1211 | $objPage->tpl_name = "登録";
|
---|
1212 | $objPage->tpl_kindname = "HTML";
|
---|
1213 | break;
|
---|
1214 |
|
---|
1215 | case '2':
|
---|
1216 | $objPage->tpl_name = "登録";
|
---|
1217 | $objPage->tpl_kindname = "テキスト";
|
---|
1218 | break;
|
---|
1219 |
|
---|
1220 | case '3':
|
---|
1221 | $objPage->tpl_name = "解除";
|
---|
1222 | break;
|
---|
1223 | }
|
---|
1224 | $objPage->tpl_email = $email;
|
---|
1225 | sfSendTplMail($email, $subject, 'mail_templates/mailmagazine_temp.tpl', $objPage);
|
---|
1226 | }
|
---|
1227 |
|
---|
1228 | // 再帰的に多段配列を検索して一次元配列(Hidden引渡し用配列)に変換する。
|
---|
1229 | function sfMakeHiddenArray($arrSrc, $arrDst = array(), $parent_key = "") {
|
---|
1230 | if(is_array($arrSrc)) {
|
---|
1231 | foreach($arrSrc as $key => $val) {
|
---|
1232 | if($parent_key != "") {
|
---|
1233 | $keyname = $parent_key . "[". $key . "]";
|
---|
1234 | } else {
|
---|
1235 | $keyname = $key;
|
---|
1236 | }
|
---|
1237 | if(is_array($val)) {
|
---|
1238 | $arrDst = SC_Utils::sfMakeHiddenArray($val, $arrDst, $keyname);
|
---|
1239 | } else {
|
---|
1240 | $arrDst[$keyname] = $val;
|
---|
1241 | }
|
---|
1242 | }
|
---|
1243 | }
|
---|
1244 | return $arrDst;
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 | // DB取得日時をタイムに変換
|
---|
1248 | function sfDBDatetoTime($db_date) {
|
---|
1249 | $date = ereg_replace("\..*$","",$db_date);
|
---|
1250 | $time = strtotime($date);
|
---|
1251 | return $time;
|
---|
1252 | }
|
---|
1253 |
|
---|
1254 | /**
|
---|
1255 | * テンプレートを切り替えて出力する
|
---|
1256 | *
|
---|
1257 | * @deprecated 2008/04/02以降使用不可
|
---|
1258 | */
|
---|
1259 | function sfCustomDisplay(&$objPage, $is_mobile = false) {
|
---|
1260 | $basename = basename($_SERVER["REQUEST_URI"]);
|
---|
1261 |
|
---|
1262 | if($basename == "") {
|
---|
1263 | $path = $_SERVER["REQUEST_URI"] . "index.php";
|
---|
1264 | } else {
|
---|
1265 | $path = $_SERVER["REQUEST_URI"];
|
---|
1266 | }
|
---|
1267 |
|
---|
1268 | if(isset($_GET['tpl']) && $_GET['tpl'] != "") {
|
---|
1269 | $tpl_name = $_GET['tpl'];
|
---|
1270 | } else {
|
---|
1271 | $tpl_name = ereg_replace("^/", "", $path);
|
---|
1272 | $tpl_name = ereg_replace("/", "_", $tpl_name);
|
---|
1273 | $tpl_name = ereg_replace("(\.php$|\.html$)", ".tpl", $tpl_name);
|
---|
1274 | }
|
---|
1275 |
|
---|
1276 | $template_path = TEMPLATE_FTP_DIR . $tpl_name;
|
---|
1277 | echo $template_path;
|
---|
1278 | if($is_mobile === true) {
|
---|
1279 | $objView = new SC_MobileView();
|
---|
1280 | $objView->assignobj($objPage);
|
---|
1281 | $objView->display(SITE_FRAME);
|
---|
1282 | } else if(file_exists($template_path)) {
|
---|
1283 | $objView = new SC_UserView(TEMPLATE_FTP_DIR, COMPILE_FTP_DIR);
|
---|
1284 | $objView->assignobj($objPage);
|
---|
1285 | $objView->display($tpl_name);
|
---|
1286 | } else {
|
---|
1287 | $objView = new SC_SiteView();
|
---|
1288 | $objView->assignobj($objPage);
|
---|
1289 | $objView->display(SITE_FRAME);
|
---|
1290 | }
|
---|
1291 | }
|
---|
1292 |
|
---|
1293 | // PHPのmb_convert_encoding関数をSmartyでも使えるようにする
|
---|
1294 | function sf_mb_convert_encoding($str, $encode = 'CHAR_CODE') {
|
---|
1295 | return mb_convert_encoding($str, $encode);
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 | // PHPのmktime関数をSmartyでも使えるようにする
|
---|
1299 | function sf_mktime($format, $hour=0, $minute=0, $second=0, $month=1, $day=1, $year=1999) {
|
---|
1300 | return date($format,mktime($hour, $minute, $second, $month, $day, $year));
|
---|
1301 | }
|
---|
1302 |
|
---|
1303 | // PHPのdate関数をSmartyでも使えるようにする
|
---|
1304 | function sf_date($format, $timestamp = '') {
|
---|
1305 | return date( $format, $timestamp);
|
---|
1306 | }
|
---|
1307 |
|
---|
1308 | // チェックボックスの型を変換する
|
---|
1309 | function sfChangeCheckBox($data , $tpl = false){
|
---|
1310 | if ($tpl) {
|
---|
1311 | if ($data == 1){
|
---|
1312 | return 'checked';
|
---|
1313 | }else{
|
---|
1314 | return "";
|
---|
1315 | }
|
---|
1316 | }else{
|
---|
1317 | if ($data == "on"){
|
---|
1318 | return 1;
|
---|
1319 | }else{
|
---|
1320 | return 2;
|
---|
1321 | }
|
---|
1322 | }
|
---|
1323 | }
|
---|
1324 |
|
---|
1325 | // 2つの配列を用いて連想配列を作成する
|
---|
1326 | function sfarrCombine($arrKeys, $arrValues) {
|
---|
1327 |
|
---|
1328 | if(count($arrKeys) <= 0 and count($arrValues) <= 0) return array();
|
---|
1329 |
|
---|
1330 | $keys = array_values($arrKeys);
|
---|
1331 | $vals = array_values($arrValues);
|
---|
1332 |
|
---|
1333 | $max = max( count( $keys ), count( $vals ) );
|
---|
1334 | $combine_ary = array();
|
---|
1335 | for($i=0; $i<$max; $i++) {
|
---|
1336 | $combine_ary[$keys[$i]] = $vals[$i];
|
---|
1337 | }
|
---|
1338 | if(is_array($combine_ary)) return $combine_ary;
|
---|
1339 |
|
---|
1340 | return false;
|
---|
1341 | }
|
---|
1342 |
|
---|
1343 | /* 子ID所属する親IDを取得する */
|
---|
1344 | function sfGetParentsArraySub($arrData, $pid_name, $id_name, $child) {
|
---|
1345 | $max = count($arrData);
|
---|
1346 | $parent = "";
|
---|
1347 | for($i = 0; $i < $max; $i++) {
|
---|
1348 | if($arrData[$i][$id_name] == $child) {
|
---|
1349 | $parent = $arrData[$i][$pid_name];
|
---|
1350 | break;
|
---|
1351 | }
|
---|
1352 | }
|
---|
1353 | return $parent;
|
---|
1354 | }
|
---|
1355 |
|
---|
1356 | /* 階層構造のテーブルから与えられたIDの兄弟を取得する */
|
---|
1357 | function sfGetBrothersArray($arrData, $pid_name, $id_name, $arrPID) {
|
---|
1358 | $max = count($arrData);
|
---|
1359 |
|
---|
1360 | $arrBrothers = array();
|
---|
1361 | foreach($arrPID as $id) {
|
---|
1362 | // 親IDを検索する
|
---|
1363 | for($i = 0; $i < $max; $i++) {
|
---|
1364 | if($arrData[$i][$id_name] == $id) {
|
---|
1365 | $parent = $arrData[$i][$pid_name];
|
---|
1366 | break;
|
---|
1367 | }
|
---|
1368 | }
|
---|
1369 | // 兄弟IDを検索する
|
---|
1370 | for($i = 0; $i < $max; $i++) {
|
---|
1371 | if($arrData[$i][$pid_name] == $parent) {
|
---|
1372 | $arrBrothers[] = $arrData[$i][$id_name];
|
---|
1373 | }
|
---|
1374 | }
|
---|
1375 | }
|
---|
1376 | return $arrBrothers;
|
---|
1377 | }
|
---|
1378 |
|
---|
1379 | /* 階層構造のテーブルから与えられたIDの直属の子を取得する */
|
---|
1380 | function sfGetUnderChildrenArray($arrData, $pid_name, $id_name, $parent) {
|
---|
1381 | $max = count($arrData);
|
---|
1382 |
|
---|
1383 | $arrChildren = array();
|
---|
1384 | // 子IDを検索する
|
---|
1385 | for($i = 0; $i < $max; $i++) {
|
---|
1386 | if($arrData[$i][$pid_name] == $parent) {
|
---|
1387 | $arrChildren[] = $arrData[$i][$id_name];
|
---|
1388 | }
|
---|
1389 | }
|
---|
1390 | return $arrChildren;
|
---|
1391 | }
|
---|
1392 |
|
---|
1393 | // SQLシングルクォート対応
|
---|
1394 | function sfQuoteSmart($in){
|
---|
1395 |
|
---|
1396 | if (is_int($in) || is_double($in)) {
|
---|
1397 | return $in;
|
---|
1398 | } elseif (is_bool($in)) {
|
---|
1399 | return $in ? 1 : 0;
|
---|
1400 | } elseif (is_null($in)) {
|
---|
1401 | return 'NULL';
|
---|
1402 | } else {
|
---|
1403 | return "'" . str_replace("'", "''", $in) . "'";
|
---|
1404 | }
|
---|
1405 | }
|
---|
1406 |
|
---|
1407 | // ディレクトリを再帰的に生成する
|
---|
1408 | function sfMakeDir($path) {
|
---|
1409 | static $count = 0;
|
---|
1410 | $count++; // 無限ループ回避
|
---|
1411 | $dir = dirname($path);
|
---|
1412 | if(ereg("^[/]$", $dir) || ereg("^[A-Z]:[\\]$", $dir) || $count > 256) {
|
---|
1413 | // ルートディレクトリで終了
|
---|
1414 | return;
|
---|
1415 | } else {
|
---|
1416 | if(is_writable(dirname($dir))) {
|
---|
1417 | if(!file_exists($dir)) {
|
---|
1418 | mkdir($dir);
|
---|
1419 | GC_Utils::gfPrintLog("mkdir $dir");
|
---|
1420 | }
|
---|
1421 | } else {
|
---|
1422 | SC_Utils::sfMakeDir($dir);
|
---|
1423 | if(is_writable(dirname($dir))) {
|
---|
1424 | if(!file_exists($dir)) {
|
---|
1425 | mkdir($dir);
|
---|
1426 | GC_Utils::gfPrintLog("mkdir $dir");
|
---|
1427 | }
|
---|
1428 | }
|
---|
1429 | }
|
---|
1430 | }
|
---|
1431 | return;
|
---|
1432 | }
|
---|
1433 |
|
---|
1434 | // ディレクトリ以下のファイルを再帰的にコピー
|
---|
1435 | function sfCopyDir($src, $des, $mess = "", $override = false){
|
---|
1436 | if(!is_dir($src)){
|
---|
1437 | return false;
|
---|
1438 | }
|
---|
1439 |
|
---|
1440 | $oldmask = umask(0);
|
---|
1441 | $mod= stat($src);
|
---|
1442 |
|
---|
1443 | // ディレクトリがなければ作成する
|
---|
1444 | if(!file_exists($des)) {
|
---|
1445 | if(!mkdir($des, $mod[2])) {
|
---|
1446 | print("path:" . $des);
|
---|
1447 | }
|
---|
1448 | }
|
---|
1449 |
|
---|
1450 | $fileArray=glob( $src."*" );
|
---|
1451 | foreach( $fileArray as $key => $data_ ){
|
---|
1452 | // CVS管理ファイルはコピーしない
|
---|
1453 | if(ereg("/CVS/Entries", $data_)) {
|
---|
1454 | break;
|
---|
1455 | }
|
---|
1456 | if(ereg("/CVS/Repository", $data_)) {
|
---|
1457 | break;
|
---|
1458 | }
|
---|
1459 | if(ereg("/CVS/Root", $data_)) {
|
---|
1460 | break;
|
---|
1461 | }
|
---|
1462 |
|
---|
1463 | mb_ereg("^(.*[\/])(.*)",$data_, $matches);
|
---|
1464 | $data=$matches[2];
|
---|
1465 | if( is_dir( $data_ ) ){
|
---|
1466 | $mess = SC_Utils::sfCopyDir( $data_.'/', $des.$data.'/', $mess);
|
---|
1467 | }else{
|
---|
1468 | if(!$override && file_exists($des.$data)) {
|
---|
1469 | $mess.= $des.$data . ":ファイルが存在します\n";
|
---|
1470 | } else {
|
---|
1471 | if(@copy( $data_, $des.$data)) {
|
---|
1472 | $mess.= $des.$data . ":コピー成功\n";
|
---|
1473 | } else {
|
---|
1474 | $mess.= $des.$data . ":コピー失敗\n";
|
---|
1475 | }
|
---|
1476 | }
|
---|
1477 | $mod=stat($data_ );
|
---|
1478 | }
|
---|
1479 | }
|
---|
1480 | umask($oldmask);
|
---|
1481 | return $mess;
|
---|
1482 | }
|
---|
1483 |
|
---|
1484 | // 指定したフォルダ内のファイルを全て削除する
|
---|
1485 | function sfDelFile($dir){
|
---|
1486 | if(file_exists($dir)) {
|
---|
1487 | $dh = opendir($dir);
|
---|
1488 | // フォルダ内のファイルを削除
|
---|
1489 | while($file = readdir($dh)){
|
---|
1490 | if ($file == "." or $file == "..") continue;
|
---|
1491 | $del_file = $dir . "/" . $file;
|
---|
1492 | if(is_file($del_file)){
|
---|
1493 | $ret = unlink($dir . "/" . $file);
|
---|
1494 | }else if (is_dir($del_file)){
|
---|
1495 | $ret = SC_Utils::sfDelFile($del_file);
|
---|
1496 | }
|
---|
1497 |
|
---|
1498 | if(!$ret){
|
---|
1499 | return $ret;
|
---|
1500 | }
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | // 閉じる
|
---|
1504 | closedir($dh);
|
---|
1505 |
|
---|
1506 | // フォルダを削除
|
---|
1507 | return rmdir($dir);
|
---|
1508 | }
|
---|
1509 | }
|
---|
1510 |
|
---|
1511 | /*
|
---|
1512 | * 関数名:sfWriteFile
|
---|
1513 | * 引数1 :書き込むデータ
|
---|
1514 | * 引数2 :ファイルパス
|
---|
1515 | * 引数3 :書き込みタイプ
|
---|
1516 | * 引数4 :パーミッション
|
---|
1517 | * 戻り値:結果フラグ 成功なら true 失敗なら false
|
---|
1518 | * 説明 :ファイル書き出し
|
---|
1519 | */
|
---|
1520 | function sfWriteFile($str, $path, $type, $permission = "") {
|
---|
1521 | //ファイルを開く
|
---|
1522 | if (!($file = fopen ($path, $type))) {
|
---|
1523 | return false;
|
---|
1524 | }
|
---|
1525 |
|
---|
1526 | //ファイルロック
|
---|
1527 | flock ($file, LOCK_EX);
|
---|
1528 | //ファイルの書き込み
|
---|
1529 | fputs ($file, $str);
|
---|
1530 | //ファイルロックの解除
|
---|
1531 | flock ($file, LOCK_UN);
|
---|
1532 | //ファイルを閉じる
|
---|
1533 | fclose ($file);
|
---|
1534 | // 権限を指定
|
---|
1535 | if($permission != "") {
|
---|
1536 | chmod($path, $permission);
|
---|
1537 | }
|
---|
1538 |
|
---|
1539 | return true;
|
---|
1540 | }
|
---|
1541 |
|
---|
1542 | function sfFlush($output = " ", $sleep = 0){
|
---|
1543 | // 実行時間を制限しない
|
---|
1544 | set_time_limit(0);
|
---|
1545 | // 出力をバッファリングしない(==日本語自動変換もしない)
|
---|
1546 | ob_end_clean();
|
---|
1547 |
|
---|
1548 | // IEのために256バイト空文字出力
|
---|
1549 | echo str_pad('',256);
|
---|
1550 |
|
---|
1551 | // 出力はブランクだけでもいいと思う
|
---|
1552 | echo $output;
|
---|
1553 | // 出力をフラッシュする
|
---|
1554 | flush();
|
---|
1555 |
|
---|
1556 | ob_flush();
|
---|
1557 | ob_start();
|
---|
1558 |
|
---|
1559 | // 時間のかかる処理
|
---|
1560 | sleep($sleep);
|
---|
1561 | }
|
---|
1562 |
|
---|
1563 | // @versionの記載があるファイルからバージョンを取得する。
|
---|
1564 | function sfGetFileVersion($path) {
|
---|
1565 | if(file_exists($path)) {
|
---|
1566 | $src_fp = fopen($path, "rb");
|
---|
1567 | if($src_fp) {
|
---|
1568 | while (!feof($src_fp)) {
|
---|
1569 | $line = fgets($src_fp);
|
---|
1570 | if(ereg("@version", $line)) {
|
---|
1571 | $arrLine = split(" ", $line);
|
---|
1572 | $version = $arrLine[5];
|
---|
1573 | }
|
---|
1574 | }
|
---|
1575 | fclose($src_fp);
|
---|
1576 | }
|
---|
1577 | }
|
---|
1578 | return $version;
|
---|
1579 | }
|
---|
1580 |
|
---|
1581 | // 指定したURLに対してPOSTでデータを送信する
|
---|
1582 | function sfSendPostData($url, $arrData, $arrOkCode = array()){
|
---|
1583 | require_once(DATA_PATH . "module/Request.php");
|
---|
1584 |
|
---|
1585 | // 送信インスタンス生成
|
---|
1586 | $req = new HTTP_Request($url);
|
---|
1587 |
|
---|
1588 | $req->addHeader('User-Agent', 'DoCoMo/2.0 P2101V(c100)');
|
---|
1589 | $req->setMethod(HTTP_REQUEST_METHOD_POST);
|
---|
1590 |
|
---|
1591 | // POSTデータ送信
|
---|
1592 | $req->addPostDataArray($arrData);
|
---|
1593 |
|
---|
1594 | // エラーが無ければ、応答情報を取得する
|
---|
1595 | if (!PEAR::isError($req->sendRequest())) {
|
---|
1596 |
|
---|
1597 | // レスポンスコードがエラー判定なら、空を返す
|
---|
1598 | $res_code = $req->getResponseCode();
|
---|
1599 |
|
---|
1600 | if(!in_array($res_code, $arrOkCode)){
|
---|
1601 | $response = "";
|
---|
1602 | }else{
|
---|
1603 | $response = $req->getResponseBody();
|
---|
1604 | }
|
---|
1605 |
|
---|
1606 | } else {
|
---|
1607 | $response = "";
|
---|
1608 | }
|
---|
1609 |
|
---|
1610 | // POSTデータクリア
|
---|
1611 | $req->clearPostData();
|
---|
1612 |
|
---|
1613 | return $response;
|
---|
1614 | }
|
---|
1615 |
|
---|
1616 | /**
|
---|
1617 | * $array の要素を $arrConvList で指定した方式で mb_convert_kana を適用する.
|
---|
1618 | *
|
---|
1619 | * @param array $array 変換する文字列の配列
|
---|
1620 | * @param array $arrConvList mb_convert_kana の適用ルール
|
---|
1621 | * @return array 変換後の配列
|
---|
1622 | * @see mb_convert_kana
|
---|
1623 | */
|
---|
1624 | function mbConvertKanaWithArray($array, $arrConvList) {
|
---|
1625 | foreach ($arrConvList as $key => $val) {
|
---|
1626 | if(isset($array[$key])) {
|
---|
1627 | $array[$key] = mb_convert_kana($array[$key] ,$val);
|
---|
1628 | }
|
---|
1629 | }
|
---|
1630 | return $array;
|
---|
1631 | }
|
---|
1632 |
|
---|
1633 | /**
|
---|
1634 | * 配列の添字が未定義の場合は空文字を代入して定義する.
|
---|
1635 | *
|
---|
1636 | * @param array $array 添字をチェックする配列
|
---|
1637 | * @param array $defineIndexes チェックする添字
|
---|
1638 | * @return array 添字を定義した配列
|
---|
1639 | */
|
---|
1640 | function arrayDefineIndexes($array, $defineIndexes) {
|
---|
1641 | foreach ($defineIndexes as $key) {
|
---|
1642 | if (!isset($array[$key])) $array[$key] = "";
|
---|
1643 | }
|
---|
1644 | return $array;
|
---|
1645 | }
|
---|
1646 |
|
---|
1647 | /**
|
---|
1648 | * XML宣言を出力する.
|
---|
1649 | *
|
---|
1650 | * XML宣言があると問題が発生する UA は出力しない.
|
---|
1651 | *
|
---|
1652 | * @return string XML宣言の文字列
|
---|
1653 | */
|
---|
1654 | function printXMLDeclaration() {
|
---|
1655 | $ua = $_SERVER['HTTP_USER_AGENT'];
|
---|
1656 | if (!preg_match("/MSIE/", $ua) || preg_match("/MSIE 7/", $ua)) {
|
---|
1657 | print("<?xml version='1.0' encoding='" . CHAR_CODE . "'?>\n");
|
---|
1658 | }
|
---|
1659 | }
|
---|
1660 |
|
---|
1661 | /*
|
---|
1662 | * 関数名:sfGetFileList()
|
---|
1663 | * 説明 :指定パス配下のディレクトリ取得
|
---|
1664 | * 引数1 :取得するディレクトリパス
|
---|
1665 | */
|
---|
1666 | function sfGetFileList($dir) {
|
---|
1667 | $arrFileList = array();
|
---|
1668 | $arrDirList = array();
|
---|
1669 |
|
---|
1670 | if (is_dir($dir)) {
|
---|
1671 | if ($dh = opendir($dir)) {
|
---|
1672 | $cnt = 0;
|
---|
1673 | // 行末の/を取り除く
|
---|
1674 | while (($file = readdir($dh)) !== false) $arrDir[] = $file;
|
---|
1675 | $dir = ereg_replace("/$", "", $dir);
|
---|
1676 | // アルファベットと数字でソート
|
---|
1677 | natcasesort($arrDir);
|
---|
1678 | foreach($arrDir as $file) {
|
---|
1679 | // ./ と ../を除くファイルのみを取得
|
---|
1680 | if($file != "." && $file != "..") {
|
---|
1681 |
|
---|
1682 | $path = $dir."/".$file;
|
---|
1683 | // SELECT内の見た目を整えるため指定文字数で切る
|
---|
1684 | $file_name = SC_Utils::sfCutString($file, FILE_NAME_LEN);
|
---|
1685 | $file_size = SC_Utils::sfCutString(SC_Utils::sfGetDirSize($path), FILE_NAME_LEN);
|
---|
1686 | $file_time = date("Y/m/d", filemtime($path));
|
---|
1687 |
|
---|
1688 | // ディレクトリとファイルで格納配列を変える
|
---|
1689 | if(is_dir($path)) {
|
---|
1690 | $arrDirList[$cnt]['file_name'] = $file;
|
---|
1691 | $arrDirList[$cnt]['file_path'] = $path;
|
---|
1692 | $arrDirList[$cnt]['file_size'] = $file_size;
|
---|
1693 | $arrDirList[$cnt]['file_time'] = $file_time;
|
---|
1694 | $arrDirList[$cnt]['is_dir'] = true;
|
---|
1695 | } else {
|
---|
1696 | $arrFileList[$cnt]['file_name'] = $file;
|
---|
1697 | $arrFileList[$cnt]['file_path'] = $path;
|
---|
1698 | $arrFileList[$cnt]['file_size'] = $file_size;
|
---|
1699 | $arrFileList[$cnt]['file_time'] = $file_time;
|
---|
1700 | $arrFileList[$cnt]['is_dir'] = false;
|
---|
1701 | }
|
---|
1702 | $cnt++;
|
---|
1703 | }
|
---|
1704 | }
|
---|
1705 | closedir($dh);
|
---|
1706 | }
|
---|
1707 | }
|
---|
1708 |
|
---|
1709 | // フォルダを先頭にしてマージ
|
---|
1710 | return array_merge($arrDirList, $arrFileList);
|
---|
1711 | }
|
---|
1712 |
|
---|
1713 | /*
|
---|
1714 | * 関数名:sfGetDirSize()
|
---|
1715 | * 説明 :指定したディレクトリのバイト数を取得
|
---|
1716 | * 引数1 :ディレクトリ
|
---|
1717 | */
|
---|
1718 | function sfGetDirSize($dir) {
|
---|
1719 | if(file_exists($dir)) {
|
---|
1720 | // ディレクトリの場合下層ファイルの総量を取得
|
---|
1721 | if (is_dir($dir)) {
|
---|
1722 | $handle = opendir($dir);
|
---|
1723 | while ($file = readdir($handle)) {
|
---|
1724 | // 行末の/を取り除く
|
---|
1725 | $dir = ereg_replace("/$", "", $dir);
|
---|
1726 | $path = $dir."/".$file;
|
---|
1727 | if ($file != '..' && $file != '.' && !is_dir($path)) {
|
---|
1728 | $bytes += filesize($path);
|
---|
1729 | } else if (is_dir($path) && $file != '..' && $file != '.') {
|
---|
1730 | // 下層ファイルのバイト数を取得する為、再帰的に呼び出す。
|
---|
1731 | $bytes += SC_Utils::sfGetDirSize($path);
|
---|
1732 | }
|
---|
1733 | }
|
---|
1734 | } else {
|
---|
1735 | // ファイルの場合
|
---|
1736 | $bytes = filesize($dir);
|
---|
1737 | }
|
---|
1738 | }
|
---|
1739 | // ディレクトリ(ファイル)が存在しない場合は0byteを返す
|
---|
1740 | if($bytes == "") $bytes = 0;
|
---|
1741 |
|
---|
1742 | return $bytes;
|
---|
1743 | }
|
---|
1744 |
|
---|
1745 | /*
|
---|
1746 | * 関数名:sfDeleteDir()
|
---|
1747 | * 説明 :指定したディレクトリを削除
|
---|
1748 | * 引数1 :削除ファイル
|
---|
1749 | */
|
---|
1750 | function sfDeleteDir($dir) {
|
---|
1751 | $arrResult = array();
|
---|
1752 | if(file_exists($dir)) {
|
---|
1753 | // ディレクトリかチェック
|
---|
1754 | if (is_dir($dir)) {
|
---|
1755 | if ($handle = opendir("$dir")) {
|
---|
1756 | $cnt = 0;
|
---|
1757 | while (false !== ($item = readdir($handle))) {
|
---|
1758 | if ($item != "." && $item != "..") {
|
---|
1759 | if (is_dir("$dir/$item")) {
|
---|
1760 | sfDeleteDir("$dir/$item");
|
---|
1761 | } else {
|
---|
1762 | $arrResult[$cnt]['result'] = @unlink("$dir/$item");
|
---|
1763 | $arrResult[$cnt]['file_name'] = "$dir/$item";
|
---|
1764 | }
|
---|
1765 | }
|
---|
1766 | $cnt++;
|
---|
1767 | }
|
---|
1768 | }
|
---|
1769 | closedir($handle);
|
---|
1770 | $arrResult[$cnt]['result'] = @rmdir($dir);
|
---|
1771 | $arrResult[$cnt]['file_name'] = "$dir/$item";
|
---|
1772 | } else {
|
---|
1773 | // ファイル削除
|
---|
1774 | $arrResult[0]['result'] = @unlink("$dir");
|
---|
1775 | $arrResult[0]['file_name'] = "$dir";
|
---|
1776 | }
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 | return $arrResult;
|
---|
1780 | }
|
---|
1781 |
|
---|
1782 | /*
|
---|
1783 | * 関数名:sfGetFileTree()
|
---|
1784 | * 説明 :ツリー生成用配列取得(javascriptに渡す用)
|
---|
1785 | * 引数1 :ディレクトリ
|
---|
1786 | * 引数2 :現在のツリーの状態開いているフォルダのパスが | 区切りで格納
|
---|
1787 | */
|
---|
1788 | function sfGetFileTree($dir, $tree_status) {
|
---|
1789 |
|
---|
1790 | $cnt = 0;
|
---|
1791 | $arrTree = array();
|
---|
1792 | $default_rank = count(split('/', $dir));
|
---|
1793 |
|
---|
1794 | // 文末の/を取り除く
|
---|
1795 | $dir = ereg_replace("/$", "", $dir);
|
---|
1796 | // 最上位層を格納(user_data/)
|
---|
1797 | if(sfDirChildExists($dir)) {
|
---|
1798 | $arrTree[$cnt]['type'] = "_parent";
|
---|
1799 | } else {
|
---|
1800 | $arrTree[$cnt]['type'] = "_child";
|
---|
1801 | }
|
---|
1802 | $arrTree[$cnt]['path'] = $dir;
|
---|
1803 | $arrTree[$cnt]['rank'] = 0;
|
---|
1804 | $arrTree[$cnt]['count'] = $cnt;
|
---|
1805 | // 初期表示はオープン
|
---|
1806 | if($_POST['mode'] != '') {
|
---|
1807 | $arrTree[$cnt]['open'] = lfIsFileOpen($dir, $tree_status);
|
---|
1808 | } else {
|
---|
1809 | $arrTree[$cnt]['open'] = true;
|
---|
1810 | }
|
---|
1811 | $cnt++;
|
---|
1812 |
|
---|
1813 | sfGetFileTreeSub($dir, $default_rank, $cnt, $arrTree, $tree_status);
|
---|
1814 |
|
---|
1815 | return $arrTree;
|
---|
1816 | }
|
---|
1817 |
|
---|
1818 | /*
|
---|
1819 | * 関数名:sfGetFileTree()
|
---|
1820 | * 説明 :ツリー生成用配列取得(javascriptに渡す用)
|
---|
1821 | * 引数1 :ディレクトリ
|
---|
1822 | * 引数2 :デフォルトの階層(/区切りで 0,1,2・・・とカウント)
|
---|
1823 | * 引数3 :連番
|
---|
1824 | * 引数4 :現在のツリーの状態開いているフォルダのパスが | 区切りで格納
|
---|
1825 | */
|
---|
1826 | function sfGetFileTreeSub($dir, $default_rank, &$cnt, &$arrTree, $tree_status) {
|
---|
1827 |
|
---|
1828 | if(file_exists($dir)) {
|
---|
1829 | if ($handle = opendir("$dir")) {
|
---|
1830 | while (false !== ($item = readdir($handle))) $arrDir[] = $item;
|
---|
1831 | // アルファベットと数字でソート
|
---|
1832 | natcasesort($arrDir);
|
---|
1833 | foreach($arrDir as $item) {
|
---|
1834 | if ($item != "." && $item != "..") {
|
---|
1835 | // 文末の/を取り除く
|
---|
1836 | $dir = ereg_replace("/$", "", $dir);
|
---|
1837 | $path = $dir."/".$item;
|
---|
1838 | // ディレクトリのみ取得
|
---|
1839 | if (is_dir($path)) {
|
---|
1840 | $arrTree[$cnt]['path'] = $path;
|
---|
1841 | if(sfDirChildExists($path)) {
|
---|
1842 | $arrTree[$cnt]['type'] = "_parent";
|
---|
1843 | } else {
|
---|
1844 | $arrTree[$cnt]['type'] = "_child";
|
---|
1845 | }
|
---|
1846 |
|
---|
1847 | // 階層を割り出す
|
---|
1848 | $arrCnt = split('/', $path);
|
---|
1849 | $rank = count($arrCnt);
|
---|
1850 | $arrTree[$cnt]['rank'] = $rank - $default_rank + 1;
|
---|
1851 | $arrTree[$cnt]['count'] = $cnt;
|
---|
1852 | // フォルダが開いているか
|
---|
1853 | $arrTree[$cnt]['open'] = lfIsFileOpen($path, $tree_status);
|
---|
1854 | $cnt++;
|
---|
1855 | // 下層ディレクトリ取得の為、再帰的に呼び出す
|
---|
1856 | sfGetFileTreeSub($path, $default_rank, $cnt, $arrTree, $tree_status);
|
---|
1857 | }
|
---|
1858 | }
|
---|
1859 | }
|
---|
1860 | }
|
---|
1861 | closedir($handle);
|
---|
1862 | }
|
---|
1863 | }
|
---|
1864 |
|
---|
1865 | /*
|
---|
1866 | * 関数名:sfDirChildExists()
|
---|
1867 | * 説明 :指定したディレクトリ配下にファイルがあるか
|
---|
1868 | * 引数1 :ディレクトリ
|
---|
1869 | */
|
---|
1870 | function sfDirChildExists($dir) {
|
---|
1871 | if(file_exists($dir)) {
|
---|
1872 | if (is_dir($dir)) {
|
---|
1873 | $handle = opendir($dir);
|
---|
1874 | while ($file = readdir($handle)) {
|
---|
1875 | // 行末の/を取り除く
|
---|
1876 | $dir = ereg_replace("/$", "", $dir);
|
---|
1877 | $path = $dir."/".$file;
|
---|
1878 | if ($file != '..' && $file != '.' && is_dir($path)) {
|
---|
1879 | return true;
|
---|
1880 | }
|
---|
1881 | }
|
---|
1882 | }
|
---|
1883 | }
|
---|
1884 |
|
---|
1885 | return false;
|
---|
1886 | }
|
---|
1887 |
|
---|
1888 | /*
|
---|
1889 | * 関数名:lfIsFileOpen()
|
---|
1890 | * 説明 :指定したファイルが前回開かれた状態にあったかチェック
|
---|
1891 | * 引数1 :ディレクトリ
|
---|
1892 | * 引数2 :現在のツリーの状態開いているフォルダのパスが | 区切りで格納
|
---|
1893 | */
|
---|
1894 | function lfIsFileOpen($dir, $tree_status) {
|
---|
1895 | $arrTreeStatus = split('\|', $tree_status);
|
---|
1896 | if(in_array($dir, $arrTreeStatus)) {
|
---|
1897 | return true;
|
---|
1898 | }
|
---|
1899 |
|
---|
1900 | return false;
|
---|
1901 | }
|
---|
1902 |
|
---|
1903 | /*
|
---|
1904 | * 関数名:sfDownloadFile()
|
---|
1905 | * 引数1 :ファイルパス
|
---|
1906 | * 説明 :ファイルのダウンロード
|
---|
1907 | */
|
---|
1908 | function sfDownloadFile($file) {
|
---|
1909 | // ファイルの場合はダウンロードさせる
|
---|
1910 | Header("Content-disposition: attachment; filename=".basename($file));
|
---|
1911 | Header("Content-type: application/octet-stream; name=".basename($file));
|
---|
1912 | Header("Cache-Control: ");
|
---|
1913 | Header("Pragma: ");
|
---|
1914 | echo (sfReadFile($file));
|
---|
1915 | }
|
---|
1916 |
|
---|
1917 | /*
|
---|
1918 | * 関数名:sfCreateFile()
|
---|
1919 | * 引数1 :ファイルパス
|
---|
1920 | * 引数2 :パーミッション
|
---|
1921 | * 説明 :ファイル作成
|
---|
1922 | */
|
---|
1923 | function sfCreateFile($file, $mode = "") {
|
---|
1924 | // 行末の/を取り除く
|
---|
1925 | if($mode != "") {
|
---|
1926 | $ret = @mkdir($file, $mode);
|
---|
1927 | } else {
|
---|
1928 | $ret = @mkdir($file);
|
---|
1929 | }
|
---|
1930 |
|
---|
1931 | return $ret;
|
---|
1932 | }
|
---|
1933 |
|
---|
1934 | /*
|
---|
1935 | * 関数名:sfReadFile()
|
---|
1936 | * 引数1 :ファイルパス
|
---|
1937 | * 説明 :ファイル読込
|
---|
1938 | */
|
---|
1939 | function sfReadFile($filename) {
|
---|
1940 | $str = "";
|
---|
1941 | // バイナリモードでオープン
|
---|
1942 | $fp = @fopen($filename, "rb" );
|
---|
1943 | //ファイル内容を全て変数に読み込む
|
---|
1944 | if($fp) {
|
---|
1945 | $str = @fread($fp, filesize($filename)+1);
|
---|
1946 | }
|
---|
1947 | @fclose($fp);
|
---|
1948 |
|
---|
1949 | return $str;
|
---|
1950 | }
|
---|
1951 |
|
---|
1952 | /**
|
---|
1953 | * CSV出力用データ取得
|
---|
1954 | *
|
---|
1955 | * @return string
|
---|
1956 | */
|
---|
1957 | function getCSVData($array, $arrayIndex) {
|
---|
1958 | for ($i = 0; $i < count($array); $i++){
|
---|
1959 | // インデックスが設定されている場合
|
---|
1960 | if (is_array($arrayIndex) && 0 < count($arrayIndex)){
|
---|
1961 | for ($j = 0; $j < count($arrayIndex); $j++ ){
|
---|
1962 | if ( $j > 0 ) $return .= ",";
|
---|
1963 | $return .= "\"";
|
---|
1964 | $return .= mb_ereg_replace("<","<",mb_ereg_replace( "\"","\"\"",$array[$i][$arrayIndex[$j]] )) ."\"";
|
---|
1965 | }
|
---|
1966 | } else {
|
---|
1967 | for ($j = 0; $j < count($array[$i]); $j++ ){
|
---|
1968 | if ( $j > 0 ) $return .= ",";
|
---|
1969 | $return .= "\"";
|
---|
1970 | $return .= mb_ereg_replace("<","<",mb_ereg_replace( "\"","\"\"",$array[$i][$j] )) ."\"";
|
---|
1971 | }
|
---|
1972 | }
|
---|
1973 | $return .= "\n";
|
---|
1974 | }
|
---|
1975 | return $return;
|
---|
1976 | }
|
---|
1977 |
|
---|
1978 | /**
|
---|
1979 | * 配列をテーブルタグで出力する。
|
---|
1980 | *
|
---|
1981 | * @return string
|
---|
1982 | */
|
---|
1983 | function getTableTag($array) {
|
---|
1984 | $html = "<table>";
|
---|
1985 | $html.= "<tr>";
|
---|
1986 | foreach($array[0] as $key => $val) {
|
---|
1987 | $html.="<th>$key</th>";
|
---|
1988 | }
|
---|
1989 | $html.= "</tr>";
|
---|
1990 |
|
---|
1991 | $cnt = count($array);
|
---|
1992 |
|
---|
1993 | for($i = 0; $i < $cnt; $i++) {
|
---|
1994 | $html.= "<tr>";
|
---|
1995 | foreach($array[$i] as $val) {
|
---|
1996 | $html.="<td>$val</td>";
|
---|
1997 | }
|
---|
1998 | $html.= "</tr>";
|
---|
1999 | }
|
---|
2000 | return $html;
|
---|
2001 | }
|
---|
2002 |
|
---|
2003 | /**
|
---|
2004 | * 出力バッファをフラッシュし, バッファリングを開始する.
|
---|
2005 | *
|
---|
2006 | * @return void
|
---|
2007 | */
|
---|
2008 | function flush() {
|
---|
2009 | flush();
|
---|
2010 | ob_end_flush();
|
---|
2011 | ob_start();
|
---|
2012 | }
|
---|
2013 |
|
---|
2014 | /* デバッグ用 ------------------------------------------------------------------------------------------------*/
|
---|
2015 | function sfPrintR($obj) {
|
---|
2016 | print("<div style='font-size: 12px;color: #00FF00;'>\n");
|
---|
2017 | print("<strong>**デバッグ中**</strong><br />\n");
|
---|
2018 | print("<pre>\n");
|
---|
2019 | //print_r($obj);
|
---|
2020 | var_dump($obj);
|
---|
2021 | print("</pre>\n");
|
---|
2022 | print("<strong>**デバッグ中**</strong></div>\n");
|
---|
2023 | }
|
---|
2024 | }
|
---|
2025 | ?>
|
---|