LiveUser
[ class tree: LiveUser ] [ index: LiveUser ] [ all elements ]

Source for file home.php

Documentation is available at home.php

  1. <?php
  2. require_once 'conf.php';
  3. require_once 'createlu.php';
  4. require_once 'HTML/Template/IT.php';
  5.  
  6. // Setup template objects
  7.  
  8. if (!$usr->isLoggedIn()) {
  9.     $tpl = new HTML_Template_IT('./');
  10.     $tpl->loadTemplatefile('login_form.tpl'truefalse);
  11.     $login $tpl->get();
  12. else {
  13.     $login  '<p>User: ' $usr->getProperty('handle'' !</p>';
  14.     $login .= '<p><a href="admin.php">Go to the admin part</a></p>';
  15.     $login .= '<p><a href="?logout=1">Logout</a></p>';
  16. }
  17.  
  18. $tpl &new HTML_Template_IT('./');
  19. $tpl->loadTemplatefile('home.tpl'truetrue);
  20.  
  21. // assign the content to the vars
  22. $tpl->setVariable('GENERALNEWS'getNews($db'general'));
  23. $tpl->setVariable('LOGIN',       $login);
  24.  
  25. $tpl->show();
  26.  
  27. // This function is to fetch news from the MDB2
  28. function getNews(&$db$newsCategory)
  29. {
  30.     $query = "
  31.         SELECT
  32.             news_id      AS id,
  33.             DATE_FORMAT(news_date, '%D %b %Y at %H:%I:%S') AS date,
  34.             news_title   AS title,
  35.             news_content AS content
  36.         FROM
  37.             news
  38.         WHERE
  39.             news_category = '$newsCategory'
  40.         AND
  41.             news_id<>0
  42.         ORDER BY
  43.             date ASC";
  44.  
  45.     $news $db->queryAll($querynullMDB2_FETCHMODE_ASSOCtrue);
  46.  
  47.     if (PEAR::isError($news)) {
  48.         die($news->getMessage(' ' $news->getUserinfo());
  49.     else {
  50.         $tpl = new HTML_Template_IT('./');
  51.  
  52.         $tpl->loadTemplatefile('news.tpl'truetrue);
  53.  
  54.         foreach ($news as $name{
  55.             $tpl->setCurrentBlock('row');
  56.             $tpl->setVariable('DATE',    $name['date']);
  57.             $tpl->setVariable('TITLE',   $name['title']);
  58.             $tpl->setVariable('CONTENT'$name['content']);
  59.             $tpl->parseCurrentBlock('row');
  60.         }
  61.         return $tpl->get();
  62.     }
  63. }
  64. ?>

Documentation generated on Mon, 11 Mar 2019 15:40:13 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.