A tumblelog CMS built on AJAX, PHP and MySQL.

user.php 5.4KB

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