This repository was archived by the owner on May 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcron.php
More file actions
163 lines (134 loc) · 6.11 KB
/
cron.php
File metadata and controls
163 lines (134 loc) · 6.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
$racine = dirname(__FILE__);
if (!isset($lancementCronDansAdmin))
{
$lancementCronDansAdmin = FALSE;
}
if (file_exists($racine . '/init.inc.php'))
{
include $racine . '/init.inc.php';
include_once $racine . '/inc/fonctions.inc.php';
include_once $racineAdmin . '/inc/fonctions.inc.php';
include_once $racine . '/inc/php-gettext/gettext.inc.php';
eval(variablesAvantConfig());
foreach (cheminsInc($racine, 'config') as $cheminFichier)
{
include $cheminFichier;
}
foreach (adminCheminsInc($racineAdmin, 'config') as $cheminFichier)
{
include $cheminFichier;
}
if ($lancementCronDansAdmin || ($activerPageCron && (empty($cleCron) || (isset($_GET['cle']) && $_GET['cle'] == $cleCron))))
{
$langueRapports = !empty($langueRapports) ? $langueRapports : $langueParDefaut;
phpGettext($racine, $langueRapports); // Nécessaire à la traduction.
$rapport = '';
$t1 = time();
$dateJour = date('Y-m-d', $t1);
$dateHeure = date('H:i:s', $t1);
$rapport .= '<h1>' . sprintf(T_("Rapport d'exécution du cron du %1\$s à %2\$s"), $dateJour, $dateHeure) . "</h1>\n";
$rapport .= '<p id="rapportCronNoteEnvoi"><em>' . sprintf(T_("Note: pour ne plus recevoir le rapport d'exécution du cron, <a href=\"%1\$s\">modifier la variable %2\$s dans le fichier de configuration du site</a>."), $urlRacineAdmin . '/porte-documents.admin.php?action=editer&valeur=' . encodeTexteGet('../site/inc/config.inc.php') . '&dossierCourant=' . encodeTexteGet('../site/inc') . '#messages', '<code>$envoyerRapportCron</code>') . "</em></p>\n";
$rapport .= "<ul id=\"rapportCronLiensAdmin\">\n";
$rapport .= '<li><a href="' . $urlRacine . '/cron.php">' . T_("Page de lancement du cron") . "</a></li>\n";
$rapport .= '<li><a href="' . $urlRacineAdmin . '/">' . T_("Section d'administration du site") . "</a></li>\n";
$rapport .= "</ul>\n";
$cheminDossierTmpCron = "$racine/site/cache/cron/";
if (@mkdir($cheminDossierTmpCron))
{
$erreurLancementCron = FALSE;
@file_put_contents("$racine/site/inc/cron.txt", $t1);
if ($dureeCache || $ajouterPagesParCronDansSitemap)
{
$listeUrl = adminListeUrl($racine, $urlRacine, $accueil, $activerCategoriesGlobales, $nombreArticlesParPageCategorie, $nombreItemsFluxRss, $activerFluxRssGlobalSite, $galerieActiverFluxRssGlobal, $galerieVignettesParPage, $activerGalerieDemo, $galerieFluxRssAuteurEstAuteurParDefaut, $auteurParDefaut, $galerieLienOriginalTelecharger, $galerieLegendeMarkdown);
}
########################################################################
##
## Cache.
##
########################################################################
$rapport .= '<h2>' . T_("Cache") . "</h2>\n";
$rapportLi = '';
if ($dureeCache || $dureeCachePartiel)
{
foreach ($listeUrl as $url => $infosUrl)
{
simuleVisite($racine, $urlRacine, $url, $dureeCache, FALSE, TRUE);
$rapportLi .= "<li><code>$url</code></li>\n";
}
}
if (empty($rapportLi))
{
$rapport .= '<p>' . T_("Aucune action à effectuer.") . "</p>\n";
}
else
{
$rapport .= '<p>' . T_("Génération du cache des URL suivantes:") . "</p>\n";
$rapport .= "<ul>\n";
$rapport .= $rapportLi;
$rapport .= "</ul>\n";
}
########################################################################
##
## Fichiers Sitemap.
##
########################################################################
$rapport .= '<h2>' . T_("Fichier Sitemap") . "</h2>\n";
if ($ajouterPagesParCronDansSitemap)
{
$rapport .= '<h3>' . T_("Ajout de pages dans le fichier Sitemap") . "</h3>\n";
$rapport .= "<ul>\n";
$contenuSitemap = adminGenereContenuSitemap($listeUrl);
$rapport .= adminEnregistreSitemap($racine, $contenuSitemap);
$rapport .= "</ul>\n";
}
$rapport .= '<h3>' . sprintf(T_("Vérification de la déclaration du fichier Sitemap dans le fichier %1\$s"), '<code>robots.txt</code>') . "</h3>\n" ;
$rapport .= "<ul>\n";
$rapport .= adminDeclareSitemapDansRobots($racine, $urlRacine);
$rapport .= "</ul>\n";
$t2 = time();
$t = $t2 - $t1;
$rapport .= "<hr />\n";
$rapport .= '<p>' . sprintf(T_ngettext("Cron exécuté en %1\$s seconde.", "Cron exécuté en %1\$s secondes.", $t), $t) . "</p>\n";
adminRmdirRecursif($cheminDossierTmpCron);
}
else
{
$erreurLancementCron = TRUE;
$rapport .= '<p class="erreur">' . T_("Le cron est déjà en cours. La présente demande de lancement de cron a donc été annulée.") . "</p>\n";
}
########################################################################
##
## Envoi du rapport.
##
########################################################################
if ($lancementCronDansAdmin)
{
$rapport = preg_replace('#<p id="rapportCronNoteEnvoi">.+?</p>#', '', $rapport);
$rapport = preg_replace('#<ul id="rapportCronLiensAdmin">.+?</ul>#s', '', $rapport);
}
elseif ((($envoyerRapportCron == 1 && $erreurLancementCron) || $envoyerRapportCron == 2) && (!empty($courrielAdmin) || !empty($contactCourrielParDefaut)))
{
$rapport = str_replace('class="erreur"', 'style="color: #630000;"', $rapport);
$rapport = str_replace('<code>', '<code style="background-color: #F2F2F2;">', $rapport);
$rapport = str_replace('<pre ', '<pre style="overflow: auto; padding: 5px; border: 1px solid #B3B3B3; background-color: #F2F2F2;" ', $rapport);
$rapport = preg_replace("#<ul>\n<li><a href=\"javascript:adminSelectionneTexte\('[^']+'\);\">[^<]+</a></li>\n</ul>#", '', $rapport);
$infosCourriel = array ();
$infosCourriel['From'] = $courrielExpediteurRapports;
$infosCourriel['format'] = 'html';
$infosCourriel['destinataire'] = !empty($courrielAdmin) ? $courrielAdmin : $contactCourrielParDefaut;
$infosCourriel['objet'] = sprintf(T_("Cron du %1\$s à %2\$s"), $dateJour, $dateHeure) . baliseTitleComplement($tableauBaliseTitleComplement, array ($langueParDefaut), FALSE);
$infosCourriel['message'] = $rapport;
courriel($infosCourriel);
}
}
elseif (!$lancementCronDansAdmin)
{
header('HTTP/1.1 401 Unauthorized');
}
}
elseif (!$lancementCronDansAdmin)
{
header('HTTP/1.1 404 Not found');
}
?>