WItam pisze sobie cms'a z modulami i na starcie mam juz problem.

Mam taka strukture katalogow:
/cms/ -> index.php
-/cms/system/ -> config.ini, layout.php, system.php
--/cms/system/modules/ -> func_m_login.php, m_login.inf, m_login.php, m_navigation.php
-/cms/theme/new/styl/normal/ -> style1.css, tpl1.tpl
-/cms/theme/new/window/ -> render.php
--/cms/theme/new/window/1/ [grafika]
--/cms/theme/new/window/2/ [grafika]
--/cms/theme/new/default_gfx/ [grafika]

PLIK Index.php

  1. <?php
  2. include('./system/system.php');
  3. include('./system/layout.php');
  4. include('./theme/new/window/render.php');
  5.  
  6. connection();
  7.  
  8. $site_self = explode('/', $_SERVER['PHP_SELF']);
  9. $site_self = $site_self[count($site_self)-1];
  10.  
  11. $result = draw_site('./theme/new/styl/normal/tpl1.tpl', $site_self);
  12.  
  13. echo($result);
  14. disconnect();
  15. ?>


PLIK system.php
  1. <?php
  2. $sql_pass = file("./system/config.ini");
  3.  
  4. function connection() {
  5.  
  6. global $sql_pass;
  7.  
  8. mysql_connect(trim($sql_pass[0]), trim($sql_pass[1]), trim($sql_pass[2])) or die('Brak połączenia z serwerem MySQL.');
  9. mysql_select_db(trim($sql_pass[3])) or die('Błąd wyboru bazy danych.');
  10. }
  11.  
  12.  
  13. function disconnect() {
  14.  
  15. }
  16.  
  17.  
  18.  
  19. function add_modules($module) {
  20.    
  21. IF(file_exists('./system/modules/'.$module)) {    
  22.    
  23.    include('./system/modules/'.$module);
  24.   }
  25. return($zawartosc);
  26. }
  27.  
  28.  
  29. function draw_site($tpl = './theme/new/styl/normal/tpl1.tpl', $self) {
  30.  
  31. $layoutObiect = new layout($tpl);
  32.  
  33. $sql = mysql_query('select * from settings where dzial = "'.$self.'"');
  34. $sql1 = mysql_query('select * from modules where module_dzial = "'.$self.'"');
  35.  
  36. $tab = mysql_fetch_assoc($sql);
  37.  
  38. foreach($tab as $key => $val) $layoutObiect -> addVar($key, $val);
  39.  
  40. while($re = mysql_fetch_assoc($sql1)) $layoutObiect -> addVar($re['module_place'], render_window($re['header'], add_modules($re['module_name'])));
  41.  
  42. $output .= $layoutObiect -> showCode();
  43.  
  44. return $output;
  45. }
  46.  
  47. ?>


I dotad wszystko dziala schodki zaczynaja sie gdy chce uzyc modul m_login.php:
  1. <?php
  2.  
  3. $db = mysql_conne*****', 'marcios', '*****') or die('Brak połączenia z serwerem MySQL.');
  4. mysql_select_db('*****') or die('Błąd wyboru bazy danych.');
  5.  
  6. if(!isset($_COOKIE['username']) && !isset($_COOKIE['userlvl'])) {
  7.  
  8.  
  9. $form = '<div class="log_w">
  10. <form action="" method="post">
  11. <table align="center">
  12. <tr><td align="center"><input type="text" name="login" value="Login"></td></tr>
  13. <tr><td align="center"><input type="password" name="haslo"></td></tr>
  14. <tr><td align="center"><input type="submit" name="log_in" value="Login"></td></tr>
  15. <tr><td align="center"><a href="#">Zapomnialem haslo</a></td></tr>
  16. <tr><td align="center"><a href="#">Zarejestroj sie</a></td></tr>
  17. </table>
  18. </form>';
  19. }
  20.  
  21.  
  22. else if(!empty($_POST['login']) && !empty($_POST['haslo']) && isset($_POST['log_in'])) {
  23.  
  24. if(preg_match("/^[0-9A-Za-z_-]{1,15}$/", $_POST['login']) && preg_match("/^[0-9A-Za-z_-]{1,15}$/", $_POST['haslo'])) {
  25.  
  26. $login = $_POST['login'];
  27. $haslo = $_POST['haslo'];
  28.  
  29.  $sql_select_user = ('select * from user_n where login = "'.mysql_real_escape_string($_POST['login']).'" limit 1');
  30.  $sql_result = mysql_query($sql_select_user, $db);
  31.  $tab = mysql_fetch_assoc($sql_result);
  32.  
  33. if($tab['login'] == $login && $tab['haslo'] == md5($haslo)) {
  34.  
  35.  setcookie("username", $login, time() + 3600);
  36.  setcookie("userlvl", $tab['lvl'], time() + 3600);
  37.  
  38.  header("Location: index.php");
  39.     }
  40. else $form .= '<center>Podano zle haslo</center></div>';
  41.  }
  42. else $form .= '<center>Podano zle znaki</center></div>';
  43. }
  44.  
  45. else if(isset($_COOKIE['username']) && isset($_COOKIE['userlvl'])) {
  46.  
  47. $form = '<div class="log_w">
  48. <table align="center">
  49. <tr><td align="center">Jestes zalogowany jako: '.htmlspecialchars($_COOKIE['username']).'</td></tr>
  50. <tr><td align="center"><a href="admin.php">Administracja</a></td></tr>
  51. </table>
  52. </div>';
  53.  
  54. }
  55.  
  56. else $form .= '</div>;
  57.  
  58. $zawartosc = $form;
  59.  
  60.  
  61. ?>


Potem jest plik z funkcjami tego moduly ktory jak narazie nie jest potrzebny po probowalem to napisac na 3 sposoby i jest tez plik konfiguracyjny ktory posiada kazdy modul zeby potem byl widoczny poprzez PA

Problem polega na tym ze przy logowaniu sie nic nie dzieje jak napisalem to troche inaczej wpisujac byle jakie dane pokazywal sie info kto jest zalogowany i linki ale bez nazwy user'a tak jakby kod php sie w ogole nie wykonywal

Moje pytanie jest jak napisac taki modul jesli ktos z was mi pomoze mysle ze z nastepnymi modulami sobie poradze

P.S tabela SETTINGS przechowywuje wszystkie dane zeby wypelnic szablon a tabela modules ma informacje takie jak na jakiej stronie gdzie i jakie sa moduly.

P.S2 to jest strona http://marcio.szu.pl/cms/index.php