@@ -23,39 +23,39 @@ discard block |
||
| 23 | 23 | // |
| 24 | 24 | // http://doc.spip.org/@test_ecrire |
| 25 | 25 | function test_ecrire($my_dir) { |
| 26 | - static $chmod = 0; |
|
| 26 | + static $chmod = 0; |
|
| 27 | 27 | |
| 28 | - $ok = false; |
|
| 29 | - $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 30 | - $self = basename($script); |
|
| 31 | - $uid = @fileowner('.'); |
|
| 32 | - $uid2 = @fileowner($self); |
|
| 33 | - $gid = @filegroup('.'); |
|
| 34 | - $gid2 = @filegroup($self); |
|
| 35 | - $perms = @fileperms($self); |
|
| 36 | - |
|
| 37 | - // Comparer l'appartenance d'un fichier cree par PHP |
|
| 38 | - // avec celle du script et du repertoire courant |
|
| 39 | - if(!$chmod) { |
|
| 40 | - @rmdir('test'); |
|
| 41 | - spip_unlink('test'); // effacer au cas ou |
|
| 42 | - @touch('test'); |
|
| 43 | - if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) |
|
| 44 | - $chmod = 0700; |
|
| 45 | - else if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) |
|
| 46 | - $chmod = 0770; |
|
| 47 | - else |
|
| 48 | - $chmod = 0777; |
|
| 49 | - // Appliquer de plus les droits d'acces du script |
|
| 50 | - if ($perms > 0) { |
|
| 51 | - $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 52 | - $chmod |= $perms; |
|
| 53 | - } |
|
| 54 | - spip_unlink('test'); |
|
| 55 | - } |
|
| 56 | - $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 57 | - |
|
| 58 | - return $ok ? $chmod : false; |
|
| 28 | + $ok = false; |
|
| 29 | + $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 30 | + $self = basename($script); |
|
| 31 | + $uid = @fileowner('.'); |
|
| 32 | + $uid2 = @fileowner($self); |
|
| 33 | + $gid = @filegroup('.'); |
|
| 34 | + $gid2 = @filegroup($self); |
|
| 35 | + $perms = @fileperms($self); |
|
| 36 | + |
|
| 37 | + // Comparer l'appartenance d'un fichier cree par PHP |
|
| 38 | + // avec celle du script et du repertoire courant |
|
| 39 | + if(!$chmod) { |
|
| 40 | + @rmdir('test'); |
|
| 41 | + spip_unlink('test'); // effacer au cas ou |
|
| 42 | + @touch('test'); |
|
| 43 | + if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) |
|
| 44 | + $chmod = 0700; |
|
| 45 | + else if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) |
|
| 46 | + $chmod = 0770; |
|
| 47 | + else |
|
| 48 | + $chmod = 0777; |
|
| 49 | + // Appliquer de plus les droits d'acces du script |
|
| 50 | + if ($perms > 0) { |
|
| 51 | + $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 52 | + $chmod |= $perms; |
|
| 53 | + } |
|
| 54 | + spip_unlink('test'); |
|
| 55 | + } |
|
| 56 | + $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 57 | + |
|
| 58 | + return $ok ? $chmod : false; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // |
@@ -66,73 +66,73 @@ discard block |
||
| 66 | 66 | // http://doc.spip.org/@install_etape_chmod_dist |
| 67 | 67 | function install_etape_chmod_dist() |
| 68 | 68 | { |
| 69 | - global $test_dirs; |
|
| 70 | - $test_dir = _request('test_dir'); |
|
| 71 | - $chmod = 0; |
|
| 72 | - |
|
| 73 | - if ($test_dir) { |
|
| 74 | - if (substr($test_dir,-1)!=='/') $test_dir .= '/'; |
|
| 75 | - if (!in_array($test_dir, $test_dirs)) $test_dirs[] = _DIR_RACINE . $test_dir; |
|
| 76 | - } else { |
|
| 77 | - if (!_FILE_CONNECT) { |
|
| 78 | - $test_dirs[] = _DIR_CONNECT; |
|
| 79 | - $test_dirs[] = _DIR_CHMOD; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - $bad_dirs = array(); |
|
| 84 | - $absent_dirs = array();; |
|
| 85 | - |
|
| 86 | - while (list(, $my_dir) = each($test_dirs)) { |
|
| 87 | - $test = test_ecrire($my_dir); |
|
| 88 | - if (!$test) { |
|
| 89 | - $m = spip_htmlspecialchars(preg_replace(',^' . _DIR_RACINE . ',', '',$my_dir)); |
|
| 90 | - if (@file_exists($my_dir)) { |
|
| 91 | - $bad_dirs["<li>".$m."</li>"] = 1; |
|
| 92 | - } else |
|
| 93 | - $absent_dirs["<li>".$m."</li>"] = 1; |
|
| 94 | - } else $chmod = max($chmod, $test); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if ($bad_dirs OR $absent_dirs) { |
|
| 98 | - |
|
| 99 | - if (!_FILE_CONNECT) { |
|
| 100 | - $titre = _T('dirs_preliminaire'); |
|
| 101 | - $continuer = ' '._T('dirs_commencer') . '.'; |
|
| 102 | - } else |
|
| 103 | - $titre = _T('dirs_probleme_droits'); |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - $res = "<div align='right'>". menu_langues('var_lang_ecrire')."</div>\n"; |
|
| 107 | - |
|
| 108 | - if ($bad_dirs) { |
|
| 109 | - $res .= |
|
| 110 | - _T('dirs_repertoires_suivants', |
|
| 111 | - array('bad_dirs' => join("\n", array_keys($bad_dirs)))) . |
|
| 112 | - "<b>". _T('login_recharger')."</b>."; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - if ($absent_dirs) { |
|
| 116 | - $res .= |
|
| 117 | - _T('dirs_repertoires_absents', |
|
| 118 | - array('bad_dirs' => join("\n", array_keys($absent_dirs)))) . |
|
| 119 | - "<b>". _T('login_recharger')."</b>."; |
|
| 120 | - } |
|
| 121 | - $res = "<p>" . $continuer . $res . aide ("install0", true) . "</p>"; |
|
| 122 | - |
|
| 123 | - $t = _T('login_recharger'); |
|
| 124 | - $t = (!$test_dir ? '' : |
|
| 125 | - "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 126 | - . "<input type='hidden' name='etape' value='chmod' />" |
|
| 127 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 128 | - |
|
| 129 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 130 | - |
|
| 131 | - } else { |
|
| 132 | - $deja = (_FILE_CONNECT AND analyse_fichier_connection(_FILE_CONNECT)); |
|
| 133 | - if (!$deja) |
|
| 134 | - redirige_url_ecrire("install", "etape=1&chmod=".$chmod); |
|
| 135 | - else redirige_url_ecrire(); |
|
| 136 | - } |
|
| 69 | + global $test_dirs; |
|
| 70 | + $test_dir = _request('test_dir'); |
|
| 71 | + $chmod = 0; |
|
| 72 | + |
|
| 73 | + if ($test_dir) { |
|
| 74 | + if (substr($test_dir,-1)!=='/') $test_dir .= '/'; |
|
| 75 | + if (!in_array($test_dir, $test_dirs)) $test_dirs[] = _DIR_RACINE . $test_dir; |
|
| 76 | + } else { |
|
| 77 | + if (!_FILE_CONNECT) { |
|
| 78 | + $test_dirs[] = _DIR_CONNECT; |
|
| 79 | + $test_dirs[] = _DIR_CHMOD; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + $bad_dirs = array(); |
|
| 84 | + $absent_dirs = array();; |
|
| 85 | + |
|
| 86 | + while (list(, $my_dir) = each($test_dirs)) { |
|
| 87 | + $test = test_ecrire($my_dir); |
|
| 88 | + if (!$test) { |
|
| 89 | + $m = spip_htmlspecialchars(preg_replace(',^' . _DIR_RACINE . ',', '',$my_dir)); |
|
| 90 | + if (@file_exists($my_dir)) { |
|
| 91 | + $bad_dirs["<li>".$m."</li>"] = 1; |
|
| 92 | + } else |
|
| 93 | + $absent_dirs["<li>".$m."</li>"] = 1; |
|
| 94 | + } else $chmod = max($chmod, $test); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if ($bad_dirs OR $absent_dirs) { |
|
| 98 | + |
|
| 99 | + if (!_FILE_CONNECT) { |
|
| 100 | + $titre = _T('dirs_preliminaire'); |
|
| 101 | + $continuer = ' '._T('dirs_commencer') . '.'; |
|
| 102 | + } else |
|
| 103 | + $titre = _T('dirs_probleme_droits'); |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + $res = "<div align='right'>". menu_langues('var_lang_ecrire')."</div>\n"; |
|
| 107 | + |
|
| 108 | + if ($bad_dirs) { |
|
| 109 | + $res .= |
|
| 110 | + _T('dirs_repertoires_suivants', |
|
| 111 | + array('bad_dirs' => join("\n", array_keys($bad_dirs)))) . |
|
| 112 | + "<b>". _T('login_recharger')."</b>."; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + if ($absent_dirs) { |
|
| 116 | + $res .= |
|
| 117 | + _T('dirs_repertoires_absents', |
|
| 118 | + array('bad_dirs' => join("\n", array_keys($absent_dirs)))) . |
|
| 119 | + "<b>". _T('login_recharger')."</b>."; |
|
| 120 | + } |
|
| 121 | + $res = "<p>" . $continuer . $res . aide ("install0", true) . "</p>"; |
|
| 122 | + |
|
| 123 | + $t = _T('login_recharger'); |
|
| 124 | + $t = (!$test_dir ? '' : |
|
| 125 | + "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 126 | + . "<input type='hidden' name='etape' value='chmod' />" |
|
| 127 | + . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 128 | + |
|
| 129 | + echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 130 | + |
|
| 131 | + } else { |
|
| 132 | + $deja = (_FILE_CONNECT AND analyse_fichier_connection(_FILE_CONNECT)); |
|
| 133 | + if (!$deja) |
|
| 134 | + redirige_url_ecrire("install", "etape=1&chmod=".$chmod); |
|
| 135 | + else redirige_url_ecrire(); |
|
| 136 | + } |
|
| 137 | 137 | } |
| 138 | 138 | ?> |