* * Use an external mailing list for PmWiki authentication * * Developed and tested using the PmWiki 2.2.0-beta series. * Requires cURL support and a working mailing list * * To install, add the following line to your configuration file : include_once("$FarmD/cookbook/mailman-auth.php"); * * usage in SiteAdmin.AuthUser: * mailman: MAILMAN_URL LISTNAME * * For more information, please see the online documentation at * http://www.pmwiki.org/wiki/Cookbook/MailmanAuth * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License, * Version 2, as published by the Free Software Foundation. * http://www.gnu.org/copyleft/gpl.html */ $RecipeInfo['MailmanAuth']['Version'] = '2008-09-02'; $AuthUserFunctions['mailman'] = 'AuthUserMailman'; function AuthUserMailman( $pagename, $id, $pw, $pwlist ) { global $MessagesFmt, $Author, $MailmanCurlOpts, $MailmanPath; SDV( $MailmanCurlOpts, array( CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_COOKIESESSION => TRUE, CURLOPT_FRESH_CONNECT => TRUE, CURLOPT_HEADER => TRUE, CURLOPT_POST => TRUE ) ); SDV( $MailmanPath, '/options.cgi/' ); list( $mailman_url, $list ) = (array)$pwlist; if (!$list) return FALSE; $url = "$mailman_url$MailmanPath$list"; $query = "email=$id&password=$pw"; $cookiepart = " $list+user+" . str_replace('@','--at--',$id) . '='; $ch = curl_init( $url ); curl_setopt_array( $ch, $MailmanCurlOpts ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $query ); $r = curl_exec($ch); if (!$r) $MessagesFmt[] = "

".curl_error($ch).'

'; curl_close($ch); if ( $r && ( $head = substr( $r, 0, intval(strpos($r,"\n\n")) ) ) && preg_match( '/^Set-Cookie:(.+)/m', $head, $m ) && ( strpos( $m[1], $cookiepart ) !== FALSE ) ) { if ( preg_match( '/]*\bname="fullname"[^>]*\bvalue="([^"]+)"/i', $r, $n ) ) { global $CookiePrefix, $Now, $AuthorCookie, $AuthorCookieExpires, $AuthorCookieDir; SDV($AuthorCookie, $CookiePrefix.'author'); SDV($AuthorCookieExpires,$Now+60*60*24*30); SDV($AuthorCookieDir,'/'); setcookie( $AuthorCookie, $n[1], $AuthorCookieExpires, $AuthorCookieDir ); } return TRUE; } return FALSE; }