A tumblelog CMS built on AJAX, PHP and MySQL.

user.php 5.4KB

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