Changeset 4 for www/aktuality/rss.php


Ignore:
Timestamp:
Jan 14, 2008, 9:48:39 PM (16 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 edited

Legend:

Unmodified
Added
Removed
  • www

    • Property svn:ignore set to
      config.php
      php_script_error.log
  • 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)));
Note: See TracChangeset for help on using the changeset viewer.