A tumblelog CMS built on AJAX, PHP and MySQL.

login.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. header("Cache-Control: no-cache, must-revalidate");
  13. require_once('entry.php');
  14. global $user, $conf;
  15. if ($user->isAuthenticated()) {
  16. header("Location: ".$conf->urlGelato."/admin/index.php");
  17. } else {
  18. if (isset($_POST["pass"]) && isset($_POST["login"])) {
  19. if ($user->validateUser($_POST['login'], md5($_POST['pass']))) {
  20. if(isset($_POST["url_redirect"])){
  21. header("Location: ".$conf->urlGelato."/admin/bm.php?url=".$_POST["url_redirect"]."&sel=".$_POST["sel"]);
  22. exit();
  23. } else {
  24. header("Location: ".$conf->urlGelato."/admin/index.php");
  25. exit();
  26. }
  27. } else {
  28. header("Location: ".$conf->urlGelato."/login.php?error=1");
  29. exit();
  30. }
  31. } else {
  32. ?>
  33. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  34. <html xmlns="http://www.w3.org/1999/xhtml">
  35. <head>
  36. <title>gelato :: <?php echo __("login screen")?></title>
  37. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  38. <meta name="generator" content="gelato cms <?php echo util::version();?>" />
  39. <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
  40. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/jquery.js"></script>
  41. <script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/jquery.validate.min.js"></script>
  42. <script type="text/javascript">
  43. $(document).ready(function(){
  44. $("#valida").validate({
  45. rules: {
  46. login: "required",
  47. pass: "required"
  48. },
  49. errorElement: "span",
  50. errorClass: "validate_span",
  51. errorPlacement: function(label, element) {
  52. label.prependTo(element.prev())
  53. }
  54. });
  55. });
  56. </script>
  57. <style type="text/css" media="screen">
  58. @import "<?php echo $conf->urlGelato;?>/admin/css/style.css";
  59. </style>
  60. </head>
  61. <body>
  62. <div id="div-process" style="display:none;"><?php echo __("Processing request&hellip;")?></div>
  63. <div id="cont">
  64. <div id="head">
  65. <h1><a href="<?php echo $conf->urlGelato;?>/" title="gelato :: <?php echo __("home")?>">gelato cms</a></h1>
  66. <ul id="nav">
  67. <li><a href="<?php echo $conf->urlGelato;?>/" title="<?php echo __("Take me to the tumblelog")?>"><?php echo __("Back to the Tumblelog")?></a></li>
  68. </ul>
  69. </div>
  70. <div id="main">
  71. <div class="box">
  72. <ul class="menu manage">
  73. <h3><?php echo __("Start session")?></h3>
  74. <li class="selected"><a><?php echo __("Login")?></a></li>
  75. </ul>
  76. <div class="tabla">
  77. <form action="login.php" method="post" id="valida" autocomplete="off" class="newpost">
  78. <?php echo (isset($_GET['redirect_url']))? "<input type=\"hidden\" name=\"url_redirect\" value=\"".$_GET['redirect_url']."\" /><input type=\"hidden\" name=\"sel\" value=\"".$_GET['sel']."\" />" : ""; ?>
  79. <fieldset>
  80. <ul>
  81. <li><label for="login"><?php echo __("User:")?></label>
  82. <input id="login" name="login" type="text" class="txt" /></li>
  83. <li><label for="pass"><?php echo __("Password:")?></label>
  84. <input id="pass" name="pass" type="password" class="txt" /></li>
  85. <li><label for="save_pass"><?php echo __("Remember me:")?></label>
  86. <input id="save_pass" name="save_pass" type="checkbox" /></li>
  87. <li><input name="btnLogin" type="submit" value="Login" /></li>
  88. </ul>
  89. </fieldset>
  90. </form>
  91. <?php
  92. if (isset($_GET["error"])) {
  93. if ($_GET["error"]==1) {
  94. ?>
  95. <div class="error">
  96. <?php echo __("&nbsp;You must be registered to use gelato.")?>
  97. </div>
  98. <?php
  99. }
  100. elseif ($_GET["error"]==2) {
  101. ?>
  102. <div class="error">
  103. <?php echo __("&nbsp;You must be logged on the system.")?>
  104. </div>
  105. <?php
  106. }
  107. }
  108. ?>
  109. </div>
  110. <div class="footer-box">&nbsp;</div>
  111. </div>
  112. </div>
  113. <div id="foot">
  114. <a href="http://www.gelatocms.com/" title="gelato CMS">gelato CMS</a> :: PHP/MySQL Tumblelog Content Management System.
  115. </div>
  116. </div>
  117. </body>
  118. </html>
  119. <?php
  120. }
  121. }
  122. ?>