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