1 | <?php |
---|
2 | /** |
---|
3 | * PAYGENT B2B MODULE |
---|
4 | * PaygentB2BModuleResources.php |
---|
5 | * |
---|
6 | * Copyright (C) 2007 by PAYGENT Co., Ltd. |
---|
7 | * All rights reserved. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * vpeBt@CÇAlÛNX |
---|
12 | * |
---|
13 | * @version $Revision: 1.5 $ |
---|
14 | * @author $Author: t-mori $ |
---|
15 | */ |
---|
16 | |
---|
17 | include_once("jp/co/ks/merchanttool/connectmodule/util/StringUtil.php"); |
---|
18 | include_once("jp/co/ks/merchanttool/connectmodule/exception/PaygentB2BModuleConnectException.php"); |
---|
19 | include_once("jp/co/ks/merchanttool/connectmodule/exception/PaygentB2BModuleException.php"); |
---|
20 | |
---|
21 | /** |
---|
22 | * vpeBt@C¼ |
---|
23 | */ |
---|
24 | define("PaygentB2BModuleResources__PROPERTIES_FILE_NAME", "modenv.properties"); |
---|
25 | |
---|
26 | /** |
---|
27 | * Æïnd¶íÊÌæØè¶ |
---|
28 | */ |
---|
29 | define("PaygentB2BModuleResources__TELEGRAM_KIND_SEPARATOR", ","); |
---|
30 | |
---|
31 | /** |
---|
32 | * d¶íÊÌæª
iÚ±æURLæ¾j |
---|
33 | */ |
---|
34 | define("PaygentB2BModuleResources__TELEGRAM_KIND_FIRST_CHARS", 2); |
---|
35 | |
---|
36 | /** |
---|
37 | * NCAgؾt@CpX |
---|
38 | */ |
---|
39 | define("PaygentB2BModuleResources__CLIENT_FILE_PATH", "paygentB2Bmodule.client_file_path"); |
---|
40 | |
---|
41 | /** |
---|
42 | * CAؾt@CpX |
---|
43 | */ |
---|
44 | define("PaygentB2BModuleResources__CA_FILE_PATH", "paygentB2Bmodule.ca_file_path"); |
---|
45 | |
---|
46 | /** |
---|
47 | * ProxyT[o¼ |
---|
48 | */ |
---|
49 | define("PaygentB2BModuleResources__PROXY_SERVER_NAME", "paygentB2Bmodule.proxy_server_name"); |
---|
50 | |
---|
51 | /** |
---|
52 | * ProxyIPAhX |
---|
53 | */ |
---|
54 | define("PaygentB2BModuleResources__PROXY_SERVER_IP", "paygentB2Bmodule.proxy_server_ip"); |
---|
55 | |
---|
56 | /** |
---|
57 | * Proxy|[gÔ |
---|
58 | */ |
---|
59 | define("PaygentB2BModuleResources__PROXY_SERVER_PORT", "paygentB2Bmodule.proxy_server_port"); |
---|
60 | |
---|
61 | /** |
---|
62 | * ftHgID |
---|
63 | */ |
---|
64 | define("PaygentB2BModuleResources__DEFAULT_ID", "paygentB2Bmodule.default_id"); |
---|
65 | |
---|
66 | /** |
---|
67 | * ftHgpX[h |
---|
68 | */ |
---|
69 | define("PaygentB2BModuleResources__DEFAULT_PASSWORD", "paygentB2Bmodule.default_password"); |
---|
70 | |
---|
71 | /** |
---|
72 | * ^CAEgl |
---|
73 | */ |
---|
74 | define("PaygentB2BModuleResources__TIMEOUT_VALUE", "paygentB2Bmodule.timeout_value"); |
---|
75 | |
---|
76 | /** |
---|
77 | * OoÍæ |
---|
78 | */ |
---|
79 | define("PaygentB2BModuleResources__LOG_OUTPUT_PATH", "paygentB2Bmodule.log_output_path"); |
---|
80 | |
---|
81 | /** |
---|
82 | * ÆïMAX |
---|
83 | */ |
---|
84 | define("PaygentB2BModuleResources__SELECT_MAX_CNT", "paygentB2Bmodule.select_max_cnt"); |
---|
85 | |
---|
86 | /** |
---|
87 | * Æïnd¶íÊID |
---|
88 | */ |
---|
89 | define("PaygentB2BModuleResources__TELEGRAM_KIND_REFS", "paygentB2Bmodule.telegram_kind.ref"); |
---|
90 | |
---|
91 | /** |
---|
92 | * Ú±æURLi¤Êj |
---|
93 | */ |
---|
94 | define("PaygentB2BModuleResources__URL_COMM", "paygentB2Bmodule.url."); |
---|
95 | |
---|
96 | |
---|
97 | class PaygentB2BModuleResources { |
---|
98 | |
---|
99 | /** NCAgؾt@CpX */ |
---|
100 | var $clientFilePath = ""; |
---|
101 | |
---|
102 | /** CAؾt@CpX */ |
---|
103 | var $caFilePath = ""; |
---|
104 | |
---|
105 | /** ProxyT[o¼ */ |
---|
106 | var $proxyServerName = ""; |
---|
107 | |
---|
108 | /** ProxyIPAhX */ |
---|
109 | var $proxyServerIp = ""; |
---|
110 | |
---|
111 | /** Proxy|[gÔ */ |
---|
112 | var $proxyServerPort = 0; |
---|
113 | |
---|
114 | /** ftHgID */ |
---|
115 | var $defaultId = ""; |
---|
116 | |
---|
117 | /** ftHgpX[h */ |
---|
118 | var $defaultPassword = ""; |
---|
119 | |
---|
120 | /** ^CAEgl */ |
---|
121 | var $timeout = 0; |
---|
122 | |
---|
123 | /** OoÍæ */ |
---|
124 | var $logOutputPath = ""; |
---|
125 | |
---|
126 | /** ÆïMAX */ |
---|
127 | var $selectMaxCnt = 0; |
---|
128 | |
---|
129 | /** Ýèt@CivpeBj */ |
---|
130 | var $propConnect = null; |
---|
131 | |
---|
132 | /** Æïnd¶íÊXg */ |
---|
133 | var $telegramKindRefs = null; |
---|
134 | |
---|
135 | /** |
---|
136 | * RXgN^ |
---|
137 | */ |
---|
138 | function PaygentB2BModuleResources() { |
---|
139 | } |
---|
140 | |
---|
141 | /** |
---|
142 | * PaygentB2BModuleResources ðæ¾ |
---|
143 | * |
---|
144 | * @return PaygentB2BModuleResources@¸sÌêAG[R[h |
---|
145 | */ |
---|
146 | function &getInstance() { |
---|
147 | static $resourceInstance = null; |
---|
148 | |
---|
149 | if (isset($resourceInstance) == false |
---|
150 | || $resourceInstance == null |
---|
151 | || is_object($resourceInstance) != true) { |
---|
152 | |
---|
153 | $resourceInstance = new PaygentB2BModuleResources(); |
---|
154 | $rslt = $resourceInstance->readProperties(); |
---|
155 | if ($rslt === true) { |
---|
156 | } else { |
---|
157 | $resourceInstance = $rslt; |
---|
158 | } |
---|
159 | } |
---|
160 | |
---|
161 | return $resourceInstance; |
---|
162 | } |
---|
163 | |
---|
164 | /** |
---|
165 | * NCAgؾt@CpXðæ¾B |
---|
166 | * |
---|
167 | * @return clientFilePath |
---|
168 | */ |
---|
169 | function getClientFilePath() { |
---|
170 | return $this->clientFilePath; |
---|
171 | } |
---|
172 | |
---|
173 | /** |
---|
174 | * CAؾt@CpXðæ¾B |
---|
175 | * |
---|
176 | * @return caFilePath |
---|
177 | */ |
---|
178 | function getCaFilePath() { |
---|
179 | return $this->caFilePath; |
---|
180 | } |
---|
181 | |
---|
182 | /** |
---|
183 | * ProxyT[o¼ðæ¾B |
---|
184 | * |
---|
185 | * @return proxyServerName |
---|
186 | */ |
---|
187 | function getProxyServerName() { |
---|
188 | return $this->proxyServerName; |
---|
189 | } |
---|
190 | |
---|
191 | /** |
---|
192 | * ProxyIPAhXðæ¾B |
---|
193 | * |
---|
194 | * @return proxyServerIp |
---|
195 | */ |
---|
196 | function getProxyServerIp() { |
---|
197 | return $this->proxyServerIp; |
---|
198 | } |
---|
199 | |
---|
200 | /** |
---|
201 | * Proxy|[gÔðæ¾B |
---|
202 | * |
---|
203 | * @return proxyServerPort |
---|
204 | */ |
---|
205 | function getProxyServerPort() { |
---|
206 | return $this->proxyServerPort; |
---|
207 | } |
---|
208 | |
---|
209 | /** |
---|
210 | * ftHgIDðæ¾B |
---|
211 | * |
---|
212 | * @return defaultId |
---|
213 | */ |
---|
214 | function getDefaultId() { |
---|
215 | return $this->defaultId; |
---|
216 | } |
---|
217 | |
---|
218 | /** |
---|
219 | * ftHgpX[hðæ¾B |
---|
220 | * |
---|
221 | * @return defaultPassword |
---|
222 | */ |
---|
223 | function getDefaultPassword() { |
---|
224 | return $this->defaultPassword; |
---|
225 | } |
---|
226 | |
---|
227 | /** |
---|
228 | * ^CAEglðæ¾B |
---|
229 | * |
---|
230 | * @return timeout |
---|
231 | */ |
---|
232 | function getTimeout() { |
---|
233 | return $this->timeout; |
---|
234 | } |
---|
235 | |
---|
236 | /** |
---|
237 | * OoÍæðæ¾B |
---|
238 | * |
---|
239 | * @return logOutputPath |
---|
240 | */ |
---|
241 | function getLogOutputPath() { |
---|
242 | return $this->logOutputPath; |
---|
243 | } |
---|
244 | |
---|
245 | /** |
---|
246 | * ÆïMAXðæ¾B |
---|
247 | * |
---|
248 | * @return selectMaxCnt |
---|
249 | */ |
---|
250 | function getSelectMaxCnt() { |
---|
251 | return $this->selectMaxCnt; |
---|
252 | } |
---|
253 | |
---|
254 | /** |
---|
255 | * Ú±æURLðæ¾B |
---|
256 | * |
---|
257 | * @param telegramKind |
---|
258 | * @return FALSE: ¸s(PaygentB2BModuleConnectException::TEREGRAM_PARAM_OUTSIDE_ERROR)A¬÷:æ¾µ½ URL |
---|
259 | */ |
---|
260 | function getUrl($telegramKind) { |
---|
261 | $rs = null; |
---|
262 | $sKey = null; |
---|
263 | |
---|
264 | // vpeB`FbN |
---|
265 | if ($this->propConnect == null) { |
---|
266 | trigger_error(PaygentB2BModuleConnectException__TEREGRAM_PARAM_OUTSIDE_ERROR |
---|
267 | . ": HTTP request contains unexpected value.", E_USER_WARNING); |
---|
268 | return false; |
---|
269 | } |
---|
270 | |
---|
271 | // ø`FbN |
---|
272 | if (StringUtil::isEmpty($telegramKind)) { |
---|
273 | trigger_error(PaygentB2BModuleConnectException__TEREGRAM_PARAM_OUTSIDE_ERROR |
---|
274 | . ": HTTP request contains unexpected value.", E_USER_WARNING); |
---|
275 | return false; |
---|
276 | } |
---|
277 | |
---|
278 | // S
ÅvpeB©çURLðæ¾ |
---|
279 | $sKey = PaygentB2BModuleResources__URL_COMM . $telegramKind; |
---|
280 | if (array_key_exists($sKey, $this->propConnect)) { |
---|
281 | $rs = $this->propConnect[$sKey]; |
---|
282 | } |
---|
283 | |
---|
284 | // S
Åæ¾Å«½êA»Ìlðß· |
---|
285 | if (!StringUtil::isEmpty($rs)) { |
---|
286 | return $rs; |
---|
287 | } |
---|
288 | |
---|
289 | // æªQ
ÅvpeB©çURLðæ¾ |
---|
290 | if (strlen($telegramKind) > PaygentB2BModuleResources__TELEGRAM_KIND_FIRST_CHARS) { |
---|
291 | $sKey = PaygentB2BModuleResources__URL_COMM |
---|
292 | . substr($telegramKind, 0, PaygentB2BModuleResources__TELEGRAM_KIND_FIRST_CHARS); |
---|
293 | } else { |
---|
294 | // S
ÆÈèAG[Æ·é |
---|
295 | trigger_error(PaygentB2BModuleConnectException__TEREGRAM_PARAM_OUTSIDE_ERROR |
---|
296 | . ": HTTP request contains unexpected value.", E_USER_WARNING); |
---|
297 | return false; |
---|
298 | } |
---|
299 | if (array_key_exists($sKey, $this->propConnect)) { |
---|
300 | $rs = $this->propConnect[$sKey]; |
---|
301 | } |
---|
302 | |
---|
303 | // S
ÆæªQ
Åæ¾Å«È©Á½êAG[ðß· |
---|
304 | if (StringUtil::isEmpty($rs)) { |
---|
305 | trigger_error(PaygentB2BModuleConnectException__TEREGRAM_PARAM_OUTSIDE_ERROR |
---|
306 | . ": HTTP request contains unexpected value.", E_USER_WARNING); |
---|
307 | return false; |
---|
308 | } |
---|
309 | |
---|
310 | return $rs; |
---|
311 | } |
---|
312 | |
---|
313 | /** |
---|
314 | * PropertiesFile Ìlðæ¾µAÝèB |
---|
315 | * |
---|
316 | * @return mixed ¬÷FTRUEA¼FG[R[h |
---|
317 | */ |
---|
318 | function readProperties() { |
---|
319 | |
---|
320 | // Properties File Read |
---|
321 | $prop = null; |
---|
322 | |
---|
323 | $prop = PaygentB2BModuleResources::parseJavaProperty(PaygentB2BModuleResources__PROPERTIES_FILE_NAME); |
---|
324 | if ($prop === false) { |
---|
325 | // Properties File ÇG[ |
---|
326 | trigger_error(PaygentB2BModuleException__RESOURCE_FILE_NOT_FOUND_ERROR |
---|
327 | . ": Properties file doesn't exist.", E_USER_WARNING); |
---|
328 | return PaygentB2BModuleException__RESOURCE_FILE_NOT_FOUND_ERROR; |
---|
329 | } |
---|
330 | |
---|
331 | // K{ÚG[`FbN |
---|
332 | if (!($this->isPropertiesIndispensableItem($prop) |
---|
333 | && $this->isPropertiesSetData($prop) |
---|
334 | && $this->isPropertieSetInt($prop)) |
---|
335 | || $this->isURLNull($prop)) { |
---|
336 | // K{ÚG[ |
---|
337 | $propConnect = null; |
---|
338 | trigger_error(PaygentB2BModuleException__RESOURCE_FILE_REQUIRED_ERROR |
---|
339 | . ": Properties file contains inappropriate value.", E_USER_WARNING); |
---|
340 | return PaygentB2BModuleException__RESOURCE_FILE_REQUIRED_ERROR; |
---|
341 | } |
---|
342 | $this->propConnect = $prop; |
---|
343 | |
---|
344 | // NCAgؾt@CpX |
---|
345 | if (array_key_exists(PaygentB2BModuleResources__CLIENT_FILE_PATH, $prop) |
---|
346 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__CLIENT_FILE_PATH]))) { |
---|
347 | $this->clientFilePath = $prop[PaygentB2BModuleResources__CLIENT_FILE_PATH]; |
---|
348 | } |
---|
349 | |
---|
350 | // CAؾt@CpX |
---|
351 | if (array_key_exists(PaygentB2BModuleResources__CA_FILE_PATH, $prop) |
---|
352 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__CA_FILE_PATH]))) { |
---|
353 | $this->caFilePath = $prop[PaygentB2BModuleResources__CA_FILE_PATH]; |
---|
354 | } |
---|
355 | |
---|
356 | // ProxyT[o¼ |
---|
357 | if (array_key_exists(PaygentB2BModuleResources__PROXY_SERVER_NAME, $prop) |
---|
358 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__PROXY_SERVER_NAME]))) { |
---|
359 | $this->proxyServerName = $prop[PaygentB2BModuleResources__PROXY_SERVER_NAME]; |
---|
360 | } |
---|
361 | |
---|
362 | // ProxyIPAhX |
---|
363 | if (array_key_exists(PaygentB2BModuleResources__PROXY_SERVER_IP, $prop) |
---|
364 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__PROXY_SERVER_IP]))) { |
---|
365 | $this->proxyServerIp = $prop[PaygentB2BModuleResources__PROXY_SERVER_IP]; |
---|
366 | } |
---|
367 | |
---|
368 | // Proxy|[gÔ |
---|
369 | if (array_key_exists(PaygentB2BModuleResources__PROXY_SERVER_PORT, $prop) |
---|
370 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__PROXY_SERVER_PORT]))) { |
---|
371 | if (StringUtil::isNumeric($prop[PaygentB2BModuleResources__PROXY_SERVER_PORT])) { |
---|
372 | $this->proxyServerPort = $prop[PaygentB2BModuleResources__PROXY_SERVER_PORT]; |
---|
373 | } else { |
---|
374 | // ÝèlG[ |
---|
375 | trigger_error(PaygentB2BModuleException__RESOURCE_FILE_REQUIRED_ERROR |
---|
376 | . ": Properties file contains inappropriate value.", E_USER_WARNING); |
---|
377 | return PaygentB2BModuleException__RESOURCE_FILE_REQUIRED_ERROR; |
---|
378 | } |
---|
379 | } |
---|
380 | |
---|
381 | // ftHgID |
---|
382 | if (array_key_exists(PaygentB2BModuleResources__DEFAULT_ID, $prop) |
---|
383 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__DEFAULT_ID]))) { |
---|
384 | $this->defaultId = $prop[PaygentB2BModuleResources__DEFAULT_ID]; |
---|
385 | } |
---|
386 | |
---|
387 | // ftHgpX[h |
---|
388 | if (array_key_exists(PaygentB2BModuleResources__DEFAULT_PASSWORD, $prop) |
---|
389 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__DEFAULT_PASSWORD]))) { |
---|
390 | $this->defaultPassword = $prop[PaygentB2BModuleResources__DEFAULT_PASSWORD]; |
---|
391 | } |
---|
392 | |
---|
393 | // ^CAEgl |
---|
394 | if (array_key_exists(PaygentB2BModuleResources__TIMEOUT_VALUE, $prop) |
---|
395 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__TIMEOUT_VALUE]))) { |
---|
396 | $this->timeout = $prop[PaygentB2BModuleResources__TIMEOUT_VALUE]; |
---|
397 | } |
---|
398 | |
---|
399 | // OoÍæ |
---|
400 | if (array_key_exists(PaygentB2BModuleResources__LOG_OUTPUT_PATH, $prop) |
---|
401 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__LOG_OUTPUT_PATH]))) { |
---|
402 | $this->logOutputPath = $prop[PaygentB2BModuleResources__LOG_OUTPUT_PATH]; |
---|
403 | } |
---|
404 | |
---|
405 | // ÆïMAX |
---|
406 | if (array_key_exists(PaygentB2BModuleResources__SELECT_MAX_CNT, $prop) |
---|
407 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__SELECT_MAX_CNT]))) { |
---|
408 | $this->selectMaxCnt = $prop[PaygentB2BModuleResources__SELECT_MAX_CNT]; |
---|
409 | } |
---|
410 | |
---|
411 | // Æïd¶íÊXg |
---|
412 | if (array_key_exists(PaygentB2BModuleResources__TELEGRAM_KIND_REFS, $prop) |
---|
413 | && !(StringUtil::isEmpty($prop[PaygentB2BModuleResources__TELEGRAM_KIND_REFS]))) { |
---|
414 | $telegramKindRef = $prop[PaygentB2BModuleResources__TELEGRAM_KIND_REFS]; |
---|
415 | $this->telegramKindRefs = $this->split($telegramKindRef, PaygentB2BModuleResources__TELEGRAM_KIND_SEPARATOR); |
---|
416 | } |
---|
417 | if ($this->telegramKindRefs == null) { |
---|
418 | $this->telegramKindRefs = array(); |
---|
419 | } |
---|
420 | |
---|
421 | return true; |
---|
422 | } |
---|
423 | |
---|
424 | /** |
---|
425 | * Properties K{Ú`FbN |
---|
426 | * |
---|
427 | * @param Properties |
---|
428 | * @return boolean true=K{ÚLè false=K{Ú³µ |
---|
429 | */ |
---|
430 | function isPropertiesIndispensableItem($prop) { |
---|
431 | $rb = false; |
---|
432 | |
---|
433 | if ((array_key_exists(PaygentB2BModuleResources__CLIENT_FILE_PATH, $prop) |
---|
434 | && array_key_exists(PaygentB2BModuleResources__CA_FILE_PATH, $prop) |
---|
435 | && array_key_exists(PaygentB2BModuleResources__TIMEOUT_VALUE, $prop) |
---|
436 | && array_key_exists(PaygentB2BModuleResources__LOG_OUTPUT_PATH, $prop) |
---|
437 | && array_key_exists(PaygentB2BModuleResources__SELECT_MAX_CNT, $prop))) { |
---|
438 | // K{ÚLè |
---|
439 | $rb = true; |
---|
440 | } |
---|
441 | |
---|
442 | return $rb; |
---|
443 | } |
---|
444 | |
---|
445 | /** |
---|
446 | * Properties f[^Ýè`FbN |
---|
447 | * |
---|
448 | * @param prop Properties |
---|
449 | * @return boolean true=f[^¢ÝèÚ³µ false=f[^¢ÝèÚLè |
---|
450 | */ |
---|
451 | function isPropertiesSetData($prop) { |
---|
452 | $rb = true; |
---|
453 | |
---|
454 | if (StringUtil::isEmpty($prop[PaygentB2BModuleResources__CLIENT_FILE_PATH]) |
---|
455 | || StringUtil::isEmpty($prop[PaygentB2BModuleResources__CA_FILE_PATH]) |
---|
456 | || StringUtil::isEmpty($prop[PaygentB2BModuleResources__TIMEOUT_VALUE]) |
---|
457 | || StringUtil::isEmpty($prop[PaygentB2BModuleResources__LOG_OUTPUT_PATH]) |
---|
458 | || StringUtil::isEmpty($prop[PaygentB2BModuleResources__SELECT_MAX_CNT])) { |
---|
459 | // K{Ú¢ÝèG[ |
---|
460 | $rb = false; |
---|
461 | } |
---|
462 | |
---|
463 | return $rb; |
---|
464 | } |
---|
465 | |
---|
466 | /** |
---|
467 | * Properties l`FbN |
---|
468 | * |
---|
469 | * @param prop Properties |
---|
470 | * @return boolean true=lÝè false=l¢Ýè |
---|
471 | */ |
---|
472 | function isPropertieSetInt($prop) { |
---|
473 | $rb = false; |
---|
474 | |
---|
475 | if (StringUtil::isNumeric($prop[PaygentB2BModuleResources__TIMEOUT_VALUE]) |
---|
476 | && StringUtil::isNumeric($prop[PaygentB2BModuleResources__SELECT_MAX_CNT])) { |
---|
477 | // lÝè |
---|
478 | $rb = true; |
---|
479 | } |
---|
480 | |
---|
481 | return $rb; |
---|
482 | } |
---|
483 | |
---|
484 | /** |
---|
485 | * Ú±æURLÍk©Ç¤©Ì`FbN |
---|
486 | * |
---|
487 | */ |
---|
488 | function isURLNull($prop) { |
---|
489 | $rb = false; |
---|
490 | if (!is_array($prop)) { |
---|
491 | return true; |
---|
492 | } |
---|
493 | |
---|
494 | foreach($prop as $key => $value) { |
---|
495 | |
---|
496 | if (strpos($key, PaygentB2BModuleResources__URL_COMM) === 0) { |
---|
497 | if (isset($value) == false |
---|
498 | || strlen(trim($value)) == 0) { |
---|
499 | $rb = true; |
---|
500 | break; |
---|
501 | } |
---|
502 | } |
---|
503 | } |
---|
504 | return $rb; |
---|
505 | } |
---|
506 | |
---|
507 | /** |
---|
508 | * wè³ê½æØè¶Å¶ñðªµAg·é |
---|
509 | * |
---|
510 | * @param str ¶ñ |
---|
511 | * @param separator æØè¶ |
---|
512 | * @return Xg |
---|
513 | */ |
---|
514 | function split($str, $separator) { |
---|
515 | $list = array(); |
---|
516 | |
---|
517 | if ($str == null) { |
---|
518 | return $list; |
---|
519 | } |
---|
520 | |
---|
521 | if ($separator == null || strlen($separator) == 0) { |
---|
522 | if (!StringUtil::isEmpty(trim($str))) { |
---|
523 | $list[] = trim($str); |
---|
524 | } |
---|
525 | return $list; |
---|
526 | } |
---|
527 | |
---|
528 | $arr = explode($separator, $str); |
---|
529 | for ($i=0; $arr && $i < sizeof($arr); $i++) { |
---|
530 | if (!StringUtil::isEmpty(trim($arr[$i]))) { |
---|
531 | $list[] = trim($arr[$i]); |
---|
532 | } |
---|
533 | } |
---|
534 | |
---|
535 | return $list; |
---|
536 | } |
---|
537 | |
---|
538 | /** |
---|
539 | * Æïd¶`FbN |
---|
540 | * @param telegramKind d¶íÊ |
---|
541 | * @return true=Æïd¶ false=Æïd¶ÈO |
---|
542 | */ |
---|
543 | function isTelegramKindRef($telegramKind) { |
---|
544 | $bRet = false; |
---|
545 | |
---|
546 | if ($this->telegramKindRefs == null) { |
---|
547 | return $bRet; |
---|
548 | } |
---|
549 | $bRet = in_array($telegramKind, $this->telegramKindRefs); |
---|
550 | return $bRet; |
---|
551 | } |
---|
552 | |
---|
553 | /** |
---|
554 | * JavatH[}bgÌvpeBt@C©çlðæ¾µÄ |
---|
555 | * zñÉüêÄÔ· |
---|
556 | * |
---|
557 | * @param fileName vpeBt@C¼ |
---|
558 | * @param commentChar Rgp¶ |
---|
559 | * @return FALSE: ¸sA¼:KEY=VALUE`®Ìzñ, |
---|
560 | */ |
---|
561 | function parseJavaProperty($fileName, $commentChar = "#") { |
---|
562 | |
---|
563 | $properties = array(); |
---|
564 | |
---|
565 | $lines = @file($fileName, FILE_USE_INCLUDE_PATH | FILE_IGNORE_NEW_LINES); |
---|
566 | if ($lines === false) { |
---|
567 | // Properties File ÇG[ |
---|
568 | return $lines; |
---|
569 | } |
---|
570 | |
---|
571 | foreach ($lines as $i => $line) { |
---|
572 | $lineData = trim($line); |
---|
573 | |
---|
574 | $index = strpos($lineData, '\r'); |
---|
575 | if (!($index === false)) { |
---|
576 | $lineData = trim(substr($lineData, 0, $index)); |
---|
577 | } |
---|
578 | $index = strpos($lineData, '\n'); |
---|
579 | if (!($index === false)) { |
---|
580 | $lineData = trim(substr($lineData, 0, $index)); |
---|
581 | } |
---|
582 | |
---|
583 | if (strlen($lineData) <= 0) { |
---|
584 | continue; |
---|
585 | } |
---|
586 | $firstChar = substr($lineData, 0, strlen($commentChar)); |
---|
587 | |
---|
588 | if ($firstChar == $commentChar) { |
---|
589 | continue; |
---|
590 | } |
---|
591 | |
---|
592 | $quotationIndex = strpos($lineData, '='); |
---|
593 | if ($quotationIndex <= 0) { |
---|
594 | continue; |
---|
595 | } |
---|
596 | |
---|
597 | $key = trim(substr($lineData, 0, $quotationIndex)); |
---|
598 | $value = null; |
---|
599 | if (strlen($lineData) > $quotationIndex) { |
---|
600 | $value = trim(substr($lineData, $quotationIndex + 1)); |
---|
601 | } |
---|
602 | $properties[$key] = $value; |
---|
603 | } |
---|
604 | |
---|
605 | return $properties; |
---|
606 | } |
---|
607 | |
---|
608 | } |
---|
609 | ?> |
---|