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 |
|
---|
15 | class modInfo{
|
---|
16 | var $xoops_mainfile_path;
|
---|
17 | var $xoops_root_path;
|
---|
18 | var $xoops_url;
|
---|
19 | var $xoops_trust_path;
|
---|
20 | var $xoops_var_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 $module_id;
|
---|
39 | var $is_impress;
|
---|
40 | var $xoops_time_zone;
|
---|
41 |
|
---|
42 | function __constructor() //for PHP5
|
---|
43 | {
|
---|
44 | $this->xpressInfo();
|
---|
45 |
|
---|
46 | }
|
---|
47 |
|
---|
48 | function modInfo() //for PHP4 constructor
|
---|
49 | {
|
---|
50 | global $xoopsModule;
|
---|
51 |
|
---|
52 | $this->xoops_mainfile_path = dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php';
|
---|
53 | $this->module_path=dirname(dirname(__FILE__));
|
---|
54 | $this->module_name=basename($this->module_path);
|
---|
55 | $this->xoops_root_path = XOOPS_ROOT_PATH;
|
---|
56 | $this->xoops_trust_path = (defined('XOOPS_TRUST_PATH')) ? XOOPS_TRUST_PATH : '';
|
---|
57 | $this->xoops_url = XOOPS_URL;
|
---|
58 | $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
|
---|
59 | $this->xoops_upload_path = XOOPS_UPLOAD_PATH;
|
---|
60 | $this->xoops_upload_url = XOOPS_UPLOAD_URL;
|
---|
61 | $this->xoops_cache_path = XOOPS_CACHE_PATH;
|
---|
62 | $this->db_prefix = XOOPS_DB_PREFIX;
|
---|
63 | $this->module_db_prefix = $this->xoops_db_prefix . '_' . preg_replace('/wordpress/','wp',$this->module_name) . '_';
|
---|
64 | $this->db_name = XOOPS_DB_NAME;
|
---|
65 | $this->db_user = XOOPS_DB_USER;
|
---|
66 | $this->db_pass = XOOPS_DB_PASS;
|
---|
67 | $this->db_host = XOOPS_DB_HOST;
|
---|
68 | $this->xoops_db_salt = (defined('XOOPS_DB_SALT')) ? XOOPS_DB_SALT : '';
|
---|
69 | $this->xoops_salt = (defined('XOOPS_SALT')) ? XOOPS_SALT : '';
|
---|
70 | $this->xoops_lang = @$GLOBALS["xoopsConfig"]['language'];
|
---|
71 | $this->module_id =! empty($xoopsModule) ? $xoopsModule->getVar('mid') : 0;
|
---|
72 | $this->module_version = empty($xoopsModule) ? $xoopsModule->getVar('version') : '';
|
---|
73 | $module_codename = $this->_get_module_codename();
|
---|
74 | // start /admin/index.php page detect
|
---|
75 | $php_script_name = $_SERVER['SCRIPT_NAME'];
|
---|
76 | $php_query_string = $_SERVER['QUERY_STRING'];
|
---|
77 | $admin_page = basename(dirname(dirname(__FILE__))) . '/admin/index.php';
|
---|
78 | $is_xoops_module_admin = false;
|
---|
79 | if (strstr($php_script_name,$admin_page) !== false) $is_xoops_module_admin = true;
|
---|
80 | if (strstr($php_query_string,$admin_page) !== false) $is_xoops_module_admin = true;
|
---|
81 |
|
---|
82 | if (function_exists('date_default_timezone_get')){
|
---|
83 | $this->xoops_time_zone = date_default_timezone_get();
|
---|
84 | }
|
---|
85 | }
|
---|
86 |
|
---|
87 |
|
---|
88 | // get XPressME module virsion and codename from xoops_versions.php
|
---|
89 | function _get_module_codename(){
|
---|
90 | $xoops_version_file = $this->module_path . '/xoops_version.php';
|
---|
91 | if(file_exists($xoops_version_file)){
|
---|
92 | $version_file = file($xoops_version_file);
|
---|
93 | $codename_pattern = '^\s*(\$modversion\[\s*\'codename\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';
|
---|
94 | for ($i = 0 ; $i <count($version_file) ; $i++){
|
---|
95 | if (preg_match( "/$codename_pattern/", $version_file[$i] ,$c_matches )){
|
---|
96 | return $c_matches[2];
|
---|
97 | }
|
---|
98 | }
|
---|
99 | }
|
---|
100 | return '';
|
---|
101 | }
|
---|
102 |
|
---|
103 | function is_wpdb_installed(){
|
---|
104 | global $xoopsDB;
|
---|
105 | $mydirname = basename(dirname( dirname( __FILE__ ) )) ;
|
---|
106 | $prefix_mod = XOOPS_DB_PREFIX .'_' . preg_replace('/wordpress/','wp',$mydirname) . '_';
|
---|
107 | $sql = "SHOW TABLES LIKE '$prefix_mod%'";
|
---|
108 | if ($result = $xoopsDB->queryf($sql)){
|
---|
109 | if($xoopsDB->getRowsNum($result)) return true;
|
---|
110 | }
|
---|
111 | return false;
|
---|
112 | }
|
---|
113 |
|
---|
114 | function is_writeable_mode($check_file) {
|
---|
115 | if (!is_dir($check_file)) {
|
---|
116 | if ( file_exists($check_file) ) {
|
---|
117 | if (! is_writeable($check_file)) {
|
---|
118 | return false;
|
---|
119 | }
|
---|
120 | }
|
---|
121 | } else {
|
---|
122 | if (! is_writeable($check_file)) {
|
---|
123 | return false;
|
---|
124 | } else {
|
---|
125 | // Windows parmission check
|
---|
126 | $src_file = __FILE__ ;
|
---|
127 | $newfile = $check_file . 'write_check.txt';
|
---|
128 | if (!@copy($src_file, $newfile)) {
|
---|
129 | return false;
|
---|
130 | } else {
|
---|
131 | unlink($newfile);
|
---|
132 | }
|
---|
133 | }
|
---|
134 | }
|
---|
135 | return true;
|
---|
136 | }
|
---|
137 |
|
---|
138 | }
|
---|
139 | ?> |
---|