Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> preg_replace - co robię źle?
Najki
post 16.08.2005, 10:41:26
Post #1





Grupa: Zarejestrowani
Postów: 190
Pomógł: 0
Dołączył: 12.02.2004
Skąd: Poznań

Ostrzeżenie: (0%)
-----


Napotkałem problem.

Oto jak wygląda fragment kodu template'a (fikcyjne linki):
Kod
[start_if_admin]
    <td><a href="[przyklej_link]">[przyklej]</a></td>
    <td><a href="news.php?edytuj=[news_id]">[edytuj]</a></td>
    <td><a href="news.php?usun=[news_id]">[usun]</a></td>
    <td><a href="news.php?komentarze=[news_id]">komentarze: [news_komentarze_ile]</a></td>
    [end_if_admin]
    [start_if_not_admin]
    <td colspan="4"><a href="news.php?komentarze=[news_id]">komentarze: [news_komentarze_ile]</a></td>
    [end_if_not_admin]

Jeśli user zalogowany jest jako admin, system template powinien wyświetlić tylko to z pomiędzy [start_if_admin], a [end_if_admin]. Powinien pominąć zawartość [start_if_not_admin] [end_if_not_admin]. Niestety tak się nie dzieje. Wyświetlane są oba kody. Oto php:
  1. <?
  2. if ( $user_level =='admin' ) {
  3. $go = preg_replace('%[start_if_admin](.*)[end_if_admin]%', '1', $go);
  4. $go = preg_replace('%[start_if_not_admin](.*)[end_if_not_admin]%', '', $go);
  5. } else {
  6. $go = preg_replace('%[start_if_not_admin](.*)[end_if_not_admin]%', '1', $go);
  7. $go = preg_replace('%[start_if_admin](.*)[end_if_admin]%', '', $go);
  8. }
  9. ?>

Co z tym zrobić?

Ten post edytował Najki 16.08.2005, 10:43:26


--------------------
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 04:45