source: branches/feature-module-paygent/data/downloads/module/mdl_paygent/jp/co/ks/merchanttool/connectmodule/system/PaygentB2BModuleResources.php @ 15162

Revision 15162, 15.2 KB checked in by naka, 17 years ago (diff)

ペイジェント決済モジュール

Line 
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 * ƒvƒƒpƒeƒBƒtƒ@ƒCƒ‹“ǍžA’l•ÛŽƒNƒ‰ƒX
12 *
13 * @version $Revision: 1.5 $
14 * @author $Author: t-mori $
15 */
16
17include_once("jp/co/ks/merchanttool/connectmodule/util/StringUtil.php");
18include_once("jp/co/ks/merchanttool/connectmodule/exception/PaygentB2BModuleConnectException.php");
19include_once("jp/co/ks/merchanttool/connectmodule/exception/PaygentB2BModuleException.php");
20
21    /**
22     * ƒvƒƒpƒeƒBƒtƒ@ƒCƒ‹–¼
23     */
24    define("PaygentB2BModuleResources__PROPERTIES_FILE_NAME", "modenv.properties");
25
26    /**
27     * Æ‰ïŒn“d•¶Ží•Ê‚Ì‹æØ‚蕶Žš
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     * ƒNƒ‰ƒCƒAƒ“ƒgØ–¾‘ƒtƒ@ƒCƒ‹ƒpƒX
38     */
39    define("PaygentB2BModuleResources__CLIENT_FILE_PATH", "paygentB2Bmodule.client_file_path");
40
41    /**
42     * CAØ–¾‘ƒtƒ@ƒCƒ‹ƒpƒX
43     */
44    define("PaygentB2BModuleResources__CA_FILE_PATH", "paygentB2Bmodule.ca_file_path");
45
46    /**
47     * ProxyƒT[ƒo–¼
48     */
49    define("PaygentB2BModuleResources__PROXY_SERVER_NAME", "paygentB2Bmodule.proxy_server_name");
50
51    /**
52     * ProxyIPƒAƒhƒŒƒX
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     * ƒfƒtƒHƒ‹ƒgID
63     */
64    define("PaygentB2BModuleResources__DEFAULT_ID", "paygentB2Bmodule.default_id");
65
66    /**
67     * ƒfƒtƒHƒ‹ƒgƒpƒXƒ[ƒh
68     */
69    define("PaygentB2BModuleResources__DEFAULT_PASSWORD", "paygentB2Bmodule.default_password");
70
71    /**
72     * ƒ^ƒCƒ€ƒAƒEƒg’l
73     */
74    define("PaygentB2BModuleResources__TIMEOUT_VALUE", "paygentB2Bmodule.timeout_value");
75
76    /**
77     * ƒƒOo—͐æ
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     * Æ‰ïŒn“d•¶Ží•ÊID
88     */
89    define("PaygentB2BModuleResources__TELEGRAM_KIND_REFS", "paygentB2Bmodule.telegram_kind.ref");
90
91    /**
92     * Ú‘±æURLi‹¤’ʁj
93     */
94    define("PaygentB2BModuleResources__URL_COMM", "paygentB2Bmodule.url.");
95
96
97 class PaygentB2BModuleResources {
98   
99    /** ƒNƒ‰ƒCƒAƒ“ƒgØ–¾‘ƒtƒ@ƒCƒ‹ƒpƒX */
100    var $clientFilePath = "";
101
102    /** CAØ–¾‘ƒtƒ@ƒCƒ‹ƒpƒX */
103    var $caFilePath = "";
104
105    /** ProxyƒT[ƒo–¼ */
106    var $proxyServerName = "";
107
108    /** ProxyIPƒAƒhƒŒƒX */
109    var $proxyServerIp = "";
110
111    /** Proxyƒ|[ƒg”ԍ† */
112    var $proxyServerPort = 0;
113
114    /** ƒfƒtƒHƒ‹ƒgID */
115    var $defaultId = "";
116
117    /** ƒfƒtƒHƒ‹ƒgƒpƒXƒ[ƒh */
118    var $defaultPassword = "";
119
120    /** ƒ^ƒCƒ€ƒAƒEƒg’l */
121    var $timeout = 0;
122
123    /** ƒƒOo—͐æ */
124    var $logOutputPath = "";
125
126    /** Æ‰ïMAXŒ” */
127    var $selectMaxCnt = 0;
128   
129    /** Ý’èƒtƒ@ƒCƒ‹iƒvƒƒpƒeƒBj */
130    var $propConnect = null;
131
132    /** Æ‰ïŒn“d•¶Ží•ÊƒŠƒXƒg */
133    var $telegramKindRefs = null;
134
135    /**
136     * ƒRƒ“ƒXƒgƒ‰ƒNƒ^
137     */
138    function PaygentB2BModuleResources() {
139    }
140
141    /**
142     * PaygentB2BModuleResources ‚ðŽæ“¾
143     *
144     * @return PaygentB2BModuleResources@Ž¸”s‚̏ꍇAƒGƒ‰[ƒ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     * ƒNƒ‰ƒCƒAƒ“ƒgØ–¾‘ƒtƒ@ƒCƒ‹ƒpƒX‚ðŽæ“¾B
166     *
167     * @return clientFilePath
168     */
169    function getClientFilePath() {
170        return $this->clientFilePath;
171    }
172
173    /**
174     * CAØ–¾‘ƒtƒ@ƒCƒ‹ƒpƒX‚ðŽæ“¾B
175     *
176     * @return caFilePath
177     */
178    function getCaFilePath() {
179        return $this->caFilePath;
180    }
181
182    /**
183     * ProxyƒT[ƒo–¼‚ðŽæ“¾B
184     *
185     * @return proxyServerName
186     */
187    function getProxyServerName() {
188        return $this->proxyServerName;
189    }
190
191    /**
192     * ProxyIPƒAƒhƒŒƒX‚ðŽæ“¾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     * ƒfƒtƒHƒ‹ƒgID‚ðŽæ“¾B
211     *
212     * @return defaultId
213     */
214    function getDefaultId() {
215        return $this->defaultId;
216    }
217
218    /**
219     * ƒfƒtƒHƒ‹ƒgƒpƒXƒ[ƒh‚ðŽæ“¾B
220     *
221     * @return defaultPassword
222     */
223    function getDefaultPassword() {
224        return $this->defaultPassword;
225    }
226
227    /**
228     * ƒ^ƒCƒ€ƒAƒEƒg’l‚ðŽæ“¾B
229     *
230     * @return timeout
231     */
232    function getTimeout() {
233        return $this->timeout;
234    }
235
236    /**
237     * ƒƒOo—͐æ‚ðŽæ“¾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        // ƒvƒƒpƒeƒBƒ`ƒFƒbƒN
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        // ˆø”ƒ`ƒFƒbƒN
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Œ…”‚ŃvƒƒpƒeƒB‚©‚ç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Œ…‚ŃvƒƒpƒeƒB‚©‚ç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Œ…”‚Æ‚È‚èAƒGƒ‰[‚Æ‚·‚é
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Œ…‚Ŏ擾‚Å‚«‚È‚©‚Á‚½ê‡AƒGƒ‰[‚ð–ß‚·
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 ¬Œ÷FTRUEA‘¼FƒGƒ‰[ƒ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ƒ‰[ƒ`ƒFƒbƒN
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        // ƒNƒ‰ƒCƒAƒ“ƒgØ–¾‘ƒtƒ@ƒCƒ‹ƒpƒX
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ƒ@ƒCƒ‹ƒpƒX
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        // ProxyƒT[ƒ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        // ProxyIPƒAƒhƒŒƒX
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                // Ý’è’lƒGƒ‰[
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        // ƒfƒtƒHƒ‹ƒgID
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        // ƒfƒtƒHƒ‹ƒgƒpƒXƒ[ƒ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        // ƒ^ƒCƒ€ƒAƒEƒg’l
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        // ƒƒOo—͐æ
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•¶Ží•ÊƒŠƒXƒg
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{€–Úƒ`ƒFƒbƒN
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[ƒ^Ý’èƒ`ƒFƒbƒN
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ƒ`ƒFƒbƒN
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ƒ‹‚©‚Ç‚¤‚©‚̃`ƒFƒbƒN
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’肳‚ꂽ‹æØ‚蕶Žš‚Å•¶Žš—ñ‚𕪊„‚µAƒgƒŠƒ€‚·‚é
509     *
510     * @param str •¶Žš—ñ
511     * @param separator ‹æØ‚蕶Žš
512     * @return ƒŠƒXƒg
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•¶ƒ`ƒFƒbƒN
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     * JavaƒtƒH[ƒ}ƒbƒg‚̃vƒƒpƒeƒBƒtƒ@ƒCƒ‹‚©‚ç’l‚ðŽæ“¾‚µ‚Ä
555     * ”z—ñ‚É“ü‚ê‚Ä•Ô‚·
556     *
557     * @param fileName ƒvƒƒpƒeƒBƒtƒ@ƒCƒ‹–¼
558     * @param commentChar ƒRƒƒ“ƒg—p•¶Žš
559     * @return FALSE: Ž¸”sA‘¼: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?>
Note: See TracBrowser for help on using the repository browser.