sample preload.php snippet
- preload.php
$http_host = $_SERVER['HTTP_HOST']; if( strpos( $http_host, ':' ) !== false ) { list( $http_host, $http_port ) = explode( ':', $http_host ); } $animal = str_replace( 'www.', '', $http_host ); $request_id = $_SERVER['REQUEST_URI']; require_once( $farmbasedir.'/conf/animal_alias.php' ); // normalizes animal names and stuff $farmdir = "$farmbasedir/domains/$animal/"; if( !$animal || !is_dir( $farmdir )) { $animal = $farmer; $farmdir = "$farmbasedir/domains/$animal/"; } if( !is_dir( $farmdir )) { die( 'nofarm' ); } define( 'FARMDIR', $farmdir ); if( !defined( 'DOKU_CONF' )) define( 'DOKU_CONF', DOKU_FARMDIR.'/'.$animal.'/conf/' ); if( !defined( 'ACL_DOM' )) define( 'ACL_DOM', $animal ); // for auth psql in .protected.php if( !defined( 'ACL_TOPDOM' )) define( 'ACL_TOPDOM', 'notomorrow.de' ); // for auth psql in .protected.php if( !defined( 'DOKU_CONF_DEFAULT' )) define( 'DOKU_CONF_DEFAULT', $farmbasedir.'/dokuwiki/conf/' ); if( !defined( 'DOKU_CONF' )) define( 'DOKU_CONF', $farmdir.'conf/' ); require_once( $farmbasedir.'/dokuwiki/inc/config_cascade.php' ); require_once( $farmbasedir.'/conf/cascade.php' );
sample farm.protected.php snippet
$conf['plugin']['authpgsql']['checkPass'] = "SELECT pass FROM usergroup AS ug JOIN users AS u ON u.uid=ug.uid JOIN groups AS g ON g.gid=ug.gid WHERE u.login='%{user}' AND g.name='%{dgroup}' AND ( u.domain='".ACL_DOM."' OR u.domain is null ) "; $conf['plugin']['authpgsql']['getUserInfo'] = "SELECT pass, fullname AS name, email AS mail FROM users WHERE lower(login)=lower('%{user}') AND ( domain='".ACL_DOM."' OR domain is null ) "; $conf['plugin']['authpgsql']['getGroups'] = "SELECT g.name as group FROM groups g, users u, usergroup ug WHERE u.uid = ug.uid AND g.gid = ug.gid AND u.login='%{user}' AND ( u.domain='".ACL_DOM."' OR u.domain is null ) "; $conf['plugin']['authpgsql']['getUsers'] = "SELECT DISTINCT u.login AS user FROM users AS u LEFT JOIN usergroup AS ug ON u.uid=ug.uid LEFT JOIN groups AS g ON ug.gid=g.gid WHERE ( u.domain='".ACL_DOM."' " .( ACL_TOPDOM ? 'OR u.domain in ( \'"'.implode( "','", explode( ',', ACL_TOPDOM )).'\' )' : '' ) #."OR u.domain is null" ." )"; $conf['plugin']['authpgsql']['FilterLogin'] = "u.login LIKE '%{user}'"; $conf['plugin']['authpgsql']['FilterName'] = "u.fullname LIKE '%{name}'"; $conf['plugin']['authpgsql']['FilterEmail'] = "u.email LIKE '%{email}'"; $conf['plugin']['authpgsql']['FilterGroup'] = "g.name LIKE '%{group}'"; $conf['plugin']['authpgsql']['SortOrder'] = "ORDER BY u.login"; $conf['plugin']['authpgsql']['addUser'] = "INSERT INTO users (login, pass, email, fullname, domain) VALUES ('%{user}', '%{pass}', '%{email}', '%{name}', '".ACL_DOM."')"; $conf['plugin']['authpgsql']['addGroup'] = "INSERT INTO groups (name) VALUES ('%{group}')"; $conf['plugin']['authpgsql']['addUserGroup']= "INSERT INTO usergroup (uid, gid) VALUES ('%{uid}', '%{gid}')"; $conf['plugin']['authpgsql']['delGroup'] = "DELETE FROM groups WHERE gid='%{gid}'"; $conf['plugin']['authpgsql']['getUserID'] = "SELECT uid AS id FROM users WHERE login='%{user}' AND ( domain='".ACL_DOM."' OR domain is null )"; $conf['plugin']['authpgsql']['getGroupID'] = "SELECT gid AS id FROM groups WHERE name='%{group}'"; $conf['plugin']['authpgsql']['delUser'] = "DELETE FROM users WHERE uid='%{uid}' AND ( domain='".ACL_DOM."' )"; $conf['plugin']['authpgsql']['delUserRefs'] = "DELETE FROM usergroup WHERE uid='%{uid}'"; $conf['plugin']['authpgsql']['updateUser'] = "UPDATE users SET"; $conf['plugin']['authpgsql']['UpdateLogin'] = "login='%{user}'"; $conf['plugin']['authpgsql']['UpdatePass'] = "pass='%{pass}'"; $conf['plugin']['authpgsql']['UpdateEmail'] = "email='%{email}'"; $conf['plugin']['authpgsql']['UpdateName'] = "fullname='%{name}'"; $conf['plugin']['authpgsql']['UpdateTarget']= "WHERE uid=%{uid}"; $conf['plugin']['authpgsql']['delUserGroup']= "DELETE FROM usergroup WHERE uid='%{uid}' AND gid='%{gid}'";