A tumblelog CMS built on AJAX, PHP and MySQL.

user.php 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?
  2. /* ===========================
  3. gelato CMS development version
  4. http://www.gelatocms.com/
  5. gelato CMS is a free software licensed under GPL (General public license)
  6. =========================== */
  7. ?>
  8. <?
  9. require_once('../config.php');
  10. include("../classes/functions.php");
  11. include("../classes/user.class.php");
  12. require_once("../classes/configuration.class.php");
  13. $user = new user();
  14. $conf = new configuration();
  15. $isEdition = isset($_GET["edit"]);
  16. $userId = ($isEdition) ? $_GET["edit"] : NULL;
  17. if ($user->isAdmin()) {
  18. if (isset($_GET["delete"])) {
  19. $user->deleteUser($_GET['delete']);
  20. header("Location: admin.php?delete=true");
  21. die();
  22. }
  23. if(isset($_POST["btnAdd"])) {
  24. unset($_POST["btnAdd"]);
  25. if (isset($_POST["repass"])) {
  26. unset($_POST["repass"]);
  27. }
  28. if (isset($_POST["btnVerifyUser"])) {
  29. unset($_POST["btnVerifyUser"]);
  30. }
  31. if (isset($_POST["password"])) {
  32. $_POST["password"] = md5($_POST["password"]);
  33. }
  34. if (isset($_POST["id_user"])) {
  35. $user->modifyUser($_POST, $_POST["id_user"]);
  36. } else {
  37. $user->addUser($_POST);
  38. }
  39. } else {
  40. if ($isEdition) {
  41. $register = $user->getUserByID($userId);
  42. }
  43. ?>
  44. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  45. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  46. <head>
  47. <title>gelato :: Add user</title>
  48. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  49. <link rel="shortcut icon" href="<?=$conf->urlGelato;?>/images/favicon.ico" />
  50. <script language="javascript" type="text/javascript" src="<?=$conf->urlGelato;?>/admin/scripts/tiny_mce/tiny_mce.js"></script>
  51. <script language="javascript" type="text/javascript" src="<?=$conf->urlGelato;?>/admin/scripts/mootools.js"></script>
  52. <script language="javascript" type="text/javascript">
  53. tinyMCE.init({
  54. width : "100%",
  55. mode : "textareas",
  56. theme : "simple"
  57. });
  58. function validateFrmAddUser() {
  59. if ($('login').value == "") {
  60. alert("The username field cannot be left blank.");
  61. document.frm_add.login.select();
  62. return false;
  63. }
  64. if ($('password').value == "") {
  65. alert("The password field cannot be left blank.");
  66. document.frm_add.password.select();
  67. return false;
  68. }
  69. if ($('password').value != $('repass').value) {
  70. alert("The password must match,\nplease verify them.");
  71. document.frm_add.password.focus();
  72. return false;
  73. }
  74. return true;
  75. }
  76. function verifyExistingUser() {
  77. $('div-process').style.display="block";
  78. el = $('target');
  79. el.style.display="block";
  80. var path = 'ajax.php?action=verify&login='+$('login').value;
  81. new Ajax(path, {
  82. onComplete:function(e) {
  83. el.setHTML(e);
  84. $('div-process').style.display="none";
  85. }
  86. }).request();
  87. return false;
  88. }
  89. </script>
  90. <style type="text/css" media="screen">
  91. @import "<?=$conf->urlGelato;?>/admin/css/style-codice.css";
  92. </style>
  93. </head>
  94. <body>
  95. <div id="div-process" style="display:none;">Processing request...</div>
  96. <div id="titulo">
  97. <img src="<?=$conf->urlGelato;?>/images/logo.jpg" alt="gelato CMS" title="gelato CMS" />
  98. </div>
  99. <div id="menuContenedor">
  100. <ul>
  101. <li id="active"><a href="#" id="current">Users</a></li>
  102. <ul>
  103. <li id="subactive"><a href="#" id="subcurrent"><? echo ($isEdition) ? "Edit" : "Add"; ?></a></li>
  104. <li><a href="admin.php">Manage</a></li>
  105. </ul>
  106. </li>
  107. <li><a href="index.php">Control Panel</a></li>
  108. </ul>
  109. </div>
  110. <div id="contenido">
  111. <div class="center">
  112. <div class="ventana">
  113. <p class="titulo"><span class="handle"><? echo ($isEdition) ? "Edit" : "Add"; ?> the user information</span></p>
  114. <div id="formulario">
  115. <form action="user.php" method="post" onSubmit="return validateFrmAddUser();" name="frm_add">
  116. <fieldset>
  117. <?
  118. if ($isEdition) {
  119. ?>
  120. <input type="hidden" name="id_user" id="id_user" value="<?=$userId;?>" />
  121. <?
  122. }
  123. ?>
  124. <p>
  125. <label for="login">user:</label>
  126. <input class="input-text" name="login" id="login" type="text" autocomplete="off" value="<?=isset($register["login"])?$register["login"]:"";?>" />
  127. <?
  128. if (!$isEdition) {
  129. ?>
  130. <script language="javascript" type="text/javascript">
  131. document.write("<br /><input class='submit_normal_azul' name='btnVerifyUser' id='btnVerifyUser' type='button' value='Check availability' onclick='verifyExistingUser()' />");
  132. </script>
  133. <?
  134. }
  135. ?>
  136. </p>
  137. <p>
  138. <div id="target" style="display:none;"></div>
  139. </p>
  140. <p>
  141. <label for="pass">password:</label>
  142. <input class="input-text" name="password" id="password" type="password" />
  143. </p>
  144. <p>
  145. <label for="repass">retype password:</label>
  146. <input class="input-text" name="repass" id="repass" type="password" />
  147. </p>
  148. <p>
  149. <label for="name">name:</label>
  150. <input class="input-text" name="name" id="name" type="text" value="<?=isset($register["name"])?$register["name"]:"";?>" />
  151. </p>
  152. <p>
  153. <label for="email">e-mail:</label>
  154. <input class="input-text" name="email" id="email" type="text" value="<?=isset($register["email"])?$register["email"]:"";?>" />
  155. </p>
  156. <p>
  157. <label for="website">website:</label>
  158. <input class="input-text" name="website" id="website" type="text" value="<?=isset($register["website"])?$register["website"]:"";?>" />
  159. </p>
  160. <p>
  161. <label for="about">about:</label><br />
  162. <textarea rows="5" cols="50" name="about" id="about" tabindex="7"><?=isset($register["about"])?$register["about"]:"";?></textarea>
  163. <script type="text/javascript">
  164. //<!--
  165. edCanvas = document.getElementById('about');
  166. // This code is meant to allow tabbing from website to about (TinyMCE).
  167. if ( tinyMCE.isMSIE )
  168. document.getElementById('website').onkeydown = function (e)
  169. {
  170. e = e ? e : window.event;
  171. if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
  172. var i = tinyMCE.selectedInstance;
  173. if(typeof i == 'undefined')
  174. return true;
  175. tinyMCE.execCommand("mceStartTyping");
  176. this.blur();
  177. i.contentWindow.focus();
  178. e.returnValue = false;
  179. return false;
  180. }
  181. }
  182. else
  183. document.getElementById('website').onkeypress = function (e)
  184. {
  185. e = e ? e : window.event;
  186. if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
  187. var i = tinyMCE.selectedInstance;
  188. if(typeof i == 'undefined')
  189. return true;
  190. tinyMCE.execCommand("mceStartTyping");
  191. this.blur();
  192. i.contentWindow.focus();
  193. e.returnValue = false;
  194. return false;
  195. }
  196. }
  197. //-->
  198. </script>
  199. </p>
  200. <p>
  201. <input class="submit" name="btnAdd" type="submit" value="<? echo ($isEdition) ? "Modify" : "Add"; ?> user" />
  202. </p>
  203. </fieldset>
  204. </form>
  205. </div>
  206. </div>
  207. </div>
  208. <div id="pie">
  209. <p>
  210. <a href="http://www.gelatocms.com/" title="gelato CMS" target="_blank">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
  211. </p>
  212. </div>
  213. </div>
  214. </body>
  215. </html>
  216. <?
  217. }
  218. } else {
  219. header("Location: ".$conf->urlGelato."/login.php");
  220. }
  221. ?>