diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..32b2ef3 --- /dev/null +++ b/.htaccess @@ -0,0 +1,12 @@ + +# BEGIN WordPress + +RewriteEngine On +RewriteBase /wp-quick-install/ +RewriteRule ^index\.php$ - [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule . /wp-quick-install/index.php [L] + + +# END WordPress \ No newline at end of file diff --git a/README.md b/README.md old mode 100644 new mode 100755 index b7aaee1..6e567fe --- a/README.md +++ b/README.md @@ -1,132 +1,47 @@ -WP Quick Install 1.4.2 -================ +# Instalace skautské Wordpress šablony DSW v Lebedě na jeden klik -WP Quick Install is the easiest way to install WordPress. +## Status: v1.0 -A lightweight script which automatically downloads and install WordPress, plugins and themes you want. +## Manuál na instalaci -Simply download the .zip archive et go to *wp-quick-install/index.php* +Jak zpřístupnit na Lebedě autoinstalaci Wordpressu: -Changelog -================ +* Jako základ používáme https://github.com/GeekPress/WP-Quick-Install (fork) +* **Nastavení** je v souboru `data.ini` (včetně instalovaných pluginů a všeho dalšího) +* Zrušili jsme GUI a JS z původního skriptu a všechno nasypali do `WordpressService.php` +* **Requirement** je v composer.json, stačí spustit `composer install` +* Chtěné **DSW téma** se získá pomocí automatického stánutí z DWS githubu. Alternativně je možnost umístit soubor vedle skriptu a pojmenovat ho `theme.zip` +* Potřebné parametry pro instalaci jsou jako paramtery metody, return zatím nemáme žádný (vzhledem k tomu, že se skript bude provádět jindy (cronem) než ho uživatel zadává) +* Potřebné **parametry** pro service: $dbName, $dbUserName, $dbPassword, $dbHost, $websiteTitle, $userLogin, $adminPassword, $adminEmail +* Pozor, skript běží dlouho (přeci jen stahuje, dekomprimuje a instaluje zaráz), takže je potřeba hlídat timeout chyb (na průměrném NB to běželo skoro minutu) -1.4.2 ------------ -* Delete Tweentyfifteen & Tweentysixteen themes +#### stahování češtiny napřímo +https://cs.wordpress.org/latest-cs_CZ.zip -1.4.1 ------------ -* Fix quote issue with WordPress.com API Key +## TODO shortterm -1.4 ------------ -* Fix database issue since WordPress 4.1 -* You can add your WordPress.com API Key +#### automaticky přidat obrázky z theme -1.3.3 ------------ +spočívá v poslání issue do DSW, aby byly obrázky includované dynamicky (teď si neporadí s subfolder v adresářové cestě) - https://github.com/skaut/dsw-oddil/issues/129 -* Add SSL compatibility -* Remove SSL function (cause trouble with process installation) +#### automaticky přidat menu z theme -1.3.2 ------------ +řešíme s Kalichem -* Add a script header -* Security improvement -1.3.1 ------------ +## TODO longterm -* Fix error for PHP > 5.5: Strict standards: Only variables should be passed by reference in ../wp-quick-install/index.php on line 10 +#### Volitelný plugin pro bazar -1.3 ------------ +na vyžádání includenout plugin pro bazar (https://wordpress.org/plugins/skaut-bazar/) -* Possiblity to select WordPress language installation -* Permaling management +#### Umožnit instalaci i přes existující web +@kalich5 - nevhodné dělat automaticky, protože se tím naseká moc problémů - lepší kontrolovat, zda je složka prázdná a pokud ne, rovnou to nepovolit (jak to dělá např. `git clone` nebo velcí hostingové) -1.2.8.1 ------------ +Inspired by literat v issue: -* You can now declare articles to be generated via data.ini file -* Fix bug on new articles -* You can now select the revision by articles - -1.2.8 ------------ - -* Media management - -1.2.7.2 ------------ - -* Security : Forbiden access to data.ini from the browser - -1.2.7.1 ------------ - -* noindex nofollow tag. - -1.2.7 ------------ - -* Premium extension by adding archives in plugins folder -* You can enable extension after installation -* Auto supression of Hello Dolly extension -* You can add a theme and enable it -* You can delete Twenty Elever and Twenty Ten - -1.2.6 ------------ - -* Fix a JS bug with data.ini - -1.2.5 ------------ - -* You can delete the default content added by WordPress -* You can add new pages with data.ini -* Data.ini update - -1.2.4 ------------ - -* Two new debug options : *Display errors* (WP_DEBUG_DISPLAY) and *Write errors in a log file* (WP_DEBUG_LOG) - -1.2.3 ------------ - -* SEO Fix bug -* Automatic deletion of licence.txt and readme.html - -1.2.2 ------------ - -* Deletion of all exec() fucntions -* Unzip WordPress and plugins with ZipArchive class -* Using scandir() and rename() to move WordPress files - -1.2.1 ------------ - -* Checking chmod on parent folder -* Adding a link to website and admin if success - -1.2 ------------ - -* You can now pre-configure the form with data.ini - - -1.1 ------------ - -* Code Optimisation - - -1.0 ------------ - -* Initial Commit +* na začátku se automatika pouze zeptá na login a heslo pro administrátorský účet +* musí proběhnout kontrola FTP a databáze, tj. pokud je zde nějaký obsah, bude smazán a uživatel na to musí být upozorněn a potvrdit to +* veškerý obsah před instalací bude z FTP i DB smazán +* jako základní šablona společně s Wordpressem bude instalována DSW Oddíl diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..69d2387 --- /dev/null +++ b/composer.json @@ -0,0 +1,12 @@ +{ + "name": "skaut/wp-instalator-lebeda", + "type": "library", + "description": "Word press instalation package", + "keywords": ["skaut"], + "homepage": "https://github.com/skaut/WordPress-Lebeda-instalator", + "require": { + "php": ">=7.0", + "guzzlehttp/guzzle": "^6.2" + }, + "minimum-stability": "stable" +} diff --git a/wp-quick-install/.htaccess b/wp-quick-install/.htaccess old mode 100644 new mode 100755 diff --git a/wp-quick-install/WordpressService.php b/wp-quick-install/WordpressService.php new file mode 100644 index 0000000..1dd314d --- /dev/null +++ b/wp-quick-install/WordpressService.php @@ -0,0 +1,107 @@ +randomString(6) . '_'; + $data['default_content'] = $data['db']['default_content']; + $data['language'] = 'en_US'; + $data['directory'] = ''; + $data['admin']['user_login'] = $userLogin; + $data['user_login'] = $data['admin']['user_login']; + $data['admin']['password'] = $adminPassword; + $data['admin']['email'] = $adminEmail; + $data['weblog_title'] = $websiteTitle; + $data['admin_password'] = $adminPassword; + $data['admin_email'] = $adminEmail; + $data['blog_public'] = 1; + $data['activate_theme'] = 1; + $data['plugins'] = 'tiled-gallery-carousel-without-jetpack;wordfence;wp-super-cache;google-calendar-events;easy-facebook-feed'; + $data['activate_plugins'] = 1; + $data['permalink_structure'] = '/%postname%/'; + $data['thumbnail_size_w'] = 0; + $data['thumbnail_size_h'] = 0; + $data['thumbnail_crop'] = 1; + $data['medium_size_w'] = 0; + $data['medium_size_h'] = 0; + $data['large_size_w'] = 0; + $data['large_size_h'] = 0; + $data['upload_dir'] = ''; + $data['uploads_use_yearmonth_folders'] = 1; + $data['post_revisions'] = 0; + $data['disallow_file_edit'] = 1; + $data['autosave_interval'] = 7200; + $data['wpcom_api_key'] = ''; + + $installAddress = 'http://localhost/wp-quick-install'; + + $client = new \GuzzleHttp\Client([ + // Base URI is used with relative requests + 'base_uri' => $installAddress, + // You can set any number of default request options. + 'timeout' => 120.0, + ]); + + $postData = [ + 'form_params' => $data + ]; + $response = $client->request('POST', $installAddress . '/wp-quick-install/index.php?action=check_before_upload', $postData); + if ($response->getStatusCode() >= 300) { + echo $response->getBody()->getContents(); + } + $response = $client->request('POST', $installAddress . '/wp-quick-install/index.php?action=download_wp', $postData); + if ($response->getStatusCode() >= 300) { + echo $response->getBody()->getContents(); + } + $response = $client->request('POST',$installAddress . '/wp-quick-install/index.php?action=unzip_wp', $postData); + if ($response->getStatusCode() >= 300) { + echo $response->getBody()->getContents(); + } + $response = $client->request('POST',$installAddress . '/wp-quick-install/index.php?action=wp_config', $postData); + if ($response->getStatusCode() >= 300) { + echo $response->getBody()->getContents(); + } + $response = $client->request('POST',$installAddress . '/wp-quick-install/index.php/wp-admin/install.php?action=install_wp', $postData); + if ($response->getStatusCode() >= 300) { + echo $response->getBody()->getContents(); + } + $response = $client->request('POST',$installAddress . '/wp-quick-install/index.php/wp-admin/install.php?action=install_theme', $postData); + if ($response->getStatusCode() >= 300) { + echo $response->getBody()->getContents(); + } + $response = $client->request('POST',$installAddress . '/wp-quick-install/index.php/wp-quick-install/index.php?action=install_plugins', $postData); + if ($response->getStatusCode() >= 300) { + echo $response->getBody()->getContents(); + } + $response = $client->request('POST',$installAddress . '/wp-quick-install/index.php/wp-quick-install/index.php?action=success', $postData); + if ($response->getStatusCode() >= 300) { + echo $response->getBody()->getContents(); + } + } +} diff --git a/wp-quick-install/assets/css/buttons.min.css b/wp-quick-install/assets/css/buttons.min.css old mode 100644 new mode 100755 diff --git a/wp-quick-install/assets/css/style.min.css b/wp-quick-install/assets/css/style.min.css old mode 100644 new mode 100755 diff --git a/wp-quick-install/assets/images/wordpress-logo.svg b/wp-quick-install/assets/images/wordpress-logo.svg old mode 100644 new mode 100755 diff --git a/wp-quick-install/assets/js/jquery-1.8.3.min.js b/wp-quick-install/assets/js/jquery-1.8.3.min.js old mode 100644 new mode 100755 diff --git a/wp-quick-install/assets/js/script.js b/wp-quick-install/assets/js/script.js old mode 100644 new mode 100755 index c29e7d3..c38e493 --- a/wp-quick-install/assets/js/script.js +++ b/wp-quick-install/assets/js/script.js @@ -1,10 +1,12 @@ +var $debug, $debug_options, $debug_display, $debug_log, $response; + $(document).ready(function() { // Debug mode - var $debug = $('#debug'), - $debug_options = $('#debug_options'), - $debug_display = $debug_options.find('#debug_display'); - $debug_log = $debug_options.find('#debug_log'); + $debug = $('#debug'); + $debug_options = $('#debug_options'); + $debug_display = $debug_options.find('#debug_display'); + $debug_log = $debug_options.find('#debug_log'); $debug.change(function() { if ( $debug.is(':checked') ) { @@ -221,7 +223,7 @@ $(document).ready(function() { } - var $response = $('#response'); + $response = $('#response'); $('#submit').click( function() { @@ -289,62 +291,79 @@ $(document).ready(function() { return false; }); - // Let's unzip WordPress - function unzip_wp() { - $response.html("

