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 '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.     $login .= '<p><a href="?logout=1">Logout</a></p>';
  15. }
  16.  
  17. $tpl &new HTML_Template_IT('./');
  18. $tpl->loadTemplatefile('home.tpl'truetrue);
  19.  
  20. // assign the content to the vars
  21. $tpl->setVariable('GENERALNEWS'getNews($db'general'));
  22. $tpl->setVariable('LOGIN',       $login);
  23.  
  24. $tpl->show();
  25.  
  26. // This function is to fetch news from the DB
  27. function getNews(&$db$newsCategory)
  28. {
  29.     $query = "
  30.         SELECT
  31.             news_id      AS id,
  32.             DATE_FORMAT(news_date, '%D %b %Y at %H:%I:%S') AS date,
  33.             news_title   AS title,
  34.             news_content AS content
  35.         FROM
  36.             news
  37.         WHERE
  38.             news_category = '$newsCategory'
  39.         AND
  40.             news_id<>0
  41.         ORDER BY
  42.             date ASC";
  43.  
  44.     $news $db->getAssoc($query);
  45.  
  46.     if (DB::isError($news)) {
  47.         die($news->getMessage(' ' $news->getUserinfo());
  48.     else {
  49.         $tpl =new HTML_Template_IT('./');
  50.  
  51.         $tpl->loadTemplatefile('news.tpl'truetrue);
  52.  
  53.         foreach ($news as $name{
  54.             $tpl->setCurrentBlock('row');
  55.             $tpl->setVariable('DATE',    $name['date']);
  56.             $tpl->setVariable('TITLE',   $name['title']);
  57.             $tpl->setVariable('CONTENT'$name['content']);
  58.             $tpl->parseCurrentBlock('row');
  59.         }
  60.         return $tpl->get();
  61.     }
  62. }
  63. ?>

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