Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Changed no import option to only exclude post and product content, set webp image format if supported, set APCu cache driver for all apps if supported

givanzc1eceff83b4e
diff --git a/install/controller/index.php b/install/controller/index.php
index 55a27db..fd352b0 100755
--- a/install/controller/index.php
+++ b/install/controller/index.php
@@ -34,6 +34,7 @@ use Vvveb\System\Core\View;
use Vvveb\System\Extensions\Plugins;
use Vvveb\System\Extensions\Themes as ThemesList;
use Vvveb\System\Functions\Str;
+use Vvveb\System\Media\Image;
use Vvveb\System\User\Admin;
use function Vvveb\userPreferedLanguage;
@@ -161,13 +162,13 @@ class Index extends Base {
$import->createTables();
if ($noimport) {
- $filter = ['taxonomy.sql', 'admin.sql', 'role.sql', 'country.sql', 'region.sql', 'site.sql', 'menu.sql', 'length_type.sql'];
+ $exclude = ['post*', 'product*', 'vendor*', 'manufacturer*', 'taxonomy_*', 'attribute*', 'option*', 'user.sql', 'comment*', 'digital_asset*'];
} else {
- $filter = [];
+ $exclude = [];
}
$import->setPath(DIR_ROOT . 'install/sql/insert/');
- $import->insertData($filter);
+ $import->insertData([], $exclude);
//$import->db->close();
$this->writeConfig($data);
@@ -258,14 +259,6 @@ class Index extends Base {
$sites = new SiteSQL();
//$result = \Vvveb\setMultiSetting('site',$settings);
- $site = [];
- $site['site_id'] = 1;
- $site['settings'] = json_encode($settings);
-
- if ($theme) {
- $site['theme'] = $theme;
- }
-
if ($noecommerce) {
Plugins::activate('hide-ecommerce', 1);
}
@@ -284,9 +277,14 @@ class Index extends Base {
$settings['admin-email'] = $user['email'];
$settings['contact-email'] = $user['email'];
+ if (Image::formats('webp')) {
+ $settings['image_format'] = 'webp';
+ }
+
$site = [
'host' => $hostname ?? '*.*.*', //$_SERVER['HTTP_HOST']
'site_id' => 1,
+ 'id' => 1,
'name' => 'Default',
'theme' => $theme,
'settings' => json_encode($settings),
@@ -359,8 +357,14 @@ class Index extends Base {
@\Vvveb\setConfig('app.key', Str::random(32));
//set APCu memory cache if available instead of default file cache
- if (function_exists('apcu_cache_info') && ini_get('apc.enabled')) {
- @\Vvveb\setConfig('app.cache.driver', 'APCu');
+ $cacheDriver = (function_exists('apcu_cache_info') && ini_get('apc.enabled')) ? 'APCu' : null;
+
+ foreach (['app', 'admin', 'graphql', 'rest'] as $app) {
+ if ($cacheDriver) {
+ @\Vvveb\setConfig($app . '.cache.driver', $cacheDriver);
+ }
+ @\Vvveb\setConfig($app . '.cronkey', Str::random(32));
+ @\Vvveb\setConfig($app . '.key', Str::random(32));
}
if (V_SUBDIR_INSTALL) {
diff --git a/system/import/sql.php b/system/import/sql.php
index 61348c7..6a03f47 100755
--- a/system/import/sql.php
+++ b/system/import/sql.php
@@ -191,7 +191,7 @@ class Sql {
$glob = ['', '*/*/', '*/'];
//$files = glob($name, GLOB_BRACE);
- if (!$files) {
+ if (! $files) {
$files = globBrace($this->sqlPath, ['', '**/', '*/*/'], '*.sql');
}
@@ -225,7 +225,7 @@ class Sql {
foreach ($queries as $query) {
$query = trim($query);
- if (empty($query) || substr_compare($query, '-- ', 0, 3) === 0) {
+ if (empty($query) || strncmp($query, '-- ', 3) === 0) {
continue;
}
$this->multiQuery($query . ';', $filename);
@@ -250,16 +250,47 @@ class Sql {
return $sql;
}
- function insertData($filter = []) {
+ function insertData($include = [], $exclude = []) {
$glob = ['', '*/*/', '*/'];
//$files = glob($name, GLOB_BRACE);
$files = globBrace($this->sqlPath, ['', '**/', '*/*/'], '*.sql');
+ //expand * and transform to regex
+ $includeRegex = '';
+
+ if ($include) {
+ foreach ($include as $filter) {
+ if ($includeRegex) {
+ $includeRegex .= '|';
+ }
+ $includeRegex .= str_replace('*', '.*', addslashes($filter));
+ }
+
+ $includeRegex = '/' . $includeRegex . '/';
+ }
+
+ $excludeRegex = '';
+
+ if ($exclude) {
+ foreach ($exclude as $filter) {
+ if ($excludeRegex) {
+ $excludeRegex .= '|';
+ }
+ $excludeRegex .= str_replace('*', '.*', addslashes($filter));
+ }
+
+ $excludeRegex = '/' . $excludeRegex . '/';
+ }
+
foreach ($files as $filename) {
$name = basename($filename);
- if ($filter && ! in_array($name, $filter)) {
+ if ($excludeRegex && preg_match($excludeRegex, $name)) {
+ continue;
+ }
+
+ if ($includeRegex && ! preg_match($includeRegex, $name)) {
continue;
}