Compare commits

..

3 Commits

5 changed files with 71 additions and 47 deletions

View File

@ -1,3 +1,7 @@
0.1 - 2023.xx.xx
- require dotclear 2.27
- require php 7.4
DotclearWatch 0.6 - 2023.08.09
===========================================================
* require dotclear 2.27
* require php 7.4
* Use curl first to send report to server
* Move third party repository
* Use Dotclear style for CHANGELOG

View File

@ -1,11 +1,10 @@
# README
[![Release](https://img.shields.io/github/v/release/JcDenis/DotclearWatch)](https://github.com/JcDenis/DotclearWatch/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/DotclearWatch)](https://github.com/JcDenis/DotclearWatch/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/DotclearWatch)](https://github.com/JcDenis/DotclearWatch/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/DotclearWatch)
[![License](https://img.shields.io/github/license/JcDenis/DotclearWatch)](https://github.com/JcDenis/DotclearWatch/blob/master/LICENSE)
[![Release](https://img.shields.io/badge/release-0.6-a2cbe9.svg)](https://git.dotclear.watch/dw/DotclearWatch/releases)
[![Date](https://img.shields.io/badge/date-2023.08.09-c44d58.svg)](https://git.dotclear.watch/dw/DotclearWatch/releases)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/DotclearWatch)
[![License](https://img.shields.io/github/license/JcDenis/DotclearWatch)](https://git.dotclear.watch/dw/DotclearWatch/blob/master/LICENSE)
## WHAT IS DOTCLEARWATCH ?
@ -13,24 +12,27 @@
web publishing software called Dotclear.
It tracks Dotclear's installation to get stats about it.
Default statistics server is located at https://dotclear.watch/statistics
What's being track :
* Dotclear version,
* PHP version,
* Database version,
* List of installed modules (only id and version)
* Number of blogs. (no name or id or whatever else)
* Dotclear version,
* PHP version,
* Database version,
* Current blog theme,
* number of blogs on multiblogs
* List of installed modules (only id and version)
* Number of blogs. (no name or id or whatever else)
If you want to hide some modules, just enter their IDs in a comma separeted list
in aboutConfig global parameters called DotclearWatch->hidden_modules
## REQUIREMENTS
DotclearWatch requires:
DotclearWatch requires:
* super admin permission to intall it
* Dotclear 2.27
* PHP 7.4+
* super admin permission to intall it
* Dotclear 2.27
* PHP 7.4+
## USAGE
@ -41,13 +43,13 @@ To disable sending stats, just deactivate or uninstall this plugin.
## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contributions : [GitHub Page](https://github.com/JcDenis/DotclearWatch)
* Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/DotclearWatch)
* Discussion & Help : [Github issue](https://github.com/JcDenis/DotclearWatch/issues)
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contributions : [Gitea Page](https://git.dotclear.watch/dw/DotclearWatch) or [GitHub Page](https://github.com/JcDenis/DotclearWatch)
* Packages & details : [Gitea Page](https://git.dotclear.watch/dw/DotclearWatch/releases) or[Dotaddict Page](https://plugins.dotaddict.org/dc2/details/DotclearWatch)
* Discussion & Help : [Gitea Page](https://github.com/dw/DotclearWatch/issues)
## CONTRIBUTORS
* Jean-Christian Denis (author)
* Jean-Christian Denis (author)
You are welcome to contribute to this code.
You are welcome to contribute to this code.

View File

@ -14,15 +14,15 @@ $this->registerModule(
'Dotclear Watch',
'Send report about your Dotclear',
'Jean-Christian Denis and contributors',
'0.5',
'0.6',
[
'requires' => [
['php', '7.4'],
['core', '2.27'],
],
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/DotclearWatch/issues',
'details' => 'http://plugins.dotaddict.org/dc2/details/DotclearWatch',
'repository' => 'https://raw.githubusercontent.com/JcDenis/DotclearWatch/master/dcstore.xml',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
]
);

View File

@ -2,12 +2,12 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="DotclearWatch">
<name>Dotclear Watch</name>
<version>0.5</version>
<version>0.6</version>
<author>Jean-Christian Denis and contributors</author>
<desc>Send report about your Dotclear</desc>
<file>https://github.com/JcDenis/DotclearWatch/releases/download/v0.5/plugin-DotclearWatch.zip</file>
<file>https://git.dotclear.watch/dw/DotclearWatch/releases/download/v0.6/plugin-DotclearWatch.zip</file>
<da:dcmin>2.27</da:dcmin>
<da:details>http://plugins.dotaddict.org/dc2/details/DotclearWatch</da:details>
<da:support>https://github.com/JcDenis/DotclearWatch/issues</da:support>
<da:support>https://git.dotclear.watch/dw/DotclearWatch/issues</da:support>
</module>
</modules>

View File

@ -48,7 +48,7 @@ class Utils
if (My::settings()->getGlobal('distant_api_url')) {
echo sprintf(
'<ul><li><a href="%s" title="%s" class="outgoing">%s<img src="%s" /></a></ul></li>',
'https://dotclear.watch/statistics',
'https://statistics.dotclear.watch',
__('DotclearWatch plugin statistics'),
__('Tracked by dotclear.watch'),
My::fileURL('icon.svg')
@ -188,28 +188,46 @@ class Utils
self::write($contents);
$client = false;
$status = 500;
$response = '';
$url = sprintf(self::url(), 'report');
$path = '';
if ($client = HttpClient::initClient($url, $path)) {
try {
if (function_exists('curl_init')) {
if (false !== ($client = curl_init($url))) {
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
curl_setopt($client, CURLOPT_POST, true);
curl_setopt($client, CURLOPT_POSTFIELDS, ['key' => self::key(), 'report' => $contents]);
if (false !== ($response = curl_exec($client))) {
$status = (int) curl_getinfo($client, CURLINFO_HTTP_CODE);
}
}
} else {
$path = '';
if (false !== ($client = HttpClient::initClient($url, $path))) {
$client->setUserAgent('Dotclear.watch ' . My::id() . '/' . self::DISTANT_API_VERSION);
$client->useGzip(false);
$client->setPersistReferers(false);
$client->post($path, ['key' => self::key(), 'report' => $contents]);
$status = $client->getStatus();
$status = (int) $client->getStatus();
$response = $client->getContent();
unset($client);
if ($status != 202) {
self::error((string) '(' . $status . ') ' . $response);
}
}
return;
unset($client);
} catch (Exception $e) {
unset($client);
}
if ($status == 202) {
return;
}
if ($status !== false) {
self::error((string) '(' . $status . ') ' . $response);
}
if ($force) {