3 @include_once
("$FarmD/cookbook/autocreate.php");
5 AutoCreatePage('Site.Admin', '(:fieldadmin:)');
7 Markup('fieldadmin','inline','/\\(:fieldadmin:\\)/e',"Keep(FieldAdmin())");
9 function WriteAdminConfig($f, $_wikititle, $_skin, $_pageLogoUrl, $_passwdread, $_passwdedit) {
10 fwrite($f, '<'.'?php '."\n");
11 fwrite($f, ' $WikiTitle = '.var_export($_wikititle,true
).';'."\n");
12 fwrite($f, ' $Skin = '.var_export($_skin,true
).';'."\n");
13 fwrite($f, ' $PageLogoUrl = '.var_export($_pageLogoUrl,true
).';'."\n");
14 fwrite($f, ' $DefaultPasswords[\'read\'] = '.var_export($_passwdread,true
).';'."\n");
15 fwrite($f, ' $DefaultPasswords[\'edit\'] = '.var_export($_passwdedit,true
).';'."\n");
19 function FieldAdmin() {
21 if (isset($_REQUEST['createconf']) && !($f = @fopen
('local/webconfig.php','r'))) {
22 $f = @fopen
('local/webconfig.php','w');
23 global $WikiTitle, $FarmD, $Skin, $PageLogoUrl, $DefaultPasswords;
24 WriteAdminConfig($f, $WikiTitle, $Skin, $PageLogoUrl, $DefaultPasswords['read'], $DefaultPasswords['edit']);
29 RetrieveAuthPage('Site.Admin', 'admin', true
);
31 if (isset($_REQUEST['admin'])) {
32 $f = @fopen
('local/webconfig.php','w');
34 $f = @fopen
('local/webconfig.php','r');
37 $error = 'Il faut que le fichier local/webconfig.php soit accessible en écriture par l\'utilisateur www-data. Il faut régler le problème puis actualiser cette page.';
39 $error = 'Il faut passer le dossier local/ en 2777 puis actualiser cette page et enfin repasser le dossier en 755.';
41 return 'Impossible d\'écrire la nouvelle configuration. '.$error;
44 stripmagic($_REQUEST['wikititle']),
45 stripmagic($_REQUEST['skin']),
46 stripmagic($_REQUEST['logo']),
47 stripmagic($_REQUEST['passwdread']),
48 stripmagic($_REQUEST['passwdedit']));
50 redirect('Site.Admin?modified=ok');
53 global $WikiTitle, $FarmD;
55 $pagehtml .= '<h1>Administration du wiki <strong>'.$WikiTitle.'</strong></h1>';
56 if (isset($_REQUEST['modified'])) {
57 $pagehtml .= '<span style="color:darkgreen;font-weight:bold">Configuration modifiée</span>';
59 $pagehtml .= '<form method="post" action="?"><ul>';
62 $pagehtml .= '<li>Nom du site : <input type="text" name="wikititle" value="'.htmlspecialchars($WikiTitle).'"/></li>';
66 $pagehtml .= '<li>Adresse du site : <input type="text" size="40" disabled="disabled" value="'.htmlspecialchars($ScriptUrl).'"/></li>';
70 $dh = opendir("$FarmD/pub/skins/");
72 while (($file = readdir($dh)) !== false
) if ($file && $file{0} != '.' && (file_exists("$FarmD/pub/skins/$file/$file.tmpl") ||
file_exists("$FarmD/pub/skins/$file/skin-$file.tmpl"))) {
73 $optionsSkins .= '<option value="'.$file.'">'.$file.'</option>';
75 $pagehtml .= '<li>Skin : <select name="skin">'.str_replace(' value="'.$Skin.'"',' value="'.$Skin.'" selected="selected"', $optionsSkins).'</select></li>';
79 $pagehtml .= '<li>Image du logo : <input type="text" size="60" name="logo" value="'.htmlentities($PageLogoUrl).'"/></li>';
81 // droits liés au groupe xnet
82 global $XnetWikiGroup;
83 if (isset($XnetWikiGroup)) {
84 $pagehtml .= '<li>Authentification liée au groupe <a href="http://www.polytechnique.net/login/'.$XnetWikiGroup.'/">'.$XnetWikiGroup.'</a></li>';
87 // droits de lecture et de modification de tout le site
88 global $DefaultPasswords;
89 $XorgAuthUsers = XorgAuthUsers();
91 foreach ($XorgAuthUsers as $v => $text) {
92 $optionsUsers .= '<option value="'.$v.'">'.$text.'</option>';
94 $optionsUsers .='<option value="...">...</option>';
95 $pagehtml .= '<li>Limiter les droits d\'accès au site : <br/>';
96 $pagehtml .= ' en lecture <select name="passwdread" onchange="AddCustomAuth(this)">'.str_replace('value="'.$DefaultPasswords['read'].'"', 'value="'.$DefaultPasswords['read'].'" selected="selected"', $optionsUsers).'</select><br/>';
97 $pagehtml .= ' en écriture <select name="passwdedit" onchange="AddCustomAuth(this)">'.str_replace('value="'.$DefaultPasswords['edit'].'"', 'value="'.$DefaultPasswords['edit'].'" selected="selected"', $optionsUsers).'</select><br/>';
100 $pagehtml .= '</ul><input type="submit" name="admin"/>';
101 $pagehtml .= '</form>';
105 if (file_exists("$LocalDir/webconfig.php")) {
106 include_once("$LocalDir/webconfig.php");