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
<?php include('./system/system.php'); include('./system/layout.php'); include('./theme/new/window/render.php'); connection(); $result = draw_site('./theme/new/styl/normal/tpl1.tpl', $site_self); disconnect(); ?>
PLIK system.php
<?php function connection() { mysql_connect(trim($sql_pass[0]), trim($sql_pass[1]), trim($sql_pass[2])) or die('Brak połączenia z serwerem MySQL.'); } function disconnect() { } function add_modules($module) { include('./system/modules/'.$module); } return($zawartosc); } function draw_site($tpl = './theme/new/styl/normal/tpl1.tpl', $self) { $layoutObiect = new layout($tpl); foreach($tab as $key => $val) $layoutObiect -> addVar($key, $val); while($re = mysql_fetch_assoc($sql1)) $layoutObiect -> addVar($re['module_place'], render_window($re['header'], add_modules($re['module_name']))); $output .= $layoutObiect -> showCode(); return $output; } ?>
I dotad wszystko dziala schodki zaczynaja sie gdy chce uzyc modul m_login.php:
<?php mysql_select_db('*****') or die('Błąd wyboru bazy danych.'); if(!isset($_COOKIE['username']) && !isset($_COOKIE['userlvl'])) { $form = '<div class="log_w"> <form action="" method="post"> <table align="center"> <tr><td align="center"><input type="text" name="login" value="Login"></td></tr> <tr><td align="center"><input type="password" name="haslo"></td></tr> <tr><td align="center"><input type="submit" name="log_in" value="Login"></td></tr> <tr><td align="center"><a href="#">Zapomnialem haslo</a></td></tr> <tr><td align="center"><a href="#">Zarejestroj sie</a></td></tr> </table> </form>'; } else if(!empty($_POST['login']) && !empty($_POST['haslo']) && isset($_POST['log_in'])) { if(preg_match("/^[0-9A-Za-z_-]{1,15}$/", $_POST['login']) && preg_match("/^[0-9A-Za-z_-]{1,15}$/", $_POST['haslo'])) { $login = $_POST['login']; $haslo = $_POST['haslo']; $sql_select_user = ('select * from user_n where login = "'.mysql_real_escape_string($_POST['login']).'" limit 1'); $sql_result = mysql_query($sql_select_user, $db); $tab = mysql_fetch_assoc($sql_result); if($tab['login'] == $login && $tab['haslo'] == md5($haslo)) { setcookie("username", $login, time() + 3600); setcookie("userlvl", $tab['lvl'], time() + 3600); header("Location: index.php"); } else $form .= '<center>Podano zle haslo</center></div>'; } else $form .= '<center>Podano zle znaki</center></div>'; } else if(isset($_COOKIE['username']) && isset($_COOKIE['userlvl'])) { $form = '<div class="log_w"> <table align="center"> <tr><td align="center">Jestes zalogowany jako: '.htmlspecialchars($_COOKIE['username']).'</td></tr> <tr><td align="center"><a href="admin.php">Administracja</a></td></tr> </table> </div>'; } else $form .= '</div>; $zawartosc = $form; ?>
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