/************************************************************************* * UrBackup - Client/Server backup system * Copyright (C) 2011-2014 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 "../server_status.h" const size_t max_display=20; void getLastActs(Helper &helper, JSON::Object &ret, std::vector clientids) { std::string filter; if(!clientids.empty()) { filter=" AND ( "; for(size_t i=0;iPrepare("SELECT * FROM (" "SELECT a.id AS backupid, clientid, name, strftime('"+helper.getTimeFormatString()+"', a.backuptime, 'localtime') AS backuptime, backuptime AS bt," "incremental, (strftime('%s',running)-strftime('%s',a.backuptime)) AS duration, size_bytes, 0 AS image, 0 AS del, size_calculated " "FROM backups a INNER JOIN clients b ON a.clientid=b.id " "WHERE complete=1 "+filter+ "UNION ALL " "SELECT c.id AS backupid, clientid, name, strftime('"+helper.getTimeFormatString()+"', c.backuptime, 'localtime') AS backuptime, backuptime AS bt," "incremental, (strftime('%s',running)-strftime('%s',c.backuptime)) AS duration, (size_bytes+IFNULL(0,(" "SELECT SUM(size_bytes) FROM backup_images INNER JOIN (SELECT * FROM assoc_images WHERE img_id=c.id) ON assoc_id=id" ")) ) AS size_bytes, 1 AS image, 0 AS del, 1 as size_calculated " "FROM backup_images c INNER JOIN clients d ON c.clientid=d.id " "WHERE complete=1 AND length(letter)<=2 "+filter+ "UNION ALL " "SELECT e.backupid AS backupid, clientid, name, strftime('"+helper.getTimeFormatString()+"', e.created, 'localtime') AS backuptime, created AS bt," "incremental, (strftime('%s',stoptime)-strftime('%s',e.created)) AS duration, delsize AS size_bytes, image, 1 AS del, 1 AS size_calculated " "FROM del_stats e INNER JOIN clients f ON e.clientid=f.id " "WHERE 1=1 "+filter+ ") ORDER BY bt DESC LIMIT "+nconvert(max_display)); for(size_t i=0;iBind(clientids[i]); } for(size_t i=0;iBind(clientids[i]); } db_results res=q->Read(); q->Reset(); JSON::Array lastacts; for(size_t i=0;iid==-1) return; std::vector clientids; std::string rights=helper.getRights("lastacts"); if(rights!="none" && rights!="all") { std::vector s_cid; Tokenize(rights, s_cid, ","); for(size_t i=0;i