Fichiers specifiques X.org
authorDamien Bobillot <damien.bobillot+gitxorg@m4x.org>
Sat, 3 May 2008 18:08:36 +0000 (20:08 +0200)
committerDamien Bobillot <damien.bobillot+gitxorg@m4x.org>
Sat, 3 May 2008 18:08:36 +0000 (20:08 +0200)
14 files changed:
.gitignore [new file with mode: 0644]
install/cookbook/autocreate.php [new file with mode: 0644]
install/cookbook/chat.php [new file with mode: 0644]
install/cookbook/faq.php [new file with mode: 0644]
install/cookbook/farmadmin.php [new file with mode: 0644]
install/cookbook/fieldadmin.php [new file with mode: 0644]
install/cookbook/geoloc.php [new file with mode: 0644]
install/cookbook/skinchange.php [new file with mode: 0644]
install/cookbook/xorgauth.php [new file with mode: 0644]
install/local/farmconfig.php [new file with mode: 0644]
install/local/farmmap.txt [new file with mode: 0644]
install/wikilib.d/Site.AuthForm [moved from install/Site.AuthForm with 100% similarity]
install/wikilib.d/Site.PageActions [moved from install/Site.PageActions with 100% similarity]
install/wikilib.d/Site.PageFootMenu [moved from install/Site.PageFootMenu with 100% similarity]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..31279aa
--- /dev/null
@@ -0,0 +1 @@
+pmwiki
diff --git a/install/cookbook/autocreate.php b/install/cookbook/autocreate.php
new file mode 100644 (file)
index 0000000..428928b
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+function AutoCreatePage($page, $text, $redirect = null) {
+       global $pagename, $WikiDir;
+       $pagename_ = str_replace('/','.',$pagename);
+       $group = substr($pagename_,0,strrpos($pagename_,'.'));
+
+       $page = str_replace('$Group', $group, $page);
+       if ($pagename_ == $page && !$WikiDir->exists($pagename_)) {
+               $WikiDir->write($pagename_, array('text' => $text));
+               if ($redirect != '') {
+                       $redirect = $pagename_;
+               }
+               Redirect($pagename_);
+       }
+}
+
+?>
diff --git a/install/cookbook/chat.php b/install/cookbook/chat.php
new file mode 100644 (file)
index 0000000..2eab8c4
--- /dev/null
@@ -0,0 +1,124 @@
+<?php
+
+$ROSPatterns['/\\(:chat(\\s+(.*))?:\\)/e'] = "CreateChat('$2')";
+$HandleActions['chat'] = 'HandleChat';
+
+Markup('chatBegin','inline','/\\(:chatBegin (\\w+):\\)/','');
+Markup('chatEnd','inline','/\\(:chatEnd (\\w+):\\)/','<br/>');
+Markup('chatNext','inline','/\\(:chatNext:\\)/','<br/>');
+Markup('chatTalk','inline','/\\(:chatTalk (\\w+) (\\w+):\\)/e',"ChatTalk('$1', '$2')");
+
+function CreateChat($size = 10) {
+  $idchat = substr(md5(rand()),0,4);
+  if (!$size) { $size = 10; }
+  return 
+    '(:chatBegin '.$idchat.':)'."\n".
+    '(:chatEnd '.$idchat.':)'."\n\n".
+    '(:if auth edit:)(:chatTalk '.$idchat.' '.$size.':)(:if:)';
+}
+
+function ChatTalk($idchat, $size = 10) {
+  return Keep(
+  '<form method="post" id="chat-'.$idchat.'">
+    <input type="text" name="postchat" size="50"/>
+    <input type="hidden" name="chatId" value="'.$idchat.'"/>
+    <input type="hidden" name="size" value="'.$size.'"/>
+    <input type="hidden" name="action" value="chat"/>
+  </form>
+  <script type="text/javascript">
+    document.getElementById("chat-'.$idchat.'").postchat.focus();
+  </script>');
+}
+
+function HandleChat() {
+  global $pagename, $CurrentTime, $Author;
+  Lock(2);
+  if (isset($_REQUEST['postchat']) && $_REQUEST['postchat'] &&
+    ($page = RetrieveAuthPage($pagename, 'edit', true))) {
+    $postchat = stripmagic($_REQUEST['postchat']);
+    $idchat = stripmagic($_REQUEST['chatId']);
+    $size = stripmagic($_REQUEST['size']);
+    
+    $origine = array('(:chatNext:)');
+    $destination = array('');
+    $chatsyntax = RetrieveAuthPage('Site.ChatSyntax', 'read', false);
+    if ($chatsyntax) {
+      $chatsyntax = explode("\n",$chatsyntax['text']);
+      foreach($chatsyntax as $s) if (preg_match('/^(.*) => (.*)$/', trim($s), $matches)) {
+        $origine[] = $matches[1];
+        $destination[] = $matches[2];
+      }
+    }
+
+    $newchat = $CurrentTime.' [[~'.$Author.']] : '.str_replace($origine, $destination, $postchat);
+
+    $talkpos = strpos($page['text'], '(:chatTalk '.$idchat.' ');
+    $beginpos = strpos($page['text'], '(:chatBegin '.$idchat.':)');
+    $endpos = strpos($page['text'], '(:chatEnd '.$idchat.':)');
+    
+    $beginpos += strlen('(:chatBegin '.$idchat.':)');
+    $lignes = explode('(:chatNext:)',substr($page['text'], $beginpos, $endpos - $beginpos));
+    
+    if ($talkpos > $beginpos) {
+      $afac = count($lignes) - $size - 1;
+      $lignes[] = $newchat;
+      for ($i = 0; $i < $afac; $i++) {
+        unset($lignes[$i]);
+      }
+    } else {
+      $nouvelleslignes = array($newchat);
+      for ($i = 0; $i < count($lignes) && $i < $size - 1; $i++) {
+        $nouvelleslignes[] = $lignes[$i];
+      }
+      $lignes = $nouvelleslignes;
+    }
+    $chatcontent = implode('(:chatNext:)', $lignes);
+    $page['text'] = substr($page['text'],0,$beginpos).$chatcontent.substr($page['text'],$endpos);
+    WritePage($pagename,$page);
+    Lock(0);
+    Redirect($pagename);
+  }
+  Lock(0);
+  return "";
+}
+function afac() {
+  global $pagename, $Author, $CurrentTime;
+  if (isset($_REQUEST['postchat']) && $_REQUEST['postchat']) {
+    Lock(2);
+    $page = RetrieveAuthPage($pagename, 'edit', false);
+    if (!$page) {
+      Lock(0);
+      return "";
+    }
+    
+    
+    
+    
+    $poschat = strpos($page['text'],'(:beginchat:)');
+    $finchat = strpos($page['text'],'(:chat');
+    if ($poschat === false) {
+      $poschat = $finchat;
+      $page['text'] = substr($page['text'],0,$poschat).'(:beginchat:)'.substr($page['text'],$poschat);
+      $finchat += strlen('(:beginchat:)');
+    }
+    $poschat += strlen('(:beginchat:)');
+    
+    $avantchat = substr($page['text'],0,$poschat);    
+    $chatcontent = substr($page['text'], $poschat, $finchat - $poschat);
+    $aprechat = substr($page['text'],$finchat);
+    
+    $lignes = explode("\n\n",$chatcontent);
+    $page['text'] = $avantchat.implode("\n\n", $lignes)."\n\n".$CurrentTime.' [[~'.$Author.']] : '.$newchat.$aprechat;
+    WritePage($pagename,$page);
+    Lock(0);
+    Redirect($pagename);
+    return "";  
+  }
+  $page = RetrieveAuthPage($pagename, 'edit', false);
+  if (!$page) {
+    return '';
+  }
+  return '<form method="post"><input type="text" name="postchat" size="50"/></form><script type="text/javascript">document.getElementsByName("postchat")[0].focus();</script>';
+}
+
+?>
diff --git a/install/cookbook/faq.php b/install/cookbook/faq.php
new file mode 100644 (file)
index 0000000..7c8ded5
--- /dev/null
@@ -0,0 +1,102 @@
+<?php
+
+$ROSPatterns['/\\(:faq:\\)/e'] = 'CreateFAQ()';
+$HandleActions['faq'] = 'HandleFAQ';
+$HandleActions['faqAnswer'] = 'HandleFAQAnswer';
+
+Markup('faqNewQuestion','inline','/\\(:faqNewQuestion (\\w+) (\\w+):\\)/e',"newFAQ('$1', '$2')");
+Markup('faqNewAnswer','inline','/\\(:faqNewAnswer (\\w+) (\\w+) (\\w+):\\)/e',"newFAQAnswer('$1', '$2', '$3')");
+Markup('faqList','inline','/\\(:faqList (\\w+):\\)/','');
+
+function CreateFAQ() {
+  $idfaq = substr(md5(rand()),0,4);
+  return "\n".
+    '!Foire aux questions'."\n".
+    '(:faqList '.$idfaq.':)'."\n".
+    '(:if auth edit:)(:faqNewQuestion '.$idfaq.' 1:)(:if:)';
+}
+
+function newFAQ($idfaq, $numquestion) {
+  return Keep('<h3>Poser une nouvelle question :</h3>
+  <form method="post">
+    <input type="hidden" name="action" value="faq"/>
+    <input type="hidden" name="faqId" value="'.$idfaq.'"/>
+    <input type="hidden" name="numQuestion" value="'.$numquestion.'"/>
+    <input type="text" name="question" size="80"/>
+  </form>');
+}
+
+function newFAQAnswer($idfaq, $numquestion, $numanswer) {
+  $idfaqanswer = 'faqAnswer-'.$idfaq.'-'.$numquestion.'-'.$numanswer;
+  return Keep('<blockquote>
+  <input type="button" value="Répondre" onclick="
+    this.style.display=\'none\';
+    var f = document.getElementById(\''.$idfaqanswer.'\');
+    f.style.display=\'\';
+    f.answer.focus()"/>
+  <form method="post" id="'.$idfaqanswer.'" style="display:none">
+    <input type="hidden" name="action" value="faqAnswer"/>
+    <input type="hidden" name="faqId" value="'.$idfaq.'"/>
+    <input type="hidden" name="numQuestion" value="'.$numquestion.'"/>
+    <input type="hidden" name="numAnswer" value="'.$numanswer.'"/>
+    <textarea name="answer" rows="3" cols="80"></textarea>
+    <br/>
+    <input type="submit" value="Envoyer la réponse"/>
+  </form>
+  </blockquote>');
+}
+
+function HandleFAQ() {
+  global $pagename, $CurrentTime, $Author;
+  Lock(2);
+  if (isset($_REQUEST['question']) && $_REQUEST['question'] &&
+    ($page = RetrieveAuthPage($pagename, 'edit', true))) {
+    $idfaq = stripmagic($_REQUEST['faqId']);
+    $question = stripmagic($_REQUEST['question']);
+    $numquestion = stripmagic($_REQUEST['numQuestion']);
+    $titre = $question;
+    if (strlen($titre) > 30) {
+      $titre = substr($question, 0, 50).'...';
+      $question = $titre."\n".$question;
+    }
+    $page['text'] = preg_replace(
+      ',(\(:faqList '.$idfaq.':\)),',
+      "\n".'*[[{$FullName}#faq'.$idfaq.'-'.$numquestion.' | '.$titre.']]$1',
+      $page['text']);
+    $page['text'] = preg_replace(
+      ',(\(:if auth edit:\)\(:faqNewQuestion '.$idfaq.') '.$numquestion.':\),',
+      '!![[#faq'.$idfaq.'-'.$numquestion.']]Q : '.$question.'\\\\\\\\'."\n".
+        '[-\'\'question posée le '.$CurrentTime.($Author?(' par [[~ '.$Author.' ]]\'\'-]'):'')."\n".
+        '(:if auth edit:)(:faqNewAnswer '.$idfaq.' '.$numquestion.' 1:)(:if:)'."\n".
+        '$1 '.($numquestion + 1).':)',
+      $page['text']);
+    WritePage($pagename,$page);
+    Redirect($pagename);
+  }
+  Lock(0);
+  return "";
+}
+
+function HandleFAQAnswer() {
+  global $pagename, $CurrentTime, $Author;
+  Lock(2);
+  if (isset($_REQUEST['answer']) && $_REQUEST['answer'] &&
+    ($page = RetrieveAuthPage($pagename, 'edit', true))) {
+    $idfaq = stripmagic($_REQUEST['faqId']);
+    $answer = str_replace("\n", "\n->", stripmagic($_REQUEST['answer']));
+    $numanswer = stripmagic($_REQUEST['numAnswer']);
+    $numquestion = stripmagic($_REQUEST['numQuestion']);
+    $page['text'] = preg_replace(
+      ',(\(:if auth edit:\)\(:faqNewAnswer '.$idfaq.' '.$numquestion.') '.$numanswer.':\),',
+      '->[[#faq'.$idfaq.'-'.$numquestion.'-'.$numanswer.']]R : '.$answer."\n".
+        '->[-\'\'réponse le '.$CurrentTime.($Author?(' par [[~ '.$Author.' ]]\'\'-]'):'')."\n".
+        '$1 '.($numanswer + 1).':)',
+      $page['text']);
+    WritePage($pagename,$page);
+    Redirect($pagename);
+  }
+  Lock(0);
+  return "";
+}
+
+?>
diff --git a/install/cookbook/farmadmin.php b/install/cookbook/farmadmin.php
new file mode 100644 (file)
index 0000000..e723539
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+// vérification de l'autorisation
+function is_farm_admin()
+{
+       global $isFarmAdmin;
+       if (!isset($isFarmAdmin)) {
+               global $WikiIsMainField;
+
+               $isFarmAdmin = $WikiIsMainField && (RetrieveAuthPage('Accueil.Accueil', 'admin', false) !== false);
+       }
+       return $isFarmAdmin;
+}
+?>
diff --git a/install/cookbook/fieldadmin.php b/install/cookbook/fieldadmin.php
new file mode 100644 (file)
index 0000000..cdf3e3a
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+
+@include_once("$FarmD/cookbook/autocreate.php");
+
+AutoCreatePage('Site.Admin', '(:fieldadmin:)');
+
+Markup('fieldadmin','inline','/\\(:fieldadmin:\\)/e',"Keep(FieldAdmin())");
+
+function WriteAdminConfig($f, $_wikititle, $_skin, $_pageLogoUrl, $_passwdread, $_passwdedit) {
+               fwrite($f, '<'.'?php '."\n");
+               fwrite($f, ' $WikiTitle = '.var_export($_wikititle,true).';'."\n");
+               fwrite($f, ' $Skin = '.var_export($_skin,true).';'."\n");
+               fwrite($f, ' $PageLogoUrl = '.var_export($_pageLogoUrl,true).';'."\n");
+               fwrite($f, ' $DefaultPasswords[\'read\'] = '.var_export($_passwdread,true).';'."\n");
+               fwrite($f, ' $DefaultPasswords[\'edit\'] = '.var_export($_passwdedit,true).';'."\n");
+               fwrite($f, '?'.'>');
+}
+
+function FieldAdmin() {
+
+  if (isset($_REQUEST['createconf']) && !($f = @fopen('local/webconfig.php','r'))) {
+    $f = @fopen('local/webconfig.php','w');
+       global $WikiTitle, $FarmD, $Skin, $PageLogoUrl, $DefaultPasswords;
+    WriteAdminConfig($f, $WikiTitle, $Skin, $PageLogoUrl, $DefaultPasswords['read'], $DefaultPasswords['edit']);
+    fclose($f);
+    mkdirp('uploads');
+  }
+  
+       RetrieveAuthPage('Site.Admin', 'admin', true);
+
+       if (isset($_REQUEST['admin'])) {
+               $f = @fopen('local/webconfig.php','w');
+               if (!$f) {
+                       $f = @fopen('local/webconfig.php','r');
+                       if ($f) {
+                               fclose($f);
+                               $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.';
+                       } else {
+                               $error = 'Il faut passer le dossier local/ en 2777 puis actualiser cette page et enfin repasser le dossier en 755.';
+                       }
+                       return 'Impossible d\'écrire la nouvelle configuration. '.$error;
+               }
+               WriteAdminConfig($f, 
+      stripmagic($_REQUEST['wikititle']),
+      stripmagic($_REQUEST['skin']),
+      stripmagic($_REQUEST['logo']),
+      stripmagic($_REQUEST['passwdread']),
+      stripmagic($_REQUEST['passwdedit']));
+               fclose($f);
+               redirect('Site.Admin?modified=ok');
+       }
+
+       global $WikiTitle, $FarmD;
+       $pagehtml = '';
+       $pagehtml .= '<h1>Administration du wiki <strong>'.$WikiTitle.'</strong></h1>';
+       if (isset($_REQUEST['modified'])) {
+               $pagehtml .= '<span style="color:darkgreen;font-weight:bold">Configuration modifiée</span>';
+       }
+       $pagehtml .= '<form method="post" action="?"><ul>';
+
+       // titre du wiki
+       $pagehtml .= '<li>Nom du site : <input type="text" name="wikititle" value="'.htmlspecialchars($WikiTitle).'"/></li>';
+
+       // url du wiki
+       global $ScriptUrl;
+       $pagehtml .= '<li>Adresse du site : <input type="text" size="40" disabled="disabled" value="'.htmlspecialchars($ScriptUrl).'"/></li>';
+
+       // skin
+       global $Skin;
+       $dh = opendir("$FarmD/pub/skins/");
+       $optionsSkins = '';
+       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"))) {
+               $optionsSkins .= '<option value="'.$file.'">'.$file.'</option>';
+       }
+       $pagehtml .= '<li>Skin : <select name="skin">'.str_replace(' value="'.$Skin.'"',' value="'.$Skin.'" selected="selected"', $optionsSkins).'</select></li>';
+
+       // url du logo
+       global $PageLogoUrl;
+       $pagehtml .= '<li>Image du logo : <input type="text" size="60" name="logo" value="'.htmlentities($PageLogoUrl).'"/></li>';
+
+       // droits liés au groupe xnet
+       global $XnetWikiGroup;
+       if (isset($XnetWikiGroup)) {
+               $pagehtml .= '<li>Authentification liée au groupe <a href="http://www.polytechnique.net/login/'.$XnetWikiGroup.'/">'.$XnetWikiGroup.'</a></li>';
+       }
+
+       // droits de lecture et de modification de tout le site
+       global $DefaultPasswords;
+       $XorgAuthUsers = XorgAuthUsers();
+       $optionsUsers = '';
+       foreach ($XorgAuthUsers as $v => $text) {
+               $optionsUsers .= '<option value="'.$v.'">'.$text.'</option>';
+       }
+       $optionsUsers .='<option value="...">...</option>';
+       $pagehtml .= '<li>Limiter les droits d\'accès au site : <br/>';
+       $pagehtml .= ' en lecture <select name="passwdread" onchange="AddCustomAuth(this)">'.str_replace('value="'.$DefaultPasswords['read'].'"', 'value="'.$DefaultPasswords['read'].'" selected="selected"', $optionsUsers).'</select><br/>';
+       $pagehtml .= ' en écriture <select name="passwdedit" onchange="AddCustomAuth(this)">'.str_replace('value="'.$DefaultPasswords['edit'].'"', 'value="'.$DefaultPasswords['edit'].'" selected="selected"', $optionsUsers).'</select><br/>';
+       $pagehtml .= '</li>';
+
+       $pagehtml .= '</ul><input type="submit" name="admin"/>';
+       $pagehtml .= '</form>';
+       return $pagehtml;
+}
+
+if (file_exists("$LocalDir/webconfig.php")) {
+    include_once("$LocalDir/webconfig.php");
+}
+
+?>
diff --git a/install/cookbook/geoloc.php b/install/cookbook/geoloc.php
new file mode 100644 (file)
index 0000000..e0cff44
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+Markup('dynamap','inline','/\\(:dynamap:\\)/e',"Keep(Dynamap())");
+
+function Dynamap() {
+       global $XnetWikiGroup;
+       if ($XnetWikiGroup) {
+               $mapfolder = 'http://www.polytechnique.net/'.$XnetWikiGroup.'/geoloc/';
+       } else {
+               $mapfolder = 'http://www.polytechnique.org/geoloc/';
+       }
+       $initfile = $mapfolder.'init/?only_current=on';
+       $mapfile = $mapfolder.'dynamap.swf';
+return '
+<object
+classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
+codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
+width="600"
+height="450"
+align="middle">
+<param name="movie" value="'.$mapfile.'"/>
+<param name="bgcolor" value="#ffffff"/>
+<param name="wmode" value="opaque"/>
+<param name="quality" value="high"/>
+<param name="flashvars" value="initfile='.urlencode($initfile).'"/>
+<embed
+src="'.$mapfile.'"
+quality="high"
+bgcolor="#ffffff"
+width="600"
+height="450"
+name="dynamap"
+id="dynamap"
+align="middle"
+flashvars="initfile='.urlencode($initfile).'"
+type="application/x-shockwave-flash"
+menu="false"
+wmode="opaque"
+salign="tl"
+pluginspage="http://www.macromedia.com/go/getflashplayer"/>
+</object>';
+}
+
+?>
diff --git a/install/cookbook/skinchange.php b/install/cookbook/skinchange.php
new file mode 100644 (file)
index 0000000..86a281d
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/*  Copyright 2004 Patrick R. Michaud (pmichaud@pobox.com)
+
+    This script enables the ?skin= and ?setskin= parameters for
+    wiki pages.  The ?skin= parameter causes the current page to be 
+    displayed with some alternate skin (defined by the WikiAdministrator),
+    the ?setskin= parameter sets a cookie on the user's browser to
+    always display pages with the requested skin.  
+    
+    To use this script, define an array called $PageSkinList 
+    containing skin names and template files, then 
+    include('cookbook/skinchange.php'); in your config.php.
+    An example $PageSkinList to set up 'pmwiki', 'myskin',
+    and 'classic' skins might read:
+
+        $PageSkinList = array(
+           'pmwiki' => 'pmwiki',
+           'myskin' => 'myskin',
+           'classic' => 'myclassicskin');
+
+    If a URL requests a skin that isn't in this array, then PmWiki
+    defaults to the skin already defined by $Skin.
+
+    By default, the setskin cookie that is created will expire after
+    one year.  You can set it to expire at the end of the browser
+    session by setting $SkinCookieExpires=0;
+*/
+
+SDV($SkinCookie, $CookiePrefix.'setskin');
+SDV($SkinCookieExpires, $Now+60*60*24*365);
+
+if (isset($_COOKIE[$SkinCookie])) $sk = $_COOKIE[$SkinCookie];
+if (isset($_GET['setskin'])) {
+  $sk = $_GET['setskin'];
+  setcookie($SkinCookie, $sk, $SkinCookieExpires, '/');
+}
+if (isset($_GET['skin'])) $sk = $_GET['skin'];
+if (@$PageSkinList[$sk]) $Skin = $PageSkinList[$sk];
diff --git a/install/cookbook/xorgauth.php b/install/cookbook/xorgauth.php
new file mode 100644 (file)
index 0000000..4c32ee6
--- /dev/null
@@ -0,0 +1,321 @@
+<?php
+
+$AuthFunction = 'XorgAuth';
+$HandleActions['attr'] = 'XorgAuthHandleAttr';
+$HandleActions['postattr'] = 'XorgAuthHandlePostAttr';
+$HandleActions['connect'] = 'XorgAuthConnectPlatal';
+
+if (isset($_POST['action']) && isset($_GET['action'])) {
+    $action = $_REQUEST['action'] = $_GET['action'] = $_POST['action'];
+}
+
+Markup('grpattributes','inline','/\\(:groupattributes:\\)/e',"Keep(XorgAuthGroupAttributes())");
+
+require_once("$FarmD/cookbook/autocreate.php");
+AutoCreatePage('$Group.GroupAttributes', '(:groupattributes:)');
+
+$HTMLHeaderFmt['xorg'] = '<script type="text/javascript" src="http://www.polytechnique.org/javascript/xorg.js"></script>';
+$HTMLHeaderFmt['xorgcustomauth'] = '<script type="text/javascript">
+  function AddCustomAuth(f){
+    if (f.value == \'...\')
+    {
+      var newval =prompt(\'Sépare les différents autorisations par des espaces\\n\\tx,membre ou admin\\n\\tprenom.nom.promo d\\\'une personne\\n\\tle numéro d\\\'une promo\\nPar exemple pour autoriser les membres et Pascal Corpet :\\n\\tmembre pascal.corpet.2001\');
+      f.value = newval;
+      if (f.value != newval && newval)
+      {
+        var op = document.createElement(\'option\');
+        op.appendChild(document.createTextNode(newval));
+        f.insertBefore(op,f.childNodes[f.childNodes.length-1]);
+        f.value = newval;
+      }
+    }
+  }
+  </script>';
+
+Markup('[[~|','<[[~','/\\[\\[~(.*?)\|(.*?)\\]\\]/e',"Keep('<a href=\"http://www.polytechnique.org/profile/$1\" class=\"popup2\">$2</a>')");
+
+Markup('xorgpage','inline','/\\(:xorgpage\\s*(.*?):\\)/e', "Keep('<iframe style=\"width:100%;height:400px;border:none\" src=\"http://dev.m4x.org/~x2001corpet/$1\"></iframe>')");
+Markup('xnetpage','inline','/\\(:xnetpage\\s*(.*?):\\)/e', "XnetPage('$1')");
+function XnetPage($page) {
+  global $XnetWikiGroup;
+  if (!$XnetWikiGroup) return;
+  return Keep('<iframe style="width:100%;height:400px;border:none" src="http://dev.polytechnique.net/~x2001corpet/'.($_SESSION['xorgauth']?'login/':'').$XnetWikiGroup.'/'.$page.'"></iframe>');
+}
+
+// Récupère les droits au niveau du dossier (Group PmWiki)
+function XorgAuthGetGroupAuth($pagename,$since) {
+       global $GroupPasswords;
+       if (!isset($GroupPasswords)) {
+               $GroupPasswords = array();
+       }
+       $group = substr($pagename, 0, strpos($pagename, '.'));
+       if (!isset($GroupPasswords[$group])) {
+               $GroupPasswords[$group] = ReadPage($group.'.GroupAttributes', $since);
+       }
+       return $GroupPasswords[$group];
+}
+
+// essaie de se connecter via xorg
+function XorgAuthConnectPlatal() {
+  $privkey = '6e9c9fa9bac23541fe67697c4eff5be6';
+       global $XnetWikiGroup;
+       $returl = 'http://'.$_SERVER['SERVER_NAME'].str_replace('action=connect', '', $_SERVER['REQUEST_URI']);
+       if (isset($_REQUEST['oldaction'])) {
+               $returl .= '&action='.$_REQUEST['oldaction'];
+       }
+       @session_destroy();
+       session_start();
+       $challenge = md5(rand());
+       $_SESSION['challenge'] = $challenge; 
+       $_SESSION['authsite'] = $XnetWikiGroup;
+       $url = "https://www.polytechnique.org/auth-groupex.php";
+       $url .= "?session=".session_id();
+       $url .= "&challenge=".$challenge;
+       $url .= "&pass=".md5($challenge.$privkey);
+       $returl .= "&challenge=".$challenge;
+       $url .= "&url=".urlencode($returl);
+       if ($XnetWikiGroup) {
+               $url .= "&group=".$XnetWikiGroup;
+       }
+       header('Location: '.$url);
+       exit();
+}
+
+
+ // comes back from auth
+ @session_start();
+ if (isset($_GET['auth']) && !$_SESSION['xorgauth'] && $_SESSION['challenge']) {
+       $tohash = '1'.$_SESSION['challenge'].'6e9c9fa9bac23541fe67697c4eff5be6';
+       $fields = explode(',','forlife,nom,prenom,promo,grpauth');
+       foreach ($fields as $f) if (isset($_GET[$f])) {
+               $tohash .= $_GET[$f];
+       }
+       $tohash .= '1';
+       if ($_GET['auth'] == md5($tohash)) {
+               $_SESSION['xorgauth'] = 1;
+               foreach ($fields as $f) if (isset($_GET[$f])) {
+                       $_SESSION[$f] = $_GET[$f];
+               }
+       } else {
+               $_SESSION['xorgauth'] = 0;
+       }
+ }
+ if (isset($_SESSION['forlife']) && $_SESSION['forlife']) {
+  $AuthId = $_SESSION['forlife'];
+  $Author = $_SESSION['forlife'].' | '.$_SESSION['prenom'].' '.$_SESSION['nom'];
+ }
+$Conditions['connected'] = 'isset($_SESSION["xorgauth"])';
+
+function XorgAuthTestPassword($password) {
+  if (!$password) {
+    return true;
+  }
+  $parts = explode(' ',$password);
+  foreach ($parts as $pass) {
+       if ($pass == 'all' || $pass == 'public') {
+        return true;
+    }
+    if ($pass == 'x' && $_SESSION['xorgauth']) {
+       return true;
+    }
+    if ($_SESSION['grpauth'] && $pass == $_SESSION['grpauth']) {
+       return true;
+    }
+    if ($_SESSION['forlife'] && $pass == $_SESSION['forlife']) {
+       return true;
+    }
+    if ($_SESSION['promo'] && $pass == $_SESSION['promo']) {
+       return true;
+    }
+  }
+  return false;
+}
+function XorgAuthIsSiteAdmin() {
+  global $DefaultPasswords;
+  return XorgAuthTestPassword($DefaultPasswords['admin']);
+}
+
+// fonction d'authentification : appellée avant tout accès à une page
+function XorgAuth($pagename, $level, $authprompt, $since) {
+ global $XnetWikiGroup;
+  if (isset($_SESSION['authsite']) && $XnetWikiGroup != $_SESSION['authsite']) {
+    XorgAuthConnectPlatal();
+       return false;
+  }
+ $group = substr($pagename, 0, strpos($pagename, '.'));
+ $page = ReadPage($pagename, $since);
+ if (!$page) { return false; }
+ if (XorgAuthIsSiteAdmin()) { return $page; }
+ global $AuthCascade, $DefaultPasswords, $GroupPasswords;
+ $password = "";
+ do
+ {
+       if (isset($page["passwd".$level])) {
+               $password = $page["passwd".$level];
+       }
+       if (!$password) {
+               $gpAuth = XorgAuthGetGroupAuth($pagename,$since);
+               if (isset($gpAuth["passwd".$level])) {
+                       $password = $gpAuth["passwd".$level];
+               }
+       }
+       if (!$password) {
+               if (isset($DefaultPasswords[$level])) {
+                       $password = $DefaultPasswords[$level];
+               }
+       }
+ } while (!$password && isset($AuthCascade[$level]) && $level = $AuthCascade[$level]);
+ if (XorgAuthTestPassword($password)) {
+       return $page;
+ }
+ if (!$authprompt) {
+       return false;
+}
+ global $AuthPromptFmt, $PageStartFmt, $PageEndFmt;
+  $postvars = '';
+  foreach($_POST as $k=>$v) {
+    if ($k == 'authpw' || $k == 'authid') continue;
+    $v = str_replace('$', '&#036;', 
+             htmlspecialchars(stripmagic($v), ENT_COMPAT));
+    $postvars .= "<input type='hidden' name='$k' value=\"$v\" />\n";
+  }
+  $FmtV['action'] = $_REQUEST['action'];
+  SDV($AuthPromptFmt, array(&$PageStartFmt, "page:Site.AuthForm", &$PageEndFmt));
+ PrintFmt($pagename,$AuthPromptFmt);
+ exit;
+}
+$XorgAuthLevels = array('read' => 'lecture','edit' => 'modification','attr' => 'administration');
+
+function XorgAuthUsers() {
+       global $XnetWikiGroup;
+       if ($XnetWikiGroup) {
+               return array('public' => 'tout le monde','x' => 'les X', 'membre' => 'membres du groupe', 'admin' => 'admins du groupe');
+       } else {
+               return array('public' => 'tout le monde','x' => 'les X', 'admin' => 'admins X.org');
+       }
+}
+
+function XorgAuthPermissions($pagename) {
+       global $XnetWikiGroup,$DefaultPasswords,$XorgAuthLevels;
+       $XorgAuthUsers = XorgAuthUsers();
+       $group = substr($pagename, 0, strpos($pagename, '.'));
+       if ($pagename != $group.'.GroupAttributes')
+               $groupAttr = XorgAuthGetGroupAuth($pagename, 0); 
+       $page = ReadPage($pagename, 0);
+       $attrshtml = '';
+       foreach ($XorgAuthLevels as $level => $action) {
+               $html = $action.' : <select name="passwd'.$level.'" onchange="AddCustomAuth(this)">';
+               if (isset($groupAttr['passwd'.$level]) && $groupAttr['passwd'.$level]) {
+                       $text = 'comme le dossier ('.$XorgAuthUsers[$groupAttr['passwd'.$level]].')';
+               } else {
+                       $text = 'comme le site ('.$XorgAuthUsers[$DefaultPasswords[$level]].')';
+               }
+               $htmloptions = '<option value="">'.$text.'</option>';
+               foreach ($XorgAuthUsers as $passwd => $user) {
+                       $htmloptions .= '<option value="'.$passwd.'">'.$user.'</option>';
+               }
+               $htmloptionsselected = str_replace(' value="'.$page['passwd'.$level].'"', ' value="'.$page['passwd'.$level].'" selected="selected"', $htmloptions);
+               $html .= $htmloptionsselected;
+               if ($htmloptionsselected == $htmloptions) {
+                 $html .= '<option value="'.$page['passwd'.$level].'" selected="selected">'.$page['passwd'.$level].'</option>';
+    }
+    $html .= '<option value="...">...</option>';
+               $html .= '</select> ';
+               if ($attrshtml) {
+                       $attrshtml .= ' - ';
+               }
+
+               $attrshtml .= $html;
+       }
+       return '<form action="?action=postattr" method="post">'.$attrshtml.'<input type="submit" value="ok"/></form>';
+}
+
+function XorgAuthHandleAttr($pagename, $auth = 'attr') {
+  $page = RetrieveAuthPage($pagename, $auth, true);
+  global $PageAttrFmt, $PageStartFmt, $PageEndFmt;
+  SDV($PageAttrFmt,"<div class='wikiattr'>
+    <h2 class='wikiaction'>$[{\$FullName} Attributes]</h2>
+    <p>".XorgAuthPermissions($pagename)."</p></div>");
+  SDV($HandleAttrFmt,array(&$PageStartFmt,&$PageAttrFmt,&$PageEndFmt));
+  PrintFmt($pagename,$HandleAttrFmt);
+}
+
+function XorgAuthHandlePostAttr($pagename, $auth = 'attr') {
+  global $XorgAuthLevels, $HandleActions;
+  Lock(2);
+  $page = RetrieveAuthPage($pagename, $auth, true);
+  if (!$page) { Abort("?unable to read $pagename"); }
+  foreach($XorgAuthLevels as $attr=>$p) {
+    $v = stripmagic(@$_REQUEST['passwd'.$attr]);
+    if ($v=='') unset($page['passwd'.$attr]);
+    else if ($v != '...') $page['passwd'.$attr] = $v;
+  }
+  WritePage($pagename,$page);
+  Lock(0);
+  Redirect($pagename);
+}
+
+function XorgAuthGroupAttributes() {
+       global $XnetWikiGroup,$DefaultPasswords,$XorgAuthLevels;
+       $XorgAuthUsers = XorgAuthUsers();
+  global $pagename, $WikiDir;
+  if (substr($pagename, strpos($pagename, '.') + 1) != 'GroupAttributes') {
+    return "";
+  }
+  if (!XorgAuth($pagename, 'attr', true,0)) {
+    return "";
+  }
+  if (isset($_REQUEST['page']) && isset($_REQUEST['user']) && isset($_REQUEST['attr'])) {
+    Lock(2);
+    $page = RetrieveAuthPage(stripmagic(@$_REQUEST['page']), 'attr', true);
+    if ($page && isset($XorgAuthLevels[stripmagic(@$_REQUEST['attr'])]) && (isset($XorgAuthUsers[stripmagic(@$_REQUEST['user'])]) || !$_REQUEST['user'])) {
+      $page['passwd'.stripmagic(@$_REQUEST['attr'])] = stripmagic(@$_REQUEST['user']);
+      if ($_REQUEST['user'] == "") {
+        unset($page['passwd'.stripmagic(@$_REQUEST['attr'])]);
+      }
+      WritePage(stripmagic(@$_REQUEST['page']),$page);
+    }
+    Lock(0);
+  }
+  $html = '<table>';
+  $html .= '<tr><td></td>';
+       foreach ($XorgAuthLevels as $level => $action) {
+    $html .= '<th>'.$action.'</th>';
+  }
+  $html .= '</tr>';
+  $group = substr($pagename, 0,  strpos($pagename, '.'));
+  $pages = $WikiDir->ls($group.'.*');
+       $groupAttr = XorgAuthGetGroupAuth($pagename, 0); 
+  foreach($pages as $p) if ($p != $pagename) {
+       $html .= '<tr>';
+       $page = ReadPage($p, 0);
+       $html .= '<th>'.substr($p,strpos($p,'.')+1).'</th>';
+       foreach ($XorgAuthLevels as $level => $action) {
+               $html .= '<td><select name="passwd'.$level.'" onchange="AddCustomAuth(this);document.location=\'?page='.$p.'&attr='.$level.'&user=\'+this.value">';
+               if (isset($groupAttr['passwd'.$level]) && $groupAttr['passwd'.$level]) {
+                 $textedossier = $groupAttr['passwd'.$level];
+                 if (isset($XorgAuthUsers[$textedossier])) {
+                   $textedossier = $XorgAuthUsers[$textedossier];
+        }
+                       $text = 'comme le dossier ('.$textedossier.')';
+               } else {
+                       $text = 'comme le site ('.$XorgAuthUsers[$DefaultPasswords[$level]].')';
+               }
+               $htmloptions = '<option value="">'.$text.'</option>';
+               foreach ($XorgAuthUsers as $passwd => $user) {
+                       $htmloptions .= '<option value="'.$passwd.'">'.$user.'</option>';
+               }
+               $htmloptionsselected = str_replace(' value="'.$page['passwd'.$level].'"', ' value="'.$page['passwd'.$level].'" selected="selected"', $htmloptions);
+               $html .= $htmloptionsselected;
+               if ($htmloptionsselected == $htmloptions) {
+                 $html .= '<option value="'.$page['passwd'.$level].'" selected="selected">'.$page['passwd'.$level].'</option>';
+      }
+               $html .= '<option value="...">...</option></select></td>';
+       }
+       $html .= '</tr>';
+  }
+  $html .= '</table>';
+  return '<h2>Edition des droits du dossier</h2>'.XorgAuthPermissions($pagename).'<h2>Edition des droits des pages du dossier</h2>'.$html;
+}
+?>
diff --git a/install/local/farmconfig.php b/install/local/farmconfig.php
new file mode 100644 (file)
index 0000000..68e5f47
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+
+$FarmPubDirUrl = 'http://wikifarm.m4x.org/pub';
+$PageLogoUrl = "http://www.polytechnique.org/images/skins/default_headlogo.jpg";
+$Skin = 'gemini';
+$EnablePathInfo = 1;
+
+$DefaultPasswords = array('admin'=>'admin','read'=>'public','edit'=>'admin','attr'=>'admin');
+$DefaultPasswords['upload'] = '';
+$AuthCascade['upload'] = 'edit';
+
+include_once("$FarmD/cookbook/xorgauth.php");
+include_once("$FarmD/cookbook/geoloc.php");
+include_once("$FarmD/cookbook/chat.php");
+include_once("$FarmD/cookbook/faq.php");
+include_once("$FarmD/cookbook/fieldadmin.php");
+
+
+##---------------Francisation ------------------------------------
+
+XLPage('fr','PmWikiFr.XLPage'); // Lrs chanes de PmWiki
+#XLPage('fr','PmWikiFr.XLPageCookbook'); // S'il y a des modules
+$XLLangs = array('fr','en');
+
+##-- Chanes et noms de pages/groupes ----------------------------
+
+$DefaultGroup = 'Accueil'; # Groupe par défaut
+$DefaultName = 'Accueil'; # Page de démarrage groupe - défaut 'HomePage' - 
+$TimeFmt = "%d/%m/%Y %H:%M";  # Format date/heure 17/02/2004 00:14
+$AuthorGroup='Profils'; # Nom du groupe des auteurs, défaut 'Profiles'
+$AuthorRequiredFmt = 'Saisir votre nom ou identifiant'; #quand auteur requis
+
+##--Gestion des pages --------------------------------------------
+
+$DefaultPageTextFmt = 'La page $Name n\'existe pas';
+
+$PageNotFound = 'PmWikiFr.PageNonTrouvée'; #Renvoi quand page inexistante
+
+## Expression utilisée pour indiquer qu'une page doit tre effacée 
+$DeleteKeyPattern = "^\\s*effacer\\s*$";
+$PageRedirectFmt = '<p><i>redirigé depuis $FullName</p>';
+
+           ## Définition des pages des derniers chargements (n'existe pas encore)
+           # $RecentUploads = array(...
+
+
+           ##-- Styles prédéfinis --------------------------------------------
+
+           $WikiStyle['noir']['color'] = 'black';
+           $WikiStyle['blanc']['color'] = 'white';
+           $WikiStyle['rouge']['color'] = 'red';
+           $WikiStyle['vert']['color'] = 'green';
+           $WikiStyle['bleu']['color'] = 'blue';
+           $WikiStyle['jaune']['color'] = 'yellow';
+           $WikiStyle['gris']['color'] = 'gray';
+           $WikiStyle['argent']['color'] = 'silver';
+           $WikiStyle['marron']['color'] = 'maroon';
+           $WikiStyle['pourpre']['color'] = 'purple';
+           $WikiStyle['bleufoncé']['color'] = 'navy';
+
+           ##-- Groupes et pages à exclure des recherches -----------------------
+
+           $SearchPatterns['default'][] = '!\\.RechercheWiki$!';
+           $SearchPatterns['default'][] = '!\\.Attributes$!';
+           $SearchPatterns['default'][] = '!\\.(All)?Recent(Changes|Uploads)$!';
+           $SearchPatterns['default'][] = '!\\.Group(Print)?Header$!';
+           $SearchPatterns['default'][] = '!\\.Présentation$!';
+           $SearchPatterns['default'][] = '!\\.Menu$!';
+           $SearchPatterns['default'][] = '!\\.Index!';
+
+           $SearchPatterns['tousgroupes'] = $SearchPatterns['default'];
+
+           $SearchPatterns['default'][] = '!^PmWiki\\.!'; # Exclusion groupe PmWiki
+           $SearchPatterns['default'][] = '!^Main\\.!';
+
+           ## Le groupe PmWiki est exclu des recherches et des listes de pages
+           ## car la traduction en Français est complète mais il est toujours
+           ## possible d'accéder aux pages de ce groupe directement.
+           ## Pour permettre la recherche dans tous les groupes, on peut voir
+           ## ci-dessus que le tableau 'tousgroupes' a été créé.
+           ## On peut alors faire des recherches ou listes comme suit:
+           ## (:pagelist group=PmWiki list=tousgroupes:)
+           ## ou en ajoutant dans le texte d'une recherche 'list=tousgroupes'
+
+           ## Exclusions complémentaire pour un Index des pages de
+           ## *documentation* du Wiki
+           $SearchPatterns['dict'] = $SearchPatterns['default'];
+           $SearchPatterns['dict'][] = '!^PmWikiFr\\.!'; # Exclusion groupe PmWikiFr
+
+           ##-- Modules ---------------------------------------------------
+
+           #-- Si le module RefCount est chargé --------------------------
+           $PageRefCountFmt = "<h1>Références croisées</h1><p>"; # Titre
+           $RefCountTimeFmt = "<small>%d-%b-%Y %H:%M</small>"; # Format date
+
+           ##-- Chanes pour le rapport par courrier - Pour les Administrateurs
+           $MailPostsMessage = "Modifications récentes du wiki:\n 
+             ($ScriptUrl/$DefaultGroup/ToutesLesModifs)\n\n\$MailPostsList\n";
+             $MailPostsSubject = "$WikiTitle : modifications récentes du wiki";
+             #$MailPostsTimeFmt = $TimeFmt;
+             $MailPostsItemFmt = ' * $FullName . . . $PostTime par $Author';
+
+             ##-- Si le module approveurl est chargé -------------------------
+             $ApprovedUrlPagesFmt = array('$DefaultGroup.LiensApprouvés');
+
+             ##-- Documentation ---------------------------------------------
+
+             ## Liste des pages où sont définies les variables 
+             ## (pour l'établissement de liens automatiques)
+             $VarPagesFmt = array('PmWikiFr.Variables','PmWikiFr.VariablesDeBase',
+             'PmWikiFr.VariablesDeMiseEnPage','PmWikiFr.VariablesDeLiens',
+             'PmWikiFr.VariablesDdition','PmWikiFr.VariablesDeTéléchargement',
+               'PmWikiFr.AutresVariables','PmWikiFr.EnvoiDeCourriel');
+?>
diff --git a/install/local/farmmap.txt b/install/local/farmmap.txt
new file mode 100644 (file)
index 0000000..d7b9c4c
--- /dev/null
@@ -0,0 +1 @@
+MainWiki       http://wikifarm.m4x.org/