[744] | 1 | <?php
|
---|
| 2 | function xp_permission_check($mydirname , $mydirpath) {
|
---|
| 3 | global $ret ; // TODO :-D
|
---|
| 4 | // permission check
|
---|
| 5 |
|
---|
| 6 | $error = false;
|
---|
| 7 |
|
---|
| 8 | if (!file_exists($mydirpath . '/wp-settings.php')){
|
---|
| 9 | $error = true;
|
---|
| 10 | }
|
---|
| 11 | $check_files = array('/templates/', '/wp-content/');
|
---|
| 12 | foreach ($check_files as $check) {
|
---|
| 13 | $check_file = $mydirpath . $check;
|
---|
| 14 | if (!is_dir($check_file)) {
|
---|
| 15 | if ( file_exists($check_file) ) {
|
---|
| 16 | @chmod($check_file, 0666);
|
---|
| 17 | if (! is_writeable($check_file)) {
|
---|
| 18 | $GLOBALS["err_log"][] = "<span style=\"color:#ff0000;\">Permission Error $check_file is not writeable</span><br />";
|
---|
| 19 | $error = true;
|
---|
| 20 | }
|
---|
| 21 | }
|
---|
| 22 | } else {
|
---|
| 23 | @chmod($check_file, 0777);
|
---|
| 24 | if (! is_writeable($check_file)) {
|
---|
| 25 | $GLOBALS["err_log"][] = "<span style=\"color:#ff0000;\">Permission Error $check_file directory is not writeable</span><br />";
|
---|
| 26 | $error = true;
|
---|
| 27 | } else {
|
---|
| 28 | // Windows parmission check
|
---|
| 29 | $src_file = __FILE__ ;
|
---|
| 30 | $newfile = $check_file . 'write_check.txt';
|
---|
| 31 | if (!@copy($src_file, $newfile)) {
|
---|
| 32 | $GLOBALS["err_log"][] = "<span style=\"color:#ff0000;\">Permission Error $check_file directory is not writeable</span><br />";
|
---|
| 33 | $error = true;
|
---|
| 34 | } else {
|
---|
| 35 | unlink($newfile);
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 | if($error) return false;
|
---|
| 41 |
|
---|
| 42 | return true;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | function wp_installer($mydirname ){
|
---|
| 46 | //xpress
|
---|
| 47 | global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles, $wp_query,$wp_embed;
|
---|
[789] | 48 | global $modInfo;
|
---|
[744] | 49 | $msgs = array();
|
---|
| 50 |
|
---|
[789] | 51 | $site_url= $modInfo->get_module_url();
|
---|
| 52 | $mydirpath = $modInfo->get_module_path();
|
---|
[744] | 53 | $path = $mydirpath . '/';
|
---|
| 54 | $site_name = ucfirst($mydirname) . ' ' . _MI_XP2_NAME;
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | // install WordPress
|
---|
| 58 | define("WP_INSTALLING", true);
|
---|
| 59 | require_once $path . 'wp-load.php';
|
---|
| 60 | include_once($mydirpath . '/wp-admin/upgrade-functions.php');
|
---|
| 61 | wp_cache_flush();
|
---|
| 62 | make_db_current_silent();
|
---|
| 63 | $msgs[] = "The data base of wordpress was made by prefix $table_prefix.<br />";
|
---|
| 64 |
|
---|
| 65 | $option_desc = __('WordPress web address');
|
---|
| 66 | $wpdb->query("INSERT INTO $wpdb->options (blog_id, option_name,option_value, autoload) VALUES ('0', 'siteurl','$site_url', 'yes')");
|
---|
| 67 | $wpdb->query("INSERT INTO $wpdb->options (blog_id, option_name,option_value, autoload) VALUES ('0', 'home','$site_url', 'yes')");
|
---|
| 68 |
|
---|
| 69 | populate_options();
|
---|
| 70 | populate_roles();
|
---|
| 71 |
|
---|
| 72 | // Admin User Data write
|
---|
| 73 | // Change uid field
|
---|
| 74 | $wpdb->query("ALTER TABLE $wpdb->posts CHANGE `post_author` `post_author` mediumint(8) NOT NULL DEFAULT '0'");
|
---|
| 75 | $user_name = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("uname"):'admin';
|
---|
| 76 | $email = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("email"):'foo@exsample.com';
|
---|
| 77 | $pass_md5 = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("pass"):'';
|
---|
| 78 |
|
---|
| 79 | if (!function_exists('username_exists')){
|
---|
| 80 | require_once($mydirpath . '/wp-includes/registration-functions.php');
|
---|
| 81 | }
|
---|
| 82 | $user_id = username_exists($user_name);
|
---|
| 83 | if ( !$user_id ) {
|
---|
| 84 | $random_password = 'admin';
|
---|
| 85 | $user_id = wp_create_user($user_name, $random_password, $email);
|
---|
| 86 | } else {
|
---|
| 87 | $random_password = __('User already exists. Password inherited.');
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | $user = new WP_User($user_id);
|
---|
| 91 | $user->set_role('administrator');
|
---|
| 92 | 'User ' . $user_name . ' of the administrator was made.';
|
---|
| 93 | // over write xoops md5 password
|
---|
| 94 | $sql = "UPDATE $wpdb->users SET user_pass ='$pass_md5' WHERE ID = $user_id";
|
---|
| 95 | $wpdb->query($sql);
|
---|
| 96 | $msgs[] = 'The password of XOOPS was copied.<br />';
|
---|
| 97 |
|
---|
| 98 | // Set Default data
|
---|
| 99 | // make WordPress Default data
|
---|
| 100 | if (function_exists('wp_install_defaults')){
|
---|
| 101 | wp_install_defaults($user_id);
|
---|
| 102 | } else {
|
---|
| 103 | wp_install_old_defaults($user_id);
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | $msgs[] = 'The first sample post & comment was written.<br />';
|
---|
| 107 |
|
---|
| 108 | // Rewrite Option for Xpress
|
---|
[789] | 109 | $xoops_conf_tbl = $modInfo->get_xoops_db_prefix() . '_config' ;
|
---|
[757] | 110 | $sql = "SELECT conf_value FROM $xoops_conf_tbl WHERE `conf_name` = 'default_TZ'";
|
---|
[744] | 111 | $xoops_default_TZ = $wpdb->get_var($sql);
|
---|
| 112 | update_option('gmt_offset', $xoops_default_TZ);
|
---|
| 113 |
|
---|
| 114 | if (WPLANG == 'ja_EUC') {
|
---|
| 115 | $setup_charset = 'EUC-JP';
|
---|
| 116 | } elseif(WPLANG == 'ja_SJIS') {
|
---|
| 117 | $setup_charset = 'Shift_JIS';
|
---|
| 118 | } else {
|
---|
| 119 | $setup_charset = 'UTF-8';
|
---|
| 120 | }
|
---|
| 121 | update_option("blog_charset", $setup_charset);
|
---|
| 122 |
|
---|
| 123 | update_option('blogname', $site_name );
|
---|
| 124 | update_option('blogdescription', 'WordPress for XOOPS');
|
---|
| 125 | update_option("admin_email", $GLOBALS["xoopsConfig"]['adminmail']);
|
---|
| 126 | update_option("ping_sites", "http://rpc.pingomatic.com/\nhttp://ping.xoopsforge.com/");
|
---|
| 127 | update_option("home", $site_url);
|
---|
| 128 | update_option("siteurl", $site_url);
|
---|
| 129 | update_option("what_to_show", "posts");
|
---|
| 130 | update_option('default_pingback_flag', 0);
|
---|
| 131 | $msgs[] = 'The initial data was written in the data base of wordpress.<br />';
|
---|
| 132 |
|
---|
| 133 | update_option("template", "xpress_default");
|
---|
| 134 | update_option("stylesheet", "xpress_default");
|
---|
| 135 | $msgs[] = 'The default theme of wordpress was set to xpress_default.<br />';
|
---|
| 136 | // update_option('uploads_use_yearmonth_folders', 1);
|
---|
| 137 | update_option('upload_path', 'wp-content/uploads');
|
---|
| 138 |
|
---|
| 139 | // activate the xpressme plugin
|
---|
| 140 | require_once dirname( __FILE__ ).'/xpress_active_plugin.php';
|
---|
| 141 | if (xpress_pulugin_activation('xpressme/xpressme.php')){
|
---|
| 142 | $msgs[] = 'The xpressme plug-in was activated.<br />';
|
---|
| 143 | } else {
|
---|
| 144 | $GLOBALS["err_log"][] = '<span style="color:#ff0000;">failed in the activation of xpressme plug-in.</span><br />';
|
---|
| 145 | return false;
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | // create XPressME table
|
---|
[789] | 150 | $xp_prefix = $modInfo->get_module_db_prefix();
|
---|
| 151 | $views_table = $xp_prefix .'views' ;
|
---|
[744] | 152 |
|
---|
| 153 | $charset_collate = '';
|
---|
| 154 | if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {
|
---|
| 155 | if ( ! empty($wpdb->charset) )
|
---|
| 156 | $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
---|
| 157 | if ( ! empty($wpdb->collate) )
|
---|
| 158 | $charset_collate .= " COLLATE $wpdb->collate";
|
---|
| 159 | }
|
---|
| 160 | $views_queries ="CREATE TABLE $views_table (
|
---|
| 161 | blog_id bigint(20) unsigned NOT NULL default '0',
|
---|
| 162 | post_id bigint(20) unsigned NOT NULL default '0',
|
---|
| 163 | post_views bigint(20) unsigned NOT NULL default '0',
|
---|
| 164 | KEY post_id (post_id)
|
---|
| 165 | )$charset_collate;";
|
---|
| 166 | dbDelta($views_queries);
|
---|
| 167 | $msgs[] = "$views_table table of XPressME was made.<br />";
|
---|
| 168 |
|
---|
[789] | 169 | $d3forum_link = $xp_prefix .'d3forum_link' ;
|
---|
[744] | 170 | $views_queries ="CREATE TABLE $d3forum_link (
|
---|
| 171 | comment_ID bigint(20) unsigned NOT NULL default '0',
|
---|
| 172 | post_id int(10) unsigned NOT NULL default '0' ,
|
---|
| 173 | wp_post_ID bigint(20) unsigned NOT NULL default '0',
|
---|
| 174 | forum_id bigint(20) unsigned NOT NULL default '0',
|
---|
| 175 | blog_id bigint(20) unsigned NOT NULL default '0',
|
---|
| 176 | KEY post_id (post_id)
|
---|
| 177 | )$charset_collate;";
|
---|
| 178 | dbDelta($views_queries);
|
---|
| 179 | $msgs[] = "$d3forum_link table of XPressME was made.<br />";
|
---|
| 180 |
|
---|
[789] | 181 | $group_role = $xp_prefix .'group_role' ;
|
---|
[744] | 182 | $views_queries ="CREATE TABLE $group_role (
|
---|
| 183 | groupid smallint(5) unsigned NOT NULL default '0',
|
---|
| 184 | blog_id bigint(20) unsigned NOT NULL default '0',
|
---|
| 185 | name varchar(50) NOT NULL default '' ,
|
---|
| 186 | description text NOT NULL default '',
|
---|
| 187 | group_type varchar(50) NOT NULL default '' ,
|
---|
| 188 | role varchar(20) NOT NULL default '' ,
|
---|
| 189 | login_all smallint(5) unsigned NOT NULL default '0' ,
|
---|
| 190 | KEY groupid (groupid)
|
---|
| 191 | )$charset_collate;";
|
---|
| 192 | dbDelta($views_queries);
|
---|
| 193 | $msgs[] = "$group_role table of XPressME was made.<br />";
|
---|
[790] | 194 | $sql = "INSERT INTO $group_role (groupid, blog_id, role) VALUES (1,1, 'administrator')";
|
---|
[744] | 195 | $wpdb->query($sql);
|
---|
| 196 |
|
---|
[789] | 197 | $notify_reserve = $xp_prefix .'notify_reserve' ;
|
---|
[744] | 198 | $queries ="CREATE TABLE $notify_reserve (
|
---|
| 199 | notify_reserve_id bigint(20) NOT NULL AUTO_INCREMENT ,
|
---|
| 200 | notify_reserve_status varchar(20) NOT NULL default '' ,
|
---|
| 201 | category text NOT NULL default '',
|
---|
| 202 | item_id bigint(20) unsigned NOT NULL default '0',
|
---|
| 203 | event varchar(20) NOT NULL default '',
|
---|
| 204 | extra_tags_arry longtext NOT NULL default '' ,
|
---|
| 205 | user_list_arry longtext NOT NULL default '' ,
|
---|
| 206 | module_id smallint(5) unsigned NOT NULL default '0' ,
|
---|
| 207 | omit_user_id varchar(20) NOT NULL default '' ,
|
---|
| 208 | KEY notify_reserve_id (notify_reserve_id)
|
---|
| 209 | )TYPE=MyISAM";
|
---|
| 210 | dbDelta($queries);
|
---|
| 211 | $msgs[] = "$notify_reserve table of XPressME was made.<br />";
|
---|
| 212 |
|
---|
| 213 | return $msgs ;
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | ?> |
---|