[ Index ] |
|
Code source de SPIP Agora 1.4 |
1 <?php 2 /***************************************************** 3 * This file is part of Agora, web based content management system. 4 * 5 * Agora is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * 9 * Agora is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details (file "COPYING"). 13 * 14 * Copyright © Arnaud Martin, Antoine Pitrou et Philippe Rivière. 15 * List of authors detailed in "copyright_fr.html" file. 16 * E-mail : agora@sig.premier-ministre.gouv.fr 17 * Web site : http://www.agora.gouv.fr 18 *****************************************************/ 19 20 // ce fichier est appele par inc-public-global ou independament via la ligne de commande 21 22 if (!(defined('FRONT') && FRONT)) { 23 chdir(dirname(__FILE__). '/../../'); // pour les include_ecrire 24 // TODO : c'est nul :-( 25 } 26 27 require_once(dirname(__FILE__). "/../inc_version.php"); 28 require_once(dirname(__FILE__). "/../inc_meta.php"); 29 require_once(dirname(__FILE__). "/../inc_connect.php"); 30 31 // ce fichier est initialement appele depuis la racine ... 32 33 // 34 // Archivage des statistiques du site public 35 // 36 37 // 38 // Envoi du mail quoi de neuf 39 // 40 if ($GLOBALS['db_ok']) { 41 if ((lire_meta('quoi_de_neuf') == 'oui') 42 AND ($jours_neuf = lire_meta('jours_neuf')) 43 AND ($adresse_neuf = lire_meta('adresse_neuf')) 44 AND (time() - ($majnouv = lire_meta('majnouv'))) > 3600 * 24 * $jours_neuf) 45 { 46 if (timeout('quoide_neuf')) { 47 include_ecrire ('inc_meta.php'); 48 ecrire_meta('majnouv', time()); 49 ecrire_metas(); 50 51 // preparation mail 52 unset($mail_nouveautes); 53 unset($sujet_nouveautes); 54 $fond = 'nouveautes'; 55 $delais = 0; 56 $contexte_inclus = array('date' => date('Y-m-d H:i:s', $majnouv)); 57 include(inclure_fichier($fond, $delais, $contexte_inclus)); 58 59 // envoi 60 if ($mail_nouveautes) { 61 spip_log("envoi mail nouveautes"); 62 include_ecrire('inc_mail.php'); 63 envoyer_mail($adresse_neuf, $sujet_nouveautes, $mail_nouveautes); 64 } 65 else 66 spip_log("envoi mail nouveautes : pas de nouveautes"); 67 } 68 } 69 } 70 71 // Mise a jour des fichiers langues de l'espace public 72 if ($cache_lang_modifs) { 73 //include_ecrire('inc_lang.php'); 74 include_once(dirname(__FILE__). '/../inc_lang.php'); 75 ecrire_caches_langues(); 76 } 77 78 // Selection d'une rubrique au hasard pour mise a jour 79 if ($GLOBALS['db_ok']) { 80 if ((time() - lire_meta('calcul_rubriques') > 3600)AND timeout('calcul_rubriques')) { 81 require_once(dirname(__FILE__). '/../include/bd/inc_rubrique_factory.php'); 82 83 // Chargement d'une rubrique au hasard 84 $rub = &recuperer_instance_rubrique(); 85 $rub_ids = $rub->getAllRubriqueId(); 86 $id = $rub_ids[array_rand($rub_ids)]; 87 $status = $rub->load($id); 88 89 // Si la rubrique contient des articles 90 if (PEAR::isError($status)) { 91 die($status->getMessage()); 92 } 93 94 if ($rub->checkForPostDated()) { 95 $status = $rub->update(); 96 97 if (PEAR::isError($status)) { 98 die($status->getMessage()); 99 } 100 if ($rub->checkForPostDated()) { 101 $status = $rub->update(); 102 if (PEAR::isError($status)) { 103 die($status->getMessage()); 104 } 105 } 106 } 107 108 // Mise a our de la derniere date de mise a jour des rubriques 109 require_once dirname(__FILE__). '/../inc_meta.php'; 110 ecrire_meta('calcul_rubriques', time()); 111 ecrire_metas(); 112 } 113 } 114 115 if ($GLOBALS['db_ok']) { 116 if (lire_meta("activer_statistiques") != "non") { 117 if (timeout(false, false)) // no lock, no action 118 { 119 // Conditions declenchant un eventuel calcul des stats 120 if ((lire_meta('calculer_referers_now') == 'oui') 121 OR (date("Y-m-d") <> lire_meta("date_statistiques")) 122 OR (time() - lire_meta('date_stats_popularite') > 1800)) { 123 include_local("inc-stats.php"); 124 archiver_stats(); 125 } 126 } 127 } 128 } 129 130 // 131 // Faire du menage dans le cache (effacer les fichiers tres anciens ou inutilises) 132 // Se declenche une fois par heure quand le cache n'est pas recalcule 133 // 134 include(dirname(__FILE__). '/../include/cacheHTML/inc_config_cacheHTML.php'); 135 $cacheDir = $containerParams['cacheHTML_directory']; 136 137 if ($use_cache AND file_exists($cacheDir . '.purge2')) { 138 if (timeout('purge_cache')) { 139 unlink($cacheDir . '.purge2'); 140 spip_log("purge cache niveau 2"); 141 if ($GLOBALS['db_ok']) { 142 require_once(dirname(__FILE__). "/../include/bd/inc_forum_factory.php"); 143 $forumMetier = &recuperer_instance_forum(); 144 $deleteExpiredCacheOK = $forumMetier->deleteExpiredCache(); 145 if (PEAR::isError($deleteExpiredCacheOK)) { 146 die("->" . $deleteExpiredCacheOK->getMessage()); 147 } 148 } 149 } 150 } 151 152 if ($use_cache AND file_exists('CACHE/.purge')) { 153 if (timeout('purge_cache')) { 154 $dir = 'CACHE/' . dechex((time() / 3600) & 0xF); 155 unlink('CACHE/.purge'); 156 spip_log("purge cache niveau 1: $dir"); 157 $f = fopen('CACHE/.purge2', 'w'); 158 fclose($f); 159 include_local("inc-cache.php"); 160 purger_repertoire($dir, 14 * 24 * 3600); 161 } 162 } 163 164 // 165 // Gerer l'indexation automatique 166 // 167 if ($GLOBALS['db_ok']) { 168 if (lire_meta('activer_moteur') == 'oui') { 169 $elementList = array('id_article', 'id_auteur', 'id_breve', 'id_mot', 'id_rubrique'); 170 171 while (list(, $val) = each($elementList)) { 172 if ($$val == "-1") { 173 $$val = false; 174 } 175 } 176 177 include_ecrire ("inc_index.php"); 178 alimenter_fichier_index($GLOBALS['db_ok']); 179 $fichier_index = 'ecrire/data/.index'; 180 181 if (defined("FRONT")) { 182 if ($use_cache AND file_exists($fichier_index)) { 183 $go_indexation = true; 184 } 185 else { 186 $go_indexation = false; 187 } 188 } 189 else { // on est en cron 190 $go_indexation = true; 191 } 192 if ($go_indexation) { 193 if ($GLOBALS['db_ok']) { 194 include_ecrire ("inc_index.php"); 195 effectuer_une_indexation(); 196 } 197 } 198 } 199 } 200 201 // 202 // Mise a jour d'un (ou de zero) site syndique 203 // 204 if ($GLOBALS['db_ok']) { 205 if ($db_ok AND lire_meta("activer_syndic") == "oui") { 206 if (timeout()) { 207 include_ecrire ("inc_sites.php"); 208 executer_une_syndication(); 209 if (lire_meta('activer_moteur') == 'oui') { 210 include_ecrire ("inc_index.php"); 211 executer_une_indexation_syndic(); 212 } 213 } 214 } 215 } 216 217 // 218 // Ce code la n'est necessaire que sur les serveurs 219 // qui ne relachent pas le lock a la fin de script php. 220 // Ce bout de n'importe quoi s'occupe d'une telle abberation 221 // Il peut etre supprime si votre serveur n'a pas de probleme. 222 require_once(dirname(__FILE__). '/../include/bd/inc_service_factory.php'); 223 $serviceMetier = &recuperer_instance_service(); 224 $serviceMetier->getLock('XXXX_INEXISTENT_XXXX'); 225 $serviceMetier->releaseLock('XXXX_INEXISTENT_XXXX'); 226 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |