1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00
Oinktube/view/reportMyVideos.json.php
2023-02-15 23:22:37 +08:00

51 lines
1.4 KiB
PHP

<?php
header('Content-Type: application/json');
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/Channel.php';
require_once $global['systemRootPath'] . 'objects/video.php';
require_once $global['systemRootPath'] . 'objects/video_statistic.php';
session_write_close();
$from = date("Y-m-d 00:00:00", strtotime($_POST['dateFrom']));
$to = date('Y-m-d 23:59:59', strtotime($_POST['dateTo']));
$users_id = 0;
if ($config->getAuthCanViewChart() == 0) {
// list all channels
if (User::isAdmin()) {
if(empty($_REQUEST['users_id'])){
$users_id = 'all';
}else{
$users_id = $_REQUEST['users_id'];
}
} elseif (User::isLogged()) {
$users_id = User::getId();
}
} elseif ($config->getAuthCanViewChart() == 1) {
if ((!empty($_SESSION['user']['canViewChart']))||(User::isAdmin())) {
if(empty($_REQUEST['users_id'])){
$users_id = 'all';
}else{
$users_id = $_REQUEST['users_id'];
}
}
}
$obj = new stdClass();
$obj->data = [];
if(empty($users_id)){
die(json_encode($obj));
}
if($users_id === 'all'){
$users_id = 0;
}
$obj->data = VideoStatistic::getStatisticTotalViewsAndSecondsWatchingFromUser($users_id, $from, $to);
echo json_encode($obj);