authorize bots to read sitemap
[wikifarm.git] / install / cookbook / fieldadmin.php
CommitLineData
b1b3c24c
DB
1<?php
2
3@include_once("$FarmD/cookbook/autocreate.php");
4
5AutoCreatePage('Site.Admin', '(:fieldadmin:)');
6
7Markup('fieldadmin','inline','/\\(:fieldadmin:\\)/e',"Keep(FieldAdmin())");
8
9function 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");
16 fwrite($f, '?'.'>');
17}
18
19function FieldAdmin() {
20
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']);
25 fclose($f);
26 mkdirp('uploads');
27 }
28
29 RetrieveAuthPage('Site.Admin', 'admin', true);
30
31 if (isset($_REQUEST['admin'])) {
32 $f = @fopen('local/webconfig.php','w');
33 if (!$f) {
34 $f = @fopen('local/webconfig.php','r');
35 if ($f) {
36 fclose($f);
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.';
38 } else {
39 $error = 'Il faut passer le dossier local/ en 2777 puis actualiser cette page et enfin repasser le dossier en 755.';
40 }
41 return 'Impossible d\'écrire la nouvelle configuration. '.$error;
42 }
43 WriteAdminConfig($f,
44 stripmagic($_REQUEST['wikititle']),
45 stripmagic($_REQUEST['skin']),
46 stripmagic($_REQUEST['logo']),
47 stripmagic($_REQUEST['passwdread']),
48 stripmagic($_REQUEST['passwdedit']));
49 fclose($f);
50 redirect('Site.Admin?modified=ok');
51 }
52
53 global $WikiTitle, $FarmD;
54 $pagehtml = '';
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>';
58 }
59 $pagehtml .= '<form method="post" action="?"><ul>';
60
61 // titre du wiki
62 $pagehtml .= '<li>Nom du site : <input type="text" name="wikititle" value="'.htmlspecialchars($WikiTitle).'"/></li>';
63
64 // url du wiki
65 global $ScriptUrl;
66 $pagehtml .= '<li>Adresse du site : <input type="text" size="40" disabled="disabled" value="'.htmlspecialchars($ScriptUrl).'"/></li>';
67
68 // skin
69 global $Skin;
70 $dh = opendir("$FarmD/pub/skins/");
71 $optionsSkins = '';
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>';
74 }
75 $pagehtml .= '<li>Skin : <select name="skin">'.str_replace(' value="'.$Skin.'"',' value="'.$Skin.'" selected="selected"', $optionsSkins).'</select></li>';
76
77 // url du logo
78 global $PageLogoUrl;
79 $pagehtml .= '<li>Image du logo : <input type="text" size="60" name="logo" value="'.htmlentities($PageLogoUrl).'"/></li>';
80
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>';
85 }
86
87 // droits de lecture et de modification de tout le site
88 global $DefaultPasswords;
89 $XorgAuthUsers = XorgAuthUsers();
90 $optionsUsers = '';
91 foreach ($XorgAuthUsers as $v => $text) {
92 $optionsUsers .= '<option value="'.$v.'">'.$text.'</option>';
93 }
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/>';
98 $pagehtml .= '</li>';
99
100 $pagehtml .= '</ul><input type="submit" name="admin"/>';
101 $pagehtml .= '</form>';
102 return $pagehtml;
103}
104
105if (file_exists("$LocalDir/webconfig.php")) {
106 include_once("$LocalDir/webconfig.php");
107}
108
109?>