[SPIP] v3.2.1-->v3.2.2
[lhc/web/www.git] / www / ecrire / install / etape_fin.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2019 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
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 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) {
14 return;
15 }
16
17 include_spip('inc/headers');
18 include_spip('inc/acces');
19
20 // Mise en place des fichiers de configuration si ce n'est fait
21
22 // http://code.spip.net/@install_etape_fin_dist
23 function install_etape_fin_dist() {
24 ecrire_acces();
25
26 $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP);
27 if (file_exists(_FILE_CHMOD_TMP)) {
28 if (!@rename(_FILE_CHMOD_TMP, $f)) {
29 if (@copy(_FILE_CHMOD_TMP, $f)) {
30 spip_unlink(_FILE_CHMOD_TMP);
31 }
32 }
33 }
34
35 $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP);
36 if (file_exists(_FILE_CONNECT_TMP)) {
37 spip_log("renomme $f");
38 if (!@rename(_FILE_CONNECT_TMP, $f)) {
39 if (@copy(_FILE_CONNECT_TMP, $f)) {
40 @spip_unlink(_FILE_CONNECT_TMP);
41 }
42 }
43 }
44
45 // creer le repertoire cache, qui sert partout !
46 // deja fait en etape 4 en principe, on garde au cas ou
47 if (!@file_exists(_DIR_CACHE)) {
48 $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE);
49 $rep = sous_repertoire(_DIR_TMP, $rep, true, true);
50 }
51
52 // Verifier la securite des htaccess
53 // Si elle ne fonctionne pas, prevenir
54 $msg = install_verifier_htaccess();
55 if ($msg) {
56 $cible = _T('public:accueil_site');
57 $cible = generer_form_ecrire('accueil', '', '', $cible);
58 echo minipres('AUTO', $msg . $cible);
59 // ok, deboucher dans l'espace prive
60 } else {
61 redirige_url_ecrire('accueil');
62 }
63 }
64
65 function install_verifier_htaccess() {
66 if (verifier_htaccess(_DIR_TMP, true)
67 and verifier_htaccess(_DIR_CONNECT, true)
68 ) {
69 return '';
70 }
71
72 $titre = _T('htaccess_inoperant');
73
74 $averti = _T(
75 'htaccess_a_simuler',
76 array(
77 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>',
78 'constantes' => '<tt>_DIR_TMP &amp; _DIR_CONNECT</tt>',
79 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>'
80 )
81 );
82
83 return "<div class='error'><h3>$titre</h3><p>$averti</p></div>";
84 }