feat : add updater that can only list wikis
This commit is contained in:
parent
d9c9096d8c
commit
b25aa91743
3 changed files with 367 additions and 253 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
.env
|
||||
/vendor/*
|
||||
yeswiki-list.csv
|
|
@ -315,7 +315,8 @@ function checkHerse($herseUser, $hersePass)
|
|||
return true; // herse needed
|
||||
}
|
||||
|
||||
function editConfigFile() {
|
||||
function editConfigFile()
|
||||
{
|
||||
// change fuseau horaire
|
||||
// 'contact_mail_func' => 'smtp',
|
||||
// 'contact_smtp_host' => 'ssl://mail.gandi.net',
|
||||
|
@ -326,12 +327,48 @@ function editConfigFile() {
|
|||
|
||||
}
|
||||
|
||||
function addExtensions() {
|
||||
function addExtensions()
|
||||
{
|
||||
// ferme pour l'option ferme
|
||||
}
|
||||
|
||||
function addStatistics() {
|
||||
function addStatistics()
|
||||
{
|
||||
// requete SQL
|
||||
// INSERT INTO `matomo_site` (`idsite`, `name`, `main_url`, `ts_created`, `ecommerce`, `sitesearch`, `sitesearch_keyword_parameters`, `sitesearch_category_parameters`, `timezone`, `currency`, `exclude_unknown_urls`, `excluded_ips`, `excluded_parameters`, `excluded_user_agents`, `excluded_referrers`, `group`, `type`, `keep_url_fragment`, `creator_login`) VALUES (NULL, 'Partage ton outil', 'https://partagetonoutil.fr', '2023-02-01 00:00:00', '0', '1', '', '', 'Europe/Paris', 'EUR', '0', '', '', '', '', '', 'website', '0', 'superadmin');
|
||||
|
||||
}
|
||||
|
||||
function searchWikis($path, $pattern)
|
||||
{
|
||||
$it = new RecursiveDirectoryIterator($path);
|
||||
$list = array();
|
||||
foreach (new RecursiveIteratorIterator($it) as $file) {
|
||||
if (preg_match('/' . preg_quote($pattern) . '$/i', $file)) {
|
||||
$wakkaConfig = [];
|
||||
include_once($file);
|
||||
$list[] = [
|
||||
'URL' => $wakkaConfig['base_url'] ?? 'KO',
|
||||
'VERSION' => $wakkaConfig['yeswiki_version'] ?? 'KO',
|
||||
'RELEASE' => $wakkaConfig['yeswiki_release'] ?? 'KO',
|
||||
];
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
76
yeswiki-updater.php
Executable file
76
yeswiki-updater.php
Executable file
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once('vendor/autoload.php');
|
||||
require_once('utils.inc.php');
|
||||
|
||||
use DevCoder\DotEnv;
|
||||
|
||||
$climate = new League\CLImate\CLImate();
|
||||
$climate->description('yeswiki-updater, find and update YesWiki like a professionnal 🌈🦄');
|
||||
|
||||
if (0 == posix_getuid()) {
|
||||
$absolutePathToEnvFile = __DIR__ . '/.env';
|
||||
if (file_exists($absolutePathToEnvFile)) {
|
||||
(new DotEnv($absolutePathToEnvFile))->load();
|
||||
} else {
|
||||
$climate->error('ERROR : No .env file found.');
|
||||
exit;
|
||||
}
|
||||
|
||||
$climate->arguments->add([
|
||||
'path' => [
|
||||
'prefix' => 'p',
|
||||
'longPrefix' => 'path',
|
||||
'description' => 'Path to scan for wikis',
|
||||
'required' => true,
|
||||
'defaultValue' => '/var/www/html'
|
||||
],
|
||||
'output' => [
|
||||
'prefix' => 'o',
|
||||
'longPrefix' => 'output',
|
||||
'description' => 'Output results in table format, json or csv',
|
||||
'defaultValue' => 'table'
|
||||
],
|
||||
'update' => [
|
||||
'prefix' => 'u',
|
||||
'longPrefix' => 'update',
|
||||
'description' => 'Update to latest version of stable yeswiki',
|
||||
'defaultValue' => '0'
|
||||
],
|
||||
]);
|
||||
$climate->arguments->parse();
|
||||
$path = $climate->arguments->get('path');
|
||||
if (!empty($path) && is_dir($path)) {
|
||||
try {
|
||||
$update = $climate->arguments->get('update');
|
||||
$output = $climate->arguments->get('output');
|
||||
$matches = searchWikis($path, 'wakka.config.php');
|
||||
switch ($output) {
|
||||
|
||||
case 'table':
|
||||
$climate->table($matches);
|
||||
break;
|
||||
|
||||
case 'json':
|
||||
$climate->json($matches);
|
||||
break;
|
||||
|
||||
case 'csv':
|
||||
$fileName = 'yeswiki-list.csv';
|
||||
$file = fopen($fileName, "w");
|
||||
foreach ($matches as $line) {
|
||||
fputcsv($file, $line);
|
||||
}
|
||||
$climate->info($fileName . ' was created.');
|
||||
break;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$climate->error('ERROR : ' . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
$climate->usage();
|
||||
}
|
||||
} else {
|
||||
$climate->error('ERROR : this script needs root privilege to run.');
|
||||
exit;
|
||||
}
|
Loading…
Add table
Reference in a new issue