X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Fbase%2Fadmin_repair.php;fp=www%2Fecrire%2Fbase%2Fadmin_repair.php;h=4b8a09662361bb7a03640071b001c6950862dbc6;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/ecrire/base/admin_repair.php b/www/ecrire/base/admin_repair.php new file mode 100644 index 0000000..4b8a096 --- /dev/null +++ b/www/ecrire/base/admin_repair.php @@ -0,0 +1,114 @@ +
"._T('avis_erreur_mysql').' '.sql_errno().': '.sql_error() ."


\n"; + } else { + include_spip('inc/rubriques'); + calculer_rubriques(); + propager_les_secteurs(); + } + include_spip('inc/minipres'); + $res .= pipeline('base_admin_repair',$res); + $res .= admin_repair_plat(); + echo minipres(_T('texte_tentative_recuperation'), + $res . generer_form_ecrire('accueil', '','',_T('public:accueil_site'))); +} + +// http://doc.spip.org/@admin_repair_plat +function admin_repair_plat(){ + spip_log("verification des documents joints"); + $out = ""; + $repertoire = array(); + include_spip('inc/getdocument'); + $res = sql_select('*','spip_documents',"fichier REGEXP CONCAT('^',extension,'[^/\]') AND distant='non'"); + + while ($row=sql_fetch($res)){ + $ext = $row['extension']; + if (!$ext) { + spip_log("document sans extension: " . $row['id_document']); + continue; + } + if (!isset($repertoire[$ext])){ + if (@file_exists($plat = _DIR_IMG. $ext .".plat")) + spip_unlink($plat); + $repertoire[$ext] = creer_repertoire_documents($ext); + if (preg_match(',_$,',$repertoire[$ext])) + $repertoire[$ext] = false; + } + if ($d=$repertoire[$ext]){ + $d = substr($d,strlen(_DIR_IMG)); + $src = $row['fichier']; + $dest = $d . substr($src,strlen($d)); + if (deplacer_fichier_upload(_DIR_IMG . $src, _DIR_IMG . $dest)) { + sql_updateq('spip_documents',array('fichier'=>$dest),'id_document='.intval($row['id_document'])); + spip_unlink(_DIR_IMG . $src); + $out .= "$src => $dest
"; + } + } + } + + return $out; +} + +// http://doc.spip.org/@admin_repair_tables +function admin_repair_tables() { + + $connexion = $GLOBALS['connexions'][0]; + $prefixe = $connexion['prefixe']; + $res1 = sql_showbase(); + $res = ""; + if ($res1) { + while ($r = sql_fetch($res1)) { + $tab = array_shift($r); + + $res .= "
$tab "; + spip_log("Repare $tab"); + $result_repair = sql_repair($tab); + if (!$result_repair) return false; + + $count = sql_countsel($tab); + + if ($count>1) + $res .= "("._T('texte_compte_elements', array('count' => $count)).")\n"; + else if ($count==1) + $res .= "("._T('texte_compte_element', array('count' => $count)).")\n"; + else + $res .= "("._T('texte_vide').")\n"; + + $msg = join(" ", sql_fetch($result_repair)) . ' '; + + $ok = strpos($msg, ' OK '); + + if (!$ok) + $res .= "
".htmlentities($msg)."
\n"; + else + $res .= " "._T('texte_table_ok')."
\n"; + } + } + return $res; +} +?>