Compare commits
3 Commits
4750d43c55
...
c3adc7123b
Author | SHA1 | Date |
---|---|---|
Jean-Christian Paul Denis | c3adc7123b | |
Jean-Christian Paul Denis | 182aa2d4c9 | |
Jean-Christian Paul Denis | 2441981717 |
|
@ -1,3 +1,10 @@
|
|||
DotclearWatch 0.7 - 2023.08.12
|
||||
===========================================================
|
||||
* require dotclear 2.27
|
||||
* require php 7.4
|
||||
* Use asynchronous report sending
|
||||
* Use HttpClient first to send report
|
||||
|
||||
DotclearWatch 0.6 - 2023.08.09
|
||||
===========================================================
|
||||
* require dotclear 2.27
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# README
|
||||
|
||||
[![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)
|
||||
[![Release](https://img.shields.io/badge/release-0.7-a2cbe9.svg)](https://git.dotclear.watch/dw/DotclearWatch/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.12-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)
|
||||
|
|
|
@ -14,7 +14,7 @@ $this->registerModule(
|
|||
'Dotclear Watch',
|
||||
'Send report about your Dotclear',
|
||||
'Jean-Christian Denis and contributors',
|
||||
'0.6',
|
||||
'0.7',
|
||||
[
|
||||
'requires' => [
|
||||
['php', '7.4'],
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="DotclearWatch">
|
||||
<name>Dotclear Watch</name>
|
||||
<version>0.6</version>
|
||||
<version>0.7</version>
|
||||
<author>Jean-Christian Denis and contributors</author>
|
||||
<desc>Send report about your Dotclear</desc>
|
||||
<file>https://git.dotclear.watch/dw/DotclearWatch/releases/download/v0.6/plugin-DotclearWatch.zip</file>
|
||||
<file>https://git.dotclear.watch/dw/DotclearWatch/releases/download/v0.7/plugin-DotclearWatch.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<da:details>http://plugins.dotaddict.org/dc2/details/DotclearWatch</da:details>
|
||||
<da:details>https://git.dotclear.watch/dw/DotclearWatch/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/dw/DotclearWatch/issues</da:support>
|
||||
</module>
|
||||
</modules>
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*global $, dotclear */
|
||||
'use strict';
|
||||
|
||||
dotclear.adminDotclearWatchSendReport = () => {
|
||||
dotclear.services(
|
||||
'adminDotclearWatchSendReport',
|
||||
(data) => {
|
||||
try {
|
||||
const response = JSON.parse(data);
|
||||
if (response?.success) {
|
||||
} else {
|
||||
console.log(dotclear.debug && response?.message ? response.message : 'Dotclear REST server error');
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
},
|
||||
true, // Use GET method
|
||||
{ json: 1 },
|
||||
);
|
||||
};
|
||||
|
||||
$(() => {
|
||||
dotclear.adminDotclearWatchSendReport();
|
||||
});
|
|
@ -30,13 +30,25 @@ class Backend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
//My::addBackendMenuItem();
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminDashboardHeaders' => [Utils::class, 'sendReport'],
|
||||
'adminPageFooterV2' => [Utils::class, 'addMark'],
|
||||
'adminDashboardHeaders' => function (): string {
|
||||
return My::jsLoad('service', dcCore::app()->getVersion(My::id()));
|
||||
},
|
||||
'adminPageFooterV2' => [Utils::class, 'addMark'],
|
||||
]);
|
||||
|
||||
dcCore::app()->rest->addFunction(
|
||||
'adminDotclearWatchSendReport',
|
||||
function (): array {
|
||||
Utils::sendReport();
|
||||
|
||||
return [
|
||||
'ret' => true,
|
||||
'msg' => 'report sent',
|
||||
];
|
||||
},
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,9 +192,18 @@ class Utils
|
|||
$status = 500;
|
||||
$response = '';
|
||||
$url = sprintf(self::url(), 'report');
|
||||
$path = '';
|
||||
|
||||
try {
|
||||
if (function_exists('curl_init')) {
|
||||
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 = (int) $client->getStatus();
|
||||
$response = $client->getContent();
|
||||
} elseif (function_exists('curl_init')) {
|
||||
if (false !== ($client = curl_init($url))) {
|
||||
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($client, CURLOPT_POST, true);
|
||||
|
@ -204,17 +213,6 @@ class Utils
|
|||
$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 = (int) $client->getStatus();
|
||||
$response = $client->getContent();
|
||||
}
|
||||
}
|
||||
|
||||
unset($client);
|
||||
|
|
Loading…
Reference in New Issue