Warning: Cannot modify header information - headers already sent by (output started at /var/www/jonas-eriksen.dk/pic/private/index.php:1) in /var/www/jonas-eriksen.dk/pic/private/index.php on line 215
auth.php 0000644 00000034756 15233537453 0006247 0 ustar 00
* @author Chris Smith
* @author Jan Schumann
*/
class auth_plugin_authplain extends DokuWiki_Auth_Plugin
{
/** @var array user cache */
protected $users = null;
/** @var array filter pattern */
protected $pattern = array();
/** @var bool safe version of preg_split */
protected $pregsplit_safe = false;
/**
* Constructor
*
* Carry out sanity checks to ensure the object is
* able to operate. Set capabilities.
*
* @author Christopher Smith
*/
public function __construct()
{
parent::__construct();
global $config_cascade;
if (!@is_readable($config_cascade['plainauth.users']['default'])) {
$this->success = false;
} else {
if (@is_writable($config_cascade['plainauth.users']['default'])) {
$this->cando['addUser'] = true;
$this->cando['delUser'] = true;
$this->cando['modLogin'] = true;
$this->cando['modPass'] = true;
$this->cando['modName'] = true;
$this->cando['modMail'] = true;
$this->cando['modGroups'] = true;
}
$this->cando['getUsers'] = true;
$this->cando['getUserCount'] = true;
$this->cando['getGroups'] = true;
}
$this->pregsplit_safe = version_compare(PCRE_VERSION, '6.7', '>=');
}
/**
* Check user+password
*
* Checks if the given user exists and the given
* plaintext password is correct
*
* @author Andreas Gohr
* @param string $user
* @param string $pass
* @return bool
*/
public function checkPass($user, $pass)
{
$userinfo = $this->getUserData($user);
if ($userinfo === false) return false;
return auth_verifyPassword($pass, $this->users[$user]['pass']);
}
/**
* Return user info
*
* Returns info about the given user needs to contain
* at least these fields:
*
* name string full name of the user
* mail string email addres of the user
* grps array list of groups the user is in
*
* @author Andreas Gohr
* @param string $user
* @param bool $requireGroups (optional) ignored by this plugin, grps info always supplied
* @return array|false
*/
public function getUserData($user, $requireGroups = true)
{
if ($this->users === null) $this->loadUserData();
return isset($this->users[$user]) ? $this->users[$user] : false;
}
/**
* Creates a string suitable for saving as a line
* in the file database
* (delimiters escaped, etc.)
*
* @param string $user
* @param string $pass
* @param string $name
* @param string $mail
* @param array $grps list of groups the user is in
* @return string
*/
protected function createUserLine($user, $pass, $name, $mail, $grps)
{
$groups = join(',', $grps);
$userline = array($user, $pass, $name, $mail, $groups);
$userline = str_replace('\\', '\\\\', $userline); // escape \ as \\
$userline = str_replace(':', '\\:', $userline); // escape : as \:
$userline = join(':', $userline)."\n";
return $userline;
}
/**
* Create a new User
*
* Returns false if the user already exists, null when an error
* occurred and true if everything went well.
*
* The new user will be added to the default group by this
* function if grps are not specified (default behaviour).
*
* @author Andreas Gohr
* @author Chris Smith
*
* @param string $user
* @param string $pwd
* @param string $name
* @param string $mail
* @param array $grps
* @return bool|null|string
*/
public function createUser($user, $pwd, $name, $mail, $grps = null)
{
global $conf;
global $config_cascade;
// user mustn't already exist
if ($this->getUserData($user) !== false) {
msg($this->getLang('userexists'), -1);
return false;
}
$pass = auth_cryptPassword($pwd);
// set default group if no groups specified
if (!is_array($grps)) $grps = array($conf['defaultgroup']);
// prepare user line
$userline = $this->createUserLine($user, $pass, $name, $mail, $grps);
if (!io_saveFile($config_cascade['plainauth.users']['default'], $userline, true)) {
msg($this->getLang('writefail'), -1);
return null;
}
$this->users[$user] = compact('pass', 'name', 'mail', 'grps');
return $pwd;
}
/**
* Modify user data
*
* @author Chris Smith
* @param string $user nick of the user to be changed
* @param array $changes array of field/value pairs to be changed (password will be clear text)
* @return bool
*/
public function modifyUser($user, $changes)
{
global $ACT;
global $config_cascade;
// sanity checks, user must already exist and there must be something to change
if (($userinfo = $this->getUserData($user)) === false) {
msg($this->getLang('usernotexists'), -1);
return false;
}
// don't modify protected users
if (!empty($userinfo['protected'])) {
msg(sprintf($this->getLang('protected'), hsc($user)), -1);
return false;
}
if (!is_array($changes) || !count($changes)) return true;
// update userinfo with new data, remembering to encrypt any password
$newuser = $user;
foreach ($changes as $field => $value) {
if ($field == 'user') {
$newuser = $value;
continue;
}
if ($field == 'pass') $value = auth_cryptPassword($value);
$userinfo[$field] = $value;
}
$userline = $this->createUserLine(
$newuser,
$userinfo['pass'],
$userinfo['name'],
$userinfo['mail'],
$userinfo['grps']
);
if (!io_replaceInFile($config_cascade['plainauth.users']['default'], '/^'.$user.':/', $userline, true)) {
msg('There was an error modifying your user data. You may need to register again.', -1);
// FIXME, io functions should be fail-safe so existing data isn't lost
$ACT = 'register';
return false;
}
$this->users[$newuser] = $userinfo;
return true;
}
/**
* Remove one or more users from the list of registered users
*
* @author Christopher Smith
* @param array $users array of users to be deleted
* @return int the number of users deleted
*/
public function deleteUsers($users)
{
global $config_cascade;
if (!is_array($users) || empty($users)) return 0;
if ($this->users === null) $this->loadUserData();
$deleted = array();
foreach ($users as $user) {
// don't delete protected users
if (!empty($this->users[$user]['protected'])) {
msg(sprintf($this->getLang('protected'), hsc($user)), -1);
continue;
}
if (isset($this->users[$user])) $deleted[] = preg_quote($user, '/');
}
if (empty($deleted)) return 0;
$pattern = '/^('.join('|', $deleted).'):/';
if (!io_deleteFromFile($config_cascade['plainauth.users']['default'], $pattern, true)) {
msg($this->getLang('writefail'), -1);
return 0;
}
// reload the user list and count the difference
$count = count($this->users);
$this->loadUserData();
$count -= count($this->users);
return $count;
}
/**
* Return a count of the number of user which meet $filter criteria
*
* @author Chris Smith
*
* @param array $filter
* @return int
*/
public function getUserCount($filter = array())
{
if ($this->users === null) $this->loadUserData();
if (!count($filter)) return count($this->users);
$count = 0;
$this->constructPattern($filter);
foreach ($this->users as $user => $info) {
$count += $this->filter($user, $info);
}
return $count;
}
/**
* Bulk retrieval of user data
*
* @author Chris Smith
*
* @param int $start index of first user to be returned
* @param int $limit max number of users to be returned
* @param array $filter array of field/pattern pairs
* @return array userinfo (refer getUserData for internal userinfo details)
*/
public function retrieveUsers($start = 0, $limit = 0, $filter = array())
{
if ($this->users === null) $this->loadUserData();
ksort($this->users);
$i = 0;
$count = 0;
$out = array();
$this->constructPattern($filter);
foreach ($this->users as $user => $info) {
if ($this->filter($user, $info)) {
if ($i >= $start) {
$out[$user] = $info;
$count++;
if (($limit > 0) && ($count >= $limit)) break;
}
$i++;
}
}
return $out;
}
/**
* Retrieves groups.
* Loads complete user data into memory before searching for groups.
*
* @param int $start index of first group to be returned
* @param int $limit max number of groups to be returned
* @return array
*/
public function retrieveGroups($start = 0, $limit = 0)
{
$groups = [];
if ($this->users === null) $this->loadUserData();
foreach($this->users as $user => $info) {
$groups = array_merge($groups, array_diff($info['grps'], $groups));
}
if($limit > 0) {
return array_splice($groups, $start, $limit);
}
return array_splice($groups, $start);
}
/**
* Only valid pageid's (no namespaces) for usernames
*
* @param string $user
* @return string
*/
public function cleanUser($user)
{
global $conf;
return cleanID(str_replace(':', $conf['sepchar'], $user));
}
/**
* Only valid pageid's (no namespaces) for groupnames
*
* @param string $group
* @return string
*/
public function cleanGroup($group)
{
global $conf;
return cleanID(str_replace(':', $conf['sepchar'], $group));
}
/**
* Load all user data
*
* loads the user file into a datastructure
*
* @author Andreas Gohr
*/
protected function loadUserData()
{
global $config_cascade;
$this->users = $this->readUserFile($config_cascade['plainauth.users']['default']);
// support protected users
if (!empty($config_cascade['plainauth.users']['protected'])) {
$protected = $this->readUserFile($config_cascade['plainauth.users']['protected']);
foreach (array_keys($protected) as $key) {
$protected[$key]['protected'] = true;
}
$this->users = array_merge($this->users, $protected);
}
}
/**
* Read user data from given file
*
* ignores non existing files
*
* @param string $file the file to load data from
* @return array
*/
protected function readUserFile($file)
{
$users = array();
if (!file_exists($file)) return $users;
$lines = file($file);
foreach ($lines as $line) {
$line = preg_replace('/#.*$/', '', $line); //ignore comments
$line = trim($line);
if (empty($line)) continue;
$row = $this->splitUserData($line);
$row = str_replace('\\:', ':', $row);
$row = str_replace('\\\\', '\\', $row);
$groups = array_values(array_filter(explode(",", $row[4])));
$users[$row[0]]['pass'] = $row[1];
$users[$row[0]]['name'] = urldecode($row[2]);
$users[$row[0]]['mail'] = $row[3];
$users[$row[0]]['grps'] = $groups;
}
return $users;
}
/**
* Get the user line split into it's parts
*
* @param string $line
* @return string[]
*/
protected function splitUserData($line)
{
// due to a bug in PCRE 6.6, preg_split will fail with the regex we use here
// refer github issues 877 & 885
if ($this->pregsplit_safe) {
return preg_split('/(?=$len) break;
} elseif ($line[$i]==':') {
$row[] = $piece;
$piece = '';
continue;
}
$piece .= $line[$i];
}
$row[] = $piece;
return $row;
}
/**
* return true if $user + $info match $filter criteria, false otherwise
*
* @author Chris Smith
*
* @param string $user User login
* @param array $info User's userinfo array
* @return bool
*/
protected function filter($user, $info)
{
foreach ($this->pattern as $item => $pattern) {
if ($item == 'user') {
if (!preg_match($pattern, $user)) return false;
} elseif ($item == 'grps') {
if (!count(preg_grep($pattern, $info['grps']))) return false;
} else {
if (!preg_match($pattern, $info[$item])) return false;
}
}
return true;
}
/**
* construct a filter pattern
*
* @param array $filter
*/
protected function constructPattern($filter)
{
$this->pattern = array();
foreach ($filter as $item => $pattern) {
$this->pattern[$item] = '/'.str_replace('/', '\/', $pattern).'/i'; // allow regex characters
}
}
}
plugin.info.txt 0000644 00000000351 15233537454 0007547 0 ustar 00 base authplain
author Andreas Gohr
email andi@splitbrain.org
date 2015-07-18
name Plain Auth Plugin
desc Provides user authentication against DokuWiki's local password storage
url http://www.dokuwiki.org/plugin:authplain
lang/lt/lang.php 0000644 00000000256 15233537454 0007554 0 ustar 00
*/
$lang['userexists'] = 'Xin lỗi, thành viên có thông tin đăng nhập này đã tồn tại.';
$lang['usernotexists'] = 'Xin lỗi, thành viên đó không tồn tại.';
$lang['writefail'] = 'Không thể sửa đổi dữ liệu thành viên. Vui lòng thông báo cho Quản trị viên Wiki';
$lang['protected'] = 'Dữ liệu cho thành viên %s được bảo vệ và không thể sửa đổi hoặc xóa.';
lang/fo/lang.php 0000644 00000000211 15233537455 0007531 0 ustar 00
*/
$lang['userexists'] = 'Det finns redan en användare med det användarnamnet.';
$lang['usernotexists'] = 'Tyvärr, den användaren existerar inte.';
$lang['writefail'] = 'Kunde inte ändra användardata. Var god informera Wiki-administratören';
lang/eu/lang.php 0000644 00000000244 15233537456 0007545 0 ustar 00
*/
$lang['userexists'] = 'Korisnik s tim korisničkim imenom već postoji.';
$lang['usernotexists'] = 'Nažalost korisnik ne postoji';
$lang['writefail'] = 'Ne mogu izmijeniti korisničke podatke. Molim obavijestite svog Wiki administratora';
$lang['protected'] = 'Podaci za korisnika %s su zaštićeni i ne mogu biti izmijenjeni ili obrisani.';
lang/ka/lang.php 0000644 00000000301 15233537457 0007522 0 ustar 00
*/
$lang['userexists'] = 'Sajnáljuk, ilyen azonosítójú felhasználónk már van.';
$lang['usernotexists'] = 'Sajnos ez a felhasználó nem létezik.';
$lang['writefail'] = 'A felhasználói adatok módosítása sikertelen. Kérlek, fordulj a wiki rendszergazdájához!';
lang/pt/lang.php 0000644 00000001154 15233537460 0007553 0 ustar 00
* @author Paulo Carmino
* @author Guilherme Sá
*/
$lang['userexists'] = 'Este nome de usuário já existe. Escolha outro.';
$lang['usernotexists'] = 'Desculpe, esse usuário não existe.';
$lang['writefail'] = 'Não foi possível modificar dados do usuário. Favor informar ao Wiki-Admin.';
$lang['protected'] = 'Os dados do usuário %s estão protegidos e não podem ser modificados ou excluídos.';
lang/af/lang.php 0000644 00000000316 15233537460 0007515 0 ustar 00
* @author sam01
*/
$lang['userexists'] = 'نام کاربریای که وارد کردید قبلن استفاده شده است. خواهشمندیم یک نام دیگر انتخاب کنید.';
$lang['usernotexists'] = 'متاسفانه این کاربر وجود ندارد.';
$lang['writefail'] = 'امکان ویرایش اطلاعات کاربر وجود ندارد. لطفا ادمین ویکی را مطلع نمایید.';
$lang['protected'] = 'دادهها برای کاربر %s محافظت شده و قابل تغییر نیست یا حذف شده اند.';
lang/bg/lang.php 0000644 00000000531 15233537461 0007517 0 ustar 00
*/
$lang['userexists'] = 'Вече съществува потребител с избраното име.';
$lang['usernotexists'] = 'За съжаление потребителят не съществува.';
lang/gl/lang.php 0000644 00000000236 15233537462 0007534 0 ustar 00
*/
$lang['userexists'] = 'Αυτός ο λογαριασμός υπάρχει ήδη.';
$lang['usernotexists'] = 'Λυπάμαι, αυτός ο χρήστης δεν υπάρχει.';
$lang['writefail'] = 'Δεν μπόρεσε να τροποποιήσει τα δεδομένα χρήστη. Παρακαλώ ενημερώστε το Wiki-Admin';
$lang['protected'] = ' Τα δεδομένα χρήστη %s είναι εμπιστευτικά και δεν μπορούν να τροποποιηθούν ή απαλειφθούν.';
lang/eo/lang.php 0000644 00000000440 15233537462 0007532 0 ustar 00
*/
$lang['userexists'] = 'Pardonu, ĉi tiu uzanto-nomo jam ekzistas.';
$lang['usernotexists'] = 'Pardonu, tiu uzanto ne ekzistas.';
lang/az/lang.php 0000644 00000000251 15233537463 0007542 0 ustar 00
*/
$lang['userexists'] = 'Užívateľ s rovnakým menom je už zaregistrovaný.';
$lang['usernotexists'] = 'Ľutujem, daný používateľ neexistuje.';
$lang['writefail'] = 'Nie je možné zmeniť údaje používateľa, informujte prosím administrátora Wiki.';
$lang['protected'] = 'Údaje používateľa %s sú chránené a nemôžu by zmenené alebo vymazané.';
lang/ru/lang.php 0000644 00000001435 15233537464 0007564 0 ustar 00
* @author Aleksandr Selivanov
* @author Radimir
*/
$lang['userexists'] = 'Извините, пользователь с таким логином уже существует.';
$lang['usernotexists'] = 'Этот пользователь не зарегистрирован.';
$lang['writefail'] = 'Невозможно обновить данные пользователя. Свяжитесь с администратором вики';
$lang['protected'] = 'Данные пользователя %s защищены и не могут быть изменены или удалены.';
lang/sr/lang.php 0000644 00000000311 15233537464 0007552 0 ustar 00
* @author Enny Rodriguez
*/
$lang['userexists'] = 'Lo siento, ya existe un usuario con este nombre.';
$lang['usernotexists'] = 'Lo sentimos, no existe ese usuario.';
$lang['writefail'] = 'No es posible modificar los datos del usuario. Por favor, informa al Administrador del Wiki';
$lang['protected'] = 'Los datos del usuario %s están protegidos y no pueden ser modificados o eliminados.';
lang/no/lang.php 0000644 00000000763 15233537465 0007556 0 ustar 00
*/
$lang['userexists'] = 'Det finnes allerede en konto med dette brukernavnet.';
$lang['usernotexists'] = 'Beklager, denne bruker fins ikke.';
$lang['writefail'] = 'Klarte ikke endre brukerdata. Dette bør meldes til wikiens administrator';
$lang['protected'] = 'Data for bruker %s er beskyttet og kan ikke endres eller slettes.';
lang/it/lang.php 0000644 00000001055 15233537465 0007551 0 ustar 00
* @author Riccardo
*/
$lang['userexists'] = 'Il nome utente inserito esiste già.';
$lang['usernotexists'] = 'Spiacente, quell\'utente non esiste.';
$lang['writefail'] = 'Impossibile modificare i dati utente. Per favore informa l\'Amministratore del Wiki';
$lang['protected'] = 'I dati relativi all\'utente %s sono protetti e non possono essere modificati o cancellati.';
lang/kk/lang.php 0000644 00000000300 15233537465 0007532 0 ustar 00
*/
$lang['userexists'] = 'Користувач з таким іменем вже існує.';
$lang['usernotexists'] = 'Вибачте, такого користувача не існує.';
lang/cs/lang.php 0000644 00000001075 15233537466 0007545 0 ustar 00
* @author Daniel Slováček
*/
$lang['userexists'] = 'Uživatel se stejným jménem už je zaregistrován.';
$lang['usernotexists'] = 'Omlouváme se, uživatel tohoto jména neexistuje.';
$lang['writefail'] = 'Nelze změnit údaje uživatele. Informujte prosím správce wiki';
$lang['protected'] = 'Data pro uživatele %s jsou chráněna a nemůžou být upravena nebo smazána.';
lang/lv/lang.php 0000644 00000000224 15233537466 0007554 0 ustar 00
* @author Nicolas Friedli
* @author Schplurtz le Déboulonné
*/
$lang['userexists'] = 'Désolé, ce nom d\'utilisateur est déjà pris.';
$lang['usernotexists'] = 'Désolé, cet utilisateur n\'existe pas.';
$lang['writefail'] = 'Impossible de modifier les données utilisateur. Merci d\'en informer l\'administrateur du wiki.';
$lang['protected'] = 'Les données du compte d\'utilisateur %s sont protégées et ne peuvent être ni modifiées ni supprimées.';
lang/he/lang.php 0000644 00000000257 15233537467 0007536 0 ustar 00
* @author tai
*/
$lang['userexists'] = '对不起,该用户名已经存在。';
$lang['usernotexists'] = '抱歉,该用户不存在';
$lang['writefail'] = '无法修改用户数据。请联系维基管理员';
$lang['protected'] = '用户 %s 的数据被保护和无法被编辑或删除。';
lang/ko/lang.php 0000644 00000001117 15233537471 0007542 0 ustar 00
*/
$lang['userexists'] = '죄송하지만 같은 이름을 사용하는 사용자가 있습니다.';
$lang['usernotexists'] = '죄송하지만 해당 사용자가 존재하지 않습니다.';
$lang['writefail'] = '사용자 데이터를 수정할 수 없습니다. 위키 관리자에게 문의하시기 바랍니다';
$lang['protected'] = '%s 사용자의 데이터는 잠겨 있어 수정하거나 삭제할 수 없습니다.';
lang/ia/lang.php 0000644 00000000242 15233537471 0007520 0 ustar 00
* @author Kenneth Schack Banner
*/
$lang['userexists'] = 'Dette brugernavn er allerede i brug.';
$lang['usernotexists'] = 'Beklager, brugeren eksisterer ikke.';
$lang['writefail'] = 'Ude af stand til at redigere bruger data. Kontakt venligst Wiki-Administratoren';
$lang['protected'] = 'Data for brugeren %s er beskyttet, og kan ikke ændres eller slettes.';
lang/nl/lang.php 0000644 00000001055 15233537471 0007543 0 ustar 00
* @author Sjoerd
*/
$lang['userexists'] = 'Er bestaat al een gebruiker met deze loginnaam.';
$lang['usernotexists'] = 'Sorry, deze gebruiker bestaat niet.';
$lang['writefail'] = 'Onmogelijk om de gebruikers data te wijzigen. Gelieve de Wiki-Admin te informeren.';
$lang['protected'] = 'Gegevens van gebruiker %s zijn beschermd en kunnen niet worden veranderd of verwijderd';
lang/cy/lang.php 0000644 00000000513 15233537472 0007544 0 ustar 00
*/
$lang['userexists'] = 'Użytkownik o tej nazwie już istnieje.';
$lang['usernotexists'] = 'Przepraszamy, użytkownik nie istnieje';
$lang['writefail'] = 'Nie można modyfikować danych użytkownika. Proszę skontaktować się z administratorem ';
$lang['protected'] = 'Dane użytkownika %s są chronione, nie mogą być modyfikowane oraz usuwane';
lang/id-ni/lang.php 0000644 00000000233 15233537472 0010130 0 ustar 00
* @author Felipe Castro
*/
$lang['userexists'] = 'Desculpe, mas já existe um usuário com esse nome.';
$lang['usernotexists'] = 'Desculpe, mas esse usuário não existe.';
$lang['writefail'] = 'Não foi possível modificar os dados do usuário. Por favor, informe ao administrador do Wiki.';
$lang['protected'] = 'Dados para o usuário %s estão protegidos e não podem ser modificados ou apagados.';
lang/lb/lang.php 0000644 00000000222 15233537473 0007524 0 ustar 00
*/
$lang['userexists'] = 'Der Benutzername existiert leider schon.';
$lang['usernotexists'] = 'Entschuldigung, dieser Nutzer existiert nicht.';
$lang['writefail'] = 'Konnte Nutzer-Daten nicht modifizieren. Bitte informiere einen Admin.';
$lang['protected'] = 'Die Daten für den Nutzer %s sind geschützt und können nicht verändert oder gelöscht werden.';
lang/ja/lang.php 0000644 00000001202 15233537474 0007521 0 ustar 00
* @author Hideaki SAWADA
*/
$lang['userexists'] = '恐れ入りますが、このユーザー名は既に存在しています。';
$lang['usernotexists'] = '恐れ入りますが、このユーザーは未登録です。';
$lang['writefail'] = 'ユーザーデータを変更できません。管理者に問い合わせてください。';
$lang['protected'] = 'ユーザ %s のデータは保護されており、変更・削除はできません。';
lang/de/lang.php 0000644 00000001070 15233537474 0007522 0 ustar 00
* @author Carsten Perthel
*/
$lang['userexists'] = 'Der Benutzername existiert leider schon.';
$lang['usernotexists'] = 'Dieser Benutzer existiert nicht.';
$lang['writefail'] = 'Kann Benutzerdaten nicht ändern. Bitte informieren Sie den Wiki-Administratoren';
$lang['protected'] = 'Die Daten des Benutzers %s sind geschützt und können nicht verändert oder gelöscht werden.';