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 | require_once dirname( __FILE__ ).'/wpInfo_class.php' ;
|
---|
15 |
|
---|
16 | class xpressInfo{
|
---|
17 | var $xoops_mainfile_path;
|
---|
18 | var $xoops_root_path;
|
---|
19 | var $xoops_url;
|
---|
20 | var $xoops_trust_path;
|
---|
21 | var $xoops_cache_path;
|
---|
22 | var $xoops_upload_path;
|
---|
23 | var $xoops_upload_url;
|
---|
24 | var $xoops_db_salt;
|
---|
25 | var $xoops_salt;
|
---|
26 | var $xoops_db_prefix;
|
---|
27 | var $xoops_language;
|
---|
28 | var $module_db_prefix;
|
---|
29 | var $db_name;
|
---|
30 | var $db_user;
|
---|
31 | var $db_pass;
|
---|
32 | var $db_host;
|
---|
33 | var $module_name;
|
---|
34 | var $module_path;
|
---|
35 | var $module_url;
|
---|
36 | var $module_version;
|
---|
37 | var $module_codename;
|
---|
38 | var $is_impress;
|
---|
39 | var $module_id;
|
---|
40 | var $xoops_time_zone;
|
---|
41 | var $xoops_var_path;
|
---|
42 |
|
---|
43 | function __constructor() //for PHP5
|
---|
44 | {
|
---|
45 | $this->xpressInfo();
|
---|
46 |
|
---|
47 | }
|
---|
48 |
|
---|
49 | function xpressInfo() //for PHP4 constructor
|
---|
50 | {
|
---|
51 | $this->xoops_mainfile_path = dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php';
|
---|
52 | $this->module_path=dirname(dirname(__FILE__));
|
---|
53 | $this->module_name=basename($this->module_path);
|
---|
54 | $this->xoops_root_path = XOOPS_ROOT_PATH;
|
---|
55 | if(defined('XOOPS_TRUST_PATH')) $this->xoops_trust_path = XOOPS_TRUST_PATH; else $this->xoops_trust_path = '';
|
---|
56 | $this->xoops_url = XOOPS_URL;
|
---|
57 | $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
|
---|
58 | $this->xoops_upload_path = XOOPS_UPLOAD_PATH;
|
---|
59 | $this->xoops_upload_url = XOOPS_UPLOAD_URL;
|
---|
60 | $this->xoops_cache_path = XOOPS_CACHE_PATH;
|
---|
61 | $this->db_prefix = XOOPS_DB_PREFIX;
|
---|
62 | $this->module_db_prefix = $this->xoops_db_prefix . '_' . preg_replace('/wordpress/','wp',$this->module_name) . '_';
|
---|
63 | $this->db_name = XOOPS_DB_NAME;
|
---|
64 | $this->db_user = XOOPS_DB_USER;
|
---|
65 | $this->db_pass = XOOPS_DB_PASS;
|
---|
66 | $this->db_host = XOOPS_DB_HOST;
|
---|
67 | if(defined('XOOPS_DB_SALT')) $this->xoops_db_salt = XOOPS_DB_SALT; else $this->xoops_db_salt = '';
|
---|
68 | if(defined('XOOPS_SALT')) $this->xoops_salt = XOOPS_SALT; else $this->xoops_salt = '';
|
---|
69 | $this->xoops_lang = @$GLOBALS["xoopsConfig"]['language'];
|
---|
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 | $this->_get_value_by_xoops_define();
|
---|
79 | // define from /settings/definition.inc.php (XCL) or /include/common.php(2016a-JP)
|
---|
80 |
|
---|
81 | $this->set_module_version();
|
---|
82 | $this->set_wp_version();
|
---|
83 | if (function_exists('date_default_timezone_get')){
|
---|
84 | $this->xoops_time_zone = date_default_timezone_get();
|
---|
85 | }
|
---|
86 | }
|
---|
87 |
|
---|
88 | // A set value is acquired from XOOPS define value .
|
---|
89 | function _get_value_by_xoops_define(){
|
---|
90 | $wp_info = new wpInfo;
|
---|
91 | $this->wp_lang = $wp_info->get_wpLang($this->xoops_lang);
|
---|
92 |
|
---|
93 | }
|
---|
94 |
|
---|
95 |
|
---|
96 | // set XPressME module virsion and codename from xoops_versions.php
|
---|
97 | function set_module_version(){
|
---|
98 | $xoops_version_file = dirname(dirname(__FILE__)) . '/xoops_version.php';
|
---|
99 | if(file_exists($xoops_version_file)){
|
---|
100 | $version_file = file($xoops_version_file);
|
---|
101 | $version_pattern = '^\s*(\$modversion\[\s*\'version\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';
|
---|
102 | $codename_pattern = '^\s*(\$modversion\[\s*\'codename\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';
|
---|
103 | $version_found = false;
|
---|
104 | $codename_found = false;
|
---|
105 | for ($i = 0 ; $i <count($version_file) ; $i++){
|
---|
106 | if (preg_match( "/$version_pattern/", $version_file[$i] ,$v_matches )){
|
---|
107 | $this->module_version = $v_matches[2];
|
---|
108 | $version_found = true;
|
---|
109 | }
|
---|
110 | if (preg_match( "/$codename_pattern/", $version_file[$i] ,$c_matches )){
|
---|
111 | $this->module_codename = $c_matches[2];
|
---|
112 | $codename_found = true;
|
---|
113 | }
|
---|
114 | if ( $version_found && $codename_found ) break;
|
---|
115 | }
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | function set_wp_version(){
|
---|
120 | include dirname(dirname(__FILE__)) . '/wp-includes/version.php';
|
---|
121 |
|
---|
122 | $this->wp_db_version = $wp_db_version;
|
---|
123 |
|
---|
124 | $this->wp_version = str_replace("ME", "", $wp_version);
|
---|
125 |
|
---|
126 | $pattern = 'ME.*';
|
---|
127 | if (preg_match('/' . $pattern . '/' ,$wp_version)){
|
---|
128 | $this->is_wp_me = true;
|
---|
129 | } else {
|
---|
130 | $this->is_wp_me = true;
|
---|
131 | }
|
---|
132 | }
|
---|
133 |
|
---|
134 | function is_wpdb_installed(){
|
---|
135 | $mydirname = basename(dirname( dirname( __FILE__ ) )) ;
|
---|
136 | $prefix_mod = XOOPS_DB_PREFIX .'_' . preg_replace('/wordpress/','wp',$mydirname) . '_';
|
---|
137 | $xoopsDB =& Database::getInstance();
|
---|
138 | $sql = "SHOW TABLES LIKE '$prefix_mod%'";
|
---|
139 | if ($result = $xoopsDB->queryf($sql)){
|
---|
140 | if($xoopsDB->getRowsNum($result)) return true;
|
---|
141 | }
|
---|
142 | return false;
|
---|
143 | }
|
---|
144 |
|
---|
145 | function is_writeable_mode($check_file) {
|
---|
146 | if (!is_dir($check_file)) {
|
---|
147 | if ( file_exists($check_file) ) {
|
---|
148 | if (! is_writeable($check_file)) {
|
---|
149 | return false;
|
---|
150 | }
|
---|
151 | }
|
---|
152 | } else {
|
---|
153 | if (! is_writeable($check_file)) {
|
---|
154 | return false;
|
---|
155 | } else {
|
---|
156 | // Windows parmission check
|
---|
157 | $src_file = __FILE__ ;
|
---|
158 | $newfile = $check_file . 'write_check.txt';
|
---|
159 | if (!@copy($src_file, $newfile)) {
|
---|
160 | return false;
|
---|
161 | } else {
|
---|
162 | unlink($newfile);
|
---|
163 | }
|
---|
164 | }
|
---|
165 | }
|
---|
166 | return true;
|
---|
167 | }
|
---|
168 |
|
---|
169 | }
|
---|
170 | ?> |
---|