Decompressing Files...

" ); - $('.progress-bar').animate({width: "16.5%"}); - $.post(window.location.href + '?action=unzip_wp', $('form').serialize(), function(data) { - wp_config(); - }); - } - - // Let's create the wp-config.php file - function wp_config() { - $response.html("

File Creation for wp-config...

"); - $('.progress-bar').animate({width: "33%"}); - $.post(window.location.href + '?action=wp_config', $('form').serialize(), function(data) { - install_wp(); - }); - } - - // CDatabase - 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) { - install_theme(); - }); - } - - // Theme - 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) { - install_plugins(); - }); - } - - // Plugin - function install_plugins() { - $response.html("

Plugins Installation in Progress...

"); - $('.progress-bar').animate({width: "82.5%"}); - $.post(window.location.href + '?action=install_plugins', $('form').serialize(), function(data) { - $response.html(data); - success(); - }); - } - - // Remove the archive - function success() { - $response.html("

Successful installation completed

"); - $('.progress-bar').animate({width: "100%"}); - $response.hide(); - $('.progress').delay(500).hide(); - $.post(window.location.href + '?action=success',$('form').serialize(), function(data) { - $('#success').show().append(data); - }); - $.get( 'http://wp-quick-install.com/inc/incr-counter.php' ); - } -}); \ No newline at end of file +}); + +// Let's unzip WordPress +function unzip_wp() { + $response.html("

