-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage_siteinit.php
executable file
·175 lines (153 loc) · 6.5 KB
/
page_siteinit.php
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
<?php
/**
* My IPv4 or IPv6 REST Services API
*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* 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.
*
* @copyright Chronolabs Cooperative http://syd.au.snails.email
* @license ACADEMIC APL 2 (https://sourceforge.net/u/chronolabscoop/wiki/Academic%20Public%20License%2C%20version%202.0/)
* @license GNU GPL 3 (http://www.gnu.org/licenses/gpl.html)
* @package myip-api
* @since 1.0.1
* @author Dr. Simon Antony Roberts <[email protected]>
* @version 1.0.3
* @description A REST Services API that returns either or both or all IPv4, IPv6 addresses of a caller!
* @link http://internetfounder.wordpress.com
* @link https://github.com/Chronolabs-Cooperative/MyIP-API-PHP
* @link https://sourceforge.net/p/chronolabs-cooperative
* @link https://facebook.com/ChronolabsCoop
* @link https://twitter.com/ChronolabsCoop
*
*/
require_once './include/common.inc.php';
defined('API_INSTALL') || die('API Installation wizard die');
$pageHasForm = true;
$pageHasHelp = false;
$vars =& $_SESSION['siteconfig'];
$error =& $_SESSION['error'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$_SESSION['settings']['ADMIN_COMPANY'] = $vars['company'] = $_POST['company'];
$_SESSION['settings']['ADMIN_UNAME'] = $vars['adminname'] = $_POST['adminname'];
$_SESSION['settings']['ADMIN_EMAIL'] = $vars['adminmail'] = $_POST['adminmail'];
$_SESSION['settings']['ADMIN_PASS'] = $vars['adminpass'] = $_POST['adminpass'];
$vars['adminpass2'] = $_POST['adminpass2'];
$error = array();
if (empty($vars['company'])) {
$error['company'][] = ERR_REQUIRED;
}
if (empty($vars['adminname'])) {
$error['name'][] = ERR_REQUIRED;
}
if (empty($vars['adminmail'])) {
$error['email'][] = ERR_REQUIRED;
}
if (empty($vars['adminpass'])) {
$error['pass'][] = ERR_REQUIRED;
}
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $vars['adminmail'])) {
$error['email'][] = ERR_INVALID_EMAIL;
}
if ($vars['adminpass'] != $vars['adminpass2']) {
$error['pass'][] = ERR_PASSWORD_MATCH;
}
if ($error) {
$wizard->redirectToPage('+0');
return 200;
} else {
$wizard->redirectToPage('+1');
return 302;
}
} else {
include_once './class/dbmanager.php';
$dbm = new Db_manager();
if (!$dbm->isConnectable()) {
$wizard->redirectToPage('dbsettings');
exit();
}
$res = $dbm->query('SELECT COUNT(*) FROM ' . $dbm->db->prefix('users'));
list($isadmin) = $dbm->db->fetchRow($res);
}
ob_start();
$extraSources = '<script type="text/javascript" src="./assets/js/zxcvbn.js"></script>';
if ($isadmin) {
$pageHasForm = false;
$pageHasHelp = false;
echo "<div class='alert alert-warning'>" . ADMIN_EXIST . "</div>\n";
} else {
echo '<script type="text/javascript">
var desc = new Array();
desc[0] = "' . PASSWORD_VERY_WEAK . '";
desc[1] = "' . PASSWORD_WEAK . '";
desc[2] = "' . PASSWORD_BETTER . '";
desc[3] = "' . PASSWORD_MEDIUM . '";
desc[4] = "' . PASSWORD_STRONG . '";
</script>';
?>
<div class="panel panel-info">
<div class="panel-heading"><?php echo LEGEND_ADMIN_ACCOUNT; ?></div>
<div class="panel-body">
<?php
echo '<div class="row"><div class="col-md-9">';
echo xoFormField('company', $vars['company'], ADMIN_COMPANY_LABEL);
if (!empty($error['company'])) {
foreach ($error['company'] as $errmsg) {
echo '<div class="alert alert-danger"><span class="fa fa-ban text-danger"></span> ' . $errmsg . '</div>';
}
}
echo xoFormField('adminname', $vars['adminname'], ADMIN_LOGIN_LABEL);
if (!empty($error['name'])) {
foreach ($error['name'] as $errmsg) {
echo '<div class="alert alert-danger"><span class="fa fa-ban text-danger"></span> ' . $errmsg . '</div>';
}
}
echo xoFormField('adminmail', $vars['adminmail'], ADMIN_EMAIL_LABEL);
if (!empty($error['email'])) {
foreach ($error['pass'] as $errmsg) {
echo '<div class="alert alert-danger"><span class="fa fa-ban text-danger"></span> ' . $errmsg . '</div>';
}
}
?>
<div id="password">
<div id="passwordinput">
<?php
echo xoPassField('adminpass', '', ADMIN_PASS_LABEL);
echo xoPassField('adminpass2', '', ADMIN_CONFIRMPASS_LABEL);
if (!empty($error['pass'])) {
foreach ($error['pass'] as $errmsg) {
echo '<div class="alert alert-danger"><span class="fa fa-ban text-danger"></span> ' . $errmsg . '</div>';
}
}
?>
</div>
</div>
</div>
<div class="col-md-3">
<div id="passwordmeter" class="well">
<h4><?php echo PASSWORD_LABEL; ?></h4>
<div id='passwordStrength' class='strength0'>
<span id='passwordDescription'><?php echo PASSWORD_DESC; ?></span>
</div>
<div id="passwordgenerator">
<label for='password_generator'><?php echo PASSWORD_GENERATOR; ?></label>
<input type="text" class="form-control" name="generated_pw" id="generated_pw" value="" onclick="this.setSelectionRange(0, this.value.length); document.execCommand('copy');"><br>
<button type="button" class="btn btn-default" onclick="suggestPassword(16);">
<?php echo PASSWORD_GENERATE; ?></button>
<button type="button" class="btn btn-default" onclick="suggestPasswordCopy();">
<?php echo PASSWORD_COPY; ?></button>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
$content = ob_get_contents();
ob_end_clean();
$error = !empty($error);
include './include/install_tpl.php';