3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) return;
15 // http://doc.spip.org/@base_admin_repair_dist
16 function base_admin_repair_dist($titre='', $reprise='') {
18 $f = sql_repair('repair', NULL, true);
20 $res = admin_repair_tables();
23 spip_log("Pas d'instruction REPAIR dans ce serveur SQL");
28 $res = "<br /><br /><span style='color: red; font-weight: bold;'><tt>"._T('avis_erreur_mysql').' '.sql_errno().': '.sql_error() ."</tt></span><br /><br /><br />\n";
30 include_spip('inc/rubriques');
32 propager_les_secteurs();
34 include_spip('inc/minipres');
35 $res .= pipeline('base_admin_repair',$res);
36 $res .= admin_repair_plat();
37 echo minipres(_T('texte_tentative_recuperation'),
38 $res . generer_form_ecrire('accueil', '','',_T('public:accueil_site')));
41 // http://doc.spip.org/@admin_repair_plat
42 function admin_repair_plat(){
43 spip_log("verification des documents joints");
45 $repertoire = array();
46 include_spip('inc/getdocument');
47 $res = sql_select('*','spip_documents',"fichier REGEXP CONCAT('^',extension,'[^/\]') AND distant='non'");
49 while ($row=sql_fetch($res)){
50 $ext = $row['extension'];
52 spip_log("document sans extension: " . $row['id_document']);
55 if (!isset($repertoire[$ext])){
56 if (@file_exists
($plat = _DIR_IMG
. $ext .".plat"))
58 $repertoire[$ext] = creer_repertoire_documents($ext);
59 if (preg_match(',_$,',$repertoire[$ext]))
60 $repertoire[$ext] = false;
62 if ($d=$repertoire[$ext]){
63 $d = substr($d,strlen(_DIR_IMG
));
64 $src = $row['fichier'];
65 $dest = $d . substr($src,strlen($d));
66 if (deplacer_fichier_upload(_DIR_IMG
. $src, _DIR_IMG
. $dest)) {
67 sql_updateq('spip_documents',array('fichier'=>$dest),'id_document='.intval($row['id_document']));
68 spip_unlink(_DIR_IMG
. $src);
69 $out .= "$src => $dest<br />";
77 // http://doc.spip.org/@admin_repair_tables
78 function admin_repair_tables() {
80 $connexion = $GLOBALS['connexions'][0];
81 $prefixe = $connexion['prefixe'];
82 $res1 = sql_showbase();
85 while ($r = sql_fetch($res1)) {
86 $tab = array_shift($r);
88 $res .= "<br /><b>$tab</b> ";
89 spip_log("Repare $tab");
90 $result_repair = sql_repair($tab);
91 if (!$result_repair) return false;
93 $count = sql_countsel($tab);
96 $res .= "("._T('texte_compte_elements', array('count' => $count)).")\n";
98 $res .= "("._T('texte_compte_element', array('count' => $count)).")\n";
100 $res .= "("._T('texte_vide').")\n";
102 $msg = join(" ", sql_fetch($result_repair)) . ' ';
104 $ok = strpos($msg, ' OK ');
107 $res .= "<pre><span style='color: red; font-weight: bold;'>".htmlentities($msg)."</span></pre>\n";
109 $res .= " "._T('texte_table_ok')."<br />\n";