diff --git a/wp-quick-install/assets/js/script.js b/wp-quick-install/assets/js/script.js index c29e7d3..ab2c12e 100644 --- a/wp-quick-install/assets/js/script.js +++ b/wp-quick-install/assets/js/script.js @@ -214,7 +214,7 @@ $(document).ready(function() { $('#debug').removeAttr('checked'); } } - + if ( typeof data.wp_config.wpcom_api_key !='undefined' ) { $('#wpcom_api_key').val(data.wp_config.wpcom_api_key); } @@ -311,7 +311,7 @@ $(document).ready(function() { function install_wp() { $response.html("
Database Installation in Progress...
"); $('.progress-bar').animate({width: "49.5%"}); - $.post(window.location.href + '/wp-admin/install.php?action=install_wp', $('form').serialize(), function(data) { + $.post(window.location.href + '?action=install_wp', $('form').serialize(), function(data) { install_theme(); }); } @@ -320,7 +320,7 @@ $(document).ready(function() { function install_theme() { $response.html("Theme Installation in Progress...
"); $('.progress-bar').animate({width: "66%"}); - $.post(window.location.href + '/wp-admin/install.php?action=install_theme', $('form').serialize(), function(data) { + $.post(window.location.href + '?action=install_theme', $('form').serialize(), function(data) { install_plugins(); }); } @@ -347,4 +347,4 @@ $(document).ready(function() { $.get( 'http://wp-quick-install.com/inc/incr-counter.php' ); } -}); \ No newline at end of file +}); diff --git a/wp-quick-install/inc/functions.php b/wp-quick-install/inc/functions.php index 9a198d2..554d8db 100644 --- a/wp-quick-install/inc/functions.php +++ b/wp-quick-install/inc/functions.php @@ -8,4 +8,86 @@ function _( $str ) { function sanit( $str ) { return addcslashes( str_replace( array( ';', "\n" ), '', $str ), '\\' ); -} \ No newline at end of file +} + +function random_capletters( $number = 0, &$excludes ) { + // Capital letters except I, L, O, Q + $letters = array_merge( range('A', 'H'), range('J', 'N'), array('P'), range('R', 'Z') ); + if ( is_array( $excludes ) ) { + $letters = array_diff( $letters, $excludes ); + } + shuffle($letters); + if ( $number == 0 || $number > sizeof( $letters ) ) { + return $letters; + } else { + return array_slice( $letters, 0, $number ); + } + +} +function random_lcaseletters( $number = 0, &$excludes ) { + // Lowercase letters except I, L, O, Q + $letters = array_merge( range('a', 'h'), range('j', 'n'), array('p'), range('r', 'z') ); + if ( is_array( $excludes ) ) { + $letters = array_diff( $letters, $excludes ); + } + shuffle( $letters ); + if ( $number == 0 || $number > sizeof( $letters ) ) { + return $letters; + } else { + return array_slice( $letters, 0, $number ); + } +} +function random_digits( $number = 0, &$excludes ) { + // Omit 0 and 1 as too similar to O and L + $numbers = range( '2','9'); + if ( is_array( $excludes ) ) { + $numbers = array_diff( $numbers, $excludes ); + } + $numbers = array_diff( $numbers, $excludes ); + shuffle($numbers); + if ( $number == 0 || $number > sizeof( $numbers ) ) { + return $numbers; + } else { + return array_slice( $numbers, 0, $number ); + } +} +function random_specialchars( $number = 0, &$excludes ) { + $chars = array( '!', '@', '#', '%', '=', '-', '_', '?', '<', '>' ) ; + if ( is_array( $excludes ) ) { + $chars = array_diff( $chars, $excludes ); + } + shuffle( $chars ); + if ( $number == 0 || $number > sizeof( $chars ) ) { + return $chars; + } else { + return array_slice( $chars, 0, $number ); + } +} +function random_pw( $length = 8, array $excludes = array() ) { + // Min length is 8 + $length = $length < 8 ? 8 : $length; + + $getlength = rand( 2, intval( $length / 4 ) ); // Allow at least two of each type + $remainder = $length - $getlength; + $special = random_specialchars( $getlength, $excludes ); + + $getlength = rand( 2, intval( $remainder / 3 ) ); // Allow at least two of each type + $remainder = $remainder - $getlength; + $digits = random_digits( $getlength, $excludes ); + + $getlength = rand( 2, intval( $remainder / 2 ) ); // Allow at least two of each type + $remainder = $remainder - $getlength; + $caps = random_capletters( $getlength, $excludes ); + + $lower = random_lcaseletters( $remainder, $excludes ); + + $pw = array_merge( $caps, $lower, $digits, $special ); + shuffle( $pw ); + return implode( '', $pw ); +} +function random_table_prefix() { + $first2 = random_lcaseletters(2); + $last2 = random_digits(2); + $prefix = implode( '', $first2) . implode( '', $last2) . '_'; + return $prefix; +} diff --git a/wp-quick-install/index.php b/wp-quick-install/index.php index 89a0a9f..19dda69 100755 --- a/wp-quick-install/index.php +++ b/wp-quick-install/index.php @@ -7,6 +7,7 @@ Version: 1.4.1 Licence: GPLv3 Last Update: 08 jan 15 + */ @set_time_limit( 0 ); @@ -280,16 +281,19 @@ /** Load wpdb */ require_once( $directory . 'wp-includes/wp-db.php' ); + // Get WordPress language + $language = substr( $_POST['language'], 0, 6 ); + // WordPress installation - wp_install( $_POST[ 'weblog_title' ], $_POST['user_login'], $_POST['admin_email'], (int) $_POST[ 'blog_public' ], '', $_POST['admin_password'] ); + wp_install( $_POST[ 'weblog_title' ], $_POST['user_login'], $_POST['admin_email'], (int) $_POST[ 'blog_public' ], '', $_POST['admin_password'], $language ); // We update the options with the right siteurl et homeurl value $protocol = ! is_ssl() ? 'http' : 'https'; - $get = basename( dirname( __FILE__ ) ) . '/index.php/wp-admin/install.php?action=install_wp'; - $dir = str_replace( '../', '', $directory ); - $link = $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - $url = str_replace( $get, $dir, $link ); - $url = trim( $url, '/' ); + $get = basename( dirname( __FILE__ ) ); + $dir = str_replace( '../', '', $directory ); + $link = $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + $url = preg_replace( "#$get.*$#", $dir, $link ); + $url = trim( $url, '/' ); update_option( 'siteurl', $url ); update_option( 'home', $url ); @@ -482,9 +486,9 @@ foreach ( $plugins as $plugin ) { // We retrieve the plugin XML file to get the link to downlad it - $plugin_repo = file_get_contents( "http://api.wordpress.org/plugins/info/1.0/$plugin.json" ); + $plugin_repo = file_get_contents( "http://api.wordpress.org/plugins/info/1.0/$plugin.json" ); - if ( $plugin_repo && $plugin = json_decode( $plugin_repo ) ) { + if ( $plugin_repo && $plugin = json_decode( $plugin_repo ) ) { $plugin_path = WPQI_CACHE_PLUGINS_PATH . $plugin->slug . '-' . $plugin->version . '.zip'; @@ -492,15 +496,16 @@ // We download the lastest version if ( $download_link = file_get_contents( $plugin->download_link ) ) { file_put_contents( $plugin_path, $download_link ); - } } + } + } - // We unzip it - $zip = new ZipArchive; + // We unzip it + $zip = new ZipArchive; if ( $zip->open( $plugin_path ) === true ) { $zip->extractTo( $plugins_dir ); $zip->close(); } - } + } } } @@ -616,7 +621,7 @@ - +|
+
- . +Suggested PW: " . htmlspecialchars( $pw ) . " |
| - + |
number of tags are available.'), 'http://codex.wordpress.org/Using_Permalinks'); ?>
@@ -781,7 +787,7 @@ - + @@ -826,7 +832,7 @@ - +wp-config.php');?>