[92] | 1 | <?php
|
---|
| 2 | /*
|
---|
| 3 | * XPressME - WordPress for XOOPS
|
---|
| 4 | *
|
---|
| 5 | * @copyright XPressME Project http://www.toemon.com
|
---|
| 6 | * @license http://www.fsf.org/copyleft/gpl.html GNU public license
|
---|
| 7 | * @author toemon
|
---|
| 8 | * @package module::xpress
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | /*
|
---|
| 12 | * The function to acquire only a set value without calling the XOOPS system is here.
|
---|
| 13 | */
|
---|
| 14 | class ConfigFromXoops{
|
---|
| 15 | var $xoops_mainfile_path;
|
---|
| 16 | var $define_arry = array();
|
---|
| 17 | var $xoops_root_path;
|
---|
| 18 | var $xoops_url;
|
---|
| 19 | var $xoops_trust_path;
|
---|
| 20 | var $xoops_db_prefix;
|
---|
| 21 | var $xoops_db_name;
|
---|
| 22 | var $xoops_db_user;
|
---|
| 23 | var $xoops_db_pass;
|
---|
| 24 | var $xoops_db_host;
|
---|
| 25 | var $module_name;
|
---|
| 26 | var $module_path;
|
---|
| 27 | var $module_url;
|
---|
[95] | 28 | var $module_db_prefix;
|
---|
| 29 | var $xoops_upload_path;
|
---|
| 30 | var $xoops_upload_url;
|
---|
[92] | 31 |
|
---|
[95] | 32 |
|
---|
[92] | 33 | function __constructor() //for PHP5
|
---|
| 34 | {
|
---|
| 35 | $this->ConfigFromXoops();
|
---|
[95] | 36 |
|
---|
[92] | 37 | }
|
---|
| 38 |
|
---|
| 39 | function ConfigFromXoops() //for PHP4 constructor
|
---|
| 40 | {
|
---|
| 41 | $this->xoops_mainfile_path = $this->get_xoops_mainfile_path();
|
---|
| 42 | $this->module_path=dirname(dirname(__FILE__));
|
---|
| 43 | $this->module_name=basename($this->module_path);
|
---|
| 44 | if(file_exists($this->xoops_mainfile_path)){
|
---|
| 45 | $array_file = file($this->xoops_mainfile_path);
|
---|
| 46 | for ($i = 0 ; $i <count($array_file) ; $i++){
|
---|
| 47 | $array_file[$i] = trim($array_file[$i]);
|
---|
| 48 | $array_file[$i] = str_replace(' ','',$array_file[$i]);
|
---|
| 49 |
|
---|
| 50 | $array_file[$i] = preg_replace('/\s\s+/', '', $array_file[$i]);
|
---|
| 51 | $array_file[$i] = preg_replace('/^include.*/','',$array_file[$i]);
|
---|
| 52 | $array_file[$i] = preg_replace('/^\/\/.*/','',$array_file[$i]);
|
---|
| 53 | $array_file[$i] = preg_replace('/^if.*/','',$array_file[$i]);
|
---|
| 54 | if (strstr($array_file[$i],'define')!== false){
|
---|
| 55 | $array_file[$i] = preg_replace('/\"/', '', $array_file[$i]);
|
---|
| 56 | $array_file[$i] = preg_replace('/\(/', '', $array_file[$i]);
|
---|
| 57 | $array_file[$i] = preg_replace('/\)/', '', $array_file[$i]);
|
---|
| 58 | $array_file[$i] = preg_replace('/\;/', '', $array_file[$i]);
|
---|
| 59 | $array_file[$i] = preg_replace('/\'/', '', $array_file[$i]);
|
---|
| 60 | $array_file[$i] = preg_replace('/define/', '', $array_file[$i]);
|
---|
| 61 | $define = explode(',',$array_file[$i] );
|
---|
| 62 | $define[0] = trim($define[0]);
|
---|
| 63 | $define[1] = trim($define[1]);
|
---|
| 64 | switch ($define[0]){
|
---|
| 65 | case 'XOOPS_ROOT_PATH':
|
---|
| 66 | $this->xoops_root_path = $define[1];
|
---|
| 67 | $this->xoops_url . '/modules/' . $this->module_name;
|
---|
| 68 | break;
|
---|
| 69 | case 'XOOPS_URL':
|
---|
| 70 | $this->xoops_url = $define[1];
|
---|
| 71 | $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
|
---|
| 72 | break;
|
---|
| 73 | case 'XOOPS_TRUST_PATH':
|
---|
| 74 | $this->xoops_trust_path = $define[1];
|
---|
| 75 | break;
|
---|
| 76 | case 'XOOPS_DB_PREFIX':
|
---|
| 77 | $this->xoops_db_prefix = $define[1];
|
---|
| 78 | break;
|
---|
| 79 | case 'XOOPS_DB_NAME':
|
---|
| 80 | $this->xoops_db_name = $define[1];
|
---|
| 81 | break;
|
---|
| 82 | case 'XOOPS_DB_USER':
|
---|
| 83 | $this->xoops_db_user = $define[1];
|
---|
| 84 | break;
|
---|
| 85 | case 'XOOPS_DB_PASS':
|
---|
| 86 | $this->xoops_db_pass = $define[1];
|
---|
| 87 | break;
|
---|
| 88 | case 'XOOPS_DB_HOST':
|
---|
| 89 | $this->xoops_db_host = $define[1];
|
---|
| 90 | break;
|
---|
| 91 | default :
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 | }
|
---|
[95] | 96 |
|
---|
| 97 | // define from /settings/definition.inc.php (XCL) or /include/common.php(2016a-JP)
|
---|
| 98 | $this->xoops_upload_path = $this->xoops_root_path .'/uploads';
|
---|
| 99 | $this->xoops_upload_url = $this->xoops_url . '/uploads';
|
---|
| 100 |
|
---|
| 101 | if ($this->module_name == 'wordpress')
|
---|
| 102 | $this->module_db_prefix = $this->xoops_db_prefix . '_wp_';
|
---|
| 103 | else
|
---|
| 104 | $this->module_db_prefix = $this->xoops_db_prefix . '_' . $this->module_name . '_';
|
---|
| 105 |
|
---|
[92] | 106 | }
|
---|
| 107 |
|
---|
| 108 | function get_xoops_mainfile_path(){
|
---|
| 109 | return dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php';
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | }
|
---|
| 113 | ?>
|
---|