95 lines
2.9 KiB
C++
95 lines
2.9 KiB
C++
|
|
// History Listing
|
|
#include "clog.h"
|
|
#include "cgi.h"
|
|
#include "input.h"
|
|
#include "wrenchboard_api.h"
|
|
#include "history.h"
|
|
#include "media.h"
|
|
#include "email.h"
|
|
#include "payments.h"
|
|
#include "safestring.h"
|
|
#include <string>
|
|
#include "pgsql.h"
|
|
#include "pgsql_wrapper.h"
|
|
#include "cfg.h"
|
|
#include <curl/curl.h>
|
|
|
|
/*
|
|
CREATE TABLE members_myfiles (
|
|
id SERIAL,
|
|
member_id INT REFERENCES members(id) NOT NULL,
|
|
uid uuid DEFAULT uuid_generate_v4(),
|
|
file_name VARCHAR(35),
|
|
saved_file_name VARCHAR(35) UNIQUE NOT NULL,
|
|
file_size INT DEFAULT 0,
|
|
file_type VARCHAR(15),
|
|
title VARCHAR(35),
|
|
description VARCHAR(100),
|
|
status INT DEFAULT 1,
|
|
added timestamp without time zone DEFAULT now(),
|
|
updated timestamp without time zone DEFAULT now()
|
|
);
|
|
ALTER TABLE ONLY members_myfiles
|
|
ADD CONSTRAINT members_myfiles_id_key UNIQUE (id);
|
|
|
|
$data = [
|
|
'action' => WRENCHBOARD_GET_MEDIA,
|
|
'sessionid' => $sessionId,
|
|
'file_section' => $fileSection,
|
|
'file_uid' => $fileUID,
|
|
];
|
|
|
|
|
|
*/
|
|
|
|
#define WRENCH_FILE_PROFILE 100
|
|
#define WRENCH_FILE_MYFILE 200
|
|
#define WRENCH_FILE_CONTRACTS 300
|
|
#define WRENCH_FILE_FAMILY 400
|
|
|
|
long WrenchFindStoredMedia(CVars in, CVars &out) {
|
|
logfmt(logINFO, "WrenchFindStoredMedia()");
|
|
long ret = PHP_API_BAD_PARAM;
|
|
char vname[500];
|
|
char file_section[50];
|
|
try {
|
|
REQ_STRING(in, "file_section", 5, 40, "(.*)");
|
|
REQ_STRING(in, "sessionid", 3, 150, "(.*)");
|
|
REQ_STRING(in, "file_uid", 3, 150, "(.*)");
|
|
long file_section_no = REQ_LONG( in, "file_section_no", 1, -1 );
|
|
|
|
snprintf(file_section, sizeof (file_section), "%s", in["file_section"].c_str());
|
|
|
|
switch(file_section_no){
|
|
|
|
case WRENCH_FILE_PROFILE:
|
|
snprintf(vname, sizeof (vname), "SELECT * FROM members WHERE id =1", in["file_uid"].c_str());
|
|
break;
|
|
|
|
case WRENCH_FILE_MYFILE:
|
|
snprintf(vname, sizeof (vname), "SELECT m.uid AS member_uid, mm.uid AS flie_uid, mm.* "
|
|
" FROM members_myfiles mm LEFT JOIN members m ON m.id=mm.member_id "
|
|
" WHERE mm.uid ='%s'", in["file_uid"].c_str());
|
|
break;
|
|
|
|
case WRENCH_FILE_CONTRACTS:
|
|
snprintf(vname, sizeof (vname), "SELECT * FROM members WHERE id =1", in["file_uid"].c_str());
|
|
break;
|
|
|
|
case WRENCH_FILE_FAMILY:
|
|
snprintf(vname, sizeof (vname), "SELECT * FROM members WHERE id =1", in["file_uid"].c_str());
|
|
break;
|
|
}
|
|
|
|
if ( load_db_record(out, "%s", vname) > 0){
|
|
ret = PHP_API_OK;
|
|
}
|
|
|
|
} catch (bad_parameter) {
|
|
logfmt(logINFO, "ERROR CALL long WrenchFindStoredMedia(CVars in, CVars &out)");
|
|
}
|
|
logfmt(logINFO, "/WrenchFindStoredMedia()");
|
|
return ret;
|
|
}
|