Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions wp-quick-install/assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -311,7 +311,7 @@ $(document).ready(function() {
function install_wp() {
$response.html("<p>Database Installation in Progress...</p>");
$('.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();
});
}
Expand All @@ -320,7 +320,7 @@ $(document).ready(function() {
function install_theme() {
$response.html("<p>Theme Installation in Progress...</p>");
$('.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();
});
}
Expand All @@ -347,4 +347,4 @@ $(document).ready(function() {
$.get( 'http://wp-quick-install.com/inc/incr-counter.php' );
}

});
});
84 changes: 83 additions & 1 deletion wp-quick-install/inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,86 @@ function _( $str ) {

function sanit( $str ) {
return addcslashes( str_replace( array( ';', "\n" ), '', $str ), '\\' );
}
}

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;
}
48 changes: 27 additions & 21 deletions wp-quick-install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Version: 1.4.1
Licence: GPLv3
Last Update: 08 jan 15

*/

@set_time_limit( 0 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -482,25 +486,26 @@
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';

if ( ! file_exists( $plugin_path ) ) {
// 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();
}
}
}
}
}

Expand Down Expand Up @@ -616,7 +621,7 @@
<h1><?php echo _('Warning');?></h1>
<p><?php echo _('This file must be in the wp-quick-install folder and not be present in the root of your project.');?></p>

<h1><?php echo _('Database Informations');?></h1>
<h1><?php echo _('Database Information');?></h1>
<p><?php echo _( "Below you should enter your database connection details. If you&#8217;re not sure about these, contact your host." ); ?></p>

<table class="form-table">
Expand Down Expand Up @@ -654,7 +659,7 @@
</tr>
</table>

<h1><?php echo _('Required Informations');?></h1>
<h1><?php echo _('Required Information');?></h1>
<p><?php echo _('Thank you to provide the following information. Don\'t worry, you will be able to change it later.');?></p>

<table class="form-table">
Expand Down Expand Up @@ -700,8 +705,9 @@
<p><?php echo _('A password will be automatically generated for you if you leave this blank.');?></p>
</th>
<td>
<?php $pw = random_pw( 12 ); // MAM ?>
<input name="admin_password" type="password" id="admin_password" size="25" value="" />
<p><?php echo _('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).');?>.</p>
<p><?php echo _('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).' . "<br />Suggested PW: " . htmlspecialchars( $pw ) . "<br />Be sure to copy the password to a safe place." );?></p>
</td>
</tr>
<tr>
Expand All @@ -715,7 +721,7 @@
</tr>
</table>

<h1><?php echo _('Theme Informations');?></h1>
<h1><?php echo _('Theme Information');?></h1>
<p><?php echo _('Enter the information below for your personal theme.');?></p>
<div class="alert alert-info">
<p style="margin:0px; padding:0px;"><?php echo _('WP Quick Install will automatically install your theme if it\'s on wp-quick-install folder and named theme.zip');?></p>
Expand All @@ -737,7 +743,7 @@
</tr>
</table>

<h1><?php echo _('Extensions Informations');?></h1>
<h1><?php echo _('Extensions Information');?></h1>
<p><?php echo _('Simply enter below the extensions that should be addend during the installation.');?></p>
<table class="form-table">
<tr>
Expand All @@ -746,7 +752,7 @@
<p><?php echo _('The extension slug is available in the url (Ex: http://wordpress.org/extend/plugins/<strong>wordpress-seo</strong>)');?></p>
</th>
<td>
<input name="plugins" type="text" id="plugins" size="50" value="wp-website-monitoring; rocket-lazy-load; imagify" />
<input name="plugins" type="text" id="plugins" size="50" value="" />
<p><?php echo _('Make sure that the extensions slugs are separated by a semicolon (;).');?></p>
</td>
</tr>
Expand All @@ -765,7 +771,7 @@
</tr>
</table>

<h1><?php echo _('Permalinks Informations');?></h1>
<h1><?php echo _('Permalinks Information');?></h1>

<p><?php echo sprintf( _('By default WordPress uses web URLs which have question marks and lots of numbers in them; however, WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="%s">number of tags are available</a>.'), 'http://codex.wordpress.org/Using_Permalinks'); ?></p>

Expand All @@ -781,7 +787,7 @@
</tr>
</table>

<h1><?php echo _('Media Informations');?></h1>
<h1><?php echo _('Media Information');?></h1>

<p><?php echo _('Specified dimensions below determine the maximum dimensions (in pixels) to use when inserting an image into the body of an article.');?></p>

Expand Down Expand Up @@ -826,7 +832,7 @@
</tr>
</table>

<h1><?php echo _('wp-config.php Informations');?></h1>
<h1><?php echo _('wp-config.php Information');?></h1>
<p><?php echo _('Choose below the additional constants you want to add in <strong>wp-config.php</strong>');?></p>

<table class="form-table">
Expand Down