A tumblelog CMS built on AJAX, PHP and MySQL.

user.php 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /* ===========================
  3. gelato CMS - A PHP based tumblelog CMS
  4. development version
  5. http://www.gelatocms.com/
  6. gelato CMS is a free software licensed under GPL (General public license)
  7. =========================== */
  8. ?>
  9. <?php
  10. require_once('../config.php');
  11. include("../classes/functions.php");
  12. include("../classes/user.class.php");
  13. require_once("../classes/configuration.class.php");
  14. $user = new user();
  15. $conf = new configuration();
  16. $isEdition = isset($_GET["edit"]);
  17. $userId = ($isEdition) ? $_GET["edit"] : NULL;
  18. if ($user->isAdmin()) {
  19. if (isset($_GET["delete"])) {
  20. $user->deleteUser($_GET['delete']);
  21. header("Location: admin.php?delete=true");
  22. die();
  23. }
  24. if(isset($_POST["btnAdd"])) {
  25. unset($_POST["btnAdd"]);
  26. if (isset($_POST["repass"])) {
  27. unset($_POST["repass"]);
  28. }
  29. if (isset($_POST["btnVerifyUser"])) {
  30. unset($_POST["btnVerifyUser"]);
  31. }
  32. if (isset($_POST["password"])) {
  33. $_POST["password"] = md5($_POST["password"]);
  34. }
  35. if (isset($_POST["id_user"])) {
  36. $user->modifyUser($_POST, $_POST["id_user"]);
  37. } else {
  38. $user->addUser($_POST);
  39. }
  40. } else {
  41. if ($isEdition) {
  42. $register = $user->getUserByID($userId);
  43. }
  44. ?>
  45. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  46. <html xmlns="http://www.w3.org/1999/xhtml">
  47. <head>
  48. <title>gelato :: add user</title>
  49. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  50. <meta name="generator" content="gelato cms <?php echo version();?>" />
  51. <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
  52. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/mootools.js"></script>
  53. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/tools.js"></script>
  54. <style type="text/css" media="screen">
  55. @import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
  56. </style>
  57. </head>
  58. <body>
  59. <div id="div-process" style="display:none;">Processing request...</div>
  60. <div id="cont">
  61. <div id="head">
  62. <h1><a href="<?php echo $conf->urlGelato;?>/" title="gelato :: home">gelato cms</a></h1>
  63. <ul id="nav">
  64. <li><a href="<?php echo $conf->urlGelato;?>/" title="Take me to the tumblelog">Back to the Tumblelog</a></li>
  65. </ul>
  66. </div>
  67. <div id="main">
  68. <div class="box">
  69. <ul class="menu manage">
  70. <h3>Start session</h3>
  71. <li><a href="index.php">Post</a></li>
  72. <li><a href="admin.php">Users</a></li>
  73. <li class="selected"><a><?php echo ($isEdition) ? "Edit" : "Add"; ?></a></li>
  74. </ul>
  75. <div class="tabla">
  76. <form action="user.php" method="post" onSubmit="return validateFrmAddUser();" name="frm_add" class="newpost">
  77. <fieldset>
  78. <ul>
  79. <?php
  80. if ($isEdition) {
  81. ?>
  82. <input type="hidden" name="id_user" id="id_user" value="<?php echo $userId;?>" />
  83. <?php
  84. }
  85. ?>
  86. <li>
  87. <label for="login">user:</label>
  88. <input class="txt" name="login" id="login" type="text" autocomplete="off" value="<?php echo isset($register["login"])?$register["login"]:"";?>" />
  89. <?php
  90. if (!$isEdition) {
  91. ?>
  92. <script language="javascript" type="text/javascript">
  93. document.write("<br /><input class='submit_normal_azul' name='btnVerifyUser' id='btnVerifyUser' type='button' value='Check availability' onclick='verifyExistingUser()' />");
  94. </script>
  95. <?php
  96. }
  97. ?>
  98. </li>
  99. <li>
  100. <div id="target" style="display:none;"></div>
  101. </li>
  102. <li>
  103. <label for="pass">password:</label>
  104. <input class="txt" name="password" id="password" type="password" />
  105. </li>
  106. <li>
  107. <label for="repass">retype password:</label>
  108. <input class="txt" name="repass" id="repass" type="password" />
  109. </li>
  110. <li>
  111. <label for="name">name:</label>
  112. <input class="txt" name="name" id="name" type="text" value="<?php echo isset($register["name"])?$register["name"]:"";?>" />
  113. </li>
  114. <li>
  115. <label for="email">e-mail:</label>
  116. <input class="txt" name="email" id="email" type="text" value="<?php echo isset($register["email"])?$register["email"]:"";?>" />
  117. </li>
  118. <li>
  119. <label for="website">website:</label>
  120. <input class="txt" name="website" id="website" type="text" value="<?php echo isset($register["website"])?$register["website"]:"";?>" />
  121. </li>
  122. <li>
  123. <label for="about">about:</label><br />
  124. <textarea rows="5" cols="50" name="about" id="about" tabindex="7"><?php echo isset($register["about"])?$register["about"]:"";?></textarea>
  125. </li>
  126. <li>
  127. <input name="btnAdd" type="submit" value="<?php echo ($isEdition) ? "Modify" : "Add"; ?> user" />
  128. </li>
  129. </ul>
  130. </fieldset>
  131. </form>
  132. </div>
  133. <div class="footer-box">&nbsp;</div>
  134. </div>
  135. </div>
  136. <div id="foot">
  137. <a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
  138. </div>
  139. </div>
  140. </body>
  141. </html>
  142. <?php
  143. }
  144. } else {
  145. header("Location: ".$conf->urlGelato."/login.php");
  146. }
  147. ?>