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 $external_define_path;
|
---|
18 | var $xp_config_file_path;
|
---|
19 | var $xoops_root_path;
|
---|
20 | var $xoops_url;
|
---|
21 | var $xoops_trust_path;
|
---|
22 | var $xoops_cache_path;
|
---|
23 | var $xoops_db_prefix;
|
---|
24 | var $xoops_db_name;
|
---|
25 | var $xoops_db_user;
|
---|
26 | var $xoops_db_pass;
|
---|
27 | var $xoops_db_host;
|
---|
28 | var $module_name;
|
---|
29 | var $module_path;
|
---|
30 | var $module_url;
|
---|
31 | var $module_db_prefix;
|
---|
32 | var $module_version;
|
---|
33 | var $module_codename;
|
---|
34 | var $xoops_upload_path;
|
---|
35 | var $xoops_upload_url;
|
---|
36 | var $xoops_db_salt;
|
---|
37 | var $xoops_salt;
|
---|
38 | var $is_impress;
|
---|
39 | var $impress_db_config_file;
|
---|
40 | var $wp_db_version;
|
---|
41 | var $wp_version;
|
---|
42 | var $is_wp_me;
|
---|
43 | var $xoops_language;
|
---|
44 | var $module_id;
|
---|
45 | var $module_config= array();
|
---|
46 | var $xoops_time_zone;
|
---|
47 | var $xoops_var_path;
|
---|
48 | var $xoops_db_charset;
|
---|
49 | var $xoops_db_pconnect;
|
---|
50 | var $xoops_path;
|
---|
51 |
|
---|
52 | function __constructor() //for PHP5
|
---|
53 | {
|
---|
54 | $this->ConfigFromXoops();
|
---|
55 |
|
---|
56 | }
|
---|
57 |
|
---|
58 | function xpress_eval($str){
|
---|
59 | $eval_str = '$ret = ' . $str . ' ;';
|
---|
60 | eval($eval_str);
|
---|
61 | return $ret;
|
---|
62 | }
|
---|
63 |
|
---|
64 | function ConfigFromXoops() //for PHP4 constructor
|
---|
65 | {
|
---|
66 | $this->xoops_mainfile_path = $this->get_xoops_mainfile_path();
|
---|
67 | $this->module_path=dirname(dirname(__FILE__));
|
---|
68 | $this->module_name=basename($this->module_path);
|
---|
69 | $this->xp_config_file_path = $this->module_path . '/xp-config.php';
|
---|
70 |
|
---|
71 | // start /admin/index.php page detect
|
---|
72 | $php_script_name = $_SERVER['SCRIPT_NAME'];
|
---|
73 | $php_query_string = $_SERVER['QUERY_STRING'];
|
---|
74 | $admin_page = basename(dirname(dirname(__FILE__))) . '/admin/index.php';
|
---|
75 | $is_xoops_module_admin = false;
|
---|
76 | if (strstr($php_script_name,$admin_page) !== false) $is_xoops_module_admin = true;
|
---|
77 | if (strstr($php_query_string,$admin_page) !== false) $is_xoops_module_admin = true;
|
---|
78 | // end of /admin/index.php page detect
|
---|
79 | $this->xoops_root_path = XOOPS_ROOT_PATH;
|
---|
80 | $this->xoops_url = XOOPS_URL;
|
---|
81 | $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
|
---|
82 | if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = '';
|
---|
83 | $this->xoops_db_prefix = XOOPS_DB_PREFIX;
|
---|
84 | $this->xoops_db_name = XOOPS_DB_NAME;
|
---|
85 | $this->xoops_db_user = XOOPS_DB_USER;
|
---|
86 | $this->xoops_db_pass = XOOPS_DB_PASS;
|
---|
87 | $this->xoops_db_host = XOOPS_DB_HOST;
|
---|
88 | if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = '';
|
---|
89 | if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = '';
|
---|
90 |
|
---|
91 | // define from /settings/definition.inc.php (XCL) or /include/common.php(2016a-JP)
|
---|
92 | $this->xoops_upload_path = $this->xoops_root_path .'/uploads';
|
---|
93 | $this->xoops_upload_url = $this->xoops_url . '/uploads';
|
---|
94 | $this->module_db_prefix = $this->xoops_db_prefix . '_' . preg_replace('/wordpress/','wp',$this->module_name) . '_';
|
---|
95 |
|
---|
96 | $this->set_module_version();
|
---|
97 | $this->set_wp_version();
|
---|
98 | if (function_exists('date_default_timezone_get')){
|
---|
99 | $this->xoops_time_zone = date_default_timezone_get();
|
---|
100 | }
|
---|
101 | $this->_get_cache_path();
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | // call after the $this->xoops_trust_path is set
|
---|
106 | function _get_cache_path(){
|
---|
107 | $cache_path = $this->xoops_trust_path . '/cache';
|
---|
108 | if (file_exists($cache_path) && is_writable($cache_path)){
|
---|
109 | $this->xoops_cache_path = $cache_path;
|
---|
110 | return;
|
---|
111 | }
|
---|
112 | $this->xoops_cache_path = $this->xoops_root_path . '/cache';
|
---|
113 | }
|
---|
114 |
|
---|
115 | function get_xoops_mainfile_path(){
|
---|
116 | return dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php';
|
---|
117 | }
|
---|
118 |
|
---|
119 | // set XPressME module virsion and codename from xoops_versions.php
|
---|
120 | function set_module_version(){
|
---|
121 | $xoops_version_file = dirname(dirname(__FILE__)) . '/xoops_version.php';
|
---|
122 | if(file_exists($xoops_version_file)){
|
---|
123 | $version_file = file($xoops_version_file);
|
---|
124 | $version_pattern = '^\s*(\$modversion\[\s*\'version\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';
|
---|
125 | $codename_pattern = '^\s*(\$modversion\[\s*\'codename\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';
|
---|
126 | $version_found = false;
|
---|
127 | $codename_found = false;
|
---|
128 | for ($i = 0 ; $i <count($version_file) ; $i++){
|
---|
129 | if (preg_match( "/$version_pattern/", $version_file[$i] ,$v_matches )){
|
---|
130 | $this->module_version = $v_matches[2];
|
---|
131 | $version_found = true;
|
---|
132 | }
|
---|
133 | if (preg_match( "/$codename_pattern/", $version_file[$i] ,$c_matches )){
|
---|
134 | $this->module_codename = $c_matches[2];
|
---|
135 | $codename_found = true;
|
---|
136 | }
|
---|
137 | if ( $version_found && $codename_found ) break;
|
---|
138 | }
|
---|
139 | }
|
---|
140 | }
|
---|
141 |
|
---|
142 | function set_wp_version(){
|
---|
143 | include dirname(dirname(__FILE__)) . '/wp-includes/version.php';
|
---|
144 |
|
---|
145 | $this->wp_db_version = $wp_db_version;
|
---|
146 |
|
---|
147 | $this->wp_version = str_replace("ME", "", $wp_version);
|
---|
148 |
|
---|
149 | $pattern = 'ME.*';
|
---|
150 | if (preg_match('/' . $pattern . '/' ,$wp_version)){
|
---|
151 | $this->is_wp_me = true;
|
---|
152 | } else {
|
---|
153 | $this->is_wp_me = true;
|
---|
154 | }
|
---|
155 | }
|
---|
156 |
|
---|
157 | }
|
---|
158 | ?> |
---|