[747] | 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 |
|
---|
[757] | 11 | if (defined( 'XOOPS_MAINFILE_INCLUDED')) :
|
---|
[747] | 12 |
|
---|
[757] | 13 | class modInfoClass {
|
---|
[747] | 14 | var $xoops_mainfile_path;
|
---|
| 15 | var $xoops_root_path;
|
---|
| 16 | var $xoops_url;
|
---|
| 17 | var $xoops_trust_path;
|
---|
[755] | 18 | var $xoops_var_path;
|
---|
[747] | 19 | var $xoops_cache_path;
|
---|
| 20 | var $xoops_upload_path;
|
---|
| 21 | var $xoops_upload_url;
|
---|
| 22 | var $xoops_db_salt;
|
---|
| 23 | var $xoops_salt;
|
---|
| 24 | var $xoops_db_prefix;
|
---|
| 25 | var $xoops_language;
|
---|
| 26 | var $module_db_prefix;
|
---|
| 27 | var $module_name;
|
---|
| 28 | var $module_path;
|
---|
| 29 | var $module_url;
|
---|
| 30 | var $module_version;
|
---|
| 31 | var $module_codename;
|
---|
[755] | 32 | var $module_id;
|
---|
[757] | 33 | var $xoops_version;
|
---|
| 34 | var $is_impress_cms;
|
---|
| 35 | var $is_cube_legacy;
|
---|
| 36 | var $is_xoops2jp;
|
---|
| 37 | var $is_xoops2;
|
---|
| 38 | var $is_xoops_legacy;
|
---|
| 39 | var $is_jpex;
|
---|
[747] | 40 | var $xoops_time_zone;
|
---|
[757] | 41 | var $wp_version;
|
---|
| 42 | var $wpConfigInfo;
|
---|
[747] | 43 |
|
---|
| 44 | function __constructor() //for PHP5
|
---|
| 45 | {
|
---|
[757] | 46 | $this->modInfoClass();
|
---|
[747] | 47 |
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[757] | 50 | function modInfoClass() //for PHP4 constructor
|
---|
[747] | 51 | {
|
---|
[757] | 52 | global $xoopsModule,$wpConfigInfo;
|
---|
| 53 | if (is_object($wpConfigInfo)){
|
---|
| 54 | include_once dirname(__FILE__).'/wpConfigInfo_class.php';
|
---|
| 55 | $this->wpConfigInfo = new wpConfigInfoClass;
|
---|
| 56 | }
|
---|
[747] | 57 | $this->xoops_root_path = XOOPS_ROOT_PATH;
|
---|
[755] | 58 | $this->xoops_trust_path = (defined('XOOPS_TRUST_PATH')) ? XOOPS_TRUST_PATH : '';
|
---|
[747] | 59 | $this->xoops_url = XOOPS_URL;
|
---|
[757] | 60 | $this->xoops_mainfile_path = XOOPS_ROOT_PATH . '/mainfile.php';
|
---|
[747] | 61 | $this->xoops_upload_path = XOOPS_UPLOAD_PATH;
|
---|
| 62 | $this->xoops_upload_url = XOOPS_UPLOAD_URL;
|
---|
| 63 | $this->xoops_cache_path = XOOPS_CACHE_PATH;
|
---|
[757] | 64 | $this->module_path=dirname(dirname(__FILE__));
|
---|
| 65 | $this->module_name=basename($this->module_path);
|
---|
| 66 | $this->module_url = $this->xoops_url . '/modules/' . $this->module_name;
|
---|
| 67 | $this->xoops_db_prefix = XOOPS_DB_PREFIX . '_';
|
---|
| 68 | $this->module_db_prefix = $this->_get_module_db_prefix();
|
---|
[747] | 69 | $this->xoops_lang = @$GLOBALS["xoopsConfig"]['language'];
|
---|
[776] | 70 | $this->module_id = ! empty($xoopsModule) ? $xoopsModule->getVar('mid') : 0;
|
---|
| 71 | $this->module_version = ! empty($xoopsModule) ? $xoopsModule->getVar('version')/100 : '';
|
---|
[757] | 72 | $this->module_codename = $this->_get_module_codename();
|
---|
| 73 | $this->wp_version = $this->_get_wp_version();
|
---|
[747] | 74 |
|
---|
[757] | 75 | $this->xoops_version = (defined('XOOPS_VERSION')) ? XOOPS_VERSION : '';
|
---|
| 76 | $this->_branches_cores();
|
---|
| 77 |
|
---|
[747] | 78 | if (function_exists('date_default_timezone_get')){
|
---|
| 79 | $this->xoops_time_zone = date_default_timezone_get();
|
---|
| 80 | }
|
---|
[757] | 81 |
|
---|
[747] | 82 | }
|
---|
| 83 |
|
---|
[757] | 84 | function _get_module_db_prefix(){
|
---|
| 85 | $module_db_prefix = XOOPS_DB_PREFIX . '_' . preg_replace('/wordpress/','wp',$this->module_name);
|
---|
| 86 | return $module_db_prefix;
|
---|
| 87 | }
|
---|
| 88 | function _branches_cores(){
|
---|
| 89 | /* XOOPS include/version.php define value */
|
---|
| 90 | //define("XOOPS_VERSION","XOOPS 2.0.16a JP");
|
---|
| 91 | //define("XOOPS_VERSION", "XOOPS Cube Legacy 2.2");
|
---|
| 92 | //define('XOOPS_VERSION', 'ImpressCMS 1.1.2 Final');
|
---|
| 93 | //define("XOOPS_VERSION", "XOOPS JPEx 1.6");
|
---|
| 94 | //define("XOOPS_VERSION", "XOOPS 2.3.3");
|
---|
| 95 | //define("XOOPS_VERSION", "Xoops Legacy"); define("XOOPS_ENGINE", "legacy");
|
---|
| 96 | $this->is_impress_cms = false;
|
---|
| 97 | $this->is_cube_legacy = false;
|
---|
| 98 | $this->is_xoops2jp = false;
|
---|
| 99 | $this->is_xoops2 = false;
|
---|
| 100 | $this->is_xoops_legacy = false;
|
---|
| 101 | $this->is_jpex = false;
|
---|
| 102 |
|
---|
| 103 | $version = XOOPS_VERSION;
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | // branches by cores
|
---|
| 107 | if( preg_match('/JP$/', $this->xoops_version))
|
---|
| 108 | $this->is_xoops2jp = true;
|
---|
| 109 | if( preg_match('/Cube\s*Legacy/', $this->xoops_version))
|
---|
| 110 | $this->is_cube_legacy = true;
|
---|
| 111 | if( preg_match('/ImpressCMS/', $this->xoops_version))
|
---|
| 112 | $this->is_impress_cms = true;
|
---|
| 113 | if( preg_match('/JPEx/', $this->xoops_version))
|
---|
| 114 | $this->is_jpex = true;
|
---|
| 115 | if( preg_match('/XOOPS\s*[0-9|\.]*$/', $this->xoops_version))
|
---|
| 116 | $this->is_xoops2 = true;
|
---|
| 117 | if( preg_match('/Xoops\s*Legacy/', $this->xoops_version))
|
---|
| 118 | $this->is_xoops_legacy = true;
|
---|
| 119 | }
|
---|
| 120 | function _get_wp_version(){
|
---|
| 121 | $wp_version_file = dirname(dirname(__FILE__)) . '/wp-includes/version.php';
|
---|
| 122 | if (file_exists($wp_version_file)){
|
---|
| 123 | include $wp_version_file;
|
---|
| 124 | return str_replace("ME", "", $wp_version);
|
---|
| 125 | }
|
---|
| 126 | return '';
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[755] | 129 | // get XPressME module virsion and codename from xoops_versions.php
|
---|
| 130 | function _get_module_codename(){
|
---|
| 131 | $xoops_version_file = $this->module_path . '/xoops_version.php';
|
---|
[747] | 132 | if(file_exists($xoops_version_file)){
|
---|
| 133 | $version_file = file($xoops_version_file);
|
---|
| 134 | $codename_pattern = '^\s*(\$modversion\[\s*\'codename\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';
|
---|
| 135 | for ($i = 0 ; $i <count($version_file) ; $i++){
|
---|
| 136 | if (preg_match( "/$codename_pattern/", $version_file[$i] ,$c_matches )){
|
---|
[755] | 137 | return $c_matches[2];
|
---|
[747] | 138 | }
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
[755] | 141 | return '';
|
---|
[747] | 142 | }
|
---|
[757] | 143 | function get_xoops_db_prefix(){
|
---|
| 144 | return $this->xoops_db_prefix;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | function get_xoops_root_path(){
|
---|
| 148 | return $this->xoops_root_path;
|
---|
| 149 | }
|
---|
| 150 | function get_xoops_trust_path(){
|
---|
| 151 | return $this->xoops_trust_path;
|
---|
| 152 | }
|
---|
| 153 | function get_xoops_mainfile_path(){
|
---|
| 154 | return $this->xoops_mainfile_path;
|
---|
| 155 | }
|
---|
| 156 | function get_xoops_header_path(){
|
---|
| 157 | return $this->xoops_root_path ."/header.php";
|
---|
| 158 | }
|
---|
| 159 | function get_xoops_footer_path(){
|
---|
| 160 | return $this->xoops_root_path . '/footer.php';
|
---|
| 161 | }
|
---|
| 162 | function get_xoops_cache_path(){
|
---|
| 163 | return $this->xoops_cache_path;
|
---|
| 164 | }
|
---|
| 165 | function get_xoops_url(){
|
---|
| 166 | return $this->xoops_url;
|
---|
| 167 | }
|
---|
| 168 | function get_xoops_upload_path(){
|
---|
| 169 | return $this->xoops_upload_path;
|
---|
| 170 | }
|
---|
| 171 | function get_xoops_upload_url(){
|
---|
| 172 | return $this->xoops_upload_url;
|
---|
| 173 | }
|
---|
| 174 | function get_module_path(){
|
---|
| 175 | return $this->module_path;
|
---|
| 176 | }
|
---|
| 177 | function get_module_templates_path(){
|
---|
| 178 | return $this->module_path . '/templates';
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | function get_module_name(){
|
---|
| 182 | return $this->module_name;
|
---|
| 183 | }
|
---|
| 184 | function get_module_dirname(){
|
---|
| 185 | return $this->module_name;
|
---|
| 186 | }
|
---|
| 187 | function get_module_url(){
|
---|
| 188 | return $this->module_url;
|
---|
| 189 | }
|
---|
| 190 | function get_module_db_prefix(){
|
---|
| 191 | return $this->xpress_db_prefix;
|
---|
| 192 | }
|
---|
| 193 | function get_xoops_time_zone(){
|
---|
| 194 | return $this->xoops_time_zone;
|
---|
| 195 | }
|
---|
| 196 | function get_module_version(){
|
---|
| 197 | return $this->module_version;
|
---|
| 198 | }
|
---|
| 199 | function get_module_codename(){
|
---|
| 200 | return $this->module_codename;
|
---|
| 201 | }
|
---|
| 202 | function get_wp_version(){
|
---|
| 203 | return $this->wp_version;
|
---|
| 204 | }
|
---|
| 205 | function get_module_full_version(){
|
---|
| 206 | return $this->module_version . $this->module_codename;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | function is_impress_cms(){
|
---|
| 210 | return $this->is_impress_cms;
|
---|
| 211 | }
|
---|
| 212 | function is_cube_legacy(){
|
---|
| 213 | return $this->is_cube_legacy;
|
---|
| 214 | }
|
---|
| 215 | function is_xoops2jp(){
|
---|
| 216 | return $this->is_xoops2jp;
|
---|
| 217 | }
|
---|
| 218 | function is_xoops2(){
|
---|
| 219 | return $this->is_xoops2;
|
---|
| 220 | }
|
---|
| 221 | function is_xoops_legacy(){
|
---|
| 222 | return $this->is_xoops_legacy;
|
---|
| 223 | }
|
---|
| 224 | function is_jpex(){
|
---|
| 225 | return $this->is_jpex;
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 | function get_moduleID_ByDirname($dir_name){
|
---|
| 229 | $module_handler =& xoops_gethandler('module');
|
---|
| 230 | $module =& $module_handler->getByDirname($dir_name);
|
---|
| 231 | $module_id = $module->getVar('mid');
|
---|
| 232 | }
|
---|
| 233 |
|
---|
| 234 | function get_moduleID(){
|
---|
| 235 | global $xoopsModule;
|
---|
| 236 | $module_id = $xoopsModule->getVar('mid');
|
---|
| 237 | return $module_id;
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | function get_ModuleConfig($key_name=''){
|
---|
| 241 | if (empty($key_name)) return '';
|
---|
| 242 | global $xoopsModuleConfig;
|
---|
| 243 | $value = isset($xoopsModuleConfig[$key_name]) ? $xoopsModuleConfig[$key_name] : '';
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | function get_ModuleConfig_ByDirname($dir_name,$key_name=''){
|
---|
| 247 | $mid = $this->get_moduleID_ByDirname($dir_name);
|
---|
| 248 | $conf_handler =& xoops_gethandler('config');
|
---|
| 249 | $modConfig = $conf_handler->getConfigsByCat(0, $mid);
|
---|
| 250 | if(empty($modConfig)) return '';
|
---|
| 251 | if(empty($key_name)) return $modConfig;
|
---|
| 252 | return isset($modConfig[$key_name]) ? $modConfig[$key_name] : '';
|
---|
| 253 | }
|
---|
| 254 |
|
---|
[747] | 255 | function is_wpdb_installed(){
|
---|
[749] | 256 | global $xoopsDB;
|
---|
[747] | 257 | $mydirname = basename(dirname( dirname( __FILE__ ) )) ;
|
---|
| 258 | $prefix_mod = XOOPS_DB_PREFIX .'_' . preg_replace('/wordpress/','wp',$mydirname) . '_';
|
---|
| 259 | $sql = "SHOW TABLES LIKE '$prefix_mod%'";
|
---|
| 260 | if ($result = $xoopsDB->queryf($sql)){
|
---|
| 261 | if($xoopsDB->getRowsNum($result)) return true;
|
---|
| 262 | }
|
---|
| 263 | return false;
|
---|
| 264 | }
|
---|
[757] | 265 | function is_wp_file_found()
|
---|
| 266 | {
|
---|
| 267 | if (!file_exists($this->module_path . '/wp-settings.php')){
|
---|
| 268 | return false;
|
---|
| 269 | }
|
---|
| 270 | return true;
|
---|
| 271 | }
|
---|
| 272 |
|
---|
[747] | 273 | function is_writeable_mode($check_file) {
|
---|
| 274 | if (!is_dir($check_file)) {
|
---|
| 275 | if ( file_exists($check_file) ) {
|
---|
| 276 | if (! is_writeable($check_file)) {
|
---|
| 277 | return false;
|
---|
| 278 | }
|
---|
| 279 | }
|
---|
| 280 | } else {
|
---|
| 281 | if (! is_writeable($check_file)) {
|
---|
| 282 | return false;
|
---|
| 283 | } else {
|
---|
| 284 | // Windows parmission check
|
---|
| 285 | $src_file = __FILE__ ;
|
---|
| 286 | $newfile = $check_file . 'write_check.txt';
|
---|
| 287 | if (!@copy($src_file, $newfile)) {
|
---|
| 288 | return false;
|
---|
| 289 | } else {
|
---|
| 290 | unlink($newfile);
|
---|
| 291 | }
|
---|
| 292 | }
|
---|
| 293 | }
|
---|
| 294 | return true;
|
---|
| 295 | }
|
---|
[757] | 296 | function get_php_version()
|
---|
| 297 | {
|
---|
| 298 | if (function_exists('phpversion'))
|
---|
| 299 | return phpversion();
|
---|
| 300 | else
|
---|
| 301 | return '';
|
---|
| 302 | }
|
---|
| 303 | function get_mysql_version()
|
---|
| 304 | {
|
---|
| 305 | global $xoopsDB;
|
---|
| 306 | list($SV) = $xoopsDB->fetchRow($xoopsDB->query('SELECT version()'));
|
---|
| 307 | return $SV;
|
---|
| 308 | }
|
---|
| 309 | public function get_mod_image_link($file_name='')
|
---|
| 310 | {
|
---|
| 311 | $link_url = '';
|
---|
| 312 | if(!empty($file_name)){
|
---|
| 313 | if(file_exists($this->module_path.'/images/'.$file_name)){
|
---|
| 314 | $link_url = '<img alt="'.$file_name.'" src="'. $this->mod_url .'/images/'.$file_name.'" title="'.$file_name.'" align=top>';
|
---|
| 315 | }
|
---|
| 316 | }
|
---|
| 317 | return $link_url;
|
---|
| 318 | }
|
---|
| 319 | function get_wpLang($xoops_lang=''){
|
---|
| 320 | return $this->wpConfigInfo->get_wpLang($xoops_lang);
|
---|
| 321 | }
|
---|
[747] | 322 |
|
---|
| 323 | }
|
---|
[757] | 324 | endif;
|
---|
[747] | 325 | ?> |
---|