Decompressing Files...

" ); + $('.progress-bar').animate({width: "16.5%"}); + $.post(window.location.href + '?action=unzip_wp', $('form').serialize(), function(data) { + console.log('unzip_wp done'); + wp_config(); + }); +} + +// Let's create the wp-config.php file +function wp_config() { + $response.html("

File Creation for wp-config...

"); + $('.progress-bar').animate({width: "33%"}); + $.post(window.location.href + '?action=wp_config', $('form').serialize(), function(data) { + console.log('wp_config done'); + // install_wp(); + }); +} + +// CDatabase +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) { + console.log('install_wp done'); + install_theme(); + }); +} + +// Theme +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) { + console.log('install_theme done'); + install_plugins(); + }); +} + +// Plugin +function install_plugins() { + $response.html("

Plugins Installation in Progress...

"); + $('.progress-bar').animate({width: "82.5%"}); + $.post(window.location.href + '?action=install_plugins', $('form').serialize(), function(data) { + $response.html(data); + console.log('install_plugins done'); + activate_dsw(); + }); +} + +// Plugin +function activate_dsw() { + $response.html("

Instaluji šablonu Dobrý skautský web

"); + $('.progress-bar').animate({width: "82.5%"}); + $.post(window.location.href + '/../../wp-content/themes/dsw-oddil-master/install.php', $('form').serialize(), function(data) { + $response.hide(); + console.log('activate_dsw done'); + success(); + }); +} + +// Remove the archive +function success() { + $response.html("

