-
Notifications
You must be signed in to change notification settings - Fork 355
Expand file tree
/
Copy pathindex.php
More file actions
192 lines (167 loc) · 7.97 KB
/
Copy pathindex.php
File metadata and controls
192 lines (167 loc) · 7.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
#==============================================================================
# LTB Self Service Password
#
# Copyright (C) 2009 Clement OUDOT
# Copyright (C) 2009 LTB-project.org
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# GPL License: http://www.gnu.org/licenses/gpl.txt
#
#==============================================================================
ob_start();
#==============================================================================
# Includes
#==============================================================================
require_once("conf/config.inc.php");
require_once("lib/vendor/defuse-crypto.phar");
require_once("lib/functions.inc.php");
if ($use_recaptcha) {
require_once("lib/vendor/autoload.php");
}
require_once('phar://'. __DIR__ . '/lib/vendor/twig.phar/Twig/Autoloader.php');
Twig_Autoloader::register();
require_once("lib/detectbrowserlanguage.php");
require_once("lib/vendor/PHPMailer/PHPMailerAutoload.php");
#==============================================================================
# Error reporting
#==============================================================================
error_reporting(0);
if($debug) {
error_reporting(E_ALL);
// Important to get error details in case of SSL/TLS failure at connection
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
}
#==============================================================================
# Language
#==============================================================================
# Available languages
$languages = array();
if ($handle = opendir('lang')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." ) {
$entry_lang = str_replace(".inc.php", "", $entry);
# Only add language to possibilities if it is the default language or part of the allowed languages
# empty $allowed_lang <=> all languages are allowed
if ($entry_lang == $lang || empty($allowed_lang) || in_array($entry_lang, $allowed_lang) ) {
array_push($languages, $entry_lang);
}
}
}
closedir($handle);
}
$lang = detectLanguage($lang, $languages);
require_once("lang/$lang.inc.php");
if (file_exists("conf/$lang.inc.php")) {
require_once("conf/$lang.inc.php");
}
#==============================================================================
# PHP modules
#==============================================================================
# Init dependency check results variable
$dependency_check_results = array();
# Check PHP-LDAP presence
if ( ! function_exists('ldap_connect') ) { $dependency_check_results[] = "nophpldap"; }
else {
# Check ldap_modify_batch presence if AD mode and password change as user
if ( $ad_mode and $who_change_password === "user" and ! function_exists('ldap_modify_batch') ) { $dependency_check_results[] = "phpupgraderequired"; }
}
# Check PHP mhash presence if Samba mode active
if ( $samba_mode and ! function_exists('hash') and ! function_exists('mhash') ) { $dependency_check_results[] = "nophpmhash"; }
# Check PHP mbstring presence
if ( ! function_exists('mb_internal_encoding') ) { $dependency_check_results[] = "nophpmbstring"; }
# Check PHP xml presence
if ( ! function_exists('utf8_decode') ) { $dependency_check_results[] = "nophpxml"; }
# Check keyphrase setting
if ( ( ( $use_tokens and $crypt_tokens ) or $use_sms ) and ( empty($keyphrase) or $keyphrase == "secret") ) { $dependency_check_results[] = "nokeyphrase"; }
#==============================================================================
# Action
#==============================================================================
if (!isset($default_action)) { $default_action = "change"; }
if (isset($_GET["action"]) and $_GET["action"]) { $action = $_GET["action"]; }
else { $action = $default_action; }
# Available actions
$available_actions = array();
if ( $use_change ) { array_push( $available_actions, "change"); }
if ( $change_sshkey ) { array_push( $available_actions, "changesshkey"); }
if ( $use_questions ) { array_push( $available_actions, "resetbyquestions", "setquestions"); }
if ( $use_tokens ) { array_push( $available_actions, "resetbytoken", "sendtoken"); }
if ( $use_sms ) { array_push( $available_actions, "resetbytoken", "sendsms"); }
if ( $use_totp ) { array_push( $available_actions, "resetbytoken", "changetotp"); }
# Ensure requested action is available, or fall back to default
if ( ! in_array($action, $available_actions) ) { $action = $default_action; }
# Get source for menu
if (isset($_REQUEST["source"]) and $_REQUEST["source"]) { $source = $_REQUEST["source"]; }
#==============================================================================
# Other default values
#==============================================================================
if (!isset($ldap_login_attribute)) { $ldap_login_attribute = "uid"; }
if (!isset($ldap_fullname_attribute)) { $ldap_fullname_attribute = "cn"; }
if (!isset($pwd_forbidden_chars)) { $pwd_forbidden_chars = ""; }
if (!isset($hash_options)) { $hash_options = array(); }
if (!isset($samba_options)) { $samba_options = array(); }
if (!isset($ldap_starttls)) { $ldap_starttls = false; }
# Password policy array
$pwd_policy_config = array(
"pwd_show_policy" => $pwd_show_policy,
"pwd_min_length" => $pwd_min_length,
"pwd_max_length" => $pwd_max_length,
"pwd_min_lower" => $pwd_min_lower,
"pwd_min_upper" => $pwd_min_upper,
"pwd_min_digit" => $pwd_min_digit,
"pwd_min_special" => $pwd_min_special,
"pwd_special_chars" => $pwd_special_chars,
"pwd_forbidden_chars" => $pwd_forbidden_chars,
"pwd_no_reuse" => $pwd_no_reuse,
"pwd_diff_login" => $pwd_diff_login,
"pwd_complexity" => $pwd_complexity
);
if (!isset($pwd_show_policy_pos)) { $pwd_show_policy_pos = "above"; }
#==============================================================================
# Email Config
#==============================================================================
$mailer = new PHPMailer;
$mailer->Priority = $mail_priority;
$mailer->CharSet = $mail_charset;
$mailer->ContentType = $mail_contenttype;
$mailer->WordWrap = $mail_wordwrap;
$mailer->Sendmail = $mail_sendmailpath;
$mailer->Mailer = $mail_protocol;
$mailer->SMTPDebug = $mail_smtp_debug;
$mailer->Debugoutput = $mail_debug_format;
$mailer->Host = $mail_smtp_host;
$mailer->Port = $mail_smtp_port;
$mailer->SMTPSecure = $mail_smtp_secure;
$mailer->SMTPAutoTLS = $mail_smtp_autotls;
$mailer->SMTPAuth = $mail_smtp_auth;
$mailer->Username = $mail_smtp_user;
$mailer->Password = $mail_smtp_pass;
$mailer->SMTPKeepAlive = $mail_smtp_keepalive;
$mailer->Timeout = $mail_smtp_timeout;
$mailer->LE = $mail_newline;
#==============================================================================
# Template engine
#==============================================================================
$loader = new Twig_Loader_Filesystem(__DIR__.'/templates');
$twig = new Twig_Environment($loader, array(
//'cache' => __DIR__ .'/templates_c',
));
function trans($id) {
global $messages;
return $messages[$id];
}
$twig->addFilter('fa_class', new Twig_SimpleFilter('fa_class', 'get_fa_class'));
$twig->addFilter('criticality', new Twig_SimpleFilter('criticality', 'get_criticity'));
$twig->addFilter('trans', new Twig_SimpleFilter('trans', 'trans'));
$twig->addFunction('show_policy', new Twig_SimpleFunction('show_policy', 'show_policy'));
require_once __DIR__ . "/pages/$action.php";
ob_end_flush();