Changeset 129
- Timestamp:
- Mar 21, 2009, 2:06:50 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/config_from_xoops.class.php
r113 r129 31 31 var $xoops_upload_path; 32 32 var $xoops_upload_url; 33 var $xoops_db_salt; 34 var $is_impress; 35 var $impress_db_config_file; 33 36 34 37 … … 46 49 if(file_exists($this->xoops_mainfile_path)){ 47 50 $array_file = file($this->xoops_mainfile_path); 51 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*(\'[^\']*\'|"[^"]*"|[^\'"])\s*\)\s*;'; 52 $impress_include_pattern = '^\s*(include_once|include)\s*\(\s*XOOPS_TRUST_PATH\s*.\s*[\'"]([^\'"]+)[\'"]\s*\)'; 48 53 for ($i = 0 ; $i <count($array_file) ; $i++){ 49 /* Ref. ImpressCMS 50 51 mainfile.php 52 define( 'XOOPS_TRUST_PATH', 'C:/xampp/trust_pathf6fac' ); 53 54 include_once(XOOPS_TRUST_PATH . '/3aec9eefada2c57b3705952094b7b070.php'); 55 56 define( 'XOOPS_DB_PREFIX', SDATA_DB_PREFIX ); 57 define( 'XOOPS_DB_HOST', SDATA_DB_HOST ); 58 define( 'XOOPS_DB_USER', SDATA_DB_USER ); 59 define( 'XOOPS_DB_PASS', SDATA_DB_PASS ); 60 define( 'XOOPS_DB_NAME', SDATA_DB_NAME ); 61 define( 'XOOPS_DB_SALT', SDATA_DB_SALT ); 62 63 XOOPS_TRUST_PATH . '/3aec9eefada2c57b3705952094b7b070.php' 64 define( 'SDATA_DB_HOST', 'localhost' ); 65 define( 'SDATA_DB_USER', 'root' ); 66 define( 'SDATA_DB_PASS', '' ); 67 define( 'SDATA_DB_NAME', 'impress' ); 68 define( 'SDATA_DB_PREFIX', 'id85d03cc' ); 69 define( 'SDATA_DB_SALT', '3mhUHMrsTU3CTifQbenOtK1ULG5QN2Dwx8zCfwtynudub4TS9AnmZAhmdQr43Uvot' ); 70 71 ref. code C:\xampp\htdocs\impress\install\page_configsave.php 72 $sdata_rewrite = array(); 73 $sdata_rewrite['DB_HOST'] = $vars['DB_HOST']; 74 $sdata_rewrite['DB_USER'] = $vars['DB_USER']; 75 $sdata_rewrite['DB_PASS'] = $vars['DB_PASS']; 76 $sdata_rewrite['DB_NAME'] = $vars['DB_NAME']; 77 $sdata_rewrite['DB_PREFIX'] = $vars['DB_PREFIX']; 78 $sdata_rewrite['DB_SALT'] = $vars['DB_SALT']; 79 80 81 foreach( $sdata_rewrite as $key => $val ) { 82 if( preg_match( "/(define\()([\"'])(SDATA_$key)\\2,\s*([\"'])(.*?)\\4\s*\)/", $content ) ) { 83 $val = addslashes( $val ); 84 $content = preg_replace( "/(define\()([\"'])(SDATA_$key)\\2,\s*([\"'])(.*?)\\4\s*\)/", 85 "define( 'SDATA_$key', '$val' )", $content ); 86 } else { 87 //$this->error = true; 88 //$this->report .= _NGIMG.sprintf( ERR_WRITING_CONSTANT, "<b>$val</b>")."<br />\n"; 89 } 90 } 91 */ 92 93 $array_file[$i] = trim($array_file[$i]); 94 $array_file[$i] = str_replace(' ','',$array_file[$i]); 95 96 $array_file[$i] = preg_replace('/\s\s+/', '', $array_file[$i]); 97 $array_file[$i] = preg_replace('/^include.*/','',$array_file[$i]); 98 $array_file[$i] = preg_replace('/^\/\/.*/','',$array_file[$i]); 99 $array_file[$i] = preg_replace('/^if.*/','',$array_file[$i]); 100 if (strstr($array_file[$i],'define')!== false){ 101 $array_file[$i] = preg_replace('/\"/', '', $array_file[$i]); 102 $array_file[$i] = preg_replace('/\(/', '', $array_file[$i]); 103 $array_file[$i] = preg_replace('/\)/', '', $array_file[$i]); 104 $array_file[$i] = preg_replace('/\;/', '', $array_file[$i]); 105 $array_file[$i] = preg_replace('/\'/', '', $array_file[$i]); 106 $array_file[$i] = preg_replace('/define/', '', $array_file[$i]); 107 $define = explode(',',$array_file[$i] ); 108 $define[0] = trim($define[0]); 109 $define[1] = trim($define[1]); 110 switch ($define[0]){ 54 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 55 $keys = $matchs[1]; 56 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 57 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 58 $key_value = $matchs[2]; 59 if (preg_match('/^\'[^\']*\'$/',$key_value)) $key_value = preg_replace('/\'/', '', $key_value); 60 if (preg_match('/^"[^"]*"$/',$key_value)) $key_value = preg_replace('/"/', '', $key_value); 61 switch ($keys){ 111 62 case 'XOOPS_ROOT_PATH': 112 $this->xoops_root_path = $ define[1];63 $this->xoops_root_path = $key_value; 113 64 $this->xoops_url . '/modules/' . $this->module_name; 114 65 break; 115 66 case 'XOOPS_URL': 116 $this->xoops_url = $ define[1];67 $this->xoops_url = $key_value; 117 68 $this->module_url = $this->xoops_url . '/modules/' . $this->module_name; 118 69 break; 119 70 case 'XOOPS_TRUST_PATH': 120 $this->xoops_trust_path = $ define[1];71 $this->xoops_trust_path = $key_value; 121 72 break; 122 73 case 'XOOPS_DB_PREFIX': 123 $this->xoops_db_prefix = $ define[1];74 $this->xoops_db_prefix = $key_value; 124 75 break; 125 76 case 'XOOPS_DB_NAME': 126 $this->xoops_db_name = $ define[1];77 $this->xoops_db_name = $key_value; 127 78 break; 128 79 case 'XOOPS_DB_USER': 129 $this->xoops_db_user = $ define[1];80 $this->xoops_db_user = $key_value; 130 81 break; 131 82 case 'XOOPS_DB_PASS': 132 $this->xoops_db_pass = $ define[1];83 $this->xoops_db_pass = $key_value; 133 84 break; 134 85 case 'XOOPS_DB_HOST': 135 $this->xoops_db_host = $define[1]; 86 $this->xoops_db_host = $key_value; 87 break; 88 case 'XOOPS_DB_SALT': 89 $this->xoops_db_salt = $key_value; 136 90 break; 137 91 default : 92 93 } // end of switch 94 } // end of if preg_match 95 96 // Check ImpressCMS 97 if (preg_match('/' . $impress_include_pattern . '/' ,$array_file[$i],$impres_matchs)){ 98 $this->is_impress = true; 99 $this->impress_db_config_file = $this->xoops_trust_path . $impres_matchs[2]; 100 } 101 } // end of for loop 102 } // end of if file_exists 103 104 // DB Config from Impress CMS impress_db_config file 105 if ($this->is_impress){ 106 if(file_exists($this->impress_db_config_file)){ 107 $array_file = file($this->impress_db_config_file); 108 $pattern = '^\s*define\s*\(\s*(\'[^\']+\'|"[^"]+")\s*,\s*(\'[^\']*\'|"[^"]*"|[^\'"])\s*\)\s*;'; 109 for ($i = 0 ; $i <count($array_file) ; $i++){ 110 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 111 $keys = $matchs[1]; 112 if (preg_match('/^\'[^\']*\'$/',$keys)) $keys = preg_replace('/\'/', '', $keys); 113 if (preg_match('/^"[^"]*"$/',$keys)) $keys = preg_replace('/"/', '', $keys); 114 $key_value = $matchs[2]; 115 if (preg_match('/^\'[^\']*\'$/',$key_value)) $key_value = preg_replace('/\'/', '', $key_value); 116 if (preg_match('/^"[^"]*"$/',$key_value)) $key_value = preg_replace('/"/', '', $key_value); 117 switch ($keys){ 118 case 'SDATA_DB_SALT': 119 $this->xoops_db_salt = $key_value; 120 break; 121 case 'SDATA_DB_PREFIX': 122 $this->xoops_db_prefix = $key_value; 123 break; 124 case 'SDATA_DB_NAME': 125 $this->xoops_db_name = $key_value; 126 break; 127 case 'SDATA_DB_USER': 128 $this->xoops_db_user = $key_value; 129 break; 130 case 'SDATA_DB_PASS': 131 $this->xoops_db_pass = $key_value; 132 break; 133 case 'SDATA_DB_HOST': 134 $this->xoops_db_host = $key_value; 135 break; 136 default : 137 138 } // end of switch 138 139 } 139 } 140 } // end of for 140 141 } 141 142 } 142 143 143 144 // define from /settings/definition.inc.php (XCL) or /include/common.php(2016a-JP) 144 145 $this->xoops_upload_path = $this->xoops_root_path .'/uploads'; … … 163 164 if(file_exists($xoops_version_file)){ 164 165 $version_file = file($xoops_version_file); 165 $version_pattern = ' (\$modversion\[\s*\'version\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';166 $codename_pattern = ' (\$modversion\[\s*\'codename\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]';166 $version_pattern = '^\s*(\$modversion\[\s*\'version\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]'; 167 $codename_pattern = '^\s*(\$modversion\[\s*\'codename\'\s*\])\s*=\s*[\'"]([^\'"]*)[\'"]'; 167 168 $version_found = false; 168 169 $codename_found = false;
Note: See TracChangeset
for help on using the changeset viewer.