Changeset 4 for www/aktuality


Ignore:
Timestamp:
Jan 14, 2008, 9:48:39 PM (17 years ago)
Author:
george
Message:

Upraveno: Změna přístupu k databázi na třídu rozšířenou mysqli.
Upraveno: Sjednocení
Upraveno: Změna kódování všech stránek na UTF-8.
Odstraňeno: Staré nepotřebné soubory.

Location:
www
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • www

    • Property svn:ignore set to
      config.php
      php_script_error.log
  • www/aktuality/index.php

    r1 r4  
    1 <?
     1<?php
    22include_once('../style.php');
    3 include_once('../is/db.php');
    4 include_once('../global.php');
    5 DB_Init('localhost','root','','is');
    6 DB_Query('SET CHARACTER SET latin2');
    73ShowHeader('Aktualní informace', 'Aktuality');
    84
     
    1410$Category = 1;
    1511$CategoryName = '';
    16 if(array_key_exists('category', $_GET))
    17 {
    18   $Category = addslashes($_GET['category']);
    19   DB_Select('news_category', '*', 'id='.$Category);
    20   if(DB_NumRows() > 0)
    21   {
    22     $Row = DB_Row();
    23     $CategoryName = $Row['caption'];
    24     $Permission = $Row['permission'];
    25   }
    26 }   
     12if(array_key_exists('category', $_GET)) $_POST['category'] = $_GET['category'];
    2713if(array_key_exists('category', $_POST))
    2814{
    29   $Category = addslashes($_POST['category']);
    30   DB_Select('news_category', '*', 'id='.$Category);
    31   if(DB_NumRows() > 0)
     15  $DbResult = $Database->select('news_category', '*', 'id='.$_POST['category']);
     16  if($DbResult->num_rows > 0)
    3217  {
    33     $Row = DB_Row();
     18    $Row = $DbResult->fetch_array();
    3419    $CategoryName = $Row['caption'];
    3520    $Permission = $Row['permission'];
     
    3823 
    3924if(!array_key_exists('action',$_GET)) $_GET['action'] = '';
    40 switch($_GET['action'])
     25switch(addslashes($_GET['action']))
    4126{
    4227  case 'add':
    43     echo('<strong>Vlo¾ení aktuality do kategorie '.$CategoryName.':</strong><br>');
    44     if($Category == 2) echo('U inzerátù uvádìjte co nejvíce informací a» pøípadný zájemce víc co kupuje. Uvádìjte kontaktní pdaje jako Jméno, email, tel. èíslo, ICQ. Dále navr¾enou cenu, detajlní popis pøedmìtu nejlépe s odkazem na stránky výrobce. Pokud vá¹ inzerát není platný, pøipi¹te do nìj napø. Prodáno pomocí editace.');
     28    echo('<strong>Vložení aktuality do kategorie '.$CategoryName.':</strong><br>');
     29    if($Category == 2) echo('U inzerátů uvádějte co nejvíce informací ať případný zájemce víc co kupuje. Uvádějte kontaktní pdaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát není platný, připište do něj např. Prodáno pomocí editace.');
    4530    echo('<form enctype="multipart/form-data" action="index.php?action=add2" method="post">'.
    4631    '<input type="hidden" value="'.$Category.'" name="category">'.
     
    4833    Autor:<br><input type="text" size="54" name="author"><br>
    4934    Obsah:<br><textarea name="content" rows="20" cols="40"></textarea><br>
    50     Pøílohy(Max. velikost souboru 1 MB):<br><input type="hidden" name="MAX_FILE_SIZE" value="1000000">
     35    Přílohy(Max. velikost souboru 1 MB):<br><input type="hidden" name="MAX_FILE_SIZE" value="1000000">
    5136    <input name="enclosure1" size="38" type="file"><br>
    5237    <input name="enclosure2" size="38" type="file"><br>
    5338    <input name="enclosure3" size="38" type="file"><br>
    54     <input type="submit" value="Vlo¾it">
     39    <input type="submit" value="Vložit">
    5540    </form>');
    5641    break;
    5742  case 'add2':
    5843    $RemoteAddr = GetRemoteAddress(); 
    59     $_POST['category'] = $_POST['category']*1;
     44    $_POST['category'] = $_POST['category'] * 1;
    6045    if($Permission == 1)
    6146    {
     
    7257        if(move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))
    7358        {
    74           echo("Soubor ".basename($_FILES[$EnclosureName]['name'])." byl ulo¾en na serveru.<br>");
     59          echo("Soubor ".basename($_FILES[$EnclosureName]['name'])." byl uložen na serveru.<br>");
    7560          $Enclosures = $Enclosures.';'.basename($_FILES[$EnclosureName]['name']);
    7661        } else
    7762        {
    78           echo("Soubor ".basename($_FILES[$EnclosureName]['name'])." se nepodaøilo nahrát na server.<br>");
     63          echo("Soubor ".basename($_FILES[$EnclosureName]['name'])." se nepodařilo nahrát na server.<br>");
    7964        }     
    8065      }
     
    8267
    8368      $_POST['content'] = str_replace("\n",'<br>',$_POST['content']);
    84       DB_Insert('news',array('category' => $_POST['category'], 'author' => $_POST['author'], 'title' => $_POST['title'], 'content' => $_POST['content'],
     69      $Database->insert('news',array('category' => $_POST['category'], 'author' => $_POST['author'], 'title' => $_POST['title'], 'content' => $_POST['content'],
    8570        'date' => 'NOW()', 'ip' => $RemoteAddr, 'enclosure' => $Enclosures));
    86       echo('Aktualita pøidána!<br>Pokud budete chtít va¹i aktualitu smazat, kliknìte na odkaz Smazat v seznamu v¹ech aktualit v kategorii.<br><br>');
    87      echo('<a href="index.php?category='.$_POST['category'].'">Zpìt na seznam aktualit</a>');
     71      echo('Aktualita přidána!<br>Pokud budete chtít vaši aktualitu smazat, klikněte na odkaz Smazat v seznamu všech aktualit v kategorii.<br><br>');
     72     echo('<a href="index.php?category='.$_POST['category'].'">Zpět na seznam aktualit</a>');
    8873     
    8974                 
    90     } else echo('Do této kategorie nelze vlo¾it aktualitu!');
     75    } else echo('Do této kategorie nelze vložit aktualitu!');
    9176    break;
    9277  case 'edit':
    93     DB_Query('SELECT * FROM news WHERE id='.$_GET['id']);
    94     $Row = DB_Row();
    95     if($Row['ip']==GetRemoteAddress())
     78    $DbResult = $Database->query('SELECT * FROM news WHERE id='.$_GET['id']);
     79    $Row = $DbResult->fetch_array();
     80    if($Row['ip'] == GetRemoteAddress())
    9681    {
    97       $Row['content'] = str_replace('<br>',"",$Row['content']);
     82      $Row['content'] = str_replace('<br>', "", $Row['content']);
    9883      echo('<strong>Editace aktuality v kategorii '.$CategoryName.':</strong><br>');
    9984      echo('<form action="index.php?action=update" method="post">'.
     
    10388      'Obsah:<br><textarea name="content" rows="20" cols="40">'.$Row['content'].'</textarea><br>'.
    10489      '<input type="hidden" name="category" value="'.$_GET['category'].'"><br>'.
    105       '<input type="submit" value="Ulo¾it">'.
     90      '<input type="submit" value="Uložit">'.
    10691      '</form>');
    10792    } else echo('Nepovolená operace!');
     
    10994  case 'update':
    11095    $RemoteAddr = GetRemoteAddress(); 
    111     $_POST['id'] = $_POST['id']*1;
    112     DB_Select('news','ip','id='.$_POST['id']);
    113     if(DB_NumRows() > 0)
     96    $_POST['id'] = $_POST['id'] * 1;
     97    $DbResult = $Database->select('news','ip','id='.$_POST['id']);
     98    if($DbResult->num_rows > 0)
    11499    {
    115       $Row = DB_Row();
    116       if($Row['ip']==GetRemoteAddress())
     100      $Row = $DbResult->fetch_array();
     101      if($Row['ip'] == GetRemoteAddress())
    117102      {
    118103        $_POST['content'] = str_replace("\n",'<br>',$_POST['content']);
    119         DB_Update('news','id='.$_POST['id'],array('author' => $_POST['author'], 'title' => $_POST['title'], 'content' => $_POST['content']));
    120         echo('Aktualita ulo¾ena!<br>');
    121         echo('<a href="index.php?category='.$_POST['category'].'">Zpìt na seznam aktualit</a>');
    122       } else echo('Nelze mìnit cizí aktualitu!<br>');
     104        $Database->update('news','id='.$_POST['id'], array('author' => $_POST['author'], 'title' => $_POST['title'], 'content' => $_POST['content']));
     105        echo('Aktualita uložena!<br>');
     106        echo('<a href="index.php?category='.$_POST['category'].'">Zpět na seznam aktualit</a>');
     107      } else echo('Nelze měnit cizí aktualitu!<br>');
    123108    } else echo('ID nenalezeno!');
    124109    break;
    125110  case 'del':
    126     DB_Query('SELECT * FROM news WHERE id='.$_GET['id']);
    127     $Row = DB_Row();
     111    $DbResult = $Database->query('SELECT * FROM news WHERE id='.$_GET['id']);
     112    $Row = $DbResult->fetch_array();
    128113    if($Row['ip'] == GetRemoteAddress())
    129114    {
    130115      if($Row['enclosure'] != '')
    131116      {
    132         echo('<br>Pøílohy: ');
     117        echo('<br>Přílohy: ');
    133118        $Enclosures = explode(';', $Row['enclosure']);
    134         foreach($Enclosures as $Enclosure)
    135         {
    136           if(file_exists($UploadedFilesFolder.$Enclosure)) unlink($UploadedFilesFolder.$Enclosure);
    137         }
     119              foreach($Enclosures as $Enclosure)
     120              {
     121                if(file_exists($UploadedFilesFolder.$Enclosure)) unlink($UploadedFilesFolder.$Enclosure);
     122              }
    138123      } 
    139124     
    140       DB_Query('DELETE FROM news WHERE id='.$_GET['id']);
    141       echo('Aktualita smazána!<br><a href="index.php?category='.$_GET['category'].'">Zpìt na seznam aktualit</a>');
     125      $Database->query('DELETE FROM news WHERE id='.$_GET['id']);
     126      echo('Aktualita smazána!<br><a href="index.php?category='.$_GET['category'].'">Zpět na seznam aktualit</a>');
    142127    }
    143128    break;
    144129  default:
    145130    $PerPage = 20;
    146     DB_Select('news','COUNT(*)',' category='.$Category);
    147     $RowTotal = DB_Row();
     131    $DbResult = $Database->select('news','COUNT(*)',' category='.$Category);
     132    $RowTotal = $DbResult->fetch_array();
    148133    $PageMax = $RowTotal[0];
    149134    if(array_key_exists('page', $_GET)) $Page = $_GET['page']; else $Page = 0; //round($PageMax/$PerPage);
     
    152137   
    153138    //echo(GetRemoteAddress().','.$_SERVER['HTTP_X_FORWARDED_FOR'].'<br>');
    154     DB_Query('SELECT * FROM news WHERE category='.$Category.' ORDER BY id DESC LIMIT '.$Page*$PerPage.','.$PerPage);
    155     while($Row  = DB_Row())
     139    $DbResult = $Database->query('SELECT * FROM news WHERE category='.$Category.' ORDER BY id DESC LIMIT '.$Page*$PerPage.','.$PerPage);
     140    while($Row = $DbResult->fetch_array())
    156141    {
    157142      echo('<div style="border: thin dotted #97ADFF;    background: #F6F7FF; margin-top: 5px; padding: 0px 5px 5px 5px;">'.
    158143      '<div style="padding-bottom: 1px; border-bottom-width: 1; border-bottom-style: solid; border-bottom-color: silver;"><strong>'.$Row['title'].' ('.HumanDate($Row['date']).', '.$Row['author'].')</strong>');
    159       if($Row['ip']==GetRemoteAddress())
     144      if($Row['ip'] == GetRemoteAddress())
    160145      {
    161146        echo('&nbsp;<a href="index.php?action=del&amp;category='.$Category.'&amp;id='.$Row['id'].'">Smazat</a>');
     
    165150      if($Row['enclosure'] != '')
    166151      {
    167         echo('<br>Pøílohy: ');
     152        echo('<br>Přílohy: ');
    168153        $Enclosures = explode(';', $Row['enclosure']);
    169         foreach($Enclosures as $Enclosure)
    170         {
    171           if(file_exists($UploadedFilesFolder.$Enclosure)) echo(' <a href="'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>');
    172         }
     154              foreach($Enclosures as $Enclosure)
     155        {
     156                if(file_exists($UploadedFilesFolder.$Enclosure)) echo(' <a href="'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>');
     157              }
    173158      }
    174159      echo('</div>');
  • www/aktuality/rss.php

    r1 r4  
    1 <?
     1<?php
    22
    33header("Content-Type: text/xml");
     
    55include_once('../global.php');
    66include_once('rss_generator.php');
    7 include_once('../is/db.php');
    8 DB_Init('localhost','root','','is');
    9 DB_Query('SET CHARACTER SET latin2');
    107
    118$NewsCount = 15;
     
    1815
    1916// Prepare WHERE condition
    20 $Where = '';
    2117if(array_key_exists('select', $_GET))
    2218{
    23   $Parts = explode('-', addslashes($_GET['select']));
     19  $Where = '';
     20  $Parts = explode('-', $_GET['select']);
    2421  foreach($Parts as $Part)
    2522  {
    26     $Where .= ' OR (category='.($Part*1).')';
     23    $Where .= 'OR (category='.($Part * 1).')';
    2724  }
    28 }
     25  $Where = substr($Where, 2);
     26} else $Where = 1;
    2927
    3028// Get category names
    3129$Categories = array();
    32 DB_Select('news_category', '*');
    33 while($Category = DB_Row())
     30$DbResult = $Database->select('news_category', '*');
     31while($Category = $DbResult->fetch_array())
    3432{
    3533  $Categories[$Category['id']] = $Category['caption'];
     
    3836// Update news from discussion forum
    3937$ForumCategory = 4;   
    40 DB_Change('forum');
    41 DB_Query('SELECT * FROM posts WHERE 1 ORDER BY post_time DESC LIMIT 0,'.$NewsCount);
     38$Database->select_db('forum');
     39$DbResult = $Database->query('SELECT posts.post_time, posts_text.post_subject, posts_text.post_text, users.username, topics.topic_title FROM posts JOIN posts_text ON posts.post_id = posts_text.post_id JOIN users ON users.user_id = posts.poster_id JOIN topics ON topics.topic_id= posts.topic_id ORDER BY post_time DESC LIMIT '.$NewsCount);
    4240$Index = 0;
    4341//echo(DB_NumRows().',');
    44 while($Row2  = DB_Row())
     42while($Row = $DbResult->fetch_array())
    4543{
    46   DB_Save();
    47   DB_Query('SELECT * FROM posts_text WHERE post_id='.$Row2['post_id']);
    48   $Row = DB_Row();
    4944  $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
    5045  $Row['post_text'] = str_replace("\n","<br>", $Row['post_text']);
    5146  $Row['post_subject'] = StrTr($Row['post_subject'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
    52   DB_Query('SELECT * FROM users WHERE user_id='.$Row2['poster_id']);
    53   $Row3 = DB_Row();
    54   DB_Query('SELECT * FROM topics WHERE topic_id='.$Row2['topic_id']);
    55   $Row4 = DB_Row();
    56   $Row4['topic_title'] = StrTr($Row4['topic_title'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
     47  $Row['topic_title'] = StrTr($Row['topic_title'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
    5748  $Index = $Index + 1;   
    5849 
    59   $Title = $Row4['topic_title'].'-'.$Row['post_subject'];
     50  $Title = $Row['topic_title'].'-'.$Row['post_subject'];
    6051  $Content = $Row['post_text'];
    61   $Date = date('Y-m-d H:i:s', $Row2['post_time']);
    62   $Author = $Row3['username'];
    63   DB_Change('is');
     52  $Date = date('Y-m-d H:i:s', $Row['post_time']);
     53  $Author = $Row['username'];
     54  $Database->select_db('is');
    6455  //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
    65   DB_Select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
    66   if(DB_NumRows() == 0) //echo('.'); else echo('x');
    67     DB_Insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date));
     56  $DbResult2 = $Database->select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
     57  if($DbResult2->num_rows == 0) //echo('.'); else echo('x');
     58    $Database->insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date));
    6859    //echo($Date); 
    69   DB_Change('forum');
    70   DB_Load();
     60  $Database->select_db('forum');
    7161}
    72 DB_Change('is');
     62$Database->select_db('is');
    7363
    7464// Get news from database by selected categories
    7565$UploadedFilesFolder = 'uploads/';
    76 DB_Query('SELECT enclosure,category,title,content,UNIX_TIMESTAMP(date),author FROM news WHERE 1'.$Where.' ORDER BY date DESC LIMIT 0,'.$NewsCount);
    77 while($Row = DB_Row())
     66$DbResult = $Database->query('SELECT enclosure,category,title,content,UNIX_TIMESTAMP(date),author FROM news WHERE '.$Where.' ORDER BY date DESC LIMIT 0,'.$NewsCount);
     67while($Row = $DbResult->fetch_array())
    7868{
    7969  $EnclosuresText = '';
    8070  if($Row['enclosure'] != '')
    8171  {
    82     $EnclosuresText .= '<br>Pøílohy: ';
     72    $EnclosuresText .= '<br>Přílohy: ';
    8373    $Enclosures = explode(';', $Row['enclosure']);
    8474    foreach($Enclosures as $Enclosure)
     
    9686
    9787echo(GenerateRSS(array(
    98   'Title' => 'ZdìchovNET - Aktuality',
     88  'Title' => 'ZděchovNET - Aktuality',
    9989  'Link' => 'http://centrala.zdechov.net/',
    100   'Description' => 'Aktuality komunitní poèítaèové sítì ZdìchovNET',
     90  'Description' => 'Aktuality komunitní počítačové sítě ZděchovNET',
    10191  'WebmasterEmail' => 'robie@centrum.cz',
    10292  'Items' => $Items)));
  • www/aktuality/rss_generator.php

    r1 r4  
    1 <?
     1<?php
     2
     3include_once('../global.php');
    24
    35function GenerateRSS($Data)
    46{
    5   $Result = '<?xml version="1.0" encoding="iso-8859-2" ?>'."\n". //<?
     7  global $Config;
     8 
     9  $Result = '<?xml version="1.0" encoding="'.$Config['Web']['Charset'].'" ?>'."\n". //<?
    610  '<rss version="2.0">'."\n".
    711  "  <channel>\n".
  • www/aktuality/subscription.php

    r1 r4  
    1 <?
    2 
     1<?php
    32include_once('../style.php');
    4 include_once('../is/db.php');
    5 include_once('../global.php');
    6 DB_Init('localhost','root','','is');
    7 DB_Query('SET CHARACTER SET latin2');
    83ShowHeader('Sestavéní RSS kanálu', 'RSS kanál');
    94
     
    1813  echo('Výsledný RSS kanál: <a href="'.$Select.'">'.$Select.'</a>');
    1914} else {
    20   echo('Vytvoøte si vlastní RSS kanál, díky kterému budete moci automaticky sledovat novinky pomocí va¹í RSS èteèky. Informace o technologii RSS a programech pro ètení kanálù najdete napø. <a href="http://www.lupa.cz/clanky/prehled-rss-ctecek/">zde</a><br>'.
     15  echo('Vytvořte si vlastní RSS kanál, díky kterému budete moci automaticky sledovat novinky pomocí vaší RSS čtečky. Informace o technologii RSS a programech pro čtení kanálů najdete např. <a href="http://www.lupa.cz/clanky/prehled-rss-ctecek/">zde</a><br>'.
    2116  '<br>Kategorie:<br>');
    2217  echo('<form action="subscription.php?build=1" method="post">');
    23   DB_Select('news_category', '*', '1 ORDER BY caption');
    24   while($Category = DB_Row())
     18  $DbResult = $Database->select('news_category', '*', '1 ORDER BY caption');
     19  while($Category = $DbResult->fetch_array())
    2520  {
    2621    echo('<input type="checkbox" name="category'.$Category['id'].'">'.$Category['caption'].'<br>');
Note: See TracChangeset for help on using the changeset viewer.