PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/install/createuser.php

http://pixie-cms.googlecode.com/
PHP | 295 lines | 249 code | 35 blank | 11 comment | 23 complexity | 79333cec1dbad10e009af299220e2360 MD5 | raw file
  1. <?php
  2. error_reporting(0); // Turns off error reporting
  3. if (!file_exists('../config.php') or filesize('../config.php') < 10) { // check for config
  4. require '../lib/lib_db.php';
  5. db_down();
  6. exit();
  7. }
  8. if (!defined('DIRECT_ACCESS')) {
  9. define('DIRECT_ACCESS', 1);
  10. }
  11. /* very important to set this first, so that we can use the new config.php */
  12. require '../lib/lib_misc.php'; //
  13. $debug = 'no'; // Set this to yes to debug and see all the global vars coming into the file
  14. globalSec('Pixie Installer createuser.php', 1);
  15. extract($_REQUEST);
  16. /* needs prefixing with pixie_ instead */
  17. require '../config.php';
  18. include '../lib/lib_db.php'; // load libraries order is important
  19. if (strnatcmp(phpversion(), '5.1.0') >= 0) {
  20. if (!isset($server_timezone)) {
  21. $server_timezone = 'Europe/London';
  22. }
  23. date_default_timezone_set("$server_timezone");
  24. }
  25. /* New! Built in php function. Tell php what the server timezone is so that we can use php's rewritten time and date functions with the correct time and without error messages */
  26. define('TZ', "$timezone");
  27. /* timezone fix (php 5.1.0 or newer will set it's server timezone using function date_default_timezone_set!) */
  28. if (isset($do)) {
  29. print($do);
  30. }
  31. if ($debug == 'yes') {
  32. error_reporting(E_ALL & ~E_DEPRECATED);
  33. $show_vars = get_defined_vars();
  34. echo '<p><pre class="showvars">The _REQUEST array contains : ';
  35. htmlspecialchars(print_r($show_vars["_REQUEST"]));
  36. echo '</pre></p>';
  37. }
  38. $prefs = get_prefs();
  39. /* Add prefs to globals using php's extract function */
  40. extract($prefs);
  41. /* Get the language file */
  42. include_once "../lang/{$language}.php";
  43. if ((isset($user_new)) && ($user_new)) {
  44. $table_name = 'pixie_users';
  45. if (!isset($error)) {
  46. $password = generate_password(6);
  47. $nonce = md5(uniqid(rand(), TRUE));
  48. if ((isset($realname)) && (isset($uname))) {
  49. $sql = "user_name = '$uname', realname = '$realname', email = '$email', pass = password(lower('$password')), nonce = '$nonce', privs = '$privs', biography =''";
  50. }
  51. $ok = safe_insert($table_name, $sql);
  52. if (!$ok) {
  53. $message = $lang['user_name_dup'];
  54. } else {
  55. // send email
  56. $emessage = "
  57. Your account information for Pixie has been set to:
  58. username: $uname
  59. password: $password
  60. ";
  61. $subject = 'Pixie account information';
  62. mail($email, $subject, $emessage);
  63. $messageok = "{$lang['user_new_ok']} {$realname} <br /> [ {$lang['form_username']} : {$uname} ] ::: [ {$lang['form_password']} : {$password} ]";
  64. }
  65. } else {
  66. $err = explode("|", $error);
  67. $message = $err[0];
  68. }
  69. }
  70. ?>
  71. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  72. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  73. <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  74. <head>
  75. <!--
  76. Pixie Powered (www.getpixie.co.uk)
  77. Licence: GNU General Public License v3
  78. Copyright (C) <?php
  79. print date('Y');
  80. ?>, Scott Evans
  81. This program is free software: you can redistribute it and/or modify
  82. it under the terms of the GNU General Public License as published by
  83. the Free Software Foundation, either version 3 of the License, or
  84. (at your option) any later version.
  85. This program is distributed in the hope that it will be useful,
  86. but WITHOUT ANY WARRANTY; without even the implied warranty of
  87. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  88. GNU General Public License for more details.
  89. You should have received a copy of the GNU General Public License
  90. along with this program. If not, see http://www.gnu.org/licenses/
  91. www.getpixie.co.uk
  92. -->
  93. <!-- meta tags -->
  94. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  95. <meta name="keywords" content="elev3n, eleven, 11, 3l3v3n, el3v3n, binary, html, xhtml, css, php, xml, mysql, flash, actionscript, action, script, web standards, accessibility, scott, evans, scott evans, sunk, media, www.sunkmedia.co.uk, scripts, news, portfolio, shop, blog, web, design, print, identity, logo, designer, fonts, typography, england, uk, london, united kingdom, staines, middlesex, computers, mac, apple, osx, os x, windows, linux, itx, mini, pc, gadgets, itunes, mp3, technology" />
  96. <meta name="description" content="elev3n.co.uk - web and print design portfolio for scott evans (uk)." />
  97. <meta http-equiv="imagetoolbar" content="no" />
  98. <meta name="robots" content="all" />
  99. <meta name="revisit-after" content="7 days" />
  100. <meta name="author" content="Scott Evans" />
  101. <meta name="copyright" content="Scott Evans" />
  102. <title>Pixie (www.getpixie.co.uk) - Create User</title>
  103. <!-- CSS -->
  104. <link rel="stylesheet" href="../admin/theme/style.php" type="text/css" media="screen" />
  105. <style type="text/css">
  106. body, html
  107. {
  108. height: auto;
  109. background: #191919;
  110. }
  111. #bg
  112. {
  113. background: #191919 url(background.jpg) 7px 0px no-repeat;
  114. width: 790px;
  115. min-height: 670px;
  116. margin: 0 auto;
  117. padding-top: 100px;
  118. }
  119. #placeholder
  120. {
  121. border: 5px solid #e1e1e1;
  122. clear: left;
  123. padding: 15px 30px 20px 30px;
  124. margin: 0 auto;
  125. background-color: #fff;
  126. width: 400px;
  127. line-height: 15pt;
  128. min-height: 480px;
  129. }
  130. #logo
  131. {
  132. margin: 0 auto;
  133. width:470px;
  134. display: block;
  135. }
  136. p
  137. {
  138. font-size: 0.8em;
  139. padding: 15px 0;
  140. }
  141. legend
  142. {
  143. color: #109bd4;
  144. }
  145. .form_text
  146. {
  147. width: 322px;
  148. }
  149. .form_item_drop select
  150. {
  151. width: 333px;
  152. padding: 2px;
  153. }
  154. label
  155. {
  156. float: left;
  157. }
  158. .form_help
  159. {
  160. float: left;
  161. font-size: 0.7em;
  162. padding-left: 5px;
  163. position: relative;
  164. top: 2px;
  165. }
  166. .form_item_drop
  167. {
  168. clear: both;
  169. }
  170. .help
  171. {
  172. margin: 0;
  173. padding: 0;
  174. color: #898989;
  175. }
  176. .error, .notice, .success
  177. {
  178. padding: 15px;
  179. border: 2px solid #ddd;
  180. width: 436px;
  181. margin: 0 auto;
  182. }
  183. .error
  184. {
  185. background: #FBE3E4;
  186. color: #D12F19;
  187. border-color: #FBC2C4;
  188. }
  189. .notice
  190. {
  191. background: #FFF6BF;
  192. color: #817134;
  193. border-color: #FFD324;
  194. }
  195. .success
  196. {
  197. background: #E6EFC2;
  198. color: #529214;
  199. border-color: #C6D880;
  200. }
  201. </style>
  202. <!-- site icons-->
  203. <link rel="Shortcut Icon" type="image/x-icon" href="../favicon.ico" />
  204. <link rel="apple-touch-icon" href="../../files/images/apple_touch_icon.jpg"/>
  205. </head>
  206. <body>
  207. <div id="bg">
  208. <?php
  209. if ($message) {
  210. print "<p class=\"error\">$message</p>";
  211. }
  212. if (isset($messageok)) {
  213. if ($messageok) {
  214. print "<p class=\"success\">$messageok</p>";
  215. }
  216. }
  217. ?>
  218. <img src="banner.gif" alt="Pixie logo" id="logo">
  219. <div id="placeholder">
  220. <h3>Create a user</h3>
  221. <p>Please fill in the user details below:</p>
  222. <form accept-charset="UTF-8" action="createuser.php" method="post" class="form">
  223. <fieldset>
  224. <div class="form_row">
  225. <div class="form_label"><label for="uname">Username <span class="form_required">*</span></label></div>
  226. <div class="form_item"><input type="text" class="form_text" name="uname" value="" size="20" maxlength="80" id="uname" /></div>
  227. </div>
  228. <div class="form_row">
  229. <div class="form_label"><label for="realname">Real Name <span class="form_required">*</span></label></div>
  230. <div class="form_item"><input type="text" class="form_text" name="realname" value="" size="20" maxlength="80" id="realname" /></div>
  231. </div>
  232. <div class="form_row">
  233. <div class="form_label"><label for="email">Email <span class="form_required">*</span></label></div>
  234. <div class="form_item"><input type="text" class="form_text" name="email" value="" size="20" maxlength="80" id="email" /></div>
  235. </div>
  236. <div class="form_row">
  237. <div class="form_label"><label for="privs">Permissions <span class="form_required">*</span></label></div>
  238. <div class="form_item_drop"><select class="form_select" name="privs" id="privs">
  239. <option value="0">User</option>
  240. <option value="1">Client</option>
  241. <option value="2">Admin</option>
  242. <option value="3" selected="selected">Super User</option>
  243. </select></div>
  244. </div>
  245. <div class="form_row_button" id="form_button">
  246. <input type="submit" name="user_new" class="form_submit" value="Create" />
  247. </div>
  248. </fieldset>
  249. </form>
  250. </div>
  251. </div>
  252. <?php
  253. if ($debug == 'yes') {
  254. /* Show the defined global vars */
  255. print '<pre class="showvars">' . htmlspecialchars(print_r(get_defined_vars(), TRUE)) . '</pre>';
  256. phpinfo();
  257. }
  258. ?>
  259. </body>
  260. </html>