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

Source for file home.php

Documentation is available at home.php

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

Documentation generated on Mon, 11 Mar 2019 10:16:04 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.