phpDocumentor koliportal
[ class tree: koliportal ] [ index: koliportal ] [ all elements ]

Source for file inc-index.php

Documentation is available at inc-index.php

  1. <?php
  2. /** Főoldal
  3. *
  4. * Ezek a kódsorok kezelik a bejelentkezési kísérleteket, menük
  5. * megjelenítését, valamint ez a php huzza be a többi menüpontnak
  6. * megfelelő további php fájlokat.
  7. *
  8. * @package koliportal
  9. * @author Karakó Miklós <palacsint_X_freemail.hu>
  10. * @copyright Copyright &copy; 2005, Karakó Miklós
  11. */
  12. /** init szkriptek behúzása */
  13. (dirname(__FILE__) . "/../init.inc.php");
  14.  
  15. // ini_set('register_globals', false) or die("ini_set");
  16. ?>
  17. <?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
  18.  
  19. <!DOCTYPE html
  20. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  21. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  22. <?php
  23. //var_dump($_SESSION);
  24. $title_extra = '';
  25. $username = '';
  26. $password = '';
  27. $login_try = false;
  28. $errc = 0;
  29. $errs = $msgs = array();
  30. $page = '';
  31. if ((false === check_login()) && (count($_POST) > 0))
  32. {
  33. $login_try = true;
  34. if ("yes" !== variable_get("login_allowed"))
  35. {
  36. $errc++;
  37. /* felesleges a hibaüzenet, mert a loginform.php
  38. is kiírja, ha az login_allowed != yes */
  39. //$errs[] = "Jelenleg nem lehet bejelentkezni!";
  40. }
  41. if (0 === $errc)
  42. {
  43. if (isset($_POST["username"]))
  44. {
  45. $username = addslashes($_POST["username"]);
  46. } else {
  47. $errc++;
  48. $errs[] = "Nincs felhasználónév megadva!";
  49. }
  50. debug_echo("username = $username");
  51. }
  52. if ((0 == $errc) && (strlen($username) < 3)) {
  53. $errc++;
  54. $errs[] = "Hibás felhasználónév!";
  55. }
  56.  
  57. if (isset($_POST["password"]))
  58. {
  59. $password = addslashes($_POST["password"]);
  60. } else {
  61. $errc++;
  62. $errs[] = "Nincs megadva a jelszó!";
  63. }
  64. if ($errc == 0)
  65. {
  66. $sql_q = "SELECT * FROM users WHERE username = '$username'
  67. AND password = MD5(CONCAT('$password', username))";
  68. debug_echo($sql_q, DEBUG_SQL);
  69. $sql_res = mysql_query($sql_q, $database);
  70. if ($sql_res === false)
  71. {
  72. mylog($sql_q);
  73. myerr("Adatbázis hiba!");
  74. }
  75. if (mysql_num_rows($sql_res) !== 1)
  76. {
  77. $errc++;
  78. $errs[] = "Hibás a megadott felhasználónév vagy jelszó!";
  79. $username = $password = '';
  80. }
  81. if (0 === $errc)
  82. {
  83. $arr = mysql_fetch_assoc($sql_res)
  84. or myerr("Adatbázis hiba!");
  85. }
  86. if ((0 === $errc) && ('Y' == $arr["disabled"]))
  87. {
  88. $errc++;
  89. $errs[] = "Ki vagy tiltva!";
  90. }
  91. if (0 === $errc) {
  92. $_SESSION["login"] = true;
  93. $_SESSION["username"] = $arr["username"];
  94. $_SESSION["sid"] = $arr["sid"];
  95. $_SESSION["bid"] = $arr["bid"];
  96. }
  97. }
  98. }
  99.  
  100. if (isset($_GET["page"]))
  101. {
  102. $page = $_GET["page"];
  103. }
  104.  
  105. if ("logout" === $page)
  106. {
  107. unset($_SESSION);
  108. $_SESSION["login"] = false;
  109. $page = "loginform";
  110. session_destroy();
  111. }
  112. //var_dump($_SESSION);
  113. ?>
  114.  
  115. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="hu" lang="hu">
  116. <head>
  117. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  118. <title>Kollégiumi információs rendszer<?= $title_extra ?></title>
  119. <style type="text/css" media="screen">@import url("<?= $css_link ?>");</style>
  120. </head>
  121. <body>
  122. <h1>Interaktív kollégiumi információs rendszer</h1>
  123.  
  124. <p id="menu">
  125. | <a href="<?= $_SERVER["PHP_SELF"] ?>">index</a> |
  126. <?php
  127. if (check_login() && ("yes" == variable_get("edit_wishes_allowed")))
  128. {
  129. ?>
  130. <a href="<?= $_SERVER["PHP_SELF"] ?>?page=wishlist">kívánságlista</a> |
  131. <?php
  132. }
  133. if (is_trusted_host() || check_login())
  134. {
  135. ?>
  136. <a href="<?= $_SERVER["PHP_SELF"] ?>?page=forum">fórum</a> |
  137. <?php
  138. }
  139.  
  140. if (check_login())
  141. {
  142. ?>
  143. <a href="<?= $_SERVER["PHP_SELF"] ?>?page=roominfo">szobainfo</a> |
  144. <a href="<?= $_SERVER["PHP_SELF"] ?>?page=chdata">jelszócsere</a> |
  145. <a href="<?= $_SERVER["PHP_SELF"] ?>?page=logout">kilépés</a> |
  146. <?php
  147. }
  148. ?>
  149. </p>
  150.  
  151. <?php
  152. if ($_SESSION["login"] === true)
  153. {
  154. ?>
  155. <p id="loginok"><?= $_SESSION["username"] ?></p>
  156. <?php
  157. }
  158. ?>
  159. <?php
  160. /** Alapértelmezett oldal
  161. *
  162. * Ez az oldal lesz az alapértelmezett, ha nem kapott a szkript semmilyen
  163. * paramétert.
  164. */
  165. define("DEFAULT_PAGE", "loginform");
  166.  
  167. $inc["loginform"] = "/loginform.php";
  168. /* bejelentkezés után elérhető oldalak */
  169. $inc["wishlist"] = "/edit.list.frame.php";
  170. $inc["roominfo"] = "/page.roominfo.php";
  171. $inc["chdata"] = "/page.chdata.php";
  172. /* bejelentkezés nélkül elérhető oldalak */
  173. $inc_anon["forum"] = "/../forum/forum.php";
  174.  
  175. /* ha nem megbízható hostról jön a kliens, akkor megszüntetjük az $inc_anon
  176. változót */
  177. if (!is_trusted_host() && !check_login())
  178. {
  179. unset($inc_anon);
  180. $inc_anon = array();
  181. } else {
  182. debug_echo("trusted host.");
  183. }
  184. /* ha most érkezett az oldalra... */
  185. if (!isset($page))
  186. {
  187. $page = DEFAULT_PAGE;
  188. }
  189.  
  190. /* ha nincs bejelentkezve és olyan oldalt akar megnézni, amit csak
  191. bejelentkezés után lehetne, akkor elküldjük bejelentkezni */
  192. if ((!check_login()) && !isset($inc_anon[$page]))
  193. {
  194. $page = DEFAULT_PAGE;
  195. }
  196. /* ha be van jelentkezve és nem létező oldalt akar elérni, akkor
  197. is elküldjük bejelentkezni
  198. FIXME: lehet 404 oldal is
  199. */
  200. if (check_login() && (!isset($inc[$page]) && !isset($inc_anon[$page])))
  201. {
  202. $page = DEFAULT_PAGE;
  203. }
  204.  
  205. if (isset($inc[$page]))
  206. {
  207. /** A megfelelő belső oldal beszúrása */
  208. (dirname(__FILE__) . $inc[$page]);
  209. }
  210. elseif (isset($inc_anon[$page]))
  211. {
  212. /** A megfelelő bejelentkezés nélkül is elérhető oldal beszúrása */
  213. (dirname(__FILE__) . $inc_anon[$page]);
  214. }
  215.  
  216.  
  217. ?>
  218. </body>
  219. </html>

Documentation generated on Wed, 18 May 2005 19:24:23 +0200 by phpDocumentor 1.3.0RC3