- Timestamp:
- May 18, 2011, 9:07:23 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Ver3.0/xpressme_integration_kit/include/oninstall.php
r733 r744 22 22 { 23 23 // transations on module install 24 $mydirpath = dirname(dirname(__FILE__)); 24 25 25 26 global $ret ; // TODO :-D 27 include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/wp_installer.php' ; 28 include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ; 26 29 27 30 // for Cube 2.1 … … 39 42 40 43 if( defined( 'XOOPS_CUBE_LEGACY' ) ) { 41 $ret[] = "********************************* Install Log ********************************<br />";44 $ret[] = "********************************* Template Install Log ********************************<br />"; 42 45 } else { 43 $ret[] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;"> Install Log</h4>';46 $ret[] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">Template Install Log</h4>'; 44 47 } 45 46 //xpress 47 global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles, $wp_query,$wp_embed; 48 global $xoops_config; 49 50 define("WP_INSTALLING", true); 51 52 $site_url= XOOPS_URL."/modules/".$mydirname; 53 $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname; 54 $path = $mydirpath . '/'; 55 $site_name = ucfirst($mydirname) . ' ' . _MI_XP2_NAME; 56 57 // permission and wordpress files check 58 require_once ($path . 'include/pre_check.php'); 48 // permission and wordpress files check 49 /* 59 50 if(! xp_permission_check($mydirname, $mydirpath)){ 60 51 if( ! defined( 'XOOPS_CUBE_LEGACY' ) ) { … … 65 56 return false; 66 57 } 58 */ 59 // make templates 60 $t_mess = xpress_templates_make($mid,$mydirname); 61 $ret = array_merge($ret,$t_mess); 67 62 68 // install WordPress 69 if (file_exists($path . 'wp-load.php')) { 70 require_once $path . 'wp-load.php'; 63 if( defined( 'XOOPS_CUBE_LEGACY' ) ) { 64 $ret[] = "********************************* WordPress Install Log ********************************<br />"; 71 65 } else { 72 require_once $path . 'wp-config.php'; 73 } 74 include_once($mydirpath . '/wp-admin/upgrade-functions.php'); 75 wp_cache_flush(); 76 make_db_current_silent(); 77 $ret[] = "The data base of wordpress was made by prefix $table_prefix.<br />"; 78 79 $option_desc = __('WordPress web address'); 80 $wpdb->query("INSERT INTO $wpdb->options (blog_id, option_name,option_value, autoload) VALUES ('0', 'siteurl','$site_url', 'yes')"); 81 $wpdb->query("INSERT INTO $wpdb->options (blog_id, option_name,option_value, autoload) VALUES ('0', 'home','$site_url', 'yes')"); 82 83 populate_options(); 84 populate_roles(); 85 86 // create XPressME table 87 $xp_prefix = preg_replace('/wordpress/','wp',$mydirname); 88 $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; 89 90 $charset_collate = ''; 91 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { 92 if ( ! empty($wpdb->charset) ) 93 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 94 if ( ! empty($wpdb->collate) ) 95 $charset_collate .= " COLLATE $wpdb->collate"; 96 } 97 $views_queries ="CREATE TABLE $views_table ( 98 blog_id bigint(20) unsigned NOT NULL default '0', 99 post_id bigint(20) unsigned NOT NULL default '0', 100 post_views bigint(20) unsigned NOT NULL default '0', 101 KEY post_id (post_id) 102 )$charset_collate;"; 103 dbDelta($views_queries); 104 $ret[] = "$views_table table of XPressME was made.<br />"; 105 106 $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_d3forum_link' ; 107 $views_queries ="CREATE TABLE $d3forum_link ( 108 comment_ID bigint(20) unsigned NOT NULL default '0', 109 post_id int(10) unsigned NOT NULL default '0' , 110 wp_post_ID bigint(20) unsigned NOT NULL default '0', 111 forum_id bigint(20) unsigned NOT NULL default '0', 112 blog_id bigint(20) unsigned NOT NULL default '0', 113 KEY post_id (post_id) 114 )$charset_collate;"; 115 dbDelta($views_queries); 116 $ret[] = "$d3forum_link table of XPressME was made.<br />"; 117 118 $group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_group_role' ; 119 $views_queries ="CREATE TABLE $group_role ( 120 groupid smallint(5) unsigned NOT NULL default '0', 121 blog_id bigint(20) unsigned NOT NULL default '0', 122 name varchar(50) NOT NULL default '' , 123 description text NOT NULL default '', 124 group_type varchar(50) NOT NULL default '' , 125 role varchar(20) NOT NULL default '' , 126 login_all smallint(5) unsigned NOT NULL default '0' , 127 KEY groupid (groupid) 128 )$charset_collate;"; 129 dbDelta($views_queries); 130 $ret[] = "$group_role table of XPressME was made.<br />"; 131 132 $notify_reserve = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_notify_reserve' ; 133 $queries ="CREATE TABLE $notify_reserve ( 134 notify_reserve_id bigint(20) NOT NULL AUTO_INCREMENT , 135 notify_reserve_status varchar(20) NOT NULL default '' , 136 category text NOT NULL default '', 137 item_id bigint(20) unsigned NOT NULL default '0', 138 event varchar(20) NOT NULL default '', 139 extra_tags_arry longtext NOT NULL default '' , 140 user_list_arry longtext NOT NULL default '' , 141 module_id smallint(5) unsigned NOT NULL default '0' , 142 omit_user_id varchar(20) NOT NULL default '' , 143 KEY notify_reserve_id (notify_reserve_id) 144 )TYPE=MyISAM"; 145 dbDelta($queries); 146 $ret[] = "$notify_reserve table of XPressME was made.<br />"; 147 148 $sql = "INSERT INTO $group_role (groupid, role) VALUES (1, 'administrator')"; 149 $wpdb->query($sql); 150 151 // make templates 152 include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ; 153 $t_mess = xpress_templates_make($mid,$mydirname); 154 155 // Admin User Data write 156 // Change uid field 157 $wpdb->query("ALTER TABLE $wpdb->posts CHANGE `post_author` `post_author` mediumint(8) NOT NULL DEFAULT '0'"); 158 $user_name = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("uname"):'admin'; 159 $email = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("email"):'foo@exsample.com'; 160 $pass_md5 = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("pass"):''; 161 162 if (!function_exists('username_exists')){ 163 require_once($mydirpath . '/wp-includes/registration-functions.php'); 164 } 165 $user_id = username_exists($user_name); 166 if ( !$user_id ) { 167 $random_password = 'admin'; 168 $user_id = wp_create_user($user_name, $random_password, $email); 169 } else { 170 $random_password = __('User already exists. Password inherited.'); 171 } 172 173 $user = new WP_User($user_id); 174 $user->set_role('administrator'); 175 'User ' . $user_name . ' of the administrator was made.'; 176 // over write xoops md5 password 177 $sql = "UPDATE $wpdb->users SET user_pass ='$pass_md5' WHERE ID = $user_id"; 178 $wpdb->query($sql); 179 $ret[] = 'The password of XOOPS was copied.<br />'; 180 181 182 // Set Default data 183 // make WordPress Default data 184 if (function_exists('wp_install_defaults')){ 185 wp_install_defaults($user_id); 186 } else { 187 wp_install_old_defaults($user_id); 188 } 189 190 $ret[] = 'The first sample post & comment was written.<br />'; 191 192 // Rewrite Option for Xpress 193 $xoops_config_tbl = XOOPS_DB_PREFIX . '_config' ; 194 $sql = "SELECT conf_value FROM $xoops_config_tbl WHERE `conf_name` = 'default_TZ'"; 195 $xoops_default_TZ = $wpdb->get_var($sql); 196 update_option('gmt_offset', $xoops_default_TZ); 197 198 if (WPLANG == 'ja_EUC') { 199 $setup_charset = 'EUC-JP'; 200 } elseif(WPLANG == 'ja_SJIS') { 201 $setup_charset = 'Shift_JIS'; 202 } else { 203 $setup_charset = 'UTF-8'; 204 } 205 update_option("blog_charset", $setup_charset); 206 207 update_option('blogname', $site_name ); 208 update_option('blogdescription', 'WordPress for XOOPS'); 209 update_option("admin_email", $GLOBALS["xoopsConfig"]['adminmail']); 210 update_option("ping_sites", "http://rpc.pingomatic.com/\nhttp://ping.xoopsforge.com/"); 211 update_option("home", $site_url); 212 update_option("siteurl", $site_url); 213 update_option("what_to_show", "posts"); 214 update_option('default_pingback_flag', 0); 215 $ret[] = 'The initial data was written in the data base of wordpress.<br />'; 216 217 update_option("template", "xpress_default"); 218 update_option("stylesheet", "xpress_default"); 219 $ret[] = 'The default theme of wordpress was set to xpress_default.<br />'; 220 // update_option('uploads_use_yearmonth_folders', 1); 221 update_option('upload_path', 'wp-content/uploads'); 222 223 // activate the xpressme plugin 224 require_once dirname( __FILE__ ).'/xpress_active_plugin.php'; 225 if (xpress_pulugin_activation('xpressme/xpressme.php')){ 226 $ret[] = 'The xpressme plug-in was activated.<br />'; 227 } else { 228 $GLOBALS["err_log"][] = '<span style="color:#ff0000;">failed in the activation of xpressme plug-in.</span><br />'; 229 return false; 230 } 231 232 $ret = array_merge($ret,$t_mess); 66 $ret[] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">WordPress Install Log</h4>'; 67 } 68 // wp install 69 // $i_mess = wp_installer($mydirname); 70 // $ret = array_merge($ret,$i_mess); 233 71 234 72 return true ; … … 254 92 if( is_array( @$GLOBALS["err_log"] ) ) { 255 93 foreach( $GLOBALS["err_log"] as $message ) { 256 $log->add( strip_tags( $message)) ;94 $log->add( strip_tags( $message ) ) ; 257 95 } 258 96 }
Note: See TracChangeset
for help on using the changeset viewer.