/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
**************************************************************************/
#ifndef CLIENT_ONLY
#include "action_header.h"
#include "../os_functions.h"
std::string constructFilter(const std::vector &clientid, std::string key);
ACTION_IMPL(logs)
{
Helper helper(tid, &GET, &PARAMS);
JSON::Object ret;
SUser *session=helper.getSession();
if(session!=NULL && session->id==-1) return;
std::wstring filter=GET[L"filter"];
std::wstring s_logid=GET[L"logid"];
int logid=watoi(s_logid);
std::string rights=helper.getRights("logs");
std::vector clientid;
if(rights!="all" && rights!="none" )
{
std::vector s_clientid;
Tokenize(rights, s_clientid, ",");
for(size_t i=0;i0 && filter.empty() )
{
for(size_t i=0;i v_filter;
if(!filter.empty())
{
std::vector s_filter;
Tokenize(filter, s_filter, L",");
for(size_t i=0;iPrepare(qstr);
db_results res=q_clients->Read();
q_clients->Reset();
JSON::Array clients;
for(size_t i=0;iPrepare(qstr);
res=q->Read();
q->Reset();
JSON::Array logs;
for(size_t i=0;iPrepare("SELECT l.clientid AS clientid, l.logdata AS logdata, strftime('"+helper.getTimeFormatString()+"', l.created, 'localtime') AS time, c.name AS name FROM logs l INNER JOIN clients c ON l.clientid=c.id WHERE l.id=?");
q->Bind(logid);
db_results res=q->Read();
q->Reset();
if(!res.empty())
{
bool ok=true;
if(!clientid.empty())
{
ok=false;
int t_clientid=watoi(res[0][L"clientid"]);
for(size_t i=0;i