Changeset 488 for branches/XPressMU/xpressme_integration_kit/include
- Timestamp:
- Dec 15, 2009, 4:52:57 PM (15 years ago)
- Location:
- branches/XPressMU/xpressme_integration_kit/include
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/XPressMU/xpressme_integration_kit/include/add_xpress_process.php
r451 r488 7 7 } 8 8 9 function safe_site_url(){ 10 global $xoops_config; 11 12 if (is_xpress_index_page_call()){ 13 $siteurl = get_option('siteurl'); 14 $home = get_option('home'); 15 $module_url = $xoops_config->module_url; 16 $module_name = $xoops_config->module_name; 17 $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; 18 $guess_url = preg_replace('|/' . $module_name . '/.*|i', '/' . $module_name, $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 19 20 if(strcmp($siteurl,$module_url) !== 0) { 21 if (!@fclose(@fopen($siteurl . '/xoops_version.php', "r"))){ 22 update_option('siteurl' , $module_url); 23 } 24 } 25 26 if(strcmp($guess_ur,$home) !== 0) { 27 if (@fclose(@fopen($guess_url . '/xoops_version.php', "r"))){ 28 update_option('home' , $guess_url); 29 } 30 } 31 } 32 } 33 9 34 require_once( dirname( __FILE__ ).'/request_url.php'); 10 35 if (is_xpress_index_page_call()){ 36 //$_SERVER['REQUEST_METHOD'] = 'POST' is 11 37 //When notifying by a private message, Notification_reserve_send(); 12 38 //it is evaded that the data base becomes read-only as a result of the check on the referrer and the method. 39 $request_method = (isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] : ''; 13 40 $_SERVER['REQUEST_METHOD'] = 'POST'; 41 require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php. 42 $_SERVER['REQUEST_METHOD'] = $request_method; 43 44 unset($offset); //This Trap is provides the case where $offset is defined on the XOOPS side. 45 require_once(ABSPATH.'wp-settings.php'); 46 47 //When it is not possible to connect it correctly at site home URL on the WordPress side, 48 //URL is corrected based on accessed URL. 49 safe_site_url(); 14 50 15 require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php.16 unset($offset);17 require_once(ABSPATH.'wp-settings.php');18 51 if (!is_object($xoopsUser)){ // before login auth cookie clear 19 52 wp_logout(); -
branches/XPressMU/xpressme_integration_kit/include/general_functions.php
r423 r488 126 126 $table_list = array(); 127 127 $ret = array(); 128 $pattern = $wp_prefix . $table_name . '|' . $wp_prefix . '[0-9]*_' . $table_name; 129 128 130 if (!empty($wp_prefix) && !empty($table_name)){ 129 131 $sql = "SHOW TABLES LIKE '" . $wp_prefix . '%' . $table_name . "'"; … … 132 134 if($result = $xoopsDB->queryF($sql)){ 133 135 while($row = $xoopsDB->fetchRow($result)){ 134 $table_list[] = $row[0]; 136 if(preg_match('/' . $pattern . '/' , $row[0])){ 137 $table_list[] = $row[0]; 138 } 135 139 } 136 140 } … … 138 142 $rows = $xoops_db->get_results($sql, ARRAY_N); 139 143 foreach ($rows as $row){ 140 $table_list[] = $row[0]; 144 if(preg_match('/' . $pattern . '/' , $row[0])){ 145 $table_list[] = $row[0]; 146 } 141 147 } 142 148 } -
branches/XPressMU/xpressme_integration_kit/include/oninstall.php
r428 r488 45 45 46 46 //xpress 47 global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles, $wp_query ;47 global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles, $wp_query,$wp_embed; 48 48 global $xoops_config; 49 49 -
branches/XPressMU/xpressme_integration_kit/include/onupdate.php
r428 r488 42 42 $site_url= XOOPS_URL."/modules/".$mydirname; 43 43 xpress_put_siteurl($mydirname,$site_url); 44 xpress_put_home($mydirname,$site_url); 45 44 $home = get_xpress_option($mydirname,'home'); 45 $home_check = 'home option is right'; 46 if (strcmp($site_url,$home) !== 0 ){ 47 if (!@fclose(@fopen($home . '/xoops_version.php', "r"))){ 48 xpress_put_home($mydirname,$site_url); 49 $home_check = 'Change home option $home to $site_url'; 50 } 51 } 52 $msgs[] = $home_check; 46 53 // XPressME orignal table update 47 54 $t_mess = xpress_table_make($module , $mydirname); … … 50 57 // make templates 51 58 include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ; 59 $mod_version = $module->getVar('version') ; 60 61 $t_mess = xpress_clean_templates_file($mydirname,$mod_version); 62 $msgs = array_merge($msgs,$t_mess); 63 52 64 $t_mess = xpress_templates_make($mid,$mydirname); 53 54 65 $msgs = array_merge($msgs,$t_mess); 55 66 … … 97 108 endif; 98 109 110 if( ! function_exists( 'get_xpress_option' ) ) { 111 function get_xpress_option($mydirname,$option_name){ 112 global $xoopsModule; 113 $wp_prefix = $mydirname; 114 if ($wp_prefix == 'wordpress'){ 115 $wp_prefix = 'wp'; 116 } 117 $xoopsDB =& Database::getInstance(); 118 $option_table = $xoopsDB->prefix($wp_prefix . '_options'); 119 120 $sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'"; 121 122 $result = $xoopsDB->query($sql, 0, 0); 123 if ($xoopsDB->getRowsNum($result) > 0){ 124 $row = $xoopsDB->fetchArray($result); 125 return $row['option_value']; 126 } 127 return 0; 128 } 129 } 99 130 100 131 if( ! function_exists( 'xpress_message_append_onupdate' ) ) : … … 190 221 $db->queryF( $queries ) ; 191 222 $msgs[] = "$views_table ADD blog_id ."; 223 } 224 225 // The table is repaired. 226 $non_blogid_sql ="SELECT * FROM $views_table WHERE blog_id IS NULL OR blog_id < 1"; 227 $non_blogid_res = $db->query($non_blogid_sql, 0, 0); 228 while($row = $db->fetchArray($non_blogid_res)){ 229 $total_view = $row['post_views']; 230 $post_id = $row['post_id']; 231 $new_blogid_sql ="SELECT SUM(post_views) as post_views_sum FROM $views_table WHERE post_id = $post_id AND blog_id = 1 GROUP BY post_id"; 232 $new_blogid_res = $db->query($new_blogid_sql, 0, 0); 233 if ($db->getRowsNum($new_blogid_res) > 0){ 234 $new_row = $db->fetchArray($new_blogid_res); 235 $total_view = $total_view + $new_row['post_views_sum']; 236 $del_sql = "DELETE FROM $views_table WHERE post_id = $post_id AND blog_id = 1"; 237 $db->queryF( $del_sql ) ; 238 } 239 $update_sql = "UPDATE $views_table SET post_views = $total_view , blog_id = 1 WHERE post_id = $post_id AND (blog_id IS NULL OR blog_id < 1)"; 240 $db->queryF( $update_sql ) ; 192 241 } 193 242 } -
branches/XPressMU/xpressme_integration_kit/include/set_cash_cookie_path.php
r232 r488 8 8 */ 9 9 if ( !defined('USER_COOKIE') ) 10 define('USER_COOKIE', $modname . 'user_' . $hash);10 define('USER_COOKIE', 'wordpress_' . $modname . '_user_' . $hash); 11 11 12 12 /** … … 15 15 */ 16 16 if ( !defined('PASS_COOKIE') ) 17 define('PASS_COOKIE', $modname . 'pass_' . $hash);17 define('PASS_COOKIE', 'wordpress_' . $modname . '_pass_' . $hash); 18 18 19 19 /** … … 22 22 */ 23 23 if ( !defined('AUTH_COOKIE') ) 24 define('AUTH_COOKIE', $modname . '_auth_' . $hash);24 define('AUTH_COOKIE', 'wordpress_' . $modname . '_auth_' . $hash); 25 25 26 26 /** … … 29 29 */ 30 30 if ( !defined('SECURE_AUTH_COOKIE') ) 31 define('SECURE_AUTH_COOKIE', $modname . '_sec_' . $hash);31 define('SECURE_AUTH_COOKIE', 'wordpress_' . $modname . '_sec_' . $hash); 32 32 33 33 /** … … 36 36 */ 37 37 if ( !defined('LOGGED_IN_COOKIE') ) 38 define('LOGGED_IN_COOKIE', $modname . '_logged_in_' . $hash);38 define('LOGGED_IN_COOKIE', 'wordpress_' . $modname . '_logged_in_' . $hash); 39 39 40 40 /** … … 43 43 */ 44 44 if ( !defined('TEST_COOKIE') ) 45 define('TEST_COOKIE', $modname . '_test_cookie');45 define('TEST_COOKIE', 'wordpress_' . $modname . '_test_cookie'); 46 46 47 47 /** -
branches/XPressMU/xpressme_integration_kit/include/xpress_block_render.php
r451 r488 29 29 $ret = @xpress_XML_unserialize($xml_data); 30 30 if (strstr($xml_data, '<?xml version="1.0" encoding="EUC-JP" ?>') !== false){ 31 $ans = mb_convert_variables('EUC-JP' , 'UTF-8', &$ret); 31 if (version_compare(PHP_VERSION, '5.0.0', '>')) { 32 $ans = mb_convert_variables('EUC-JP' , 'UTF-8', &$ret); //xpress_XML_unserialize() Return UTF-8 at PHP5 33 } 32 34 } 33 35 return $ret; … … 52 54 } 53 55 return $block_id; 56 } 57 58 function get_block_mid($mydirname) 59 { 60 $xoopsDB =& Database::getInstance(); 61 $modules_tbl = $xoopsDB->prefix('modules'); 62 63 $sql = "SELECT mid FROM $modules_tbl WHERE dirname = '$mydirname'"; 64 $result = $xoopsDB->query($sql, 0, 0); 65 if ($xoopsDB->getRowsNum($result) > 0){ 66 $row = $xoopsDB->fetchArray($result); 67 $mid = $row['mid']; 68 } 69 return $mid; 54 70 } 55 71 … … 160 176 function xpress_block_render($mydirname,$block_function_name,$options) 161 177 { 162 global $wpdb ;178 global $wpdb,$xoops_config; 163 179 $func_file = $block_function_name; 164 180 $call_theme_function_name = str_replace(".php", "", $block_function_name); … … 167 183 $blockID =get_block_id($mydirname,$func_file,$options); 168 184 169 $this_ url = '/modules/'. $mydirname;185 $this_block_url = '/' . $mydirname . '/'; 170 186 $call_url = $_SERVER['REQUEST_URI']; 171 187 172 188 xpress_block_css_set($mydirname); 173 if (strstr($call_url ,$this_url)){189 if (strstr($call_url , $this_block_url) !== false){ 174 190 $block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name); 175 191 require_once $block_theme_file['file_path']; … … 185 201 } 186 202 } 187 188 $templates_file = 'db:'.$mydirname. '_' . str_replace(".php", ".html", $block_function_name); 203 $temp_option = explode(':' , $options[1]); 204 205 if (isset($temp_option[1])) { 206 $templates_file = $temp_option[1]; 207 } else { 208 $templates_file = 'db:'.$mydirname. '_' . str_replace(".php", ".html", $block_function_name); 209 } 210 189 211 $tpl =& new XoopsTpl() ; 212 $tpl->template_dir = $xoops_config->module_path . '/templates'; 213 if (!$tpl->template_exists($templates_file)){ 214 $src_file_path = $xoops_config->module_path . '/templates/' .$mydirname. '_' . str_replace(".php", ".html", $block_function_name); 215 $templates_file = add_xpress_tpl($mydirname,$templates_file,$src_file_path); 216 } 190 217 $tpl->assign( 'block' , $block ) ; 191 218 $ret['content'] = $tpl->fetch( $templates_file ) ; 192 219 return $ret ; 220 } 221 222 function add_xpress_tpl($mydirname,$templates='',$src_file_path){ 223 global $wpdb,$xoops_config , $xoops_db; 224 225 $mid = get_block_mid($mydirname); 226 227 $temp_parm = explode(':' , $templates); 228 if (empty($temp_parm[1])) { 229 $filename=$temp_parm[0]; 230 $type = 'db'; 231 } else { 232 $filename=$temp_parm[1]; 233 $type = $temp_parm[0]; 234 } 235 $temp_file_path = $xoops_config->module_path . '/templates/'. $filename; 236 $pattern = '^' . $mydirname . '_'; 237 if (preg_match('/' . $pattern . '/' , $filename, $match)){ // file prefix check 238 if (!file_exists($temp_file_path)){ // Repetition check 239 if (file_exists($src_file_path)){ // source file check 240 $rcd = copy($src_file_path, $temp_file_path); 241 } 242 } 243 return 'file:' . $filename; 244 } 245 return $templates; 193 246 } 194 247 … … 243 296 { 244 297 global $xoops_db,$xoops_config; 298 245 299 $mid = get_xpress_modid(); 246 300 $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid AND visible = 1"; … … 260 314 if ($dh = opendir($cache_dir)) { 261 315 while (($file = readdir($dh)) !== false) { 262 if (preg_match('/^' . preg_quote($mydirname) . ' /', $file)) {316 if (preg_match('/^' . preg_quote($mydirname) . '_/', $file)) { 263 317 if(! preg_match('/' . $pattern . '/', $file)) { 264 318 unlink($cache_dir.$file); … … 287 341 return $xu_row['conf_value']; 288 342 } 289 } 290 343 } 291 344 } 292 345 ?> -
branches/XPressMU/xpressme_integration_kit/include/xpress_templates_make.php
r384 r488 7 7 $tplfile_handler =& xoops_gethandler( 'tplfile' ) ; 8 8 $tpl_path = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/templates' ; 9 10 //copy template file from source 9 11 if( $handler = @opendir( $tpl_path . '/source/' ) ) { 10 12 while( ( $file = readdir( $handler ) ) !== false ) { … … 26 28 $msgs[] = '<span style="color:#ff0000;">ERROR: Could not copy template <b>'.htmlspecialchars($target_file_name).'</b> from ' . htmlspecialchars($file). '(check templates directory permision (777))</span><br />'; 27 29 } 28 $tplfile =& $tplfile_handler->create() ; 29 if ($rcd) { 30 $mtime = intval( @filemtime( $target_file_path ) ) ; 31 $tplfile->setVar( 'tpl_source' , file_get_contents( $target_file_path ) , true ) ; 32 } else { 33 $mtime = intval( @filemtime( $file_path ) ) ; 34 $tplfile->setVar( 'tpl_source' , file_get_contents( $file_path ) , true ) ; 35 } 36 37 $tplfile->setVar( 'tpl_refid' , $mid ) ; 38 $tplfile->setVar( 'tpl_tplset' , 'default' ) ; 39 $tplfile->setVar( 'tpl_file' , $target_file_name ) ; 40 $tplfile->setVar( 'tpl_desc' , '' , true ) ; 41 $tplfile->setVar( 'tpl_module' , $mydirname ) ; 42 $tplfile->setVar( 'tpl_lastmodified' , $mtime ) ; 43 $tplfile->setVar( 'tpl_lastimported' , 0 ) ; 44 $tplfile->setVar( 'tpl_type' , 'module' ) ; 45 if( ! $tplfile_handler->insert( $tplfile ) ) { 46 $msgs[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>'.htmlspecialchars($target_file_name).'</b> to the database.</span><br />'; 47 } else { 48 $tplid = $tplfile->getVar( 'tpl_id' ) ; 49 $msgs[] = 'Template <b>'.htmlspecialchars($target_file_name) .'</b> added to the database. (ID: <b>'.$tplid.'</b>)<br />'; 50 // generate compiled file 51 include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ; 52 include_once XOOPS_ROOT_PATH.'/class/template.php' ; 53 if( ! xoops_template_touch( $tplid ) ) { 54 $msgs[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars($target_file_name).'</b>.</span><br />'; 55 } else { 56 $msgs[] = 'Template <b>'.htmlspecialchars($target_file_name).'</b> compiled.</span><br />'; 57 } 30 } 31 } 32 closedir( $handler ) ; 33 } 34 35 // template added to the database. 36 if( $handler = @opendir( $tpl_path . '/' ) ) { 37 while( ( $file = readdir( $handler ) ) !== false ) { 38 if( substr( $file , 0 , 1 ) == '.' ) continue ; 39 $file_path = $tpl_path . '/' . $file ; 40 $file_name = $file ; 41 $pattern = '^' . $mydirname . '_'; 42 if (preg_match('/' . $pattern . '/' , $file_name, $match)){ 43 if( is_file( $file_path ) ) { 44 $msgs[] = xpress_create_db_template($file_name,$file_path,$mydirname,$mid); 58 45 } 59 46 } … … 61 48 closedir( $handler ) ; 62 49 } 50 63 51 include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ; 64 52 include_once XOOPS_ROOT_PATH.'/class/template.php' ; … … 68 56 } 69 57 58 function xpress_create_db_template($file_name,$file_path,$mydirname,$mid){ 59 if( is_file( $file_path ) ) { 60 $tplfile_handler =& xoops_gethandler( 'tplfile' ) ; 61 $tplfile =& $tplfile_handler->create() ; 62 $mtime = intval( @filemtime( $file_path ) ) ; 63 $tplfile->setVar( 'tpl_source' , file_get_contents( $file_path ) , true ) ; 64 $tplfile->setVar( 'tpl_refid' , $mid ) ; 65 $tplfile->setVar( 'tpl_tplset' , 'default' ) ; 66 $tplfile->setVar( 'tpl_file' , $file_name ) ; 67 $tplfile->setVar( 'tpl_desc' , '' , true ) ; 68 $tplfile->setVar( 'tpl_module' , $mydirname ) ; 69 $tplfile->setVar( 'tpl_lastmodified' , $mtime ) ; 70 $tplfile->setVar( 'tpl_lastimported' , 0 ) ; 71 $tplfile->setVar( 'tpl_type' , 'module' ) ; 72 if( ! $tplfile_handler->insert( $tplfile ) ) { 73 $msg = '<span style="color:#ff0000;">ERROR: Template Could not added to the database. <b>'.htmlspecialchars($file_name).'</b> to the database.</span><br />'; 74 } else { 75 $tplid = $tplfile->getVar( 'tpl_id' ) ; 76 $msg = 'Template <b>'.htmlspecialchars($file_name) .'</b> added to the database. (ID: <b>'.$tplid.'</b>)<br />'; 77 // generate compiled file 78 include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ; 79 include_once XOOPS_ROOT_PATH.'/class/template.php' ; 80 if( ! xoops_template_touch( $tplid ) ) { 81 $msg = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars($file_name).'</b>.</span><br />'; 82 } else { 83 $msg = 'Template <b>'.htmlspecialchars($file_name).'</b> compiled.</span><br />'; 84 } 85 } 86 } 87 return $msg; 88 } 70 89 71 90 function is_template($file_name){ … … 96 115 } 97 116 117 function xpress_clean_templates_file($mydirname,$mod_version) 118 { 119 $tpl_path = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/templates/' ; 120 $msgs = array(); 121 if( $handler = @opendir( $tpl_path) ) { 122 while( ( $file = readdir( $handler ) ) !== false ) { 123 if( substr( $file , 0 , 1 ) == '.' ) continue ; 124 if ( strcmp($file,'source')==0 ) continue ; 125 if ( strcmp($file,'index.html')==0 ) continue ; 126 $target_file_path = $tpl_path . $file; 127 if (is_dir($target_file_path)){ 128 rmDirectory($target_file_path); 129 $msgs[] = 'Template <b>'.htmlspecialchars($file).'</b> directory deleted.</span><br />'; 130 } else { 131 if ($mod_version >= 200){ 132 $pattern = '^' . $mydirname . '_'; 133 if (preg_match('/' . $pattern . '/' , $file, $match)) continue ; 134 } 135 $rcd = @unlink($target_file_path); 136 $msgs[] = 'Template <b>'.htmlspecialchars($file).'</b> file deleted.</span><br />'; 137 } 138 } 139 closedir( $handler ) ; 140 } 141 return $msgs; 142 } 143 144 function rmDirectory($dir){ 145 if ($handle = opendir("$dir")){ 146 while (false !== ($item = readdir($handle))){ 147 if ($item != "." && $item != ".."){ 148 if (is_dir("$dir/$item")){ 149 rmDirectory("$dir/$item"); 150 }else{ 151 unlink("$dir/$item"); 152 } 153 } 154 } 155 closedir($handle); 156 rmdir($dir); 157 } 158 } 98 159 99 160 ?>
Note: See TracChangeset
for help on using the changeset viewer.