Successful installation completed

"); + $('.progress-bar').animate({width: "100%"}); + $response.hide(); + $('.progress').delay(500).hide(); + $.post(window.location.href + '?action=success',$('form').serialize(), function(data) { + $('#success').show().append(data); + }); + $.get( 'http://wp-quick-install.com/inc/incr-counter.php' ); +} diff --git a/wp-quick-install/data.ini b/wp-quick-install/data.ini old mode 100644 new mode 100755 index 7b5f8c8..1674c7e --- a/wp-quick-install/data.ini +++ b/wp-quick-install/data.ini @@ -25,10 +25,10 @@ ;db['dbname'] = demo ;db['dbhost'] = localhost -;db['prefix'] = wp_ +db['prefix'] = skautwp_ ;db['uname'] = root ;db['pwd'] = root -;db['default_content'] = 1 +db['default_content'] = 1 ;;;; @@ -45,7 +45,7 @@ ; 1 = Yes, 0 = No ;;;; -;seo = 0 +seo = 1 ;;;; @@ -53,7 +53,7 @@ ; 1 = Yes, 0 = No ;;;; -;activate_theme = 1 +activate_theme = 1 ;;;; @@ -68,9 +68,16 @@ ; List all plugin you want to install below (uncomment to use): ;;;; -;plugins[] = wordpress-seo - - +;plugins[] = wordpress-seo +;plugins[] = rocket-lazy-load +;plugins[] = image-widget +plugins[] = tiled-gallery-carousel-without-jetpack +plugins[] = wordfence +plugins[] = wp-super-cache +plugins[] = google-calendar-events +plugins[] = easy-facebook-feed +plugins[] = skautis-integration +plugins[] = mainwp-child ;;;; ; Install extensions which are on the "wp-quick-install" "plugins" folder (uncomment to use): @@ -85,7 +92,7 @@ ; 1 = Yes, 0 = No ;;;; -;activate_plugins = 0 +activate_plugins = 1 ;;;; @@ -130,5 +137,4 @@ ; parent = Parent page Title ;;;; -;posts[0] = title::Legal - status::publish - content::Lorem ipsum dolor sit amet - type::page -;posts[1] = title::Contact - status::publish - content::Lorem ipsum dolor sit amet - type::page - parent::Legal \ No newline at end of file +posts[0] = title::Tvůj Dobrý skautský web je skoro připraven - status::publish - content::Ted už zbývá nastavit pár detailů... - type::post diff --git a/wp-quick-install/inc/functions.php b/wp-quick-install/inc/functions.php deleted file mode 100644 index 9a198d2..0000000 --- a/wp-quick-install/inc/functions.php +++ /dev/null @@ -1,11 +0,0 @@ - - + - + @@ -685,12 +699,12 @@ - + - +

@@ -700,13 +714,13 @@

- +

.

- +

diff --git a/wp-quick-install/run.php b/wp-quick-install/run.php new file mode 100644 index 0000000..41e11a0 --- /dev/null +++ b/wp-quick-install/run.php @@ -0,0 +1,19 @@ +installWordpress('wordpress', 'root', '', 'localhost', 'my wordpress', 'admin', 'admin', 'admin@admin.cz'); + +$time_post = microtime(true); + +$exec_time = $time_post - $time_pre; +print($exec_time); \ No newline at end of file