Disable Functions: Path : /opt/eig_wp/wp_install/ |
Current File : //opt/eig_wp/wp_install/common_core_post_install.php |
<?php //ini_set("display_errors", 1); //error_reporting(E_ALL); $time_begin = microtime(true); // This will typically be /opt/eig_wp/wp_install/includes.php // However, when testing withn the GIT repo the includes.php file resides // [repo_path]/wp_install/includes.php. So we will detect and adapt. $includes_path = __FILE__; $includes_path = preg_replace('/\/[^\/]+$/', '', $includes_path); // $redis_path = $includes_path; $includes_path .= '/includes.php'; if (!file_exists($includes_path)) { die("[ERROR]\tincludes.php not found at $includes_path."); } // $redis_path .= '/common_core_add_redis.php'; // if (!file_exists($redis_path)) { // die("[ERROR]\tcommon_core_add_redis.php not found at $redis_path."); // } include($includes_path); // include($redis_path); $total_start = microtime(true); $install_options = setup_options( array( "site_url" => "", "brand" => "", "host_id" => "", "token" => "", "blog_title" => "Welcome", "user_name" => "admin", "admin_email" => "", "install_path" => "", // If not provided, fall back to just homedir/public_html. "core_source_path" => "", // This is a new field. It needs to reflect where to find the core install "mu_plugins" => "::", // Comma delimited list, required. "plugins" => "::", // Comma delimited list, required. "redis_hosts" => "", "redis_master_user" => "", "redis_master_pass" => "", "redis_user_pass" => "", ) ); // create_redis($redis_hosts, $user_name, $redis_user_pass, $redis_master_user, $redis_master_pass); // These fields (mu_plugins, and plugins) are comma-delimited lists. $mu_plugins = explode(',', $install_options['mu_plugins']); $plugins = explode(',', $install_options['plugins']); if (preg_match("/^\//", $install_options['install_path'])) { die("[ERROR]\tinstall_path must be a relative path to be appended to homedir/public_html"); } if ( posix_getuid() < 500 ) { die("[ERROR]\tUID < 500\n\n"); } $pwu_data = posix_getpwuid(posix_geteuid()); $posix_username = $pwu_data['name']; $homedir = "/home/" . $posix_username; if ( getenv("HOME") ) { $homedir = getenv("HOME"); } $install_path = $homedir . "/public_html" . (empty($install_options['install_path'] || $install_options['install_path'] == "") ? "" : ("/" . $install_options['install_path'])); if ( ! is_dir("$install_path") ) { //die("No dir.. something is wrong. ($install_path)\n"); mkdir("$install_path"); } # Spot check if ( ! is_dir("$install_path/wp-content/") ) { die("wp-content dir missing\n"); } chdir("$install_path"); // create_wpconf ( $install_options['db_name'], $install_options['db_user'], $install_options['db_password'], $install_options['table_prefix'] ); // wp-config.php was created by the calling script. if (!file_exists('wp-config.php')) { die("No wp-config.php was found.\n"); } define( 'WP_INSTALLING', true ); include("wp-config.php"); require_once( 'wp-load.php' ); require_once( 'wp-admin/includes/upgrade.php' ); require_once( 'wp-includes/wp-db.php' ); $time_last = microtime(true); $time = round(($time_last - $time_begin), 3); echo "Library and config setup (${time})\n"; // blog title, username, user_email, public (bool), deprecated_value, user_pass, lang wp_install( $install_options['blog_title'], $install_options['user_name'], $install_options['admin_email'], '1', ''); $time_next = microtime(true); $time = round(($time_next - $time_last), 3); echo "WP_install (${time})\n"; $time_last = $time_next; // Turn off default password nag -- Maybe we should have it look up // username instead of assuming its ID 1 update_user_option( 1, 'default_password_nag', false, true ); if ( ! $install_options['site_url'] ) { list($host) = explode('.', gethostname() ); $url = "http://" . $host . ".temp.domains/~" . $posix_username; } else { $url = $install_options['site_url']; } update_option_audit( 'siteurl', $url ); update_option_audit( 'home', $url ); update_option_audit( 'close_comments_for_old_posts' , '1'); update_option_audit( 'close_comments_days_old', '28'); update_option_audit( 'comments_per_page', '20'); update_option_audit( 'mm_install_date', date('Y-m-d') ); update_option_audit( 'mm_coming_soon', 'true'); update_option_audit( 'mm_brand', $install_options['brand'] ); update_option_audit( 'host_id', $install_options['host_id'] ); //update_option_audit( '_mm_refresh_token', $install_options['token'] ); update_option_audit( "permalink_structure", '/%postname%/' ); if ($install_options['admin_email']) { update_option_audit( 'admin_email', $install_options['admin_email'] ); } $time_next = microtime(true); $time = round(($time_next - $time_last), 3); echo "Update options (${time})\n"; $time_last = $time_next; // Check existence of mu_plugins, and activate plugins. mu_plugin_check_array($mu_plugins); activate_plugin_list_array($plugins); $time_next = microtime(true); $time = round(($time_next - $time_last), 3); echo "Activate plugins (${time})\n"; $time_last = $time_next; update_option_audit( "enduance_page_cache", '2' ); $GLOBALS['wp_rewrite'] = new WP_Rewrite(); $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() ); insert_with_markers( ".htaccess", 'WordPress', $rules ); echo "[OK]\tWP Install COMPLETE.\n"; $time_next = microtime(true); $time = round(($time_next - $time_last), 3); echo "Final writes (${time})\n"; $time_last = $time_next; $total_end = microtime(true); $time = round(($total_end - $total_start), 5); //echo "Total install time ($time) seconds\n"; $time_end = microtime(true); $time2 = round(($time_end - $time_begin), 3); echo "Completed (${time2})\n"; echo " ****************************** ****************************** ****************************** ****************************** WP Blog installed at $url/ Total install time ($time) seconds ****************************** ****************************** ****************************** ****************************** "; ?>