Changeset 583 for trunk/inc/html.php


Ignore:
Timestamp:
May 7, 2009, 9:15:17 AM (15 years ago)
Author:
george
Message:
  • Opraveno: Chyba v CSS stylech způsobovala špatné zobrazení rámečků tabulek a stylů dalších prvnků.
  • Upraveno: Sjednocen styl různých tabulek.
  • Upraveno: Přepis nejednotného přístupu k databázi přes jiné proměnné a konstanty než dle konfigurace proměnné $Config.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/inc/html.php

    r578 r583  
    195195  public function ShowNews($kategorie)
    196196  {
    197           include('inc/db.php');
    198                 global $db_webu;
     197          global $Config;
    199198               
    200199    echo('<table class="NewsCategoryTable">'.
     
    208207    $this->QuickNew();
    209208
    210     if($kategorie == "all")
    211     {
    212       $where = " ";
    213     } else
    214     {
    215       $where = "WHERE `category` = '".$kategorie."'";
     209    if($kategorie == 'all')
     210    {
     211      $where = '';
     212    } else
     213    {
     214      $where = 'WHERE `category` = "'.$kategorie.'"';
    216215    }
    217216               
    218     mysql_connect($db_server, $db_user, $db_pass);
    219     mysql_select_db($db_webu);
     217    $this->db->select_db($Config['Database']['Database']);
    220218    $limit = 5;
    221219   
    222     $pocet = mysql_num_rows(mysql_query("SELECT id FROM `articles`".$where."ORDER BY `date` DESC;"));
    223     $offset = (isset($_GET["offset"]) ? $_GET["offset"] : $pocet);
     220    $DbResult = $this->db->query('SELECT id FROM `articles` '.$where.' ORDER BY `date` DESC;');
     221    $pocet = $DbResult->num_rows;
     222    $offset = (isset($_GET['offset']) ? $_GET['offset'] : $pocet);
    224223
    225224    if($pocet != 0)
    226225    {
    227                   mysql_query('SET NAMES utf8');
    228       $result = mysql_query("SELECT * FROM articles $where ORDER BY date DESC, id DESC LIMIT $limit OFFSET " . ($pocet - $offset));
    229       while($row = mysql_fetch_array($result))
     226      $result = $this->db->query('SELECT * FROM articles '.$where.' ORDER BY date DESC, id DESC LIMIT '.$limit.' OFFSET '.($pocet - $offset));
     227      while($row = $result->fetch_array())
    230228      {
    231229        $row['text'] = str_replace('<br>', '<br />', $row['text']);
    232         switch ($row["category"])
     230        switch($row['category'])
    233231        {
    234232          case 1:
    235             $cat = "Server novinky";
    236             $link = "servernews";
     233            $cat = 'Server novinky';
     234            $link = 'servernews';
    237235            break;
    238236          case 2:
    239             $cat = "GM novinky";
    240             $link = "gmnews";
     237            $cat = 'GM novinky';
     238            $link = 'gmnews';
    241239            break;
    242240          case 3:
    243             $cat = "In-game novinky";
    244             $link = "gamenews";
     241            $cat = 'In-game novinky';
     242            $link = 'gamenews';
    245243            break;
    246244          case 4:
    247             $cat = "Články";
    248             $link = "articles";
     245            $cat = 'Články';
     246            $link = 'articles';
    249247            break;
    250248        }
     
    252250        $date = explode('-', $date_arr[0]);
    253251        $time = mktime(0, 0, 0, $date[1], $date[2], $date[0]);
    254         $human_date = date ("d.m.Y", $time);
     252        $human_date = date('d.m.Y', $time);
    255253        echo('<table class="NewsQuickInfoTable">'.
    256254          '<tr>'.
    257           '<td><strong>'.$row["title"].'</strong></td>'.
     255          '<td><strong>'.$row['title'].'</strong></td>'.
    258256          '<td style="width: 100px">'.$human_date.'</td>'.
    259257          '</tr>'.
    260258          '<tr>'.
    261           '<td colspan="2">'.$row["text"].'</td>'.
     259          '<td colspan="2">'.$row['text'].'</td>'.
    262260          '</tr>'.
    263261          '<tr>'.
     
    271269      if($offset < $pocet)
    272270      {
    273         echo("<a href='$_SERVER[PHP_SELF]" . ($offset + $limit < $pocet ? "?offset=" . ($offset + $limit) : "") . "'><-- novější</a>\n &nbsp;");
     271        echo('<a href="'.$_SERVER['PHP_SELF'].($offset + $limit < $pocet ? '?offset='.($offset + $limit) : '').'"><-- novější</a>\n &nbsp;');
    274272      }
    275273      if($offset > $limit)
Note: See TracChangeset for help on using the changeset viewer.