Dokuwiki users: generating from a list

24 Sep

Recently, I had to create a whole bunch of Dokuwiki users from a list. Here is a script I used for the same.

Dokuwiki stores its user info in conf/users.auth.php file. You can generate a list of users from a plain text or other file in this format:


and then run the following PHP script (say, name it, dokuusers.php) and output the result to a text file, and move the files as below:

$ php dokuusers.php > users.txt
(copy-paste the user list here)
$ cat users.txt users.auth.php > users2.auth.php
$ mv users2.auth.php users.auth.php

The dokuusers.php file is below.

/* Customize these lines */
// Company e-mail domain
$companyDomain = "";
// Group(s) to add users to
$groups = "user";
// Function that returns password string
// First example: john.doe has password john11111
function passwd ($string) {
        return $string . "11111";

$f = fopen('php://stdin', 'r');
while ($line = fgets($f)) {
        $line = trim($line);
        list($first, $last) = explode(".", $line);
        $passwd = md5(passwd($first));
        $name = ucfirst ($first) . " " . ucfirst ($last);
        $email = $line . "@" . $companyDomain;

        echo "$line:$passwd:$name:$email:$groups\n";

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: