Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP][MySQL]problem z uruchomieniem smartów
Forum PHP.pl > Forum > Przedszkole
doti
Witam,
Jestem na forum pierwszy raz i nie wiem gdzie pisać na temat smartów, wiec wybrałam ten dział.
Jeśli temat nie nadaje sie do tego działu prosze o przeniesienie.


Zainstalowałam wampserwer-a i strone zrobioną na smartach (która działała na innym serwerze bez zarzutu)

Po wyświetleniu strony o takim adresie: http://localhost/test/index.html
pojawia sie komunikat błędu:

rodzaj : 512
tresc : Smarty error: unable to read resource: ""
plik : E:\wamp\www\test\libs\Smarty.class.php
wiersz : 1088
data : 2011-06-22, 21:36

Nie wiem gdzie jest błąd, czy w konfiguracji wampa, czy w plikach smarty jest coś nie tak.

bardzo proszę o pomoc

pozdrawiam wszystkich

CuteOne
Oj tak na pewno w plikach SMARTY coś jest nie tak... lepiej wklej tu zawartość pliku index.html i includowanych
doti
zawartość pliku index.php:
CODE
<?php
ini_set ('register_globals', 0);

// ustawienie aby id sesji przechowywane bylo zawsze w ciasteczku
ini_set('session.use_only_cookies', 1);

// czas zycia ciasteczka sesyjnego w sekundach
ini_set('session.cookie_lifetime', 1800);

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// nazwa sesji
session_name('eTankuj');

// inicjalizacja sesji
session_start();

// generowanie nowego identyfikatora z kazdym wywolaniem skryptu
session_regenerate_id();

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
include_once 'configs/config.inc.php';
include_once 'include/smarty_setup.inc.php';
include_once 'include/error_handler.inc.php';
include_once 'include/navigation.inc.php';


$smarty = new Page();

include_once 'configs/languages.php';
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

include_once 'class/class.db_controller.php';

$sql = new DbController();
$sql->connect(DB_HOST, DB_USER_LOGIN, DB_USER_PASS, DB_NAME);

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

if(isset($_REQUEST['run']))
{
Navigation::Run($smarty, $_REQUEST);
}
else
{
Navigation::Redirect(array('run'=>'Index.Main'));
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

$smarty->display('page_body.tpl');

//echo '<pre>';
//print_r($_SESSION);
//echo '</pre>';
?>
mit2
pokaz zawartosc tego pliku

E:\wamp\www\test\libs\Smarty.class.php
nospor
@mit2 chyba nie tędy droga

@doti smarty w Twoim przypadku próbuje odczytać zasób, o nazwie "" czyli o braku jakiejkolwiek nazwy.
Wina nie leży więc po stronie Smartiego a aplikacji, że przekazuje zasób o pustej nazwie.

Może to być np. winą register_globals lub kupą masą innych rzeczy.

Włącz najlepiej wyświetlanie wszystkich błędów, a sprawa może się wyjaśni.
Tu masz napisane jak to zrobić.
Temat: Jak poprawnie zada pytanie

Jeśli ta aplikacja jest stara , to może się okazać, że chodzi właśnie o register_globals. Włącz więć wpierw tę opcję (w pliku php.ini), zrestartuj serwer i spróbuj jeszcze raz odpalić aplikację.
doti
po włączeniu wszystkich błędów oprócz powyższego błędu pojawił sie kolejny komunikat:

Notice: Undefined index: id in E:\wamp\www\test\include\navigation.inc.php on line 140

Jeśli chodzi o "register_globals" to mam włączone w wampie w ustawieniach php.
nospor
Tylko jeden dodatkowy błąd?

Nie wiele to mówi w takim razie.
Owszem, może być tak, że zasób jest określany na podstawie ID, którego właśnie nie ma.
doti
tylko problem jest taki ze ta strona dziala na innym serwerze a na moim nie chce ruszyc...
więc wydaje mi się ze to jednak ustawienia wampa odpowiadają za te błędy.
Tylko nie mam pojęcia które to ustawienia.
nospor
Cytat
więc wydaje mi się ze to jednak ustawienia wampa odpowiadają za te błędy.
Tak, i dlatego myślałem, w pierwszej chwili, że chodzi właśnie o register_globals.

Do rozwiązania zagadki może się okazać, że jest potrzebny ten kawałek kodu, w którym smarty próbuje załadować pusty zasób.
W tym celu wejdź do pliku Smart.class.php w okolicę linii 1088. Powinieneś tam mieć funkcje coś ala:
function trigger_error()

W ciele tej funkcje daj kod:
debug_print_backtrace();
i będziemy wówczas znali całą ścieżkę błędu.
doti
po dokonianiu zmian w funkcji trigger_error wyświetliło dosyć spory kawałek błędów, oto one:

#0 Smarty->trigger_error(unable to read resource: "") called at [E:\wamp\www\test\libs\Smarty.class.php:1585] #1 Smarty->_fetch_resource_info(Array ([resource_name] => ,[get_source] => 1,[quiet] => )) called at [E:\wamp\www\test\libs\Smarty.class.php:1411] #2 Smarty->_compile_resource(, E:\wamp\www\test/tpl/_compile/\.php) called at [E:\wamp\www\test\libs\Smarty.class.php:1860] #3 Smarty->_smarty_include(Array ([smarty_include_tpl_file] => ,[smarty_include_vars] => Array ())) called at [E:\wamp\www\test\tpl\_compile\%%15_150_1504C075%%page_body.tpl.php:50] #4 include(E:\wamp\www\test\tpl\_compile\%%15_150_1504C075%%page_body.tpl.php) called at [E:\wamp\www\test\libs\Smarty.class.php:1259] #5 Smarty->fetch(page_body.tpl, , , 1) called at [E:\wamp\www\test\libs\Smarty.class.php:1102] #6 Smarty->display(page_body.tpl) called at [E:\wamp\www\test\index.php:53]
nospor
Pokaż plik page_body.tpl

oraz plik skompilowany czyli:
E:\wamp\www\test\tpl\_compile\%%15_150_1504C075%%page_body.tpl.php

Cytat
wyświetliło dosyć spory kawałek błędów
To nie błędy a informacje debugujące o które prosiłem smile.gif
doti
plik page_body.tpl:

CODE
{config_load file="site.conf"}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={#pageCharset#}" />
<title>Mewa Druk Drukarnia</title>

<link href="css/global.css" rel="stylesheet" type="text/css"/>
<link href="css/lightbox.css" rel="stylesheet" type="text/css"/>
<link href="css/{$cur_obj}.css" rel="stylesheet" type="text/css"/>

{if $cur_lang == 0}
<link href="css/pl.css" rel="stylesheet" type="text/css"/>
{elseif $cur_lang == 1}
<link href="css/en.css" rel="stylesheet" type="text/css"/>
{elseif $cur_lang == 2}
<link href="css/de.css" rel="stylesheet" type="text/css"/>
{/if}

<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/window.js" type="text/javascript"></script>
<script src="js/scriptaculous.js?load=effects" type="text/javascript"></script>
<script src="js/lightbox.js" type="text/javascript"></script>
<script src="js/global.js" type="text/javascript"></script>
<script src="js/index.js" type="text/javascript"></script>
<script src="js/minmax.js" type="text/javascript"></script>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="js/AC_RunActiveContent.js" language="javascript"></script>

</head>
<body>
<div id="PageTop">{include file="page_top.tpl"}</div>
<div id="PageMenu">{include file="page_menu.tpl"}</div>
<div id="PageBody">{include file=$basepage}</div>
<div id="PageBottom">{include file="page_bottom.tpl"}</div>
<div id="PageFooter">{include file="page_footer.tpl"}</div>
</body>
</html>


plik skompilowany:

  1. <?php /* Smarty version 2.6.9, created on 2011-06-22 21:54:41
  2.   compiled from page_body.tpl */ ?>
  3. <?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
  4. smarty_core_load_plugins(array('plugins' => array(array('function', 'config_load', 'page_body.tpl', 1, false),)), $this); ?>
  5. <?php echo smarty_function_config_load(array('file' => "site.conf"), $this);?>
  6.  
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  8. <html xmlns="http://www.w3.org/1999/xhtml">
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $this->_config[0]['vars']['pageCharset']; ?>
  11. " />
  12. <title>Mewa Druk Drukarnia</title>
  13.  
  14. <link href="css/global.css" rel="stylesheet" type="text/css"/>
  15. <link href="css/lightbox.css" rel="stylesheet" type="text/css"/>
  16. <link href="css/<?php echo $this->_tpl_vars['cur_obj']; ?>
  17. .css" rel="stylesheet" type="text/css"/>
  18.  
  19. <?php if ($this->_tpl_vars['cur_lang'] == 0): ?>
  20. <link href="css/pl.css" rel="stylesheet" type="text/css"/>
  21. <?php elseif ($this->_tpl_vars['cur_lang'] == 1): ?>
  22. <link href="css/en.css" rel="stylesheet" type="text/css"/>
  23. <?php elseif ($this->_tpl_vars['cur_lang'] == 2): ?>
  24. <link href="css/de.css" rel="stylesheet" type="text/css"/>
  25. <?php endif; ?>
  26.  
  27. <script src="js/prototype.js" type="text/javascript"></script>
  28. <script src="js/window.js" type="text/javascript"></script>
  29. <script src="js/scriptaculous.js?load=effects" type="text/javascript"></script>
  30. <script src="js/lightbox.js" type="text/javascript"></script>
  31. <script src="js/global.js" type="text/javascript"></script>
  32. <script src="js/index.js" type="text/javascript"></script>
  33. <script src="js/minmax.js" type="text/javascript"></script>
  34. <script language="javascript">AC_FL_RunContent = 0;</script>
  35. <script src="js/AC_RunActiveContent.js" language="javascript"></script>
  36.  
  37. </head>
  38. <body>
  39. <div id="PageTop"><?php $_smarty_tpl_vars = $this->_tpl_vars;
  40. $this->_smarty_include(array('smarty_include_tpl_file' => "page_top.tpl", 'smarty_include_vars' => array()));
  41. $this->_tpl_vars = $_smarty_tpl_vars;
  42. unset($_smarty_tpl_vars);
  43. ?></div>
  44. <div id="PageMenu"><?php $_smarty_tpl_vars = $this->_tpl_vars;
  45. $this->_smarty_include(array('smarty_include_tpl_file' => "page_menu.tpl", 'smarty_include_vars' => array()));
  46. $this->_tpl_vars = $_smarty_tpl_vars;
  47. unset($_smarty_tpl_vars);
  48. ?></div>
  49. <div id="PageBody"><?php $_smarty_tpl_vars = $this->_tpl_vars;
  50. $this->_smarty_include(array('smarty_include_tpl_file' => $this->_tpl_vars['basepage'], 'smarty_include_vars' => array()));
  51. $this->_tpl_vars = $_smarty_tpl_vars;
  52. unset($_smarty_tpl_vars);
  53. ?></div>
  54. <div id="PageBottom"><?php $_smarty_tpl_vars = $this->_tpl_vars;
  55. $this->_smarty_include(array('smarty_include_tpl_file' => "page_bottom.tpl", 'smarty_include_vars' => array()));
  56. $this->_tpl_vars = $_smarty_tpl_vars;
  57. unset($_smarty_tpl_vars);
  58. ?></div>
  59. <div id="PageFooter"><?php $_smarty_tpl_vars = $this->_tpl_vars;
  60. $this->_smarty_include(array('smarty_include_tpl_file' => "page_footer.tpl", 'smarty_include_vars' => array()));
  61. $this->_tpl_vars = $_smarty_tpl_vars;
  62. unset($_smarty_tpl_vars);
  63. ?></div>
  64. </body>
  65. </html>
nospor
{include file=$basepage}
Zmienna $basepage nie jest określona.

Wyszukaj teraz w kodzie kodu, który przypisuje coś do basepage.
Najlepiej szukaj po frazie basepage

Kawałek jaki mnie interesuje będzie wyglądał prawdopodobnie tak:
->assign('basepage',

A słuchaj... powiedz mi jeszcze, czy oprócz tego, że wyswietla ci się ten blad:
rodzaj : 512
tresc : Smarty error: unable to read resource: ""
plik : E:\wamp\www\test\libs\Smarty.class.php
wiersz : 1088
data : 2011-06-22, 21:36

To strona działa normalnie? Czy może jednak wyświetla się ten błąd i strona już nie działa?

ps: prawdopodobnie ten basepage jest ustawiany w pliku navigation.inc.php więc pokaż mi ten plik
doti
strona wyświetla się jak poprzednio czyli:
u góry błąd:

Notice: Undefined index: id in E:\wamp\www\test\include\navigation.inc.php on line 140

nastepnie wyswietla mi sie baner i menu a w czesci gdzie jest tresc strony ten "długi" błąd:
#0 Smarty->trigger_error(unable to read resource: "") called at [E:\wamp\www\test\libs\Smarty.class.php:1585] #1 Smarty->_fetch_resource_info(Array ([resource_name] => ,[get_source] => 1,[quiet] => )) called at [E:\wamp\www\test\libs\Smarty.class.php:1411] #2 Smarty->_compile_resource(, E:\wamp\www\test/tpl/_compile/\.php) called at [E:\wamp\www\test\libs\Smarty.class.php:1860] #3 Smarty->_smarty_include(Array ([smarty_include_tpl_file] => ,[smarty_include_vars] => Array ())) called at [E:\wamp\www\test\tpl\_compile\%%15_150_1504C075%%page_body.tpl.php:50] #4 include(E:\wamp\www\test\tpl\_compile\%%15_150_1504C075%%page_body.tpl.php) called at [E:\wamp\www\test\libs\Smarty.class.php:1259] #5 Smarty->fetch(page_body.tpl, , , 1) called at [E:\wamp\www\test\libs\Smarty.class.php:1102] #6 Smarty->display(page_body.tpl) called at [E:\wamp\www\test\index.php:53]

i na dole stopka normalnie sie wyświetla.

czyli bląd jest gdzieś w ładowaniu treści strony która zresztą pochodzi z bazy danych
nospor
W poprzednim poście prosiłem CIę o parę rzeczy. Odpowiedziałeś tylko na jedną z nich.
doti
zawartośc pliku navigation.inc.php

  1. <?php
  2. class Navigation
  3. {
  4. var $params;
  5. var $smarty;
  6. //
  7. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  8. //
  9. function __construct ( &$smarty, $params )
  10. {
  11. $this->params = $params;
  12. $this->smarty = $smarty;
  13. }
  14. //
  15. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  16. //
  17. function GetParams($fields)
  18. {
  19. foreach ($fields as $f)
  20. $out[$f] = $this->params[$f];
  21. return $out;
  22. }
  23.  
  24. //
  25. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  26. //
  27. function GetFormVariable($fields)
  28. {
  29. foreach ($fields as $f)
  30. {
  31. $out[$f] = trim($this->params[$f]);
  32. $out[$f] = strip_tags($out[$f]);
  33. $out[$f] = stripslashes($out[$f]);
  34. }
  35. return $out;
  36. }
  37.  
  38. //
  39. //
  40. //
  41. function HTML_entities_encode (&$fields)
  42. {
  43. if ( count($fields) > 0 )
  44. {
  45. foreach ($fields as $key => &$val)
  46. {
  47. $val = htmlentities($val,ENT_QUOTES, 'UTF-8');
  48. }
  49. }
  50. }
  51.  
  52. //
  53. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  54. //
  55. function Redirect($params){
  56.  
  57. // sprawdza czy podano parametr 'run'
  58. if ( !array_key_exists('run', $params))
  59. trigger_error('brak parametru: run', E_USER_WARNING);
  60.  
  61. // sprawdzanei poprawnosci parametru 'run' ( nazwa_klasy:nazwa_metody )
  62. if ( !ereg('^[a-zA-Z]+\.[a-zA-Z0-9_]+$',$params['run']))
  63. trigger_error('parametr: run ma niepoprawna skladnie', E_USER_WARNING);
  64.  
  65. $tab = explode('.', $params['run']);
  66.  
  67. unset($params['run']);
  68.  
  69. $class_name = strtolower($tab[0]);
  70. $method = strtolower($tab[1]);
  71.  
  72. $id_params = '';
  73.  
  74. if ( array_key_exists('id', $params))
  75. $id_params = ','.$params['id'];
  76.  
  77. if ( $method == 'main' )
  78. Header("Location: $class_name$id_params.html");
  79. else
  80. Header("Location: $class_name,$method$id_params.html");
  81. }
  82. //
  83. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  84. //
  85. function Run(&$smarty, $params)
  86. {
  87.  
  88.  
  89.  
  90.  
  91.  
  92. // sprawdza czy podano parametr 'run'
  93. if ( !array_key_exists('run', $params))
  94. trigger_error('brak parametru: run', E_USER_WARNING);
  95.  
  96. // sprawdzanei poprawnosci parametru 'run' ( nazwa_klasy:nazwa_metody )
  97. if ( !ereg('^[a-z]+\.[a-z0-9_]+$',$params['run']))
  98. trigger_error('parametr: run ma niepoprawna skladnie', E_USER_WARNING);
  99.  
  100. $tab = explode('.', $params['run']);
  101.  
  102. unset($params['run']);
  103.  
  104. $class_name = ucfirst($tab[0]);
  105. $method = ucfirst($tab[1]);
  106.  
  107. // sprawdzenie istnienia pliku klasy
  108. if(file_exists(SITE_ROOT.'/pages/' . strtolower($class_name) . '.php'))
  109. {
  110. include_once SITE_ROOT.'/pages/' . strtolower($class_name) . '.php';
  111. }
  112. else
  113. {
  114. trigger_error("plik: $class_name.php nie istnieje", E_USER_WARNING);
  115. }
  116.  
  117. // sprawdzanie istnienia deklaracji klasy
  118. if ( class_exists($class_name))
  119. {
  120. $object = new $class_name($smarty, $params);
  121. }
  122. else
  123. {
  124. trigger_error("brak zdefiniowanej klasy: $class_name", E_USER_WARNING);
  125. }
  126.  
  127. // sprawdzanie czy istnieje metoda oraz czy jest ona publiczna
  128. if(!is_callable(array($object, $method)))
  129. trigger_error("brak metody: $method w klasie: $class_name lub jest ona prywatna", E_USER_WARNING);
  130.  
  131. // sprawdza czy zdefiniowano modyfikator dostepu dla metody
  132. if (!array_key_exists($method, $object->perms))
  133. trigger_error("brak zdefiniowanego modyfikatora dostepu do metody: $method w klasie: $class_name", E_USER_WARNING);
  134.  
  135. // sprawdzanie dostepu do metody (free, admin itp)
  136. if (in_array('guest', $object->perms[$method]))
  137. {
  138. $smarty->assign('cur_obj', strtolower($class_name));
  139. $smarty->assign('cur_meth', strtolower($method));
  140. $smarty->assign('cur_id', $_GET['id']);
  141. $object->$method($smarty, $params);
  142. }
  143. else if (in_array($_SESSION['user_type'], $object->perms[$method]))
  144. {
  145. $smarty->assign('cur_obj', strtolower($class_name));
  146. $smarty->assign('cur_meth', strtolower($method));
  147. $smarty->assign('cur_id', $_GET['id']);
  148. $object->$method($smarty, $params);
  149. }
  150. else
  151. {
  152. Header("Location: index.html");
  153. }
  154. }
  155. }
  156.  
  157. ?>
nospor
Cytat
a w czesci gdzie jest tresc strony
Ale treść strony też się wyświetla?
doti
właśnie nie wyświetla mi sie treśc strony (to co pochodzi z bazy).
Połaczenie z baza wiem ze mam prawidłowe, ale nie mam pojecia dlaczego wysypuje sie ten błąd.
mortus
Pokaż treść pliku site.conf.
nospor
Czyli chodzi jednak nadal o ten basepage. Szukaj więc gdzie on jest określany jak ci pisałem parę postów temu.
doti
nie wiem czy o to chodzi.

W katalogu pages w pliku index.php znalazłam cos z basepage.
Podaje cały kod pliku index.php z katalogu pages:
CODE
<?php

include_once 'include/navigation.inc.php';
include_once 'db/db_index.php';

// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # //

class Index extends Navigation
{
private $db;
var $perms;

function __construct(&$smarty, $params)
{
parent::__construct($smarty, $params);

$this->perms['Main'] = array('guest');
$this->perms['News'] = array('guest');
$this->perms['Archiwum'] = array('guest');

$this->db = new DbIndex();
}

// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # //

function Main()
{
$this->smarty->assign('powitanie', $this->db->getPowitanieTxt());
$this->smarty->assign('specjalisci', $this->db->getSpecjalisciTxt());
$this->smarty->assign('systemy', $this->db->getSystemyTxt());
$this->smarty->assign('basepage', 'index/main.tpl');

}

// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # //

function News()
{

if ( !isset($this->params['id']) )
{
$this->Redirect(array('run' => 'Index.Main'));
}

$this->smarty->assign('news_main', $this->db->getNews($this->params['id']));
$this->smarty->assign('basepage', 'index/news.tpl');

}

// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # //

function Archiwum()
{

if ( !isset($this->params['id']) )
{
$current_page = 1;
}
else
{
$current_page = $this->params['id'];
}


if ( $this->db->getMaxPageNumber() < $current_page )
Navigation::Redirect(array('run'=>'Index.Archiwum'));

$this->smarty->assign('current_page', $current_page);
$this->smarty->assign('max_page_number', $this->db->getMaxPageNumber());
$this->smarty->assign('news_main', $this->db->getNewsLimit($current_page));
$this->smarty->assign('basepage', 'index/archiwum.tpl');

}

}
?>


i tak jest przy kazdej z podstron (np. oferta tutaj podaje wycinek z pliku oferta.php > $this->smarty->assign('basepage', 'oferta/main.tpl')wink.gif

napisz czy o to chodziło

nie znalazłam więcej wpisów z "basepage"
mortus
O to chodziło. W pliku index.php powinieneś użyć zamiast:
  1. if(isset($_REQUEST['run']))
  2. {
  3. Navigation::Run($smarty, $_REQUEST);
  4. }
  5. else
  6. {
  7. Navigation::Redirect(array('run'=>'Index.Main'));
  8. }

tego
  1. if(isset($_REQUEST['run']))
  2. {
  3. Index::Run($smarty, $_REQUEST);
  4. }
  5. else
  6. {
  7. Index::Redirect(array('run'=>'Index.Main'));
  8. }


I jeszcze na początku gdzieś:
  1. include_once 'ścieżka_do_katalogu_pages/index.php';


Ech... A jednak nie do końca! Po przeanalizowaniu funkcji Run klasy Navigation dochodzę do wniosku, że powinno to działać. Pytanie, czy klasa ta tworzy poprawni obiekt (linia 120 w pliku navigation.inc.php w oparciu o parametr w $_REQUEST, bo wygląda na to, że nie do końca. W sumie to nie wiem dlaczego.

Trochę to zakręcone: bezpośrednio przy pomocy metody Run klasy Navigation tworzymy obiekt klasy Index, rozszerzającej klasę Navigation. Za każdym razem przekazujemy referencję do szablonu Smarty. Na końcu metody Run sprawdziłbym, co się znajduje w naszej klasie Navigation dodając:
  1. echo '<pre>'; var_dump($this);

w liniach 142 i 149.
doti
dodając: echo '<pre>'; var_dump($this);
w liniach 142 i 149 strona sie rozsypala. Pojawiaja sie te same elementy co wczesniej ale "porozjeżdzane" a u góry wyświetla błędy:

Notice: Undefined index: id in E:\wamp\www\test\include\navigation.inc.php on line 140


Notice: Undefined variable: this in E:\wamp\www\test\include\navigation.inc.php on line 142

NULL

zaś w części gdzie powinna znajdować sie treść strony:

#0 Smarty->trigger_error(unable to read resource: "") called at [E:\wamp\www\test\libs\Smarty.class.php:1585]
#1 Smarty->_fetch_resource_info(Array ([resource_name] => ,[get_source] => 1,[quiet] => )) called at [E:\wamp\www\test\libs\Smarty.class.php:1411]
#2 Smarty->_compile_resource(, E:\wamp\www\test/tpl/_compile/\.php) called at [E:\wamp\www\test\libs\Smarty.class.php:1860]
#3 Smarty->_smarty_include(Array ([smarty_include_tpl_file] => ,[smarty_include_vars] => Array ())) called at [E:\wamp\www\test\tpl\_compile\%%15_150_1504C075%%page_body.tpl.php:50]
#4 include(E:\wamp\www\test\tpl\_compile\%%15_150_1504C075%%page_body.tpl.php) called at [E:\wamp\www\test\libs\Smarty.class.php:1259]
#5 Smarty->fetch(page_body.tpl, , , 1) called at [E:\wamp\www\test\libs\Smarty.class.php:1102]
#6 Smarty->display(page_body.tpl) called at [E:\wamp\www\test\index.php:54]

oj chyba nie dojdziemy do sedna...







mortus
To jak nam klasa nie chce pokazać samej siebie, to niech nam chociaż pokaże $smarty. W tych samych liniach, co poprzednio zamiast var_dump($this) wstaw var_dump($smarty).
Powinno nam to pokazać obiekt Smarty z przypisaną już zmienną $basepage.
doti
no to teraz się wysypało:

CODE
Notice: Undefined index: id in E:\wamp\www\test\include\navigation.inc.php on line 140

object(Page)#1 (58) {
["template_dir"]=>
string(21) "E:\wamp\www\test/tpl/"
["compile_dir"]=>
string(30) "E:\wamp\www\test/tpl/_compile/"
["config_dir"]=>
string(25) "E:\wamp\www\test/configs/"
["plugins_dir"]=>
array(2) {
[0]=>
string(30) "E:\wamp\www\test/libs//plugins"
[1]=>
string(24) "E:\wamp\www\test/plugins"
}
["debugging"]=>
bool(false)
["error_reporting"]=>
NULL
["debug_tpl"]=>
string(0) ""
["debugging_ctrl"]=>
string(4) "NONE"
["compile_check"]=>
bool(true)
["force_compile"]=>
bool(false)
["caching"]=>
int(0)
["cache_dir"]=>
string(5) "cache"
["cache_lifetime"]=>
int(3600)
["cache_modified_check"]=>
bool(false)
["php_handling"]=>
int(0)
["security"]=>
bool(false)
["secure_dir"]=>
array(0) {
}
["security_settings"]=>
array(6) {
["PHP_HANDLING"]=>
bool(false)
["IF_FUNCS"]=>
array(11) {
[0]=>
string(5) "array"
[1]=>
string(4) "list"
[2]=>
string(5) "isset"
[3]=>
string(5) "empty"
[4]=>
string(5) "count"
[5]=>
string(6) "sizeof"
[6]=>
string(8) "in_array"
[7]=>
string(8) "is_array"
[8]=>
string(4) "true"
[9]=>
string(5) "false"
[10]=>
string(4) "null"
}
["INCLUDE_ANY"]=>
bool(false)
["PHP_TAGS"]=>
bool(false)
["MODIFIER_FUNCS"]=>
array(1) {
[0]=>
string(5) "count"
}
["ALLOW_CONSTANTS"]=>
bool(false)
}
["trusted_dir"]=>
array(0) {
}
["left_delimiter"]=>
string(1) "{"
["right_delimiter"]=>
string(1) "}"
["request_vars_order"]=>
string(5) "EGPCS"
["request_use_auto_globals"]=>
bool(true)
["compile_id"]=>
NULL
["use_sub_dirs"]=>
bool(false)
["default_modifiers"]=>
array(0) {
}
["default_resource_type"]=>
string(4) "file"
["cache_handler_func"]=>
NULL
["autoload_filters"]=>
array(2) {
["pre"]=>
array(1) {
[0]=>
string(20) "remove_html_comments"
}
["output"]=>
array(1) {
[0]=>
string(14) "trimwhitespace"
}
}
["config_overwrite"]=>
bool(true)
["config_booleanize"]=>
bool(true)
["config_read_hidden"]=>
bool(false)
["config_fix_newlines"]=>
bool(true)
["default_template_handler_func"]=>
string(0) ""
["compiler_file"]=>
string(25) "Smarty_Compiler.class.php"
["compiler_class"]=>
string(15) "Smarty_Compiler"
["config_class"]=>
string(11) "Config_File"
["_tpl_vars"]=>
array(5) {
["SCRIPT_NAME"]=>
string(15) "/test/index.php"
["cur_lang"]=>
string(1) "0"
["cur_obj"]=>
string(5) "index"
["cur_meth"]=>
string(4) "main"
["cur_id"]=>
NULL
}
["_smarty_vars"]=>
NULL
["_sections"]=>
array(0) {
}
["_foreach"]=>
array(0) {
}
["_tag_stack"]=>
array(0) {
}
["_conf_obj"]=>
NULL
["_config"]=>
array(1) {
[0]=>
array(2) {
["vars"]=>
array(0) {
}
["files"]=>
array(0) {
}
}
}
["_smarty_md5"]=>
string(32) "f8d698aea36fcbead2b9d5359ffca76f"
["_version"]=>
string(5) "2.6.9"
["_inclusion_depth"]=>
int(0)
["_compile_id"]=>
NULL
["_smarty_debug_id"]=>
string(12) "SMARTY_DEBUG"
["_smarty_debug_info"]=>
array(0) {
}
["_cache_info"]=>
array(0) {
}
["_file_perms"]=>
int(420)
["_dir_perms"]=>
int(505)
["_reg_objects"]=>
array(0) {
}
["_plugins"]=>
array(9) {
["modifier"]=>
array(0) {
}
["function"]=>
array(0) {
}
["block"]=>
array(0) {
}
["compiler"]=>
array(0) {
}
["prefilter"]=>
array(0) {
}
["postfilter"]=>
array(0) {
}
["outputfilter"]=>
array(0) {
}
["resource"]=>
array(0) {
}
["insert"]=>
array(0) {
}
}
["_cache_serials"]=>
array(0) {
}
["_cache_include"]=>
NULL
["_cache_including"]=>
bool(false)
}
mortus
No i to oznacza, że gubimy referencję. Odpowiedź na pytanie "Dlaczego?" jest tak zakręcona, jak działanie skryptu i nawet nie wiem, czy umiem poprawnie na to pytanie odpowiedzieć.
Wygląda na to, że nie można w taki sposób przekazywać referencji - przynajmniej w nowszych wersjach PHP.
doti
mam jeszcze pytanie: dlaczego ta strona działa na innym serwerze?? Skoro to błąd w smartach to też nie powinna działac...
nie mam już sił...sad.gif
mortus
Może to kwestia wersji PHP. Jeśli masz możliwość, to sprawdź, jaka wersja jest na serwerze i porównaj z lokalną.
doti
wersja php (wersja 5.2.6) jest taka sama na obu serwerach.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.