mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-13 08:09:49 +02:00
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
* Converted rdfeed.xml to use RDApplication.
This commit is contained in:
parent
afc426226c
commit
a78fbf5232
@ -16649,3 +16649,5 @@
|
|||||||
* Converted sas_shim(8) to use RDApplication.
|
* Converted sas_shim(8) to use RDApplication.
|
||||||
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
|
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Converted rdcastmanager.cgi to use RDApplication.
|
* Converted rdcastmanager.cgi to use RDApplication.
|
||||||
|
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Converted rdfeed.xml to use RDApplication.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// An RSS Feed Generator for Rivendell.
|
// An RSS Feed Generator for Rivendell.
|
||||||
//
|
//
|
||||||
// (C) Copyright 2002-2007,2016 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2002-2007,2016-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License version 2 as
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -29,23 +29,25 @@
|
|||||||
#include <qdatetime.h>
|
#include <qdatetime.h>
|
||||||
#include <qstringlist.h>
|
#include <qstringlist.h>
|
||||||
|
|
||||||
|
#include <rdapplication.h>
|
||||||
#include <rdconf.h>
|
#include <rdconf.h>
|
||||||
#include <rdconfig.h>
|
|
||||||
#include <rdpodcast.h>
|
|
||||||
#include <rddb.h>
|
#include <rddb.h>
|
||||||
#include <rdweb.h>
|
#include <rdfeed.h>
|
||||||
#include <rdfeedlog.h>
|
#include <rdfeedlog.h>
|
||||||
#include <rdformpost.h>
|
#include <rdformpost.h>
|
||||||
#include <rdfeed.h>
|
#include <rdpodcast.h>
|
||||||
#include <dbversion.h>
|
#include <dbversion.h>
|
||||||
|
#include <rdweb.h>
|
||||||
|
|
||||||
#include <rdfeed_script.h>
|
#include "rdfeed_script.h"
|
||||||
|
|
||||||
char server_name[PATH_MAX];
|
char server_name[PATH_MAX];
|
||||||
|
|
||||||
MainObject::MainObject(QObject *parent)
|
MainObject::MainObject(QObject *parent)
|
||||||
:QObject(parent)
|
:QObject(parent)
|
||||||
{
|
{
|
||||||
|
QString err_msg;
|
||||||
|
|
||||||
char keyname[10];
|
char keyname[10];
|
||||||
int cast_id=-1;
|
int cast_id=-1;
|
||||||
bool count;
|
bool count;
|
||||||
@ -54,7 +56,9 @@ MainObject::MainObject(QObject *parent)
|
|||||||
// Validate Feed Key Name
|
// Validate Feed Key Name
|
||||||
//
|
//
|
||||||
if(getenv("QUERY_STRING")==NULL) {
|
if(getenv("QUERY_STRING")==NULL) {
|
||||||
printf("Content-type: text/html\n\n");
|
printf("Content-type: text/html\n");
|
||||||
|
printf("Status: 400\n");
|
||||||
|
printf("\n");
|
||||||
printf("rdfeed: missing feed key name\n");
|
printf("rdfeed: missing feed key name\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -65,7 +69,9 @@ MainObject::MainObject(QObject *parent)
|
|||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
if(arg==9) {
|
if(arg==9) {
|
||||||
printf("Content-type: text/html\n\n");
|
printf("Content-type: text/html\n");
|
||||||
|
printf("Status: 400\n");
|
||||||
|
printf("\n");
|
||||||
printf("rdfeed: invalid feed key name\n");
|
printf("rdfeed: invalid feed key name\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -76,19 +82,14 @@ MainObject::MainObject(QObject *parent)
|
|||||||
// Get the Server Name
|
// Get the Server Name
|
||||||
//
|
//
|
||||||
if(getenv("SERVER_NAME")==NULL) {
|
if(getenv("SERVER_NAME")==NULL) {
|
||||||
printf("Content-type: text/html\n\n");
|
printf("Content-type: text/html\n");
|
||||||
|
printf("Status: 500\n");
|
||||||
|
printf("\n");
|
||||||
printf("rdfeed: missing SERVER_NAME\n");
|
printf("rdfeed: missing SERVER_NAME\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
strncpy(server_name,getenv("SERVER_NAME"),PATH_MAX);
|
strncpy(server_name,getenv("SERVER_NAME"),PATH_MAX);
|
||||||
|
|
||||||
//
|
|
||||||
// Read Configuration
|
|
||||||
//
|
|
||||||
config=new RDConfig();
|
|
||||||
config->load();
|
|
||||||
config->setModuleName("rdfeed.cgi");
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Determine Range
|
// Determine Range
|
||||||
//
|
//
|
||||||
@ -100,40 +101,30 @@ MainObject::MainObject(QObject *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open Database
|
// Open the Database
|
||||||
//
|
//
|
||||||
QSqlDatabase *db=QSqlDatabase::addDatabase(config->mysqlDriver());
|
rda=new RDApplication("rdfeed.xml","rdfeed.xml",RDFEED_XML_USAGE,this);
|
||||||
if(!db) {
|
if(!rda->open(&err_msg)) {
|
||||||
printf("Content-type: text/html\n\n");
|
|
||||||
printf("rdfeed: unable to initialize connection to database\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
db->setDatabaseName(config->mysqlDbname());
|
|
||||||
db->setUserName(config->mysqlUsername());
|
|
||||||
db->setPassword(config->mysqlPassword());
|
|
||||||
db->setHostName(config->mysqlHostname());
|
|
||||||
if(!db->open()) {
|
|
||||||
printf("Content-type: text/html\n\n");
|
|
||||||
printf("rdfeed: unable to connect to database\n");
|
|
||||||
db->removeDatabase(config->mysqlDbname());
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
RDSqlQuery *q=new RDSqlQuery("select DB from VERSION");
|
|
||||||
if(!q->first()) {
|
|
||||||
printf("Content-type: text/html\n");
|
printf("Content-type: text/html\n");
|
||||||
printf("Status: 500\n\n");
|
printf("Status: 500\n");
|
||||||
printf("rdfeed: missing/invalid database version!\n");
|
printf("\n");
|
||||||
db->removeDatabase(config->mysqlDbname());
|
printf("rdfeed.xml: %s\n",(const char *)err_msg);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
if(q->value(0).toUInt()!=RD_VERSION_DATABASE) {
|
|
||||||
printf("Content-type: text/html\n");
|
//
|
||||||
printf("Status: 500\n\n");
|
// Read Command Options
|
||||||
printf("rdfeed: skewed database version!\n");
|
//
|
||||||
db->removeDatabase(config->mysqlDbname());
|
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
|
||||||
exit(0);
|
if(!rda->cmdSwitch()->processed(i)) {
|
||||||
|
printf("Content-type: text/html\n");
|
||||||
|
printf("Status: 500\n");
|
||||||
|
printf("\n");
|
||||||
|
printf("rdfeed.xml: unknown command option \"%s\"\n",
|
||||||
|
(const char *)rda->cmdSwitch()->key(i));
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
delete q;
|
|
||||||
|
|
||||||
if(cast_id<0) {
|
if(cast_id<0) {
|
||||||
ServeRss(keyname,count);
|
ServeRss(keyname,count);
|
||||||
@ -280,7 +271,7 @@ QString MainObject::ResolveChannelWildcards(RDSqlQuery *chan_q)
|
|||||||
QString MainObject::ResolveItemWildcards(const QString &keyname,
|
QString MainObject::ResolveItemWildcards(const QString &keyname,
|
||||||
RDSqlQuery *item_q,RDSqlQuery *chan_q)
|
RDSqlQuery *item_q,RDSqlQuery *chan_q)
|
||||||
{
|
{
|
||||||
RDFeed *feed=new RDFeed(keyname,config);
|
RDFeed *feed=new RDFeed(keyname,rda->config());
|
||||||
QString ret=chan_q->value(11).toString();
|
QString ret=chan_q->value(11).toString();
|
||||||
ret.replace("%ITEM_TITLE%",RDXmlEscape(item_q->value(0).toString()));
|
ret.replace("%ITEM_TITLE%",RDXmlEscape(item_q->value(0).toString()));
|
||||||
ret.replace("%ITEM_DESCRIPTION%",
|
ret.replace("%ITEM_DESCRIPTION%",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// An RSS Feed Generator for Rivendell.
|
// An RSS Feed Generator for Rivendell.
|
||||||
//
|
//
|
||||||
// (C) Copyright 2002-2016 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License version 2 as
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -22,11 +22,11 @@
|
|||||||
#define RDFEED_SCRIPT_H
|
#define RDFEED_SCRIPT_H
|
||||||
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qsqldatabase.h>
|
|
||||||
|
|
||||||
#include <rdconfig.h>
|
|
||||||
#include <rddb.h>
|
#include <rddb.h>
|
||||||
|
|
||||||
|
#define RDFEED_XML_USAGE "\n"
|
||||||
|
|
||||||
class MainObject : public QObject
|
class MainObject : public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -42,7 +42,6 @@ class MainObject : public QObject
|
|||||||
unsigned cast_id);
|
unsigned cast_id);
|
||||||
bool ShouldCount(const QString &hdr);
|
bool ShouldCount(const QString &hdr);
|
||||||
void Redirect(const QString &url);
|
void Redirect(const QString &url);
|
||||||
RDConfig *config;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user