Skip to content

Commit

Permalink
wrote my own rss class
Browse files Browse the repository at this point in the history
  • Loading branch information
ambiversive committed Nov 12, 2011
1 parent 737324d commit 5d79368
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 236 deletions.
8 changes: 4 additions & 4 deletions classes/core/DbTable.php
@@ -1,10 +1,10 @@
<?php

abstract class DbTable {
static protected $_cols;
static protected $_fields;
static protected $_dbh;
static protected $_id;
protected $_cols;
protected $_fields;
protected $_dbh;
protected $_id;

public function __construct($id, $dbhx = null) {
global $config;
Expand Down
11 changes: 3 additions & 8 deletions classes/core/Feed.php
@@ -1,5 +1,5 @@
<?php
include_once("lastRSS.php");
include_once("myRss.php");

class Feed extends DbTable {
protected $_table;
Expand All @@ -11,13 +11,8 @@ function __construct($id){
}

function getRss(){
$rss = new lastRSS;
$rss->cache_dir = '../cache/';
$rss->cache_time = 3600;
$rss->CDATA = 'strip';
$rss->stripHTML = TRUE;
$rs = $rss->get($this->get('url'));
return $rs;
$rss = new myRss($this->get('url'));
return $rss->getItems();
}

function delete(){
Expand Down
220 changes: 0 additions & 220 deletions classes/core/lastRSS.php

This file was deleted.

37 changes: 37 additions & 0 deletions classes/core/myRss.php
@@ -0,0 +1,37 @@
<?php

class myRss {
private $url;

function __construct($url){
$this->url = $url;
}

function getRaw(){
return $this->rawFeed;
}

function getXML(){
return $this->feedXML;
}

function getItems(){

$doc = new DOMDocument();
$doc->load($this->url);
$arrFeeds = array();
foreach ($doc->getElementsByTagName('item') as $node) {
$itemRSS = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue
);
array_push($arrFeeds, $itemRSS);
}

return $arrFeeds;


}
}
6 changes: 3 additions & 3 deletions database/config.php
Expand Up @@ -19,9 +19,9 @@

$config = array(
"db" => array(
"dbname" => "",
"username" => "",
"password" => "",
"dbname" => "improvis_simp",
"username" => "root",
"password" => "sql1682m",
"host" => "localhost"
),
"urls" => array(
Expand Down
2 changes: 1 addition & 1 deletion rss/fetch_single_rss.php
Expand Up @@ -7,7 +7,7 @@
$subreddit = $feed->get('subreddit');
$link_num = 1;
echo "{";
foreach($rs['items'] as $item){
foreach($rs as $item){
$ret .= "\"link$link_num\":";
$arr['title'] = $item['title'];
$arr['url'] = $item['link'];
Expand Down

0 comments on commit 5d79368

Please sign in to comment.