Platform
3.1
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Pages
init_admin_passwd.php
Go to the documentation of this file.
1
#!/usr/bin/env php
2
<?php
3
/*
4
* @author Anakeen
5
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
6
* @package FDL
7
*/
8
9
$WIFF_ROOT
= getenv(
"WIFF_ROOT"
);
10
if
(
$WIFF_ROOT
===
false
) {
11
print
"WIFF_ROOT environment variable is not set!\n"
;
12
exit
(1);
13
}
14
15
$WIFF_CONTEXT_ROOT
= getenv(
"WIFF_CONTEXT_ROOT"
);
16
if
(
$WIFF_CONTEXT_ROOT
===
false
) {
17
print
"WIFF_CONTEXT_ROOT environment variable not set!\n"
;
18
exit
(1);
19
}
20
21
set_include_path(get_include_path() . PATH_SEPARATOR .
$WIFF_CONTEXT_ROOT
. PATH_SEPARATOR .
"$WIFF_ROOT/include"
);
22
23
$prefix
=
$WIFF_CONTEXT_ROOT
.
"/WHAT/Lib.Prefix.php"
;
24
if
(!include (
$prefix
)) {
25
print
"cannot include file $prefix"
;
26
exit
(1);
27
}
28
29
include_once (
'lib/Lib.Cli.php'
);
30
include_once (
'WHAT/Lib.Common.php'
);
31
include_once (
'WHAT/Class.User.php'
);
32
33
$admin_passwd
= wiff_getParamValue(
'core_admin_passwd'
);
34
if
(
$admin_passwd
==
''
) {
35
print
"Empty core_admin_passwd."
;
36
exit
(1);
37
}
38
39
$dbaccess
=
getParam
(
'CORE_DB'
);
40
41
$user
=
new
User
(
$dbaccess
, 1);
42
if
(!is_object(
$user
) || !
$user
->isAffected()) {
43
print
"Could not find user with id '1' (admin)."
;
44
exit
(1);
45
}
46
47
$user
->computepass(
$admin_passwd
,
$user
->password);
48
$err
=
$user
->modify(
true
,
''
,
true
);
49
if
(
$err
!=
''
) {
50
print sprintf(
"Modify returned with error: %s"
,
$err
);
51
exit
(1);
52
}
53
54
$err
=
$user
->setAdminHtpasswd(
$admin_passwd
);
55
if
(
$err
!=
''
) {
56
print sprintf(
"Error setting password in 'admin/.htpasswd': %s"
,
$err
);
57
exit
(1);
58
}
59
60
exit
(0);
61
?>
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase