A tumblelog CMS built on AJAX, PHP and MySQL.

user.php 5.6KB

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