2018-02-03 Fred Gleason <fredg@paravelsystems.com>

* Converted rdxport.cgi to use RDApplication.
This commit is contained in:
Fred Gleason 2018-02-02 19:18:58 -05:00
parent a78fbf5232
commit 0b59fa865a
16 changed files with 174 additions and 191 deletions

View File

@ -16651,3 +16651,5 @@
* Converted rdcastmanager.cgi to use RDApplication.
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
* Converted rdfeed.xml to use RDApplication.
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
* Converted rdxport.cgi to use RDApplication.

View File

@ -24,6 +24,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <rdapplication.h>
#include <rdformpost.h>
#include <rdweb.h>
#include <rdcart.h>
@ -51,7 +52,7 @@ void Xport::AudioInfo()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cartnum)) {
if(!rda->user()->cartAuthorized(cartnum)) {
XmlExit("No such cart",404,"audioinfo.cpp",LINE_NUMBER);
}

View File

@ -25,20 +25,21 @@
#include <sys/vfs.h>
#include <fcntl.h>
#include <rdformpost.h>
#include <rdweb.h>
#include <rdapplication.h>
#include <rdcart.h>
#include <rdwavefile.h>
#include <rdconf.h>
#include <rdformpost.h>
#include <rdwavefile.h>
#include <rdweb.h>
#include <rdxport.h>
#include "rdxport.h"
void Xport::AudioStore()
{
struct statvfs stat;
memset(&stat,0,sizeof(stat));
if(statvfs(xport_config->audioRoot(),&stat)<0) {
if(statvfs(rda->config()->audioRoot(),&stat)<0) {
XmlExit("Internal Error",400,"audiostore.cpp",LINE_NUMBER);
}
printf("Content-type: application/xml\n");

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- Cart services
//
// (C) Copyright 2010-2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -24,16 +24,17 @@
#include <fcntl.h>
#include <errno.h>
#include <rdformpost.h>
#include <rdlog_line.h>
#include <rdweb.h>
#include <rduser.h>
#include <rdgroup.h>
#include <rdapplication.h>
#include <rdcart_search_text.h>
#include <rdconf.h>
#include <rdescape_string.h>
#include <rdcart_search_text.h>
#include <rdformpost.h>
#include <rdgroup.h>
#include <rdlog_line.h>
#include <rduser.h>
#include <rdweb.h>
#include <rdxport.h>
#include "rdxport.h"
void Xport::AddCart()
{
@ -70,7 +71,7 @@ void Xport::AddCart()
//
// Verify User Perms
//
if(!xport_user->groupAuthorized(group_name)) {
if(!rda->user()->groupAuthorized(group_name)) {
XmlExit("No such group",404,"carts.cpp",LINE_NUMBER);
}
group=new RDGroup(group_name);
@ -85,7 +86,7 @@ void Xport::AddCart()
XmlExit("Cart number out of range for group",404,"carts.cpp",LINE_NUMBER);
}
delete group;
if(!xport_user->createCarts()) {
if(!rda->user()->createCarts()) {
XmlExit("Forbidden",404,"carts.cpp",LINE_NUMBER);
}
@ -145,14 +146,14 @@ void Xport::ListCarts()
// Generate Cart List
//
if(group_name.isEmpty()||(group_name==tr("ALL"))) {
where=RDAllCartSearchText(filter,"",xport_user->name(),false);
where=RDAllCartSearchText(filter,"",rda->user()->name(),false);
}
else {
sql=QString().
sprintf("select GROUP_NAME from USER_PERMS \
where (GROUP_NAME=\"%s\")&&(USER_NAME=\"%s\")",
(const char *)RDEscapeString(group_name),
(const char *)RDEscapeString(xport_user->name()));
(const char *)RDEscapeString(rda->user()->name()));
q=new RDSqlQuery(sql);
if(!q->first()) {
delete q;
@ -200,7 +201,7 @@ void Xport::ListCart()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
@ -246,14 +247,14 @@ void Xport::EditCart()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
if(!xport_user->modifyCarts()) {
if(!rda->user()->modifyCarts()) {
XmlExit("Unauthorized",404,"carts.cpp",LINE_NUMBER);
}
if(xport_post->getValue("GROUP_NAME",&group_name)) {
if(!xport_user->groupAuthorized(group_name)) {
if(!rda->user()->groupAuthorized(group_name)) {
XmlExit("No such group",404,"carts.cpp",LINE_NUMBER);
}
group=new RDGroup(group_name);
@ -314,8 +315,8 @@ void Xport::EditCart()
cart->setGroupName(group_name);
}
if(xport_post->getValue("TITLE",&value)) {
if((!xport_system->allowDuplicateCartTitles())&&
(!xport_system->fixDuplicateCartTitles())&&
if((!rda->system()->allowDuplicateCartTitles())&&
(!rda->system()->fixDuplicateCartTitles())&&
(!RDCart::titleIsUnique(cart_number,value))) {
XmlExit("Duplicate Cart Title Not Allowed",404,"carts.cpp",LINE_NUMBER);
}
@ -415,10 +416,10 @@ void Xport::RemoveCart()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
if(!xport_user->deleteCarts()) {
if(!rda->user()->deleteCarts()) {
XmlExit("Unauthorized",404,"carts.cpp",LINE_NUMBER);
}
@ -430,7 +431,7 @@ void Xport::RemoveCart()
delete cart;
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
if(!cart->remove(NULL,NULL,xport_config)) {
if(!cart->remove(NULL,NULL,rda->config())) {
delete cart;
XmlExit("Unable to delete cart",500,"carts.cpp",LINE_NUMBER);
}
@ -456,10 +457,10 @@ void Xport::AddCut()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
}
if(!xport_user->editAudio()) {
if(!rda->user()->editAudio()) {
XmlExit("Forbidden",404);
}
@ -507,7 +508,7 @@ void Xport::ListCuts()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
}
@ -550,7 +551,7 @@ void Xport::ListCut()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
}
@ -622,10 +623,10 @@ void Xport::EditCut()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
}
if(!xport_user->editAudio()) {
if(!rda->user()->editAudio()) {
XmlExit("Forbidden",404);
}
@ -913,10 +914,10 @@ void Xport::RemoveCut()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
}
if(!xport_user->editAudio()) {
if(!rda->user()->editAudio()) {
XmlExit("Forbidden",404);
}
@ -929,7 +930,7 @@ void Xport::RemoveCut()
XmlExit("No such cart",404);
}
if(!cart->removeCut(NULL,NULL,RDCut::cutName(cart_number,cut_number),
xport_config)) {
rda->config())) {
delete cart;
XmlExit("No such cut",404);
}

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- CopyAudio service
//
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -26,12 +26,13 @@
#include <errno.h>
#include <unistd.h>
#include <rdformpost.h>
#include <rdweb.h>
#include <rdcart.h>
#include <rdapplication.h>
#include <rdaudioconvert.h>
#include <rdsettings.h>
#include <rdcart.h>
#include <rdconf.h>
#include <rdformpost.h>
#include <rdsettings.h>
#include <rdweb.h>
#include <rdxport.h>
@ -61,10 +62,10 @@ void Xport::CopyAudio()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(source_cartnum)) {
if(!rda->user()->cartAuthorized(source_cartnum)) {
XmlExit("No such cart",404,"copyaudio.cpp",LINE_NUMBER);
}
if(!xport_user->cartAuthorized(destination_cartnum)) {
if(!rda->user()->cartAuthorized(destination_cartnum)) {
XmlExit("No such cart",404,"copyaudio.cpp",LINE_NUMBER);
}

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- DeleteAudio service
//
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -24,10 +24,11 @@
#include <fcntl.h>
#include <errno.h>
#include <rdformpost.h>
#include <rdweb.h>
#include <rdapplication.h>
#include <rdcart.h>
#include <rdconf.h>
#include <rdformpost.h>
#include <rdweb.h>
#include <rdxport.h>
@ -48,7 +49,7 @@ void Xport::DeleteAudio()
//
// Process Request
//
if((!xport_user->deleteCarts())&&(!xport_user->adminConfig())) {
if((!rda->user()->deleteCarts())&&(!rda->user()->adminConfig())) {
XmlExit("User not authorized",404,"deleteaudio.cpp",LINE_NUMBER);
}
RDCut *cut=new RDCut(cartnum,cutnum);

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- Export service
//
// (C) Copyright 2010-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -24,6 +24,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <rdapplication.h>
#include <rdaudioconvert.h>
#include <rdcart.h>
#include <rdconf.h>
@ -96,7 +97,7 @@ void Xport::Export()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cartnum)) {
if(!rda->user()->cartAuthorized(cartnum)) {
XmlExit("No such cart",404,"export.cpp",LINE_NUMBER);
}
@ -145,7 +146,7 @@ void Xport::Export()
XmlExit("unable to create temporary directory ["+err_msg+"]",500);
}
QString tmpfile=tempdir->path()+"/exported_audio";
RDAudioConvert *conv=new RDAudioConvert(xport_config->stationName());
RDAudioConvert *conv=new RDAudioConvert(rda->config()->stationName());
conv->setSourceFile(RDCut::pathName(cartnum,cutnum));
conv->setDestinationFile(tmpfile);
conv->setDestinationSettings(settings);

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- ExportPeaks service
//
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -24,14 +24,15 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <rdformpost.h>
#include <rdweb.h>
#include <rdcart.h>
#include <rdapplication.h>
#include <rdaudioconvert.h>
#include <rdsettings.h>
#include <rdcart.h>
#include <rdconf.h>
#include <rdformpost.h>
#include <rdsettings.h>
#include <rdweb.h>
#include <rdxport.h>
#include "rdxport.h"
void Xport::ExportPeaks()
{
@ -50,7 +51,7 @@ void Xport::ExportPeaks()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cartnum)) {
if(!rda->user()->cartAuthorized(cartnum)) {
XmlExit("No such cart",404,"exportpeaks.cpp",LINE_NUMBER);
}

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- Group services
//
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -24,14 +24,15 @@
#include <fcntl.h>
#include <errno.h>
#include <rdformpost.h>
#include <rdweb.h>
#include <rduser.h>
#include <rdgroup.h>
#include <rdapplication.h>
#include <rdconf.h>
#include <rdescape_string.h>
#include <rdformpost.h>
#include <rdgroup.h>
#include <rduser.h>
#include <rdweb.h>
#include <rdxport.h>
#include "rdxport.h"
void Xport::ListGroups()
{
@ -44,7 +45,7 @@ void Xport::ListGroups()
//
sql=QString().sprintf("select GROUP_NAME from USER_PERMS \
where USER_NAME=\"%s\" order by GROUP_NAME",
(const char *)RDEscapeString(xport_user->name()));
(const char *)RDEscapeString(rda->user()->name()));
q=new RDSqlQuery(sql);
//
@ -85,7 +86,7 @@ void Xport::ListGroup()
//
sql=QString().sprintf("select GROUP_NAME from USER_PERMS \
where (USER_NAME=\"%s\")&&(GROUP_NAME=\"%s\")",
(const char *)RDEscapeString(xport_user->name()),
(const char *)RDEscapeString(rda->user()->name()),
(const char *)RDEscapeString(group_name));
q=new RDSqlQuery(sql);
if(!q->first()) {

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- Import service
//
// (C) Copyright 2010,2016-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -23,17 +23,18 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <rdformpost.h>
#include <rdweb.h>
#include <rdcart.h>
#include <rdapplication.h>
#include <rdaudioconvert.h>
#include <rdsettings.h>
#include <rdcart.h>
#include <rdconf.h>
#include <rdformpost.h>
#include <rdgroup.h>
#include <rdhash.h>
#include <rdlibrary_conf.h>
#include <rdsettings.h>
#include <rdweb.h>
#include <rdxport.h>
#include "rdxport.h"
void Xport::Import()
{
@ -102,13 +103,13 @@ void Xport::Import()
// Verify User Perms
//
if(RDCart::exists(cartnum)) {
if(!xport_user->cartAuthorized(cartnum)) {
if(!rda->user()->cartAuthorized(cartnum)) {
XmlExit("No such cart",404,"import.cpp",LINE_NUMBER);
}
}
else {
if(create) {
if(!xport_user->groupAuthorized(group_name)) {
if(!rda->user()->groupAuthorized(group_name)) {
XmlExit("No such group",404,"import.cpp",LINE_NUMBER);
}
}
@ -116,10 +117,10 @@ void Xport::Import()
XmlExit("No such cart",404,"import.cpp",LINE_NUMBER);
}
}
if(!xport_user->editAudio()) {
if(!rda->user()->editAudio()) {
XmlExit("Forbidden",404,"import.cpp",LINE_NUMBER);
}
if(create&&(!xport_user->createCarts())) {
if(create&&(!rda->user()->createCarts())) {
XmlExit("Forbidden",404,"import.cpp",LINE_NUMBER);
}
@ -127,8 +128,8 @@ void Xport::Import()
// Verify Title Uniqueness
//
if(!title.isEmpty()) {
if((!xport_system->allowDuplicateCartTitles())&&
(!xport_system->fixDuplicateCartTitles())&&
if((!rda->system()->allowDuplicateCartTitles())&&
(!rda->system()->fixDuplicateCartTitles())&&
(!RDCart::titleIsUnique(cartnum,title))) {
XmlExit("Duplicate Cart Title Not Allowed",404,"import.cpp",LINE_NUMBER);
}
@ -167,7 +168,7 @@ void Xport::Import()
if(!RDCut::exists(cartnum,cutnum)) {
XmlExit("No such cut",404,"import.cpp",LINE_NUMBER);
}
RDLibraryConf *conf=new RDLibraryConf(xport_config->stationName());
RDLibraryConf *conf=new RDLibraryConf(rda->config()->stationName());
RDSettings *settings=new RDSettings();
switch(conf->defaultFormat()) {
case 0:
@ -183,7 +184,7 @@ void Xport::Import()
break;
}
settings->setChannels(channels);
settings->setSampleRate(xport_system->sampleRate());
settings->setSampleRate(rda->system()->sampleRate());
settings->setBitRate(channels*conf->defaultBitrate());
settings->setNormalizationLevel(normalization_level);
RDWaveData wavedata;
@ -194,13 +195,13 @@ void Xport::Import()
}
delete wave;
if(use_metadata) {
if((!xport_system->allowDuplicateCartTitles())&&
(!xport_system->fixDuplicateCartTitles())&&
if((!rda->system()->allowDuplicateCartTitles())&&
(!rda->system()->fixDuplicateCartTitles())&&
(!RDCart::titleIsUnique(cartnum,wavedata.title()))) {
XmlExit("Duplicate Cart Title Not Allowed",404,"import.cpp",LINE_NUMBER);
}
}
RDAudioConvert *conv=new RDAudioConvert(xport_config->stationName());
RDAudioConvert *conv=new RDAudioConvert(rda->config()->stationName());
conv->setSourceFile(filename);
conv->setDestinationFile(RDCut::pathName(cartnum,cutnum));
conv->setDestinationSettings(settings);
@ -216,7 +217,7 @@ void Xport::Import()
XmlExit("Unable to access imported file",500,"import.cpp",LINE_NUMBER);
}
delete wave;
cut->checkInRecording(xport_config->stationName(),xport_user->name(),
cut->checkInRecording(rda->config()->stationName(),rda->user()->name(),
remote_host,settings,msecs);
if(use_metadata>0) {
cart->setMetadata(conv->sourceWaveData());

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- Log services
//
// (C) Copyright 2013,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2013-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -24,6 +24,7 @@
#include <fcntl.h>
#include <errno.h>
#include <rdapplication.h>
#include <rdconf.h>
#include <rdcreate_log.h>
#include <rddb.h>
@ -57,13 +58,13 @@ void Xport::AddLog()
//
// Verify User Perms
//
if(!xport_user->createLog()) {
if(!rda->user()->createLog()) {
XmlExit("Unauthorized",404,"logs.cpp",LINE_NUMBER);
}
QString err_msg;
if(!RDLog::create(log_name,service_name,xport_user->name(),&err_msg,
xport_config)) {
if(!RDLog::create(log_name,service_name,rda->user()->name(),&err_msg,
rda->config())) {
XmlExit(err_msg,500,"logs.cpp",LINE_NUMBER);
}
XmlExit("OK",200,"logs.cpp",LINE_NUMBER);
@ -84,13 +85,13 @@ void Xport::DeleteLog()
//
// Verify User Perms
//
if(!xport_user->deleteLog()) {
if(!rda->user()->deleteLog()) {
XmlExit("Unauthorized",404,"logs.cpp",LINE_NUMBER);
}
RDLog *log=new RDLog(log_name);
if(log->exists()) {
if(!log->remove(xport_station,xport_user,xport_config)) {
if(!log->remove(rda->station(),rda->user(),rda->config())) {
delete log;
XmlExit("Unable to delete log",500,"logs.cpp",LINE_NUMBER);
}
@ -135,7 +136,7 @@ void Xport::ListLogs()
}
if(service_name.isEmpty()) {
QString sql2=QString("select SERVICE_NAME from USER_SERVICE_PERMS where ")+
"USER_NAME=\""+RDEscapeString(xport_user->name())+"\"";
"USER_NAME=\""+RDEscapeString(rda->user()->name())+"\"";
q=new RDSqlQuery(sql2);
sql+="(";
while(q->next()) {
@ -240,7 +241,7 @@ void Xport::SaveLog()
//
// Verify User Perms
//
if((!xport_user->addtoLog())||(!xport_user->removefromLog())||(!xport_user->arrangeLog())) {
if((!rda->user()->addtoLog())||(!rda->user()->removefromLog())||(!rda->user()->arrangeLog())) {
XmlExit("No user privilege",404,"logs.cpp",LINE_NUMBER);
}
@ -498,7 +499,7 @@ void Xport::SaveLog()
XmlExit("No such log",404,"logs.cpp",LINE_NUMBER);
}
if(lock_guid.isEmpty()) {
QString username=xport_user->name();
QString username=rda->user()->name();
QString stationname=xport_remote_hostname;
QHostAddress addr=xport_remote_address;
lock_guid=RDLogLock::makeGuid(stationname);
@ -510,7 +511,7 @@ void Xport::SaveLog()
log->setStartDate(start_date);
log->setEndDate(end_date);
log->setModifiedDatetime(QDateTime::currentDateTime());
logevt->save(xport_config);
logevt->save(rda->config());
RDLogLock::clearLock(lock_guid);
}
else {
@ -526,7 +527,7 @@ void Xport::SaveLog()
log->setStartDate(start_date);
log->setEndDate(end_date);
log->setModifiedDatetime(QDateTime::currentDateTime());
logevt->save(xport_config);
logevt->save(rda->config());
}
else {
XmlExit("invalid log lock",400);
@ -590,7 +591,7 @@ void Xport::LockLog()
printf("Status: 200\n\n");
switch(op_type) {
case Xport::LockLogCreate:
username=xport_user->name();
username=rda->user()->name();
stationname=xport_remote_hostname;
addr=xport_remote_address;
lock_guid=RDLogLock::makeGuid(xport_remote_hostname);
@ -624,14 +625,14 @@ void Xport::LockLog()
RDSvc *Xport::GetLogService(const QString &svc_name)
{
QString sql=QString("select SERVICE_NAME from USER_SERVICE_PERMS where ")+
"(USER_NAME=\""+RDEscapeString(xport_user->name())+"\")&&"+
"(USER_NAME=\""+RDEscapeString(rda->user()->name())+"\")&&"+
"(SERVICE_NAME=\""+RDEscapeString(svc_name)+"\")";
RDSqlQuery *q=new RDSqlQuery(sql);
if(!q->first()) {
XmlExit("No such service",404,"logs.cpp",LINE_NUMBER);
}
delete q;
RDSvc *svc=new RDSvc(svc_name,xport_station,xport_config);
RDSvc *svc=new RDSvc(svc_name,rda->station(),rda->config());
if(!svc->exists()) {
XmlExit("No such service",404,"logs.cpp",LINE_NUMBER);
}
@ -646,7 +647,7 @@ bool Xport::ServiceUserValid(const QString &svc_name)
QString sql=QString("select SERVICE_NAME from USER_SERVICE_PERMS where ")+
"(SERVICE_NAME=\""+RDEscapeString(svc_name)+"\")&&"+
"(USER_NAME=\""+RDEscapeString(xport_user->name())+"\")";
"(USER_NAME=\""+RDEscapeString(rda->user()->name())+"\")";
RDSqlQuery *q=new RDSqlQuery(sql);
ret=q->first();
delete q;

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal
//
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010,2016-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -33,6 +33,7 @@
#include <qdatetime.h>
#include <qstringlist.h>
#include <rdapplication.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdweb.h>
@ -40,27 +41,46 @@
#include <rdxport_interface.h>
#include <dbversion.h>
#include <rdxport.h>
#include "rdxport.h"
Xport::Xport(QObject *parent)
:QObject(parent)
{
xport_user=NULL;
QString err_msg;
//
// Read Configuration
// Open the Database
//
xport_config=new RDConfig();
xport_config->load();
xport_config->setModuleName("rdxport.cgi");
rda=new RDApplication("rdxport.cgi","rdxport.cgi",RDXPORT_CGI_USAGE,this);
if(!rda->open(&err_msg)) {
printf("Content-type: text/html\n");
printf("Status: 500\n");
printf("\n");
printf("rdxport.cgi: %s\n",(const char *)err_msg);
Exit(0);
}
//
// Read Command Options
//
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
if(!rda->cmdSwitch()->processed(i)) {
printf("Content-type: text/html\n");
printf("Status: 500\n");
printf("\n");
printf("rdxport.cgi: unknown command option \"%s\"\n",
(const char *)rda->cmdSwitch()->key(i));
Exit(0);
}
}
//
// Drop root permissions
//
if(setgid(xport_config->gid())<0) {
if(setgid(rda->config()->gid())<0) {
XmlExit("Unable to set Rivendell group",500,"rdxport.cpp",LINE_NUMBER);
}
if(setuid(xport_config->uid())<0) {
if(setuid(rda->config()->uid())<0) {
XmlExit("Unable to set Rivendell user",500,"rdxport.cpp",LINE_NUMBER);
}
if(getuid()==0) {
@ -68,55 +88,17 @@ Xport::Xport(QObject *parent)
LINE_NUMBER);
}
//
// Open Database
//
QSqlDatabase *db=QSqlDatabase::addDatabase(xport_config->mysqlDriver());
if(!db) {
printf("Content-type: text/html\n\n");
printf("rdfeed: unable to initialize connection to database\n");
Exit(0);
}
db->setDatabaseName(xport_config->mysqlDbname());
db->setUserName(xport_config->mysqlUsername());
db->setPassword(xport_config->mysqlPassword());
db->setHostName(xport_config->mysqlHostname());
if(!db->open()) {
printf("Content-type: text/html\n\n");
printf("rdxport: unable to connect to database\n");
db->removeDatabase(xport_config->mysqlDbname());
Exit(0);
}
RDSqlQuery *q=new RDSqlQuery("select DB from VERSION");
if(!q->first()) {
printf("Content-type: text/html\n");
printf("Status: 500\n\n");
printf("rdxport: missing/invalid database version!\n");
db->removeDatabase(xport_config->mysqlDbname());
Exit(0);
}
if(q->value(0).toUInt()!=RD_VERSION_DATABASE) {
printf("Content-type: text/html\n");
printf("Status: 500\n\n");
printf("rdxport: skewed database version!\n");
db->removeDatabase(xport_config->mysqlDbname());
Exit(0);
}
delete q;
//
// Determine Connection Type
//
if(getenv("REQUEST_METHOD")==NULL) {
printf("Content-type: text/html\n\n");
printf("rdxport: missing REQUEST_METHOD\n");
db->removeDatabase(xport_config->mysqlDbname());
Exit(0);
}
if(QString(getenv("REQUEST_METHOD")).lower()!="post") {
printf("Content-type: text/html\n\n");
printf("rdxport: invalid web method\n");
db->removeDatabase(xport_config->mysqlDbname());
Exit(0);
}
if(getenv("REMOTE_ADDR")!=NULL) {
@ -129,12 +111,6 @@ Xport::Xport(QObject *parent)
xport_remote_hostname=xport_remote_address.toString();
}
//
// Load System Settings
//
xport_system=new RDSystem();
xport_station=new RDStation(xport_config->stationName());
//
// Generate Post
//
@ -292,7 +268,6 @@ Xport::Xport(QObject *parent)
default:
printf("Content-type: text/html\n\n");
printf("rdxport: missing/invalid command\n");
db->removeDatabase(xport_config->mysqlDbname());
Exit(0);
break;
}
@ -319,7 +294,7 @@ bool Xport::Authenticate()
"(EXPIRATION_DATETIME>now())";
q=new RDSqlQuery(sql);
if(q->first()) {
xport_user=new RDUser(q->value(0).toString());
rda->user()->setName(q->value(0).toString());
delete q;
return true;
}
@ -335,8 +310,8 @@ bool Xport::Authenticate()
if(!xport_post->getValue("PASSWORD",&passwd)) {
return false;
}
xport_user=new RDUser(name);
if(!xport_user->exists()) {
rda->user()->setName(name);
if(!rda->user()->exists()) {
return false;
}
if((xport_post->clientAddress().toIPv4Address()>>24)==127) { // Localhost
@ -356,7 +331,7 @@ bool Xport::Authenticate()
//
// Finally, try password
//
if(!xport_user->checkPassword(passwd,false)) {
if(!rda->user()->checkPassword(passwd,false)) {
return false;
}
TryCreateTicket(name);
@ -401,7 +376,7 @@ void Xport::TryCreateTicket(const QString &name)
"LOGIN_NAME=\""+RDEscapeString(name)+"\","+
"IPV4_ADDRESS=\""+xport_post->clientAddress().toString()+"\","+
"EXPIRATION_DATETIME=\""+
now.addSecs(xport_user->webapiAuthTimeout()).
now.addSecs(rda->user()->webapiAuthTimeout()).
toString("yyyy-MM-dd hh:mm:ss")+"\"";
q=new RDSqlQuery(sql);
delete q;
@ -410,7 +385,7 @@ void Xport::TryCreateTicket(const QString &name)
printf("<ticketInfo>\n");
printf(" %s\n",(const char *)RDXmlField("ticket",ticket));
printf(" %s\n",(const char *)
RDXmlField("expires",now.addSecs(xport_user->webapiAuthTimeout())));
RDXmlField("expires",now.addSecs(rda->user()->webapiAuthTimeout())));
printf("</ticketInfo>\n");
exit(0);
}

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal
//
// (C) Copyright 2010,2014,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -18,20 +18,16 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDXPORT_H
#define RDXPORT_H
#include <qobject.h>
#include <rdaudioconvert.h>
#include <rdconfig.h>
#include <rdformpost.h>
#include <rdstation.h>
#include <rdsvc.h>
#include <rdsystem.h>
#include <rduser.h>
#define RDXPORT_CGI_USAGE "\n"
#define STRINGIZE(x) STRINGIZE2(x)
#define STRINGIZE2(x) #x
#define LINE_NUMBER QString(STRINGIZE(__LINE__)).toInt()
@ -90,10 +86,6 @@ class Xport : public QObject
const QString &srcfile="",int line=-1,
RDAudioConvert::ErrorCode err=RDAudioConvert::ErrorOk);
RDFormPost *xport_post;
RDUser *xport_user;
RDConfig *xport_config;
RDSystem *xport_system;
RDStation *xport_station;
QString xport_remote_hostname;
QHostAddress xport_remote_address;
};

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal
//
// (C) Copyright 2015 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2015-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -20,9 +20,11 @@
#include <qstringlist.h>
#include "rdcart.h"
#include "rddb.h"
#include "rdschedcode.h"
#include <rdapplication.h>
#include <rdcart.h>
#include <rddb.h>
#include <rdschedcode.h>
#include "rdxport.h"
void Xport::ListSchedCodes()
@ -77,7 +79,7 @@ void Xport::AssignSchedCode()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404,"schedcodes.cpp",LINE_NUMBER);
}
@ -122,7 +124,7 @@ void Xport::UnassignSchedCode()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404,"schedcodes.cpp",LINE_NUMBER);
}
@ -158,7 +160,7 @@ void Xport::ListCartSchedCodes()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cart_number)) {
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404,"schedcodes.cpp",LINE_NUMBER);
}
//

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- Service services
//
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -24,15 +24,16 @@
#include <fcntl.h>
#include <errno.h>
#include <rddb.h>
#include <rdformpost.h>
#include <rdweb.h>
#include <rduser.h>
#include <rdsvc.h>
#include <rdapplication.h>
#include <rdconf.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdformpost.h>
#include <rdsvc.h>
#include <rduser.h>
#include <rdweb.h>
#include <rdxport.h>
#include "rdxport.h"
void Xport::ListServices()
{
@ -52,7 +53,7 @@ void Xport::ListServices()
//
sql=QString("select NAME from SERVICES where ");
sql2=QString("select SERVICE_NAME from USER_SERVICE_PERMS where ")+
"USER_NAME=\""+RDEscapeString(xport_user->name())+"\"";
"USER_NAME=\""+RDEscapeString(rda->user()->name())+"\"";
q=new RDSqlQuery(sql2);
sql+="(";
while(q->next()) {
@ -76,7 +77,7 @@ void Xport::ListServices()
printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
printf("<serviceList>\n");
while(q->next()) {
svc=new RDSvc(q->value(0).toString(),xport_station,xport_config);
svc=new RDSvc(q->value(0).toString(),rda->station(),rda->config());
printf("%s",(const char *)svc->xml());
delete svc;
}

View File

@ -2,7 +2,7 @@
//
// Rivendell web service portal -- TrimAudio service
//
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@ -24,14 +24,15 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <rdformpost.h>
#include <rdweb.h>
#include <rdcart.h>
#include <rdapplication.h>
#include <rdaudioconvert.h>
#include <rdsettings.h>
#include <rdcart.h>
#include <rdconf.h>
#include <rdformpost.h>
#include <rdsettings.h>
#include <rdweb.h>
#include <rdxport.h>
#include "rdxport.h"
void Xport::TrimAudio()
{
@ -57,7 +58,7 @@ void Xport::TrimAudio()
//
// Verify User Perms
//
if(!xport_user->cartAuthorized(cartnum)) {
if(!rda->user()->cartAuthorized(cartnum)) {
XmlExit("No such cart",404,"trimaudio.cpp",LINE_NUMBER);
}