// Route to export datas to Excel
Route::post($segment . '/stats/{fluidbook_id}_{hash}/{date?}/{period_override?}/generate', $controller . '@generateExcel')
->name('generateexcel');
+
+ Route::get('s/prxtm', $controller . '@matomoProxy')->withoutMiddleware([CheckIfAdmin::class]);
+ }
+
+ protected function matomoProxy()
+ {
+ $u = base64_decode(request()->get('d'));
+ $c = parse_url($u);
+ $token = Stats::getMatomoToken($c['host']);
+ if ($token) {
+ $u .= '&token_auth=' . rawurlencode($token) . '&cip=' . rawurlencode($_SERVER['HTTP_X_REAL_IP']);
+ }
+ file_get_contents(html_entity_decode($u));
+ return response('',204);
}
protected function setupStatsDefaults()
* @throws ContainerExceptionInterface
* @throws Exception
*/
- public function generateExcel($fluidbook_id, $hash, $date = null, $period_override = null) {
+ public function generateExcel($fluidbook_id, $hash, $date = null, $period_override = null)
+ {
$url = route('stats', compact('fluidbook_id', 'hash', 'date', 'period_override'));
- $dateForFilename = str_replace('-','',str_replace(',','_', $date));
- $name = "stats_".$fluidbook_id."_".$dateForFilename;
+ $dateForFilename = str_replace('-', '', str_replace(',', '_', $date));
+ $name = "stats_" . $fluidbook_id . "_" . $dateForFilename;
$locale = backpack_user()->locale;
$acceptLang = [
"en" => "en-US,en;q=0.5"
];
- $html = $this->translateHtml($url,$acceptLang[$locale]);
+ $html = $this->translateHtml($url, $acceptLang[$locale]);
$html = HtmlDomParser::str_get_html($html);
$names = [...$html->find('h2'), ...$html->find('h3')];
$head = [];
$datas = [];
- if($theads) {
+ if ($theads) {
foreach ($theads as $thead) {
$head[] = $thead->text;
}
foreach ($tr as $k => $lines) {
foreach ($lines->find('td') as $td) {
$text = $td->text;
- if($td->getAttribute('data-flag')) {
+ if ($td->getAttribute('data-flag')) {
$text = $td->getAttribute('data-flag');
- } elseif($td->getAttribute('sorttable_customkey')) {
+ } elseif ($td->getAttribute('sorttable_customkey')) {
$text = $td->getAttribute('sorttable_customkey');
}
$writer->save($output);
}
- protected function translateHtml($url,$lang) {
+ protected function translateHtml($url, $lang)
+ {
$ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
+ curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [
- 'Accept-Language: '.$lang,
+ 'Accept-Language: ' . $lang,
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- $html = curl_exec ($ch);
- curl_close ($ch);
+ $html = curl_exec($ch);
+ curl_close($ch);
return $html;
}
}
$this->addSettingField('matomoSiteId', Integer::class, $this->__('Site ID'), ['when' => ['matomoServer' => '_not_empty_']]);
$this->addSettingField('', FormSeparator::class);
$this->addSettingField('matomoTagManager', Text::class, 'Matomo Tag Manager', ['prefix' => 'https://']);
+ $this->addSettingField('', FormSeparator::class);
+ $this->addSettingField('matomoTracking', SelectFromArray::class, $this->__('Type de tracker'),
+ ['default' => 'js', 'options' => ['js' => __('Tracker JS') . ' (' . __('recommandé') . ')', 'pixel' => __('Pixel'), 'proxy' => __('Proxy')]]);
}
protected function _statsGoogleAnalytics()