XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
page_siteinit.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
29 require_once './include/common.inc.php';
30 defined('XOOPS_INSTALL') or die('XOOPS Installation wizard die');
31 
34 
35 $vars =& $_SESSION['siteconfig'];
36 
37 $error =& $_SESSION['error'];
38 
39 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
40  $vars['adminname'] = $_POST['adminname'];
41  $vars['adminmail'] = $_POST['adminmail'];
42  $vars['adminpass'] = $_POST['adminpass'];
43  $vars['adminpass2'] = $_POST['adminpass2'];
44  $error = array();
45 
46  if (empty( $vars['adminname'])) {
47  $error['name'][] = ERR_REQUIRED;
48  }
49  if (empty( $vars['adminmail'])) {
50  $error['email'][] = ERR_REQUIRED;
51  }
52  if (empty( $vars['adminpass'])) {
53  $error['pass'][] = ERR_REQUIRED;
54  }
55  if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $vars['adminmail'])) {
56  $error['email'][] = ERR_INVALID_EMAIL;
57  }
58  if ($vars['adminpass'] != $vars['adminpass2'] ) {
59  $error['pass'][] = ERR_PASSWORD_MATCH;
60  }
61  if ($error) {
62  $wizard->redirectToPage('+0');
63  return 200;
64  } else {
65  $wizard->redirectToPage('+1');
66  return 302;
67  }
68 } else {
69  include_once './class/dbmanager.php';
70  $dbm = new db_manager();
71 
72  if (!$dbm->isConnectable()) {
73  $wizard->redirectToPage('dbsettings');
74  exit();
75  }
76 
77  $res = $dbm->query("SELECT COUNT(*) FROM " . $dbm->db->prefix("users"));
78  list ($isadmin) = $dbm->db->fetchRow($res);
79 }
80 
81 ob_start();
82 
83 if ($isadmin) {
84  $pageHasForm = false;
85  $pageHasHelp = false;
86  echo "<div class='x2-note errorMsg'>" . ADMIN_EXIST . "</div>\n";
87 } else {
88 ?>
89  <fieldset>
90  <legend><?php echo LEGEND_ADMIN_ACCOUNT; ?></legend>
91 
92  <?php
93  echo '<script type="text/javascript">
94  var desc = new Array();
95  desc[0] = "' . PASSWORD_DESC . '";
96  desc[1] = "' . PASSWORD_VERY_WEAK . '";
97  desc[2] = "' . PASSWORD_WEAK . '";
98  desc[3] = "' . PASSWORD_BETTER . '";
99  desc[4] = "' . PASSWORD_MEDIUM . '";
100  desc[5] = "' . PASSWORD_STRONG . '";
101  desc[6] = "' . PASSWORD_STRONGEST . '";
102  </script>';
103 
104  echo xoFormField( 'adminname', $vars['adminname'], ADMIN_LOGIN_LABEL );
105  if (!empty($error["name"])) {
106  echo '<ul class="diags1">';
107  foreach ($error["name"] as $errmsg) {
108  echo '<li class="failure">' . $errmsg . '</li>';
109  }
110  echo '</ul>';
111  }
112 
113  echo xoFormField( 'adminmail', $vars['adminmail'], ADMIN_EMAIL_LABEL );
114  if (!empty($error["email"])) {
115  echo '<ul class="diags1">';
116  foreach ($error["email"] as $errmsg) {
117  echo '<li class="failure">' . $errmsg . '</li>';
118  }
119  echo '</ul>';
120  }
121  ?>
122 
123  <div id="password">
124  <div id="passwordinput">
125  <?php
126  echo xoPassField('adminpass', '', ADMIN_PASS_LABEL);
127  echo xoPassField('adminpass2', '', ADMIN_CONFIRMPASS_LABEL);
128  if (!empty($error["pass"])) {
129  echo '<ul class="diags1">';
130  foreach ($error["pass"] as $errmsg) {
131  echo '<li class="failure">' . $errmsg . '</li>';
132  }
133  echo '</ul>';
134  }
135  ?>
136  </div>
137 
138  <div id="passwordmetter" class="xoform-help">
139  <label class="xolabel" for='passwordStrength'><strong><?php echo PASSWORD_LABEL; ?></strong></label>
140  <div id='passwordStrength' class='strength0'>
141  <span id='passwordDescription'><?php echo PASSWORD_DESC; ?></span>
142  </div>
143 
144  <label class="xolabel" for='password_generator'><strong><?php echo PASSWORD_GENERATOR; ?></strong></label>
145  <div id="passwordgenerator">
146  <input type='text' name='generated_pw' id='generated_pw' value='' /><br />
147  <button type='button' onclick='javascript:suggestPassword(14);'/><?php echo PASSWORD_GENERATE; ?></button>
148  <button type='button' onclick='javascript:suggestPasswordCopy("adminpass");'/><?php echo PASSWORD_COPY; ?></button>
149  </div>
150  </div>
151  </div>
152  <br style="clear: both;" />
153  </fieldset>
154  <script type="text/javascript">
155  showHideHelp(this);
156  </script>
157 <?php
158 }
159 $content = ob_get_contents();
160 ob_end_clean();
161 $error = '';
162 include './include/install_tpl.php';
163 ?>