Changeset 4 for www/aktuality/rss.php
- Timestamp:
- Jan 14, 2008, 9:48:39 PM (17 years ago)
- Location:
- www
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
www
-
Property svn:ignore
set to
config.php
php_script_error.log
-
Property svn:ignore
set to
-
www/aktuality/rss.php
r1 r4 1 <? 1 <?php 2 2 3 3 header("Content-Type: text/xml"); … … 5 5 include_once('../global.php'); 6 6 include_once('rss_generator.php'); 7 include_once('../is/db.php');8 DB_Init('localhost','root','','is');9 DB_Query('SET CHARACTER SET latin2');10 7 11 8 $NewsCount = 15; … … 18 15 19 16 // Prepare WHERE condition 20 $Where = '';21 17 if(array_key_exists('select', $_GET)) 22 18 { 23 $Parts = explode('-', addslashes($_GET['select'])); 19 $Where = ''; 20 $Parts = explode('-', $_GET['select']); 24 21 foreach($Parts as $Part) 25 22 { 26 $Where .= ' OR (category='.($Part*1).')';23 $Where .= 'OR (category='.($Part * 1).')'; 27 24 } 28 } 25 $Where = substr($Where, 2); 26 } else $Where = 1; 29 27 30 28 // Get category names 31 29 $Categories = array(); 32 DB_Select('news_category', '*');33 while($Category = DB_Row())30 $DbResult = $Database->select('news_category', '*'); 31 while($Category = $DbResult->fetch_array()) 34 32 { 35 33 $Categories[$Category['id']] = $Category['caption']; … … 38 36 // Update news from discussion forum 39 37 $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); 42 40 $Index = 0; 43 41 //echo(DB_NumRows().','); 44 while($Row 2 = DB_Row())42 while($Row = $DbResult->fetch_array()) 45 43 { 46 DB_Save();47 DB_Query('SELECT * FROM posts_text WHERE post_id='.$Row2['post_id']);48 $Row = DB_Row();49 44 $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 50 45 $Row['post_text'] = str_replace("\n","<br>", $Row['post_text']); 51 46 $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"); 57 48 $Index = $Index + 1; 58 49 59 $Title = $Row 4['topic_title'].'-'.$Row['post_subject'];50 $Title = $Row['topic_title'].'-'.$Row['post_subject']; 60 51 $Content = $Row['post_text']; 61 $Date = date('Y-m-d H:i:s', $Row 2['post_time']);62 $Author = $Row 3['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'); 64 55 //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)); 68 59 //echo($Date); 69 DB_Change('forum'); 70 DB_Load(); 60 $Database->select_db('forum'); 71 61 } 72 DB_Change('is');62 $Database->select_db('is'); 73 63 74 64 // Get news from database by selected categories 75 65 $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); 67 while($Row = $DbResult->fetch_array()) 78 68 { 79 69 $EnclosuresText = ''; 80 70 if($Row['enclosure'] != '') 81 71 { 82 $EnclosuresText .= '<br>P øílohy: ';72 $EnclosuresText .= '<br>Přílohy: '; 83 73 $Enclosures = explode(';', $Row['enclosure']); 84 74 foreach($Enclosures as $Enclosure) … … 96 86 97 87 echo(GenerateRSS(array( 98 'Title' => 'Zd ìchovNET - Aktuality',88 'Title' => 'ZděchovNET - Aktuality', 99 89 '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', 101 91 'WebmasterEmail' => 'robie@centrum.cz', 102 92 'Items' => $Items)));
Note:
See TracChangeset
for help on using the changeset viewer.