Media finder
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef __mx_media_h__
|
||||||
|
#define __mx_media_h__
|
||||||
|
|
||||||
|
#include "vars.h"
|
||||||
|
|
||||||
|
//long WrenchPurchaseHx( CVars in, CVars &out );
|
||||||
|
//long WrenchRefferHx( CVars in, CVars &out );
|
||||||
|
//long WrenchMyFilesList( CVars in, CVars &out );
|
||||||
|
long WrenchFindStoredMedia(CVars in, CVars &out);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
// 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);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This profile apps*/
|
||||||
|
long WrenchFindStoredMedia(CVars in, CVars &out) {
|
||||||
|
logfmt(logINFO, "WrenchUpdateUserProfile()");
|
||||||
|
long ret = PHP_API_BAD_PARAM;
|
||||||
|
try {
|
||||||
|
REQ_STRING(in, "firstname", 3, 49, "(.*)");
|
||||||
|
REQ_STRING(in, "lastname", 3, 49, "(.*)");
|
||||||
|
REQ_STRING(in, "email", 5, 150, "(.*)");
|
||||||
|
REQ_STRING(in, "state", 3, 150, "(.*)");
|
||||||
|
REQ_STRING(in, "city", 3, 150, "(.*)");
|
||||||
|
long member_id = REQ_LONG(in, "member_id", 1, -1);
|
||||||
|
REQ_STRING(in, "uid", 3, 150, "(.*)");
|
||||||
|
OPTIONAL(in, "online_name") REQ_STRING(in, "online_name", 3, 15, "(.*)");
|
||||||
|
REQ_LONG(in, "pref_email", 1, -1);
|
||||||
|
REQ_LONG(in, "pref_phone", 1, -1);
|
||||||
|
|
||||||
|
const PGresult *res;
|
||||||
|
res = pgsql_query("SELECT * FROM members WHERE id = %lu AND uid='%s'", member_id, in["uid"].c_str() );
|
||||||
|
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||||
|
CVars x;
|
||||||
|
x["firstname"] = in["firstname"];
|
||||||
|
x["firstname"].set_valid(true);
|
||||||
|
x["lastname"] = in["lastname"];
|
||||||
|
x["lastname"].set_valid(true);
|
||||||
|
x["email"] = in["email"];
|
||||||
|
x["email"].set_valid(true);
|
||||||
|
x["state"] = in["state"];
|
||||||
|
x["state"].set_valid(true);
|
||||||
|
x["city"] = in["city"];
|
||||||
|
x["city"].set_valid(true);
|
||||||
|
|
||||||
|
x["online_name"] = in["online_name"];
|
||||||
|
x["online_name"].set_valid(true);
|
||||||
|
|
||||||
|
x["pref_email"] = in["pref_email"];
|
||||||
|
x["pref_email"].set_valid(true);
|
||||||
|
|
||||||
|
x["pref_phone"] = in["pref_phone"];
|
||||||
|
x["pref_phone"].set_valid(true);
|
||||||
|
|
||||||
|
update_db_record(DBS_VALID, "members", x, member_id);
|
||||||
|
ret = PHP_API_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (bad_parameter) {
|
||||||
|
logfmt(logINFO, "ERROR CALL long WrenchUpdateUserProfile(CVars in, CVars &out)");
|
||||||
|
}
|
||||||
|
logfmt(logINFO, "/WrenchUpdateUserProfile()");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "coupons.h"
|
#include "coupons.h"
|
||||||
#include "cards.h"
|
#include "cards.h"
|
||||||
#include "family_acc.h"
|
#include "family_acc.h"
|
||||||
|
#include "media.h"
|
||||||
|
|
||||||
#include "twilo.h"
|
#include "twilo.h"
|
||||||
//extern CSQL *sql;
|
//extern CSQL *sql;
|
||||||
|
|||||||
@@ -30,21 +30,41 @@ class WrenchMedia extends BaseController
|
|||||||
|
|
||||||
public function apigate(){
|
public function apigate(){
|
||||||
|
|
||||||
// $file = __DIR__ . DIRECTORY_SEPARATOR . "books.png";
|
$uriSegments = explode("/", parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
|
||||||
// $fileData = exif_read_data($file);
|
$segLen = count($uriSegments);
|
||||||
// ob_start();
|
echo $segLen;
|
||||||
// header("Content-Type: " . $fileData["MimeType"]);
|
|
||||||
// header("Content-Length: " . $fileData["FileSize"]);
|
|
||||||
// readfile($file);
|
|
||||||
// ob_end_flush();
|
|
||||||
$segs = $this->uri->segment_array();
|
|
||||||
|
|
||||||
foreach ($segs as $segment)
|
if ( $segLen < 4 ){
|
||||||
{
|
return;
|
||||||
echo $segment;
|
|
||||||
echo '<br />';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sessionId = $uriSegments[$segLen-3];
|
||||||
|
$fileSection = $uriSegments[$segLen-2];
|
||||||
|
$fileUID = $uriSegments[$segLen-1];
|
||||||
|
|
||||||
|
$supportedSections = ['profile','myfile','contracts','family'];
|
||||||
|
if (!in_array($fileSection, $supportedSections)) {
|
||||||
|
// section not supported
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* VERIFY ALL PARAMETERS ARE GOOD
|
||||||
|
*/
|
||||||
|
|
||||||
|
//We can check cache for the file or
|
||||||
|
// OR
|
||||||
|
// WE need to ask backend for this file now /
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'action' => WRENCHBOARD_GET_MEDIA,
|
||||||
|
'sessionid' => $sessionId,
|
||||||
|
'file_section' => $fileSection,
|
||||||
|
'file_uid' => $fileUID,
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$file = 'books.png';
|
$file = 'books.png';
|
||||||
|
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user