Arrays/DB Inserts
Posted: Mon Aug 20, 2007 3:09 pm
feyd | Please use
If there are any questions please ask and I will attempt to answer. As I said, I think this is an important piece of the 3000 lines of code, but I just don't know how to alter it!
Thank you
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello,
Bare with me, I need to expain my environment before the php part!
I am using a plugin for a blogging/CMS system.
It reads an RSS feed and then inserts specific fields (description, title, date, etc) into a database.
The problem with this is that I am reading 4 different RSS feeds from different websites, and they all haev different publish dates for their entries. Some of them have the specific time that the entry was made, others seem to attach the same date to all entries within a 12 hour build of the feed. (eg, 10 entries all with the time of 6:00, even though none of them were actually made at that time, just within that 12 hour period).
The plugin has two parts, the actual code, about 3000 lines, then a small chunk whcih you insert into a file, where you declare what fields you want to grab (date, title, description). There is also a parameter called "offset", whcih allows you to alter the date whcih is input into the database.
Well this works somewhat, i add/subtract the amount of time needed to get the entry date to be the as my current server time. To test this, i delete the latest entry, then run the file that grabs the entries, it grabs that entry again, and low and behold, the time and date is correct!
The problem is that if I come back the next day, and look at the new entries, they are not using the correct ime again. They are using a time that is hours into the future. I don't know why this is, since the test entry I use had the matched up time. Before this, i thought this Offset paramater was my savior, but alas, it is not.
So I am running out of ideas, my latest idea was to possibly alter the plugin php code itself, so that it totaly ignores the date field in the rss file, and just inserts the current time in unix timestamp, but this code is far to advanced for me.
One of the *important* parts of the code I think I have found is the below. I think it's the code that inserts the values into the database. I was hoping someone might know how insert the current time, instead of that 4 lines of code you see taht has to do with the date.. from entry_date to day lines.Code: Select all
// Insert into weblog_titles
$data = array(
'entry_id' => '',
'weblog_id' => $this->feed_weblog_id,
'author_id' => $this->author_id,
'title' => $this->post['title'],
'url_title' => $this->post['url_title'],
'ip_address' => '127.0.0.1',
'entry_date' => ($this->post['date'] - $this->time_offset),
'year' => gmdate('Y', $this->post['date'] - $this->time_offset),
'month' => gmdate('m', $this->post['date'] - $this->time_offset),
'day' => gmdate('d', $this->post['date'] - $this->time_offset),
'sticky' => 'n',
'status' => $query->row['deft_status'],
'allow_comments' => $query->row['deft_comments'],
'allow_trackbacks' => $query->row['deft_trackbacks']
);Thank you
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]