1: <?php
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: require_once __DIR__ . '/include/common.inc.php';
27:
28: set_time_limit(0);
29:
30: function exception_handler($exception)
31: {
32: echo "Uncaught exception: " , $exception->getMessage(), "\n";
33: var_dump($exception->getTrace());
34: }
35:
36: set_exception_handler('exception_handler');
37:
38: \Xoops\Core\Cache\CacheManager::createDefaultConfig();
39:
40: $xoops = Xoops::getInstance();
41:
42:
43: $GLOBALS['xoopsDB'] = \XoopsDatabaseFactory::getDatabaseConnection(true);
44:
45:
46:
47: $modules_active = array();
48: $xoops->cache()->write('system/modules/active', $modules_active);
49:
50: $root = dirname(__DIR__);
51: $language = $wizard->language;
52: $xoops->setConfig('locale', $language);
53: $xoops->loadLocale();
54: $xoops->loadLocale('system');
55:
56:
57: include_once $root . "/modules/system/class/module.php";
58: include_once $root . "/modules/system/class/system.php";
59:
60: $system_module = new SystemModule();
61: $system = System::getInstance();
62: $status = $system_module->install('system', true);
63: if (!$status) {
64: $_SESSION['error'] = $system_module->error;
65:
66: }
67: $system_module->install('xmf');
68: $pageHasForm = true;
69: $pageHasHelp = false;
70:
71: $siteconfig = $_SESSION['siteconfig'];
72:
73: $error = $_SESSION['error'];
74:
75: if ($_SERVER['REQUEST_METHOD'] === 'POST') {
76: $siteconfig['adminname'] = $_POST['adminname'];
77: $siteconfig['adminmail'] = $_POST['adminmail'];
78: $siteconfig['adminpass'] = $_POST['adminpass'];
79: $siteconfig['adminpass2'] = $_POST['adminpass2'];
80: $error = array();
81:
82: if (empty($siteconfig['adminname'])) {
83: $error['name'][] = ERR_REQUIRED;
84: }
85: if (empty($siteconfig['adminmail'])) {
86: $error['email'][] = ERR_REQUIRED;
87: }
88: if (empty($siteconfig['adminpass'])) {
89: $error['pass'][] = ERR_REQUIRED;
90: }
91: if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $siteconfig['adminmail'])) {
92: $error['email'][] = ERR_INVALID_EMAIL;
93: }
94: if ($siteconfig['adminpass'] != $siteconfig['adminpass2']) {
95: $error['pass'][] = ERR_PASSWORD_MATCH;
96: }
97: if ($error) {
98: $_SESSION['error'] = $error;
99: $_SESSION['siteconfig'] = $siteconfig;
100: $wizard->redirectToPage('+0');
101: return 200;
102: } else {
103: $_SESSION['error'] = $error;
104: $_SESSION['siteconfig'] = $siteconfig;
105: $wizard->redirectToPage('+1');
106: return 302;
107: }
108: } else {
109: $dbm = new XoopsDatabaseManager();
110:
111: if (!$dbm->isConnectable()) {
112: $_SESSION['error'] = $error;
113: $_SESSION['siteconfig'] = $siteconfig;
114: $wizard->redirectToPage('dbsettings');
115: exit();
116: }
117:
118: $res = $dbm->query("SELECT COUNT(*) FROM " . $dbm->db->prefix('system_user'));
119: list ($isadmin) = $dbm->db->fetchRow($res);
120: }
121:
122: ob_start();
123:
124: if ($isadmin) {
125: $pageHasForm = false;
126: $pageHasHelp = false;
127: echo "<div class='x2-note errorMsg'>" . ADMIN_EXIST . "</div>\n";
128: } else {
129: ?>
130: <fieldset>
131: <legend><?php echo LEGEND_ADMIN_ACCOUNT; ?></legend>
132:
133: <?php
134: echo '<script type="text/javascript">
135: var desc = new Array();
136: desc[0] = "' . PASSWORD_DESC . '";
137: desc[1] = "' . PASSWORD_VERY_WEAK . '";
138: desc[2] = "' . PASSWORD_WEAK . '";
139: desc[3] = "' . PASSWORD_BETTER . '";
140: desc[4] = "' . PASSWORD_MEDIUM . '";
141: desc[5] = "' . PASSWORD_STRONG . '";
142: desc[6] = "' . PASSWORD_STRONGEST . '";
143: </script>';
144:
145: echo xoFormField('adminname', $siteconfig['adminname'], ADMIN_LOGIN_LABEL);
146: if (!empty($error["name"])) {
147: echo '<ul class="diags1">';
148: foreach ($error["name"] as $errmsg) {
149: echo '<li class="failure">' . $errmsg . '</li>';
150: }
151: echo '</ul>';
152: }
153:
154: echo xoFormField('adminmail', $siteconfig['adminmail'], ADMIN_EMAIL_LABEL);
155: if (!empty($error["email"])) {
156: echo '<ul class="diags1">';
157: foreach ($error["email"] as $errmsg) {
158: echo '<li class="failure">' . $errmsg . '</li>';
159: }
160: echo '</ul>';
161: }
162: ?>
163:
164: <div id="password">
165: <div id="passwordinput">
166: <?php
167: echo xoPassField('adminpass', '', ADMIN_PASS_LABEL);
168: echo xoPassField('adminpass2', '', ADMIN_CONFIRMPASS_LABEL);
169: if (!empty($error["pass"])) {
170: echo '<ul class="diags1">';
171: foreach ($error["pass"] as $errmsg) {
172: echo '<li class="failure">' . $errmsg . '</li>';
173: }
174: echo '</ul>';
175: }
176: ?>
177: </div>
178:
179: <div id="passwordmetter" class="xoform-help">
180: <label class="xolabel" for='passwordStrength'><strong><?php echo PASSWORD_LABEL; ?></strong></label>
181:
182: <div id='passwordStrength' class='strength0'>
183: <span id='passwordDescription'><?php echo PASSWORD_DESC; ?></span>
184: </div>
185:
186: <label class="xolabel" for='password_generator'><strong><?php echo PASSWORD_GENERATOR; ?></strong></label>
187:
188: <div id="passwordgenerator">
189: <input type='text' name='generated_pw' id='generated_pw' value=''/><br/>
190: <button type='button' class="gradient_bar button" onclick='javascript:suggestPassword(14);'/>
191: <?php echo PASSWORD_GENERATE; ?></button>
192: <button type='button' class="gradient_bar button"
193: onclick='javascript:suggestPasswordCopy("adminpass");'/>
194: <?php echo PASSWORD_COPY; ?></button>
195: </div>
196: </div>
197: </div>
198: <br style="clear: both;"/>
199: </fieldset>
200: <script type="text/javascript">
201: showHideHelp(this);
202: </script>
203: <?php
204:
205: }
206: $content = ob_get_contents();
207: ob_end_clean();
208: $error = '';
209:
210: $_SESSION['error'] = $error;
211: $_SESSION['siteconfig'] = $siteconfig;
212: $_SESSION['pageHasHelp'] = $pageHasHelp;
213: $_SESSION['pageHasForm'] = $pageHasForm;
214: $_SESSION['content'] = $content;
215: include XOOPS_INSTALL_PATH . '/include/install_tpl.php';